Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(185)

Side by Side Diff: chrome/browser/chromeos/arc/intent_helper/arc_settings_service.cc

Issue 2507073002: Split ArcSessionManager from ArcAuthService. (Closed)
Patch Set: Fix rebase mistake Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/chromeos/arc/intent_helper/arc_settings_service.h" 5 #include "chrome/browser/chromeos/arc/intent_helper/arc_settings_service.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/gtest_prod_util.h" 9 #include "base/gtest_prod_util.h"
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
11 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "chrome/browser/browser_process.h" 13 #include "chrome/browser/browser_process.h"
14 #include "chrome/browser/chromeos/arc/arc_auth_service.h" 14 #include "chrome/browser/chromeos/arc/arc_session_manager.h"
15 #include "chrome/browser/chromeos/settings/cros_settings.h" 15 #include "chrome/browser/chromeos/settings/cros_settings.h"
16 #include "chrome/browser/profiles/profile_manager.h" 16 #include "chrome/browser/profiles/profile_manager.h"
17 #include "chrome/common/pref_names.h" 17 #include "chrome/common/pref_names.h"
18 #include "chromeos/network/network_handler.h" 18 #include "chromeos/network/network_handler.h"
19 #include "chromeos/network/network_state.h" 19 #include "chromeos/network/network_state.h"
20 #include "chromeos/network/network_state_handler.h" 20 #include "chromeos/network/network_state_handler.h"
21 #include "chromeos/network/network_state_handler_observer.h" 21 #include "chromeos/network/network_state_handler_observer.h"
22 #include "chromeos/network/onc/onc_utils.h" 22 #include "chromeos/network/onc/onc_utils.h"
23 #include "chromeos/network/proxy/proxy_config_service_impl.h" 23 #include "chromeos/network/proxy/proxy_config_service_impl.h"
24 #include "chromeos/settings/cros_settings_names.h" 24 #include "chromeos/settings/cros_settings_names.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 78
79 } // namespace 79 } // namespace
80 80
81 namespace arc { 81 namespace arc {
82 82
83 // Listens to changes for select Chrome settings (prefs) that Android cares 83 // Listens to changes for select Chrome settings (prefs) that Android cares
84 // about and sends the new values to Android to keep the state in sync. 84 // about and sends the new values to Android to keep the state in sync.
85 class ArcSettingsServiceImpl 85 class ArcSettingsServiceImpl
86 : public chromeos::system::TimezoneSettings::Observer, 86 : public chromeos::system::TimezoneSettings::Observer,
87 public device::BluetoothAdapter::Observer, 87 public device::BluetoothAdapter::Observer,
88 public ArcAuthService::Observer, 88 public ArcSessionManager::Observer,
89 public chromeos::NetworkStateHandlerObserver { 89 public chromeos::NetworkStateHandlerObserver {
90 public: 90 public:
91 explicit ArcSettingsServiceImpl(ArcBridgeService* arc_bridge_service); 91 explicit ArcSettingsServiceImpl(ArcBridgeService* arc_bridge_service);
92 ~ArcSettingsServiceImpl() override; 92 ~ArcSettingsServiceImpl() override;
93 93
94 // Called when a Chrome pref we have registered an observer for has changed. 94 // Called when a Chrome pref we have registered an observer for has changed.
95 // Obtains the new pref value and sends it to Android. 95 // Obtains the new pref value and sends it to Android.
96 void OnPrefChanged(const std::string& pref_name) const; 96 void OnPrefChanged(const std::string& pref_name) const;
97 97
98 // TimezoneSettings::Observer: 98 // TimezoneSettings::Observer:
99 void TimezoneChanged(const icu::TimeZone& timezone) override; 99 void TimezoneChanged(const icu::TimeZone& timezone) override;
100 100
101 // BluetoothAdapter::Observer: 101 // BluetoothAdapter::Observer:
102 void AdapterPoweredChanged(device::BluetoothAdapter* adapter, 102 void AdapterPoweredChanged(device::BluetoothAdapter* adapter,
103 bool powered) override; 103 bool powered) override;
104 104
105 // ArcAuthService::Observer: 105 // ArcSessionManager::Observer:
106 void OnInitialStart() override; 106 void OnInitialStart() override;
107 107
108 // NetworkStateHandlerObserver: 108 // NetworkStateHandlerObserver:
109 void DefaultNetworkChanged(const chromeos::NetworkState* network) override; 109 void DefaultNetworkChanged(const chromeos::NetworkState* network) override;
110 110
111 private: 111 private:
112 // Registers to observe changes for Chrome settings we care about. 112 // Registers to observe changes for Chrome settings we care about.
113 void StartObservingSettingsChanges(); 113 void StartObservingSettingsChanges();
114 114
115 // Stops listening for Chrome settings changes. 115 // Stops listening for Chrome settings changes.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 base::WeakPtrFactory<ArcSettingsServiceImpl> weak_factory_; 162 base::WeakPtrFactory<ArcSettingsServiceImpl> weak_factory_;
163 163
164 DISALLOW_COPY_AND_ASSIGN(ArcSettingsServiceImpl); 164 DISALLOW_COPY_AND_ASSIGN(ArcSettingsServiceImpl);
165 }; 165 };
166 166
167 ArcSettingsServiceImpl::ArcSettingsServiceImpl( 167 ArcSettingsServiceImpl::ArcSettingsServiceImpl(
168 ArcBridgeService* arc_bridge_service) 168 ArcBridgeService* arc_bridge_service)
169 : arc_bridge_service_(arc_bridge_service), weak_factory_(this) { 169 : arc_bridge_service_(arc_bridge_service), weak_factory_(this) {
170 StartObservingSettingsChanges(); 170 StartObservingSettingsChanges();
171 SyncRuntimeSettings(); 171 SyncRuntimeSettings();
172 DCHECK(ArcAuthService::Get()); 172 DCHECK(ArcSessionManager::Get());
173 ArcAuthService::Get()->AddObserver(this); 173 ArcSessionManager::Get()->AddObserver(this);
174 } 174 }
175 175
176 ArcSettingsServiceImpl::~ArcSettingsServiceImpl() { 176 ArcSettingsServiceImpl::~ArcSettingsServiceImpl() {
177 StopObservingSettingsChanges(); 177 StopObservingSettingsChanges();
178 178
179 ArcAuthService* arc_auth_service = ArcAuthService::Get(); 179 ArcSessionManager* arc_session_manager = ArcSessionManager::Get();
180 if (arc_auth_service) 180 if (arc_session_manager)
181 arc_auth_service->RemoveObserver(this); 181 arc_session_manager->RemoveObserver(this);
182 182
183 if (bluetooth_adapter_) 183 if (bluetooth_adapter_)
184 bluetooth_adapter_->RemoveObserver(this); 184 bluetooth_adapter_->RemoveObserver(this);
185 } 185 }
186 186
187 void ArcSettingsServiceImpl::StartObservingSettingsChanges() { 187 void ArcSettingsServiceImpl::StartObservingSettingsChanges() {
188 Profile* profile = ProfileManager::GetActiveUserProfile(); 188 Profile* profile = ProfileManager::GetActiveUserProfile();
189 registrar_.Init(profile->GetPrefs()); 189 registrar_.Init(profile->GetPrefs());
190 190
191 AddPrefToObserve(prefs::kWebKitDefaultFixedFontSize); 191 AddPrefToObserve(prefs::kWebKitDefaultFixedFontSize);
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 505
506 void ArcSettingsService::OnInstanceReady() { 506 void ArcSettingsService::OnInstanceReady() {
507 impl_.reset(new ArcSettingsServiceImpl(arc_bridge_service())); 507 impl_.reset(new ArcSettingsServiceImpl(arc_bridge_service()));
508 } 508 }
509 509
510 void ArcSettingsService::OnInstanceClosed() { 510 void ArcSettingsService::OnInstanceClosed() {
511 impl_.reset(); 511 impl_.reset();
512 } 512 }
513 513
514 } // namespace arc 514 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698