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

Side by Side Diff: chrome/browser/chromeos/arc/arc_auth_service.cc

Issue 1854463002: arc: Fix issue when Arc OptIn is not started on fresh devices. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/arc_auth_service.h" 5 #include "chrome/browser/chromeos/arc/arc_auth_service.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 storage_partition_ = content::BrowserContext::GetStoragePartitionForSite( 221 storage_partition_ = content::BrowserContext::GetStoragePartitionForSite(
222 profile_, GURL(site_url)); 222 profile_, GURL(site_url));
223 CHECK(storage_partition_); 223 CHECK(storage_partition_);
224 224
225 // In case UI is disabled we assume that ARC is opted-in. 225 // In case UI is disabled we assume that ARC is opted-in.
226 if (!IsOptInVerificationDisabled()) { 226 if (!IsOptInVerificationDisabled()) {
227 if (profile_->GetPrefs()->GetBoolean(prefs::kArcEnabled)) { 227 if (profile_->GetPrefs()->GetBoolean(prefs::kArcEnabled)) {
228 OnOptInPreferenceChanged(); 228 OnOptInPreferenceChanged();
229 } else { 229 } else {
230 UpdateEnabledStateUMA(false); 230 UpdateEnabledStateUMA(false);
231 if (!disable_ui_for_testing && profile_->IsNewProfile()) { 231 PrefServiceSyncableFromProfile(profile_)->AddObserver(this);
khmel 2016/03/31 22:19:21 In one of the recent CLs I changed observer scheme
232 PrefServiceSyncableFromProfile(profile_)->AddObserver(this); 232 OnIsSyncingChanged();
233 OnIsSyncingChanged();
234 }
235 } 233 }
236 } else { 234 } else {
237 auth_code_.clear(); 235 auth_code_.clear();
238 StartArc(); 236 StartArc();
239 } 237 }
240 } 238 }
241 239
242 void ArcAuthService::OnIsSyncingChanged() { 240 void ArcAuthService::OnIsSyncingChanged() {
243 syncable_prefs::PrefServiceSyncable* const pref_service_syncable = 241 syncable_prefs::PrefServiceSyncable* const pref_service_syncable =
244 PrefServiceSyncableFromProfile(profile_); 242 PrefServiceSyncableFromProfile(profile_);
245 if (!pref_service_syncable->IsSyncing()) 243 if (!pref_service_syncable->IsSyncing())
246 return; 244 return;
247 245
248 pref_service_syncable->RemoveObserver(this); 246 pref_service_syncable->RemoveObserver(this);
249 if (!profile_->GetPrefs()->HasPrefPath(prefs::kArcEnabled)) 247
248 if (profile_->GetPrefs()->GetBoolean(prefs::kArcEnabled))
249 OnOptInPreferenceChanged();
250
251 if (!disable_ui_for_testing && profile_->IsNewProfile() &&
xiyuan 2016/03/31 22:32:44 nit: profile_->IsNewProfile() might not be necessa
khmel 2016/03/31 22:47:34 I think it might be required. For example: User st
xiyuan 2016/03/31 22:50:50 Okay. That sounds like a valid case.
252 !profile_->GetPrefs()->HasPrefPath(prefs::kArcEnabled)) {
250 arc::ArcAuthNotification::Show(); 253 arc::ArcAuthNotification::Show();
254 }
251 } 255 }
252 256
253 void ArcAuthService::Shutdown() { 257 void ArcAuthService::Shutdown() {
254 ShutdownBridgeAndCloseUI(); 258 ShutdownBridgeAndCloseUI();
255 if (profile_) { 259 if (profile_) {
256 syncable_prefs::PrefServiceSyncable* pref_service_syncable = 260 syncable_prefs::PrefServiceSyncable* pref_service_syncable =
257 PrefServiceSyncableFromProfile(profile_); 261 PrefServiceSyncableFromProfile(profile_);
258 pref_service_syncable->RemoveObserver(this); 262 pref_service_syncable->RemoveObserver(this);
259 pref_service_syncable->RemoveSyncedPrefObserver(prefs::kArcEnabled, this); 263 pref_service_syncable->RemoveSyncedPrefObserver(prefs::kArcEnabled, this);
260 } 264 }
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 return os << kStateFetchingCode; 530 return os << kStateFetchingCode;
527 case ArcAuthService::State::ACTIVE: 531 case ArcAuthService::State::ACTIVE:
528 return os << kStateActive; 532 return os << kStateActive;
529 default: 533 default:
530 NOTREACHED(); 534 NOTREACHED();
531 return os; 535 return os;
532 } 536 }
533 } 537 }
534 538
535 } // namespace arc 539 } // namespace arc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698