| 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" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 const ConnectCallback& callback) { | 22 const ConnectCallback& callback) { |
| 23 auto* connector = content::BrowserContext::GetConnectorFor( | 23 auto* connector = content::BrowserContext::GetConnectorFor( |
| 24 ProfileManager::GetActiveUserProfile()->GetOriginalProfile()); | 24 ProfileManager::GetActiveUserProfile()->GetOriginalProfile()); |
| 25 connector->BindInterface(prefs::mojom::kServiceName, &connector_ptr_); | 25 connector->BindInterface(prefs::mojom::kServiceName, &connector_ptr_); |
| 26 connector_ptr_.set_connection_error_handler(base::Bind( | 26 connector_ptr_.set_connection_error_handler(base::Bind( |
| 27 &ActiveProfilePrefService::OnConnectError, base::Unretained(this))); | 27 &ActiveProfilePrefService::OnConnectError, base::Unretained(this))); |
| 28 connector_ptr_->Connect(std::move(pref_registry), already_connected_types, | 28 connector_ptr_->Connect(std::move(pref_registry), already_connected_types, |
| 29 callback); | 29 callback); |
| 30 } | 30 } |
| 31 | 31 |
| 32 void ActiveProfilePrefService::ConnectToUserPrefStore( |
| 33 prefs::mojom::PrefStoreRequest request) { |
| 34 auto* connector = content::BrowserContext::GetConnectorFor( |
| 35 ProfileManager::GetActiveUserProfile()->GetOriginalProfile()); |
| 36 connector->BindInterface(prefs::mojom::kServiceName, &connector_ptr_); |
| 37 connector_ptr_.set_connection_error_handler(base::Bind( |
| 38 &ActiveProfilePrefService::OnConnectError, base::Unretained(this))); |
| 39 connector_ptr_->ConnectToUserPrefStore(std::move(request)); |
| 40 } |
| 41 |
| 32 void ActiveProfilePrefService::Create( | 42 void ActiveProfilePrefService::Create( |
| 33 const service_manager::BindSourceInfo& source_info, | 43 const service_manager::BindSourceInfo& source_info, |
| 34 prefs::mojom::PrefStoreConnectorRequest request) { | 44 prefs::mojom::PrefStoreConnectorRequest request) { |
| 35 connector_bindings_.AddBinding(this, std::move(request)); | 45 connector_bindings_.AddBinding(this, std::move(request)); |
| 36 } | 46 } |
| 37 | 47 |
| 38 void ActiveProfilePrefService::OnStart() {} | 48 void ActiveProfilePrefService::OnStart() {} |
| 39 | 49 |
| 40 void ActiveProfilePrefService::OnBindInterface( | 50 void ActiveProfilePrefService::OnBindInterface( |
| 41 const service_manager::BindSourceInfo& source_info, | 51 const service_manager::BindSourceInfo& source_info, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 52 << " from connecting to the active profile's pref service."; | 62 << " from connecting to the active profile's pref service."; |
| 53 return; | 63 return; |
| 54 } | 64 } |
| 55 registry_.BindInterface(source_info, interface_name, | 65 registry_.BindInterface(source_info, interface_name, |
| 56 std::move(interface_pipe)); | 66 std::move(interface_pipe)); |
| 57 } | 67 } |
| 58 | 68 |
| 59 void ActiveProfilePrefService::OnConnectError() { | 69 void ActiveProfilePrefService::OnConnectError() { |
| 60 connector_bindings_.CloseAllBindings(); | 70 connector_bindings_.CloseAllBindings(); |
| 61 } | 71 } |
| OLD | NEW |