preferences_manager.cc 990 B

12345678910111213141516171819202122232425262728293031323334
  1. // Copyright (c) 2016 GitHub, Inc.
  2. // Use of this source code is governed by the MIT license that can be
  3. // found in the LICENSE file.
  4. #include "atom/renderer/preferences_manager.h"
  5. #include "atom/common/api/api_messages.h"
  6. #include "content/public/renderer/render_thread.h"
  7. namespace atom {
  8. PreferencesManager::PreferencesManager() {
  9. content::RenderThread::Get()->AddObserver(this);
  10. }
  11. PreferencesManager::~PreferencesManager() {}
  12. bool PreferencesManager::OnControlMessageReceived(const IPC::Message& message) {
  13. bool handled = true;
  14. IPC_BEGIN_MESSAGE_MAP(PreferencesManager, message)
  15. IPC_MESSAGE_HANDLER(AtomMsg_UpdatePreferences, OnUpdatePreferences)
  16. IPC_MESSAGE_UNHANDLED(handled = false)
  17. IPC_END_MESSAGE_MAP()
  18. return handled;
  19. }
  20. void PreferencesManager::OnUpdatePreferences(
  21. const base::ListValue& preferences) {
  22. auto copy =
  23. base::ListValue::From(base::Value::ToUniquePtrValue(preferences.Clone()));
  24. preferences_.swap(copy);
  25. }
  26. } // namespace atom