Chromium Code Reviews| Index: chrome/browser/ui/webui/settings/people_handler.cc |
| diff --git a/chrome/browser/ui/webui/settings/sync_handler.cc b/chrome/browser/ui/webui/settings/people_handler.cc |
| similarity index 88% |
| rename from chrome/browser/ui/webui/settings/sync_handler.cc |
| rename to chrome/browser/ui/webui/settings/people_handler.cc |
| index b60851a6b192ab7a5041d4cffc97c54f4087bf80..5f16fee54113fbddf4758f9b048e9f9e14941d87 100644 |
| --- a/chrome/browser/ui/webui/settings/sync_handler.cc |
| +++ b/chrome/browser/ui/webui/settings/people_handler.cc |
| @@ -2,7 +2,7 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#include "chrome/browser/ui/webui/settings/sync_handler.h" |
| +#include "chrome/browser/ui/webui/settings/people_handler.h" |
| #include "base/basictypes.h" |
| #include "base/bind.h" |
| @@ -79,8 +79,7 @@ SyncConfigInfo::SyncConfigInfo() |
| : encrypt_all(false), |
| sync_everything(false), |
| sync_nothing(false), |
| - passphrase_is_gaia(false) { |
| -} |
| + passphrase_is_gaia(false) {} |
| SyncConfigInfo::~SyncConfigInfo() {} |
| @@ -150,15 +149,16 @@ bool GetConfiguration(const std::string& json, SyncConfigInfo* config) { |
| namespace settings { |
| -SyncHandler::SyncHandler(Profile* profile) |
| +PeopleHandler::PeopleHandler(Profile* profile) |
| : profile_(profile), |
| configuring_sync_(false), |
| sync_service_observer_(this) { |
| PrefService* prefs = profile_->GetPrefs(); |
| profile_pref_registrar_.Init(prefs); |
| profile_pref_registrar_.Add( |
| - prefs::kSigninAllowed, base::Bind(&SyncHandler::OnSigninAllowedPrefChange, |
| - base::Unretained(this))); |
| + prefs::kSigninAllowed, |
| + base::Bind(&PeopleHandler::OnSigninAllowedPrefChange, |
| + base::Unretained(this))); |
| ProfileSyncService* sync_service( |
| ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_)); |
| @@ -166,7 +166,7 @@ SyncHandler::SyncHandler(Profile* profile) |
| sync_service_observer_.Add(sync_service); |
| } |
| -SyncHandler::~SyncHandler() { |
| +PeopleHandler::~PeopleHandler() { |
| // Just exit if running unit tests (no actual WebUI is attached). |
| if (!web_ui()) |
| return; |
| @@ -175,7 +175,7 @@ SyncHandler::~SyncHandler() { |
| CloseSyncSetup(); |
| } |
| -void SyncHandler::ConfigureSyncDone() { |
| +void PeopleHandler::ConfigureSyncDone() { |
| base::StringValue page("done"); |
| web_ui()->CallJavascriptFunction("settings.SyncPrivateApi.showSyncSetupPage", |
| page); |
| @@ -198,53 +198,50 @@ void SyncHandler::ConfigureSyncDone() { |
| } |
| } |
| -bool SyncHandler::IsActiveLogin() const { |
| +bool PeopleHandler::IsActiveLogin() const { |
| // LoginUIService can be nullptr if page is brought up in incognito mode |
| // (i.e. if the user is running in guest mode in cros and brings up settings). |
| LoginUIService* service = GetLoginUIService(); |
| return service && (service->current_login_ui() == this); |
| } |
| -void SyncHandler::RegisterMessages() { |
| +void PeopleHandler::RegisterMessages() { |
| web_ui()->RegisterMessageCallback( |
| "SyncSetupDidClosePage", |
| - base::Bind(&SyncHandler::OnDidClosePage, |
| - base::Unretained(this))); |
| + base::Bind(&PeopleHandler::OnDidClosePage, base::Unretained(this))); |
| web_ui()->RegisterMessageCallback( |
| "SyncSetupConfigure", |
| - base::Bind(&SyncHandler::HandleConfigure, |
| - base::Unretained(this))); |
| + base::Bind(&PeopleHandler::HandleConfigure, base::Unretained(this))); |
| web_ui()->RegisterMessageCallback( |
| "SyncSetupShowSetupUI", |
| - base::Bind(&SyncHandler::HandleShowSetupUI, |
| - base::Unretained(this))); |
| + base::Bind(&PeopleHandler::HandleShowSetupUI, base::Unretained(this))); |
| web_ui()->RegisterMessageCallback( |
| "SyncSetupCloseTimeout", |
| - base::Bind(&SyncHandler::HandleCloseTimeout, base::Unretained(this))); |
| + base::Bind(&PeopleHandler::HandleCloseTimeout, base::Unretained(this))); |
| web_ui()->RegisterMessageCallback( |
| "SyncSetupGetSyncStatus", |
| - base::Bind(&SyncHandler::HandleGetSyncStatus, base::Unretained(this))); |
| + base::Bind(&PeopleHandler::HandleGetSyncStatus, base::Unretained(this))); |
| web_ui()->RegisterMessageCallback( |
| "SyncSetupManageOtherPeople", |
| - base::Bind(&SyncHandler::HandleManageOtherPeople, |
| + base::Bind(&PeopleHandler::HandleManageOtherPeople, |
| base::Unretained(this))); |
| #if defined(OS_CHROMEOS) |
| web_ui()->RegisterMessageCallback( |
| "SyncSetupDoSignOutOnAuthError", |
| - base::Bind(&SyncHandler::HandleDoSignOutOnAuthError, |
| + base::Bind(&PeopleHandler::HandleDoSignOutOnAuthError, |
| base::Unretained(this))); |
| #else |
| - web_ui()->RegisterMessageCallback("SyncSetupStopSyncing", |
| - base::Bind(&SyncHandler::HandleStopSyncing, |
| - base::Unretained(this))); |
| - web_ui()->RegisterMessageCallback("SyncSetupStartSignIn", |
| - base::Bind(&SyncHandler::HandleStartSignin, |
| - base::Unretained(this))); |
| + web_ui()->RegisterMessageCallback( |
| + "SyncSetupStopSyncing", |
| + base::Bind(&PeopleHandler::HandleStopSyncing, base::Unretained(this))); |
| + web_ui()->RegisterMessageCallback( |
| + "SyncSetupStartSignIn", |
| + base::Bind(&PeopleHandler::HandleStartSignin, base::Unretained(this))); |
| #endif |
| } |
| #if !defined(OS_CHROMEOS) |
| -void SyncHandler::DisplayGaiaLogin(signin_metrics::AccessPoint access_point) { |
| +void PeopleHandler::DisplayGaiaLogin(signin_metrics::AccessPoint access_point) { |
| DCHECK(!sync_startup_tracker_); |
| // Advanced options are no longer being configured if the login screen is |
| // visible. If the user exits the signin wizard after this without |
| @@ -253,10 +250,10 @@ void SyncHandler::DisplayGaiaLogin(signin_metrics::AccessPoint access_point) { |
| DisplayGaiaLoginInNewTabOrWindow(access_point); |
| } |
| -void SyncHandler::DisplayGaiaLoginInNewTabOrWindow( |
| +void PeopleHandler::DisplayGaiaLoginInNewTabOrWindow( |
| signin_metrics::AccessPoint access_point) { |
| - Browser* browser = chrome::FindBrowserWithWebContents( |
| - web_ui()->GetWebContents()); |
| + Browser* browser = |
| + chrome::FindBrowserWithWebContents(web_ui()->GetWebContents()); |
| bool force_new_tab = false; |
| if (!browser) { |
| // Settings is not displayed in a browser window. Open a new window. |
| @@ -269,8 +266,8 @@ void SyncHandler::DisplayGaiaLoginInNewTabOrWindow( |
| // re-auth scenario, and we need to ensure that the user signs in with the |
| // same email address. |
| GURL url; |
| - if (SigninManagerFactory::GetForProfile( |
| - browser->profile())->IsAuthenticated()) { |
| + if (SigninManagerFactory::GetForProfile(browser->profile()) |
| + ->IsAuthenticated()) { |
|
dschuyler
2015/12/10 00:51:48
I think cl format is making a mistake here. Pleas
tommycli
2015/12/10 01:57:02
Done. I provided a third alternative, since I thin
|
| UMA_HISTOGRAM_ENUMERATION("Signin.Reauth", |
| signin_metrics::HISTOGRAM_REAUTH_SHOWN, |
| signin_metrics::HISTOGRAM_REAUTH_MAX); |
| @@ -304,7 +301,7 @@ void SyncHandler::DisplayGaiaLoginInNewTabOrWindow( |
| } |
| #endif |
| -bool SyncHandler::PrepareSyncSetup() { |
| +bool PeopleHandler::PrepareSyncSetup() { |
| // If the wizard is already visible, just focus that one. |
| if (FocusExistingWizardIfPresent()) { |
| if (!IsActiveLogin()) |
| @@ -322,7 +319,7 @@ bool SyncHandler::PrepareSyncSetup() { |
| return true; |
| } |
| -void SyncHandler::DisplaySpinner() { |
| +void PeopleHandler::DisplaySpinner() { |
| configuring_sync_ = true; |
| base::StringValue page("spinner"); |
| base::DictionaryValue args; |
| @@ -331,8 +328,8 @@ void SyncHandler::DisplaySpinner() { |
| DCHECK(!backend_start_timer_); |
| backend_start_timer_.reset(new base::OneShotTimer()); |
| backend_start_timer_->Start(FROM_HERE, |
| - base::TimeDelta::FromSeconds(kTimeoutSec), |
| - this, &SyncHandler::DisplayTimeout); |
| + base::TimeDelta::FromSeconds(kTimeoutSec), this, |
| + &PeopleHandler::DisplayTimeout); |
| web_ui()->CallJavascriptFunction("settings.SyncPrivateApi.showSyncSetupPage", |
| page, args); |
| @@ -340,7 +337,7 @@ void SyncHandler::DisplaySpinner() { |
| // TODO(kochi): Handle error conditions other than timeout. |
| // http://crbug.com/128692 |
| -void SyncHandler::DisplayTimeout() { |
| +void PeopleHandler::DisplayTimeout() { |
| // Stop a timer to handle timeout in waiting for checking network connection. |
| backend_start_timer_.reset(); |
| @@ -353,11 +350,11 @@ void SyncHandler::DisplayTimeout() { |
| page, args); |
| } |
| -void SyncHandler::OnDidClosePage(const base::ListValue* args) { |
| +void PeopleHandler::OnDidClosePage(const base::ListValue* args) { |
| CloseSyncSetup(); |
| } |
| -void SyncHandler::SyncStartupFailed() { |
| +void PeopleHandler::SyncStartupFailed() { |
| // Stop a timer to handle timeout in waiting for checking network connection. |
| backend_start_timer_.reset(); |
| @@ -366,7 +363,7 @@ void SyncHandler::SyncStartupFailed() { |
| CloseUI(); |
| } |
| -void SyncHandler::SyncStartupCompleted() { |
| +void PeopleHandler::SyncStartupCompleted() { |
| ProfileSyncService* service = GetSyncService(); |
| DCHECK(service->IsBackendInitialized()); |
| @@ -376,13 +373,13 @@ void SyncHandler::SyncStartupCompleted() { |
| DisplayConfigureSync(false); |
| } |
| -ProfileSyncService* SyncHandler::GetSyncService() const { |
| +ProfileSyncService* PeopleHandler::GetSyncService() const { |
| return profile_->IsSyncAllowed() |
| ? ProfileSyncServiceFactory::GetForProfile(profile_) |
| : nullptr; |
| } |
| -void SyncHandler::HandleConfigure(const base::ListValue* args) { |
| +void PeopleHandler::HandleConfigure(const base::ListValue* args) { |
| DCHECK(!sync_startup_tracker_); |
| std::string json; |
| if (!args->GetString(0, &json)) { |
| @@ -505,7 +502,7 @@ void SyncHandler::HandleConfigure(const base::ListValue* args) { |
| ProfileMetrics::LogProfileSyncInfo(ProfileMetrics::SYNC_CHOOSE); |
| } |
| -void SyncHandler::HandleShowSetupUI(const base::ListValue* args) { |
| +void PeopleHandler::HandleShowSetupUI(const base::ListValue* args) { |
| if (!GetSyncService()) { |
| CloseUI(); |
| return; |
| @@ -540,20 +537,20 @@ void SyncHandler::HandleShowSetupUI(const base::ListValue* args) { |
| #if defined(OS_CHROMEOS) |
| // On ChromeOS, we need to sign out the user session to fix an auth error, so |
| // the user goes through the real signin flow to generate a new auth token. |
| -void SyncHandler::HandleDoSignOutOnAuthError(const base::ListValue* args) { |
| +void PeopleHandler::HandleDoSignOutOnAuthError(const base::ListValue* args) { |
| DVLOG(1) << "Signing out the user to fix a sync error."; |
| chrome::AttemptUserExit(); |
| } |
| #endif |
| #if !defined(OS_CHROMEOS) |
| -void SyncHandler::HandleStartSignin(const base::ListValue* args) { |
| +void PeopleHandler::HandleStartSignin(const base::ListValue* args) { |
| // Should only be called if the user is not already signed in. |
| DCHECK(!SigninManagerFactory::GetForProfile(profile_)->IsAuthenticated()); |
| OpenSyncSetup(args); |
| } |
| -void SyncHandler::HandleStopSyncing(const base::ListValue* args) { |
| +void PeopleHandler::HandleStopSyncing(const base::ListValue* args) { |
| if (GetSyncService()) |
| ProfileSyncService::SyncEvent(ProfileSyncService::STOP_FROM_OPTIONS); |
| SigninManagerFactory::GetForProfile(profile_) |
| @@ -567,20 +564,20 @@ void SyncHandler::HandleStopSyncing(const base::ListValue* args) { |
| } |
| #endif |
| -void SyncHandler::HandleCloseTimeout(const base::ListValue* args) { |
| +void PeopleHandler::HandleCloseTimeout(const base::ListValue* args) { |
| CloseSyncSetup(); |
| } |
| -void SyncHandler::HandleGetSyncStatus(const base::ListValue* /* args */) { |
| +void PeopleHandler::HandleGetSyncStatus(const base::ListValue* /* args */) { |
| UpdateSyncState(); |
| } |
| -void SyncHandler::HandleManageOtherPeople(const base::ListValue* /* args */) { |
| +void PeopleHandler::HandleManageOtherPeople(const base::ListValue* /* args */) { |
| UserManager::Show(base::FilePath(), profiles::USER_MANAGER_NO_TUTORIAL, |
| profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); |
| } |
| -void SyncHandler::CloseSyncSetup() { |
| +void PeopleHandler::CloseSyncSetup() { |
| // Stop a timer to handle timeout in waiting for checking network connection. |
| backend_start_timer_.reset(); |
| @@ -592,7 +589,8 @@ void SyncHandler::CloseSyncSetup() { |
| // Don't log a cancel event if the sync setup dialog is being |
| // automatically closed due to an auth error. |
| if (!sync_service || (!sync_service->HasSyncSetupCompleted() && |
| - sync_service->GetAuthError().state() == GoogleServiceAuthError::NONE)) { |
| + sync_service->GetAuthError().state() == |
| + GoogleServiceAuthError::NONE)) { |
| if (configuring_sync_) { |
| ProfileSyncService::SyncEvent( |
| ProfileSyncService::CANCEL_DURING_CONFIGURE); |
| @@ -606,7 +604,7 @@ void SyncHandler::CloseSyncSetup() { |
| if (sync_service) { |
| DVLOG(1) << "Sync setup aborted by user action"; |
| sync_service->RequestStop(ProfileSyncService::CLEAR_DATA); |
| - #if !defined(OS_CHROMEOS) |
| +#if !defined(OS_CHROMEOS) |
| // Sign out the user on desktop Chrome if they click cancel during |
| // initial setup. |
| // TODO(rsimha): Revisit this for M30. See http://crbug.com/252049. |
| @@ -614,7 +612,7 @@ void SyncHandler::CloseSyncSetup() { |
| SigninManagerFactory::GetForProfile(profile_) |
| ->SignOut(signin_metrics::ABORT_SIGNIN); |
| } |
| - #endif |
| +#endif |
| } |
| } |
| } |
| @@ -631,7 +629,7 @@ void SyncHandler::CloseSyncSetup() { |
| configuring_sync_ = false; |
| } |
| -void SyncHandler::OpenSyncSetup(const base::ListValue* args) { |
| +void PeopleHandler::OpenSyncSetup(const base::ListValue* args) { |
| if (!PrepareSyncSetup()) |
| return; |
| @@ -681,42 +679,42 @@ void SyncHandler::OpenSyncSetup(const base::ListValue* args) { |
| DisplayConfigureSync(false); |
| } |
| -void SyncHandler::OpenConfigureSync() { |
| +void PeopleHandler::OpenConfigureSync() { |
| if (!PrepareSyncSetup()) |
| return; |
| DisplayConfigureSync(false); |
| } |
| -void SyncHandler::FocusUI() { |
| +void PeopleHandler::FocusUI() { |
| DCHECK(IsActiveLogin()); |
| WebContents* web_contents = web_ui()->GetWebContents(); |
| web_contents->GetDelegate()->ActivateContents(web_contents); |
| } |
| -void SyncHandler::CloseUI() { |
| +void PeopleHandler::CloseUI() { |
| CloseSyncSetup(); |
| base::StringValue page("done"); |
| web_ui()->CallJavascriptFunction("settings.SyncPrivateApi.showSyncSetupPage", |
| page); |
| } |
| -void SyncHandler::GoogleSigninSucceeded(const std::string& /* account_id */, |
| - const std::string& /* username */, |
| - const std::string& /* password */) { |
| +void PeopleHandler::GoogleSigninSucceeded(const std::string& /* account_id */, |
| + const std::string& /* username */, |
| + const std::string& /* password */) { |
| UpdateSyncState(); |
| } |
| -void SyncHandler::GoogleSignedOut(const std::string& /* account_id */, |
| - const std::string& /* username */) { |
| +void PeopleHandler::GoogleSignedOut(const std::string& /* account_id */, |
| + const std::string& /* username */) { |
| UpdateSyncState(); |
| } |
| -void SyncHandler::OnStateChanged() { |
| +void PeopleHandler::OnStateChanged() { |
| UpdateSyncState(); |
| } |
| -scoped_ptr<base::DictionaryValue> SyncHandler::GetSyncStateDictionary() { |
| +scoped_ptr<base::DictionaryValue> PeopleHandler::GetSyncStateDictionary() { |
| // The items which are to be written into |sync_status| are also described in |
| // chrome/browser/resources/options/browser_options.js in @typedef |
| // for SyncStatus. Please update it whenever you add or remove any keys here. |
| @@ -769,13 +767,13 @@ scoped_ptr<base::DictionaryValue> SyncHandler::GetSyncStateDictionary() { |
| return sync_status.Pass(); |
| } |
| -bool SyncHandler::IsExistingWizardPresent() { |
| +bool PeopleHandler::IsExistingWizardPresent() { |
| LoginUIService* service = GetLoginUIService(); |
| DCHECK(service); |
| return service->current_login_ui() != nullptr; |
| } |
| -bool SyncHandler::FocusExistingWizardIfPresent() { |
| +bool PeopleHandler::FocusExistingWizardIfPresent() { |
| if (!IsExistingWizardPresent()) |
| return false; |
| @@ -785,7 +783,7 @@ bool SyncHandler::FocusExistingWizardIfPresent() { |
| return true; |
| } |
| -void SyncHandler::DisplayConfigureSync(bool passphrase_failed) { |
| +void PeopleHandler::DisplayConfigureSync(bool passphrase_failed) { |
| // Should never call this when we are not signed in. |
| DCHECK(SigninManagerFactory::GetForProfile(profile_)->IsAuthenticated()); |
| ProfileSyncService* service = GetSyncService(); |
| @@ -864,10 +862,9 @@ void SyncHandler::DisplayConfigureSync(bool passphrase_failed) { |
| if (!passphrase_time.is_null()) { |
| base::string16 passphrase_time_str = |
| base::TimeFormatShortDate(passphrase_time); |
| - args.SetString( |
| - "enterPassphraseBody", |
| - GetStringFUTF16(IDS_SYNC_ENTER_PASSPHRASE_BODY_WITH_DATE, |
| - passphrase_time_str)); |
| + args.SetString("enterPassphraseBody", |
| + GetStringFUTF16(IDS_SYNC_ENTER_PASSPHRASE_BODY_WITH_DATE, |
| + passphrase_time_str)); |
| args.SetString( |
| "enterGooglePassphraseBody", |
| GetStringFUTF16(IDS_SYNC_ENTER_GOOGLE_PASSPHRASE_BODY_WITH_DATE, |
| @@ -886,19 +883,16 @@ void SyncHandler::DisplayConfigureSync(bool passphrase_failed) { |
| passphrase_time_str)); |
| break; |
| default: |
| - args.SetString( |
| - "fullEncryptionBody", |
| - GetStringUTF16(IDS_SYNC_FULL_ENCRYPTION_BODY_CUSTOM)); |
| + args.SetString("fullEncryptionBody", |
| + GetStringUTF16(IDS_SYNC_FULL_ENCRYPTION_BODY_CUSTOM)); |
| break; |
| } |
| } else if (passphrase_type == syncer::CUSTOM_PASSPHRASE) { |
| - args.SetString( |
| - "fullEncryptionBody", |
| - GetStringUTF16(IDS_SYNC_FULL_ENCRYPTION_BODY_CUSTOM)); |
| + args.SetString("fullEncryptionBody", |
| + GetStringUTF16(IDS_SYNC_FULL_ENCRYPTION_BODY_CUSTOM)); |
| } else { |
| - args.SetString( |
| - "fullEncryptionBody", |
| - GetStringUTF16(IDS_SYNC_FULL_ENCRYPTION_DATA)); |
| + args.SetString("fullEncryptionBody", |
| + GetStringUTF16(IDS_SYNC_FULL_ENCRYPTION_DATA)); |
| } |
| base::StringValue page("configure"); |
| @@ -910,16 +904,16 @@ void SyncHandler::DisplayConfigureSync(bool passphrase_failed) { |
| FocusUI(); |
| } |
| -LoginUIService* SyncHandler::GetLoginUIService() const { |
| +LoginUIService* PeopleHandler::GetLoginUIService() const { |
| return LoginUIServiceFactory::GetForProfile(profile_); |
| } |
| -void SyncHandler::UpdateSyncState() { |
| +void PeopleHandler::UpdateSyncState() { |
| web_ui()->CallJavascriptFunction("settings.SyncPrivateApi.sendSyncStatus", |
| *GetSyncStateDictionary()); |
| } |
| -void SyncHandler::OnSigninAllowedPrefChange() { |
| +void PeopleHandler::OnSigninAllowedPrefChange() { |
| UpdateSyncState(); |
| } |