| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/ui/webui/options/manage_profile_handler.h" | 5 #include "chrome/browser/ui/webui/options/manage_profile_handler.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 ProfileMetrics::DELETE_PROFILE_SETTINGS_SHOW_WARNING); | 69 ProfileMetrics::DELETE_PROFILE_SETTINGS_SHOW_WARNING); |
| 70 } | 70 } |
| 71 | 71 |
| 72 } // namespace | 72 } // namespace |
| 73 | 73 |
| 74 ManageProfileHandler::ManageProfileHandler() | 74 ManageProfileHandler::ManageProfileHandler() |
| 75 : weak_factory_(this) { | 75 : weak_factory_(this) { |
| 76 } | 76 } |
| 77 | 77 |
| 78 ManageProfileHandler::~ManageProfileHandler() { | 78 ManageProfileHandler::~ManageProfileHandler() { |
| 79 ProfileSyncService* service = | 79 browser_sync::ProfileSyncService* service = |
| 80 ProfileSyncServiceFactory::GetForProfile(Profile::FromWebUI(web_ui())); | 80 ProfileSyncServiceFactory::GetForProfile(Profile::FromWebUI(web_ui())); |
| 81 // Sync may be disabled in tests. | 81 // Sync may be disabled in tests. |
| 82 if (service) | 82 if (service) |
| 83 service->RemoveObserver(this); | 83 service->RemoveObserver(this); |
| 84 } | 84 } |
| 85 | 85 |
| 86 void ManageProfileHandler::GetLocalizedValues( | 86 void ManageProfileHandler::GetLocalizedValues( |
| 87 base::DictionaryValue* localized_strings) { | 87 base::DictionaryValue* localized_strings) { |
| 88 DCHECK(localized_strings); | 88 DCHECK(localized_strings); |
| 89 | 89 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 void ManageProfileHandler::InitializeHandler() { | 144 void ManageProfileHandler::InitializeHandler() { |
| 145 g_browser_process->profile_manager()-> | 145 g_browser_process->profile_manager()-> |
| 146 GetProfileAttributesStorage().AddObserver(this); | 146 GetProfileAttributesStorage().AddObserver(this); |
| 147 | 147 |
| 148 Profile* profile = Profile::FromWebUI(web_ui()); | 148 Profile* profile = Profile::FromWebUI(web_ui()); |
| 149 pref_change_registrar_.Init(profile->GetPrefs()); | 149 pref_change_registrar_.Init(profile->GetPrefs()); |
| 150 pref_change_registrar_.Add( | 150 pref_change_registrar_.Add( |
| 151 prefs::kSupervisedUserCreationAllowed, | 151 prefs::kSupervisedUserCreationAllowed, |
| 152 base::Bind(&ManageProfileHandler::OnCreateSupervisedUserPrefChange, | 152 base::Bind(&ManageProfileHandler::OnCreateSupervisedUserPrefChange, |
| 153 base::Unretained(this))); | 153 base::Unretained(this))); |
| 154 ProfileSyncService* service = | 154 browser_sync::ProfileSyncService* service = |
| 155 ProfileSyncServiceFactory::GetForProfile(profile); | 155 ProfileSyncServiceFactory::GetForProfile(profile); |
| 156 // Sync may be disabled for tests. | 156 // Sync may be disabled for tests. |
| 157 if (service) | 157 if (service) |
| 158 service->AddObserver(this); | 158 service->AddObserver(this); |
| 159 } | 159 } |
| 160 | 160 |
| 161 void ManageProfileHandler::InitializePage() { | 161 void ManageProfileHandler::InitializePage() { |
| 162 SendExistingProfileNames(); | 162 SendExistingProfileNames(); |
| 163 OnCreateSupervisedUserPrefChange(); | 163 OnCreateSupervisedUserPrefChange(); |
| 164 } | 164 } |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 weak_factory_.GetWeakPtr())); | 467 weak_factory_.GetWeakPtr())); |
| 468 } | 468 } |
| 469 | 469 |
| 470 void ManageProfileHandler::RequestCreateProfileUpdate( | 470 void ManageProfileHandler::RequestCreateProfileUpdate( |
| 471 const base::ListValue* args) { | 471 const base::ListValue* args) { |
| 472 Profile* profile = Profile::FromWebUI(web_ui()); | 472 Profile* profile = Profile::FromWebUI(web_ui()); |
| 473 SigninManagerBase* manager = | 473 SigninManagerBase* manager = |
| 474 SigninManagerFactory::GetForProfile(profile); | 474 SigninManagerFactory::GetForProfile(profile); |
| 475 base::string16 username = | 475 base::string16 username = |
| 476 base::UTF8ToUTF16(manager->GetAuthenticatedAccountInfo().email); | 476 base::UTF8ToUTF16(manager->GetAuthenticatedAccountInfo().email); |
| 477 ProfileSyncService* service = | 477 browser_sync::ProfileSyncService* service = |
| 478 ProfileSyncServiceFactory::GetForProfile(profile); | 478 ProfileSyncServiceFactory::GetForProfile(profile); |
| 479 GoogleServiceAuthError::State state = GoogleServiceAuthError::NONE; | 479 GoogleServiceAuthError::State state = GoogleServiceAuthError::NONE; |
| 480 | 480 |
| 481 // |service| might be null if Sync is disabled from the command line. | 481 // |service| might be null if Sync is disabled from the command line. |
| 482 if (service) | 482 if (service) |
| 483 state = service->GetAuthError().state(); | 483 state = service->GetAuthError().state(); |
| 484 | 484 |
| 485 bool has_error = (!service || | 485 bool has_error = (!service || |
| 486 state == GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS || | 486 state == GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS || |
| 487 state == GoogleServiceAuthError::USER_NOT_SIGNED_UP || | 487 state == GoogleServiceAuthError::USER_NOT_SIGNED_UP || |
| 488 state == GoogleServiceAuthError::ACCOUNT_DELETED || | 488 state == GoogleServiceAuthError::ACCOUNT_DELETED || |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 | 540 |
| 541 // Update the UI buttons. | 541 // Update the UI buttons. |
| 542 OnHasProfileShortcuts(false); | 542 OnHasProfileShortcuts(false); |
| 543 } | 543 } |
| 544 | 544 |
| 545 void ManageProfileHandler::RefreshGaiaPicture(const base::ListValue* args) { | 545 void ManageProfileHandler::RefreshGaiaPicture(const base::ListValue* args) { |
| 546 profiles::UpdateGaiaProfileInfoIfNeeded(Profile::FromWebUI(web_ui())); | 546 profiles::UpdateGaiaProfileInfoIfNeeded(Profile::FromWebUI(web_ui())); |
| 547 } | 547 } |
| 548 | 548 |
| 549 } // namespace options | 549 } // namespace options |
| OLD | NEW |