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

Side by Side Diff: chrome/browser/managed_mode/managed_user_registration_service.cc

Issue 16950018: Collect the custodian's full name when a supervised user is created. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/managed_mode/managed_user_registration_service.h" 5 #include "chrome/browser/managed_mode/managed_user_registration_service.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 ManagedUserRegistrationInfo::ManagedUserRegistrationInfo(const string16& name) 67 ManagedUserRegistrationInfo::ManagedUserRegistrationInfo(const string16& name)
68 : name(name) { 68 : name(name) {
69 } 69 }
70 70
71 ManagedUserRegistrationService::ManagedUserRegistrationService( 71 ManagedUserRegistrationService::ManagedUserRegistrationService(
72 PrefService* prefs, 72 PrefService* prefs,
73 scoped_ptr<ManagedUserRefreshTokenFetcher> token_fetcher) 73 scoped_ptr<ManagedUserRefreshTokenFetcher> token_fetcher)
74 : weak_ptr_factory_(this), 74 : weak_ptr_factory_(this),
75 prefs_(prefs), 75 prefs_(prefs),
76 token_fetcher_(token_fetcher.Pass()), 76 token_fetcher_(token_fetcher.Pass()),
77 pending_managed_user_acknowledged_(false) { 77 pending_managed_user_acknowledged_(false),
78 download_profile_(NULL) {
78 pref_change_registrar_.Init(prefs); 79 pref_change_registrar_.Init(prefs);
79 pref_change_registrar_.Add( 80 pref_change_registrar_.Add(
80 prefs::kGoogleServicesLastUsername, 81 prefs::kGoogleServicesLastUsername,
81 base::Bind(&ManagedUserRegistrationService::OnLastSignedInUsernameChange, 82 base::Bind(&ManagedUserRegistrationService::OnLastSignedInUsernameChange,
82 base::Unretained(this))); 83 base::Unretained(this)));
83 } 84 }
84 85
85 ManagedUserRegistrationService::~ManagedUserRegistrationService() { 86 ManagedUserRegistrationService::~ManagedUserRegistrationService() {
86 DCHECK(pending_managed_user_id_.empty()); 87 DCHECK(pending_managed_user_id_.empty());
87 DCHECK(callback_.is_null()); 88 DCHECK(callback_.is_null());
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 SyncError error = 137 SyncError error =
137 sync_processor_->ProcessSyncChanges(FROM_HERE, change_list); 138 sync_processor_->ProcessSyncChanges(FROM_HERE, change_list);
138 DCHECK(!error.IsSet()) << error.ToString(); 139 DCHECK(!error.IsSet()) << error.ToString();
139 } 140 }
140 141
141 browser_sync::DeviceInfo::CreateLocalDeviceInfo( 142 browser_sync::DeviceInfo::CreateLocalDeviceInfo(
142 base::Bind(&ManagedUserRegistrationService::FetchToken, 143 base::Bind(&ManagedUserRegistrationService::FetchToken,
143 weak_ptr_factory_.GetWeakPtr(), info.name)); 144 weak_ptr_factory_.GetWeakPtr(), info.name));
144 } 145 }
145 146
147 void ManagedUserRegistrationService::DownloadProfile(
148 Profile* profile,
149 const DownloadProfileCallback& callback) {
150 if (profile_downloader_)
Bernhard Bauer 2013/06/21 15:52:07 Should it be a DCHECK to try to download a profile
Pam (message me for reviews) 2013/06/21 16:19:09 Well, since the downloader isn't guaranteed to eve
Bernhard Bauer 2013/06/21 16:46:57 But I don't think silently returning is the correc
Pam (message me for reviews) 2013/06/21 19:20:25 Fair enough. On a second look, as far as I can tel
151 return;
152
153 download_callback_ = callback;
154 download_profile_ = profile;
155 profile_downloader_.reset(new ProfileDownloader(this));
156 profile_downloader_->Start();
157 }
158
146 void ManagedUserRegistrationService::CancelPendingRegistration() { 159 void ManagedUserRegistrationService::CancelPendingRegistration() {
147 AbortPendingRegistration( 160 AbortPendingRegistration(
148 false, // Don't run the callback. The error will be ignored. 161 false, // Don't run the callback. The error will be ignored.
149 GoogleServiceAuthError(GoogleServiceAuthError::NONE)); 162 GoogleServiceAuthError(GoogleServiceAuthError::NONE));
150 } 163 }
151 164
152 void ManagedUserRegistrationService::Shutdown() { 165 void ManagedUserRegistrationService::Shutdown() {
153 AbortPendingRegistration( 166 AbortPendingRegistration(
154 true, // Run the callback. 167 true, // Run the callback.
155 GoogleServiceAuthError(GoogleServiceAuthError::REQUEST_CANCELED)); 168 GoogleServiceAuthError(GoogleServiceAuthError::REQUEST_CANCELED));
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 sync_processor_->ProcessSyncChanges(FROM_HERE, change_list); 405 sync_processor_->ProcessSyncChanges(FROM_HERE, change_list);
393 DCHECK(!sync_error.IsSet()); 406 DCHECK(!sync_error.IsSet());
394 } 407 }
395 } 408 }
396 } 409 }
397 410
398 pending_managed_user_token_.clear(); 411 pending_managed_user_token_.clear();
399 pending_managed_user_id_.clear(); 412 pending_managed_user_id_.clear();
400 pending_managed_user_acknowledged_ = false; 413 pending_managed_user_acknowledged_ = false;
401 } 414 }
415
416 bool ManagedUserRegistrationService::NeedsProfilePicture() const {
417 return false;
418 }
419
420 int ManagedUserRegistrationService::GetDesiredImageSideLength() const {
421 return 0;
422 }
423
424 std::string ManagedUserRegistrationService::GetCachedPictureURL() const {
425 return std::string();
426 }
427
428 Profile* ManagedUserRegistrationService::GetBrowserProfile() {
429 DCHECK(download_profile_);
430 return download_profile_;
431 }
432
433 void ManagedUserRegistrationService::OnProfileDownloadComplete() {
434 download_callback_.Reset();
435 download_profile_ = NULL;
436 profile_downloader_.reset();
437 }
438
439 void ManagedUserRegistrationService::OnProfileDownloadSuccess(
440 ProfileDownloader* downloader) {
441 download_callback_.Run(downloader->GetProfileFullName());
442 OnProfileDownloadComplete();
443 }
444
445 void ManagedUserRegistrationService::OnProfileDownloadFailure(
446 ProfileDownloader* downloader,
447 ProfileDownloaderDelegate::FailureReason reason) {
448 // Ignore failures; proceed without the custodian's name.
449 OnProfileDownloadComplete();
450 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698