| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/prefs/preferences_connection_manager.h" | 5 #include "chrome/browser/prefs/preferences_connection_manager.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
| 9 #include "chrome/browser/prefs/preferences_service.h" | 9 #include "chrome/browser/prefs/preferences_service.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 const service_manager::Identity& remote_identity, | 90 const service_manager::Identity& remote_identity, |
| 91 prefs::mojom::PreferencesServiceFactoryRequest request) { | 91 prefs::mojom::PreferencesServiceFactoryRequest request) { |
| 92 factory_bindings_.AddBinding(this, std::move(request)); | 92 factory_bindings_.AddBinding(this, std::move(request)); |
| 93 } | 93 } |
| 94 | 94 |
| 95 void PreferencesConnectionManager::OnStart() { | 95 void PreferencesConnectionManager::OnStart() { |
| 96 // Certain tests have no profiles to connect to, and static initializers | 96 // Certain tests have no profiles to connect to, and static initializers |
| 97 // which block the creation of test profiles. | 97 // which block the creation of test profiles. |
| 98 if (!g_browser_process->profile_manager()->GetNumberOfProfiles()) | 98 if (!g_browser_process->profile_manager()->GetNumberOfProfiles()) |
| 99 return; | 99 return; |
| 100 | |
| 101 profile_shutdown_notification_ = | |
| 102 ShutdownNotifierFactory::GetInstance() | |
| 103 ->Get(ProfileManager::GetActiveUserProfile()) | |
| 104 ->Subscribe( | |
| 105 base::Bind(&PreferencesConnectionManager::OnProfileDestroyed, | |
| 106 base::Unretained(this))); | |
| 107 } | 100 } |
| 108 | 101 |
| 109 bool PreferencesConnectionManager::OnConnect( | 102 bool PreferencesConnectionManager::OnConnect( |
| 110 const service_manager::ServiceInfo& remote_info, | 103 const service_manager::ServiceInfo& remote_info, |
| 111 service_manager::InterfaceRegistry* registry) { | 104 service_manager::InterfaceRegistry* registry) { |
| 105 if (!profile_shutdown_notification_) { |
| 106 profile_shutdown_notification_ = |
| 107 ShutdownNotifierFactory::GetInstance() |
| 108 ->Get(ProfileManager::GetActiveUserProfile()) |
| 109 ->Subscribe( |
| 110 base::Bind(&PreferencesConnectionManager::OnProfileDestroyed, |
| 111 base::Unretained(this))); |
| 112 } |
| 112 registry->AddInterface<prefs::mojom::PreferencesServiceFactory>(this); | 113 registry->AddInterface<prefs::mojom::PreferencesServiceFactory>(this); |
| 113 return true; | 114 return true; |
| 114 } | 115 } |
| OLD | NEW |