| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/active_profile_pref_service.h" | 5 #include "chrome/browser/prefs/active_profile_pref_service.h" |
| 6 | 6 |
| 7 #include "chrome/browser/profiles/profile_manager.h" | 7 #include "chrome/browser/profiles/profile_manager.h" |
| 8 #include "content/public/browser/browser_context.h" | 8 #include "content/public/browser/browser_context.h" |
| 9 #include "mojo/public/cpp/bindings/interface_request.h" | 9 #include "mojo/public/cpp/bindings/interface_request.h" |
| 10 #include "services/service_manager/public/cpp/connector.h" | 10 #include "services/service_manager/public/cpp/connector.h" |
| 11 #include "services/service_manager/public/cpp/interface_registry.h" | 11 #include "services/service_manager/public/cpp/interface_registry.h" |
| 12 | 12 |
| 13 ActiveProfilePrefService::ActiveProfilePrefService() = default; | 13 ActiveProfilePrefService::ActiveProfilePrefService() = default; |
| 14 | 14 |
| 15 ActiveProfilePrefService::~ActiveProfilePrefService() = default; | 15 ActiveProfilePrefService::~ActiveProfilePrefService() = default; |
| 16 | 16 |
| 17 void ActiveProfilePrefService::Connect( | 17 void ActiveProfilePrefService::Connect( |
| 18 prefs::mojom::PrefRegistryPtr pref_registry, | 18 prefs::mojom::PrefRegistryPtr pref_registry, |
| 19 const std::vector<PrefValueStore::PrefStoreType>& already_connected_types, | 19 const std::vector<PrefValueStore::PrefStoreType>& already_connected_types, |
| 20 const ConnectCallback& callback) { | 20 const ConnectCallback& callback) { |
| 21 auto* connector = content::BrowserContext::GetConnectorFor( | 21 auto* connector = content::BrowserContext::GetConnectorFor( |
| 22 ProfileManager::GetActiveUserProfile()); | 22 ProfileManager::GetActiveUserProfile()->GetOriginalProfile()); |
| 23 connector->BindInterface(prefs::mojom::kServiceName, &connector_ptr_); | 23 connector->BindInterface(prefs::mojom::kServiceName, &connector_ptr_); |
| 24 connector_ptr_.set_connection_error_handler(base::Bind( | 24 connector_ptr_.set_connection_error_handler(base::Bind( |
| 25 &ActiveProfilePrefService::OnConnectError, base::Unretained(this))); | 25 &ActiveProfilePrefService::OnConnectError, base::Unretained(this))); |
| 26 connector_ptr_->Connect(std::move(pref_registry), already_connected_types, | 26 connector_ptr_->Connect(std::move(pref_registry), already_connected_types, |
| 27 callback); | 27 callback); |
| 28 } | 28 } |
| 29 | 29 |
| 30 void ActiveProfilePrefService::Create( | 30 void ActiveProfilePrefService::Create( |
| 31 const service_manager::Identity& remote_identity, | 31 const service_manager::Identity& remote_identity, |
| 32 prefs::mojom::PrefStoreConnectorRequest request) { | 32 prefs::mojom::PrefStoreConnectorRequest request) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 48 << " from connecting to the active profile's pref service."; | 48 << " from connecting to the active profile's pref service."; |
| 49 return false; | 49 return false; |
| 50 } | 50 } |
| 51 registry->AddInterface<prefs::mojom::PrefStoreConnector>(this); | 51 registry->AddInterface<prefs::mojom::PrefStoreConnector>(this); |
| 52 return true; | 52 return true; |
| 53 } | 53 } |
| 54 | 54 |
| 55 void ActiveProfilePrefService::OnConnectError() { | 55 void ActiveProfilePrefService::OnConnectError() { |
| 56 connector_bindings_.CloseAllBindings(); | 56 connector_bindings_.CloseAllBindings(); |
| 57 } | 57 } |
| OLD | NEW |