Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/ui/webui/settings/sync_handler.h" | 5 #include "chrome/browser/ui/webui/settings/people_handler.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/i18n/time_formatting.h" | 12 #include "base/i18n/time_formatting.h" |
| 13 #include "base/json/json_reader.h" | 13 #include "base/json/json_reader.h" |
| 14 #include "base/json/json_writer.h" | 14 #include "base/json/json_writer.h" |
| 15 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 76 bool sync_nothing; | 76 bool sync_nothing; |
| 77 syncer::ModelTypeSet data_types; | 77 syncer::ModelTypeSet data_types; |
| 78 std::string passphrase; | 78 std::string passphrase; |
| 79 bool passphrase_is_gaia; | 79 bool passphrase_is_gaia; |
| 80 }; | 80 }; |
| 81 | 81 |
| 82 SyncConfigInfo::SyncConfigInfo() | 82 SyncConfigInfo::SyncConfigInfo() |
| 83 : encrypt_all(false), | 83 : encrypt_all(false), |
| 84 sync_everything(false), | 84 sync_everything(false), |
| 85 sync_nothing(false), | 85 sync_nothing(false), |
| 86 passphrase_is_gaia(false) { | 86 passphrase_is_gaia(false) {} |
| 87 } | |
| 88 | 87 |
| 89 SyncConfigInfo::~SyncConfigInfo() {} | 88 SyncConfigInfo::~SyncConfigInfo() {} |
| 90 | 89 |
| 91 bool GetConfiguration(const std::string& json, SyncConfigInfo* config) { | 90 bool GetConfiguration(const std::string& json, SyncConfigInfo* config) { |
| 92 scoped_ptr<base::Value> parsed_value = base::JSONReader::Read(json); | 91 scoped_ptr<base::Value> parsed_value = base::JSONReader::Read(json); |
| 93 base::DictionaryValue* result; | 92 base::DictionaryValue* result; |
| 94 if (!parsed_value || !parsed_value->GetAsDictionary(&result)) { | 93 if (!parsed_value || !parsed_value->GetAsDictionary(&result)) { |
| 95 DLOG(ERROR) << "GetConfiguration() not passed a Dictionary"; | 94 DLOG(ERROR) << "GetConfiguration() not passed a Dictionary"; |
| 96 return false; | 95 return false; |
| 97 } | 96 } |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 147 return false; | 146 return false; |
| 148 } | 147 } |
| 149 } | 148 } |
| 150 return true; | 149 return true; |
| 151 } | 150 } |
| 152 | 151 |
| 153 } // namespace | 152 } // namespace |
| 154 | 153 |
| 155 namespace settings { | 154 namespace settings { |
| 156 | 155 |
| 157 SyncHandler::SyncHandler(Profile* profile) | 156 PeopleHandler::PeopleHandler(Profile* profile) |
| 158 : profile_(profile), | 157 : profile_(profile), |
| 159 configuring_sync_(false), | 158 configuring_sync_(false), |
| 160 sync_service_observer_(this) { | 159 sync_service_observer_(this) { |
| 161 PrefService* prefs = profile_->GetPrefs(); | 160 PrefService* prefs = profile_->GetPrefs(); |
| 162 profile_pref_registrar_.Init(prefs); | 161 profile_pref_registrar_.Init(prefs); |
| 163 profile_pref_registrar_.Add( | 162 profile_pref_registrar_.Add( |
| 164 prefs::kSigninAllowed, base::Bind(&SyncHandler::OnSigninAllowedPrefChange, | 163 prefs::kSigninAllowed, |
| 165 base::Unretained(this))); | 164 base::Bind(&PeopleHandler::OnSigninAllowedPrefChange, |
| 165 base::Unretained(this))); | |
| 166 | 166 |
| 167 ProfileSyncService* sync_service( | 167 ProfileSyncService* sync_service( |
| 168 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_)); | 168 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_)); |
| 169 if (sync_service) | 169 if (sync_service) |
| 170 sync_service_observer_.Add(sync_service); | 170 sync_service_observer_.Add(sync_service); |
| 171 } | 171 } |
| 172 | 172 |
| 173 SyncHandler::~SyncHandler() { | 173 PeopleHandler::~PeopleHandler() { |
| 174 // Just exit if running unit tests (no actual WebUI is attached). | 174 // Just exit if running unit tests (no actual WebUI is attached). |
| 175 if (!web_ui()) | 175 if (!web_ui()) |
| 176 return; | 176 return; |
| 177 | 177 |
| 178 // This case is hit when the user performs a back navigation. | 178 // This case is hit when the user performs a back navigation. |
| 179 CloseSyncSetup(); | 179 CloseSyncSetup(); |
| 180 } | 180 } |
| 181 | 181 |
| 182 void SyncHandler::ConfigureSyncDone() { | 182 void PeopleHandler::ConfigureSyncDone() { |
| 183 base::StringValue page("done"); | 183 base::StringValue page("done"); |
| 184 web_ui()->CallJavascriptFunction("settings.SyncPrivateApi.showSyncSetupPage", | 184 web_ui()->CallJavascriptFunction("settings.SyncPrivateApi.showSyncSetupPage", |
| 185 page); | 185 page); |
| 186 | 186 |
| 187 // Suppress the sign in promo once the user starts sync. This way the user | 187 // Suppress the sign in promo once the user starts sync. This way the user |
| 188 // doesn't see the sign in promo even if they sign out later on. | 188 // doesn't see the sign in promo even if they sign out later on. |
| 189 signin::SetUserSkippedPromo(profile_); | 189 signin::SetUserSkippedPromo(profile_); |
| 190 | 190 |
| 191 ProfileSyncService* service = GetSyncService(); | 191 ProfileSyncService* service = GetSyncService(); |
| 192 DCHECK(service); | 192 DCHECK(service); |
| 193 if (!service->HasSyncSetupCompleted()) { | 193 if (!service->HasSyncSetupCompleted()) { |
| 194 // This is the first time configuring sync, so log it. | 194 // This is the first time configuring sync, so log it. |
| 195 base::FilePath profile_file_path = profile_->GetPath(); | 195 base::FilePath profile_file_path = profile_->GetPath(); |
| 196 ProfileMetrics::LogProfileSyncSignIn(profile_file_path); | 196 ProfileMetrics::LogProfileSyncSignIn(profile_file_path); |
| 197 | 197 |
| 198 // We're done configuring, so notify ProfileSyncService that it is OK to | 198 // We're done configuring, so notify ProfileSyncService that it is OK to |
| 199 // start syncing. | 199 // start syncing. |
| 200 service->SetSetupInProgress(false); | 200 service->SetSetupInProgress(false); |
| 201 service->SetSyncSetupCompleted(); | 201 service->SetSyncSetupCompleted(); |
| 202 } | 202 } |
| 203 } | 203 } |
| 204 | 204 |
| 205 bool SyncHandler::IsActiveLogin() const { | 205 bool PeopleHandler::IsActiveLogin() const { |
| 206 // LoginUIService can be nullptr if page is brought up in incognito mode | 206 // LoginUIService can be nullptr if page is brought up in incognito mode |
| 207 // (i.e. if the user is running in guest mode in cros and brings up settings). | 207 // (i.e. if the user is running in guest mode in cros and brings up settings). |
| 208 LoginUIService* service = GetLoginUIService(); | 208 LoginUIService* service = GetLoginUIService(); |
| 209 return service && (service->current_login_ui() == this); | 209 return service && (service->current_login_ui() == this); |
| 210 } | 210 } |
| 211 | 211 |
| 212 void SyncHandler::RegisterMessages() { | 212 void PeopleHandler::RegisterMessages() { |
| 213 web_ui()->RegisterMessageCallback( | 213 web_ui()->RegisterMessageCallback( |
| 214 "SyncSetupDidClosePage", | 214 "SyncSetupDidClosePage", |
| 215 base::Bind(&SyncHandler::OnDidClosePage, | 215 base::Bind(&PeopleHandler::OnDidClosePage, base::Unretained(this))); |
| 216 base::Unretained(this))); | |
| 217 web_ui()->RegisterMessageCallback( | 216 web_ui()->RegisterMessageCallback( |
| 218 "SyncSetupConfigure", | 217 "SyncSetupConfigure", |
| 219 base::Bind(&SyncHandler::HandleConfigure, | 218 base::Bind(&PeopleHandler::HandleConfigure, base::Unretained(this))); |
| 220 base::Unretained(this))); | |
| 221 web_ui()->RegisterMessageCallback( | 219 web_ui()->RegisterMessageCallback( |
| 222 "SyncSetupShowSetupUI", | 220 "SyncSetupShowSetupUI", |
| 223 base::Bind(&SyncHandler::HandleShowSetupUI, | 221 base::Bind(&PeopleHandler::HandleShowSetupUI, base::Unretained(this))); |
| 224 base::Unretained(this))); | |
| 225 web_ui()->RegisterMessageCallback( | 222 web_ui()->RegisterMessageCallback( |
| 226 "SyncSetupCloseTimeout", | 223 "SyncSetupCloseTimeout", |
| 227 base::Bind(&SyncHandler::HandleCloseTimeout, base::Unretained(this))); | 224 base::Bind(&PeopleHandler::HandleCloseTimeout, base::Unretained(this))); |
| 228 web_ui()->RegisterMessageCallback( | 225 web_ui()->RegisterMessageCallback( |
| 229 "SyncSetupGetSyncStatus", | 226 "SyncSetupGetSyncStatus", |
| 230 base::Bind(&SyncHandler::HandleGetSyncStatus, base::Unretained(this))); | 227 base::Bind(&PeopleHandler::HandleGetSyncStatus, base::Unretained(this))); |
| 231 web_ui()->RegisterMessageCallback( | 228 web_ui()->RegisterMessageCallback( |
| 232 "SyncSetupManageOtherPeople", | 229 "SyncSetupManageOtherPeople", |
| 233 base::Bind(&SyncHandler::HandleManageOtherPeople, | 230 base::Bind(&PeopleHandler::HandleManageOtherPeople, |
| 234 base::Unretained(this))); | 231 base::Unretained(this))); |
| 235 #if defined(OS_CHROMEOS) | 232 #if defined(OS_CHROMEOS) |
| 236 web_ui()->RegisterMessageCallback( | 233 web_ui()->RegisterMessageCallback( |
| 237 "SyncSetupDoSignOutOnAuthError", | 234 "SyncSetupDoSignOutOnAuthError", |
| 238 base::Bind(&SyncHandler::HandleDoSignOutOnAuthError, | 235 base::Bind(&PeopleHandler::HandleDoSignOutOnAuthError, |
| 239 base::Unretained(this))); | 236 base::Unretained(this))); |
| 240 #else | 237 #else |
| 241 web_ui()->RegisterMessageCallback("SyncSetupStopSyncing", | 238 web_ui()->RegisterMessageCallback( |
| 242 base::Bind(&SyncHandler::HandleStopSyncing, | 239 "SyncSetupStopSyncing", |
| 243 base::Unretained(this))); | 240 base::Bind(&PeopleHandler::HandleStopSyncing, base::Unretained(this))); |
| 244 web_ui()->RegisterMessageCallback("SyncSetupStartSignIn", | 241 web_ui()->RegisterMessageCallback( |
| 245 base::Bind(&SyncHandler::HandleStartSignin, | 242 "SyncSetupStartSignIn", |
| 246 base::Unretained(this))); | 243 base::Bind(&PeopleHandler::HandleStartSignin, base::Unretained(this))); |
| 247 #endif | 244 #endif |
| 248 } | 245 } |
| 249 | 246 |
| 250 #if !defined(OS_CHROMEOS) | 247 #if !defined(OS_CHROMEOS) |
| 251 void SyncHandler::DisplayGaiaLogin(signin_metrics::AccessPoint access_point) { | 248 void PeopleHandler::DisplayGaiaLogin(signin_metrics::AccessPoint access_point) { |
| 252 DCHECK(!sync_startup_tracker_); | 249 DCHECK(!sync_startup_tracker_); |
| 253 // Advanced options are no longer being configured if the login screen is | 250 // Advanced options are no longer being configured if the login screen is |
| 254 // visible. If the user exits the signin wizard after this without | 251 // visible. If the user exits the signin wizard after this without |
| 255 // configuring sync, CloseSyncSetup() will ensure they are logged out. | 252 // configuring sync, CloseSyncSetup() will ensure they are logged out. |
| 256 configuring_sync_ = false; | 253 configuring_sync_ = false; |
| 257 DisplayGaiaLoginInNewTabOrWindow(access_point); | 254 DisplayGaiaLoginInNewTabOrWindow(access_point); |
| 258 } | 255 } |
| 259 | 256 |
| 260 void SyncHandler::DisplayGaiaLoginInNewTabOrWindow( | 257 void PeopleHandler::DisplayGaiaLoginInNewTabOrWindow( |
| 261 signin_metrics::AccessPoint access_point) { | 258 signin_metrics::AccessPoint access_point) { |
| 262 Browser* browser = chrome::FindBrowserWithWebContents( | 259 Browser* browser = |
| 263 web_ui()->GetWebContents()); | 260 chrome::FindBrowserWithWebContents(web_ui()->GetWebContents()); |
| 264 bool force_new_tab = false; | 261 bool force_new_tab = false; |
| 265 if (!browser) { | 262 if (!browser) { |
| 266 // Settings is not displayed in a browser window. Open a new window. | 263 // Settings is not displayed in a browser window. Open a new window. |
| 267 browser = new Browser(Browser::CreateParams(Browser::TYPE_TABBED, profile_, | 264 browser = new Browser(Browser::CreateParams(Browser::TYPE_TABBED, profile_, |
| 268 chrome::GetActiveDesktop())); | 265 chrome::GetActiveDesktop())); |
| 269 force_new_tab = true; | 266 force_new_tab = true; |
| 270 } | 267 } |
| 271 | 268 |
| 272 // If the signin manager already has an authenticated username, this is a | 269 // If the signin manager already has an authenticated username, this is a |
| 273 // re-auth scenario, and we need to ensure that the user signs in with the | 270 // re-auth scenario, and we need to ensure that the user signs in with the |
| 274 // same email address. | 271 // same email address. |
| 275 GURL url; | 272 GURL url; |
| 276 if (SigninManagerFactory::GetForProfile( | 273 if (SigninManagerFactory::GetForProfile( |
| 277 browser->profile())->IsAuthenticated()) { | 274 browser->profile())->IsAuthenticated()) { |
|
dschuyler
2015/12/10 17:55:16
nit: the wrapped line is indented too far.
tommycli
2015/12/10 19:34:35
Err... I think the old way doesn't follow the styl
| |
| 278 UMA_HISTOGRAM_ENUMERATION("Signin.Reauth", | 275 UMA_HISTOGRAM_ENUMERATION("Signin.Reauth", |
| 279 signin_metrics::HISTOGRAM_REAUTH_SHOWN, | 276 signin_metrics::HISTOGRAM_REAUTH_SHOWN, |
| 280 signin_metrics::HISTOGRAM_REAUTH_MAX); | 277 signin_metrics::HISTOGRAM_REAUTH_MAX); |
| 281 | 278 |
| 282 SigninErrorController* error_controller = | 279 SigninErrorController* error_controller = |
| 283 SigninErrorControllerFactory::GetForProfile(browser->profile()); | 280 SigninErrorControllerFactory::GetForProfile(browser->profile()); |
| 284 DCHECK(error_controller->HasError()); | 281 DCHECK(error_controller->HasError()); |
| 285 if (!force_new_tab) { | 282 if (!force_new_tab) { |
| 286 browser->window()->ShowAvatarBubbleFromAvatarButton( | 283 browser->window()->ShowAvatarBubbleFromAvatarButton( |
| 287 BrowserWindow::AVATAR_BUBBLE_MODE_REAUTH, | 284 BrowserWindow::AVATAR_BUBBLE_MODE_REAUTH, |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 301 access_point, signin_metrics::Reason::REASON_SIGNIN_PRIMARY_ACCOUNT, | 298 access_point, signin_metrics::Reason::REASON_SIGNIN_PRIMARY_ACCOUNT, |
| 302 true); | 299 true); |
| 303 } | 300 } |
| 304 } | 301 } |
| 305 | 302 |
| 306 if (url.is_valid()) | 303 if (url.is_valid()) |
| 307 chrome::ShowSingletonTab(browser, url); | 304 chrome::ShowSingletonTab(browser, url); |
| 308 } | 305 } |
| 309 #endif | 306 #endif |
| 310 | 307 |
| 311 bool SyncHandler::PrepareSyncSetup() { | 308 bool PeopleHandler::PrepareSyncSetup() { |
| 312 // If the wizard is already visible, just focus that one. | 309 // If the wizard is already visible, just focus that one. |
| 313 if (FocusExistingWizardIfPresent()) { | 310 if (FocusExistingWizardIfPresent()) { |
| 314 if (!IsActiveLogin()) | 311 if (!IsActiveLogin()) |
| 315 CloseSyncSetup(); | 312 CloseSyncSetup(); |
| 316 return false; | 313 return false; |
| 317 } | 314 } |
| 318 | 315 |
| 319 // Notify services that login UI is now active. | 316 // Notify services that login UI is now active. |
| 320 GetLoginUIService()->SetLoginUI(this); | 317 GetLoginUIService()->SetLoginUI(this); |
| 321 | 318 |
| 322 ProfileSyncService* service = GetSyncService(); | 319 ProfileSyncService* service = GetSyncService(); |
| 323 if (service) | 320 if (service) |
| 324 service->SetSetupInProgress(true); | 321 service->SetSetupInProgress(true); |
| 325 | 322 |
| 326 return true; | 323 return true; |
| 327 } | 324 } |
| 328 | 325 |
| 329 void SyncHandler::DisplaySpinner() { | 326 void PeopleHandler::DisplaySpinner() { |
| 330 configuring_sync_ = true; | 327 configuring_sync_ = true; |
| 331 base::StringValue page("spinner"); | 328 base::StringValue page("spinner"); |
| 332 base::DictionaryValue args; | 329 base::DictionaryValue args; |
| 333 | 330 |
| 334 const int kTimeoutSec = 30; | 331 const int kTimeoutSec = 30; |
| 335 DCHECK(!backend_start_timer_); | 332 DCHECK(!backend_start_timer_); |
| 336 backend_start_timer_.reset(new base::OneShotTimer()); | 333 backend_start_timer_.reset(new base::OneShotTimer()); |
| 337 backend_start_timer_->Start(FROM_HERE, | 334 backend_start_timer_->Start(FROM_HERE, |
| 338 base::TimeDelta::FromSeconds(kTimeoutSec), | 335 base::TimeDelta::FromSeconds(kTimeoutSec), this, |
| 339 this, &SyncHandler::DisplayTimeout); | 336 &PeopleHandler::DisplayTimeout); |
| 340 | 337 |
| 341 web_ui()->CallJavascriptFunction("settings.SyncPrivateApi.showSyncSetupPage", | 338 web_ui()->CallJavascriptFunction("settings.SyncPrivateApi.showSyncSetupPage", |
| 342 page, args); | 339 page, args); |
| 343 } | 340 } |
| 344 | 341 |
| 345 // TODO(kochi): Handle error conditions other than timeout. | 342 // TODO(kochi): Handle error conditions other than timeout. |
| 346 // http://crbug.com/128692 | 343 // http://crbug.com/128692 |
| 347 void SyncHandler::DisplayTimeout() { | 344 void PeopleHandler::DisplayTimeout() { |
| 348 // Stop a timer to handle timeout in waiting for checking network connection. | 345 // Stop a timer to handle timeout in waiting for checking network connection. |
| 349 backend_start_timer_.reset(); | 346 backend_start_timer_.reset(); |
| 350 | 347 |
| 351 // Do not listen to sync startup events. | 348 // Do not listen to sync startup events. |
| 352 sync_startup_tracker_.reset(); | 349 sync_startup_tracker_.reset(); |
| 353 | 350 |
| 354 base::StringValue page("timeout"); | 351 base::StringValue page("timeout"); |
| 355 base::DictionaryValue args; | 352 base::DictionaryValue args; |
| 356 web_ui()->CallJavascriptFunction("settings.SyncPrivateApi.showSyncSetupPage", | 353 web_ui()->CallJavascriptFunction("settings.SyncPrivateApi.showSyncSetupPage", |
| 357 page, args); | 354 page, args); |
| 358 } | 355 } |
| 359 | 356 |
| 360 void SyncHandler::OnDidClosePage(const base::ListValue* args) { | 357 void PeopleHandler::OnDidClosePage(const base::ListValue* args) { |
| 361 CloseSyncSetup(); | 358 CloseSyncSetup(); |
| 362 } | 359 } |
| 363 | 360 |
| 364 void SyncHandler::SyncStartupFailed() { | 361 void PeopleHandler::SyncStartupFailed() { |
| 365 // Stop a timer to handle timeout in waiting for checking network connection. | 362 // Stop a timer to handle timeout in waiting for checking network connection. |
| 366 backend_start_timer_.reset(); | 363 backend_start_timer_.reset(); |
| 367 | 364 |
| 368 // Just close the sync overlay (the idea is that the base settings page will | 365 // Just close the sync overlay (the idea is that the base settings page will |
| 369 // display the current error.) | 366 // display the current error.) |
| 370 CloseUI(); | 367 CloseUI(); |
| 371 } | 368 } |
| 372 | 369 |
| 373 void SyncHandler::SyncStartupCompleted() { | 370 void PeopleHandler::SyncStartupCompleted() { |
| 374 ProfileSyncService* service = GetSyncService(); | 371 ProfileSyncService* service = GetSyncService(); |
| 375 DCHECK(service->IsBackendInitialized()); | 372 DCHECK(service->IsBackendInitialized()); |
| 376 | 373 |
| 377 // Stop a timer to handle timeout in waiting for checking network connection. | 374 // Stop a timer to handle timeout in waiting for checking network connection. |
| 378 backend_start_timer_.reset(); | 375 backend_start_timer_.reset(); |
| 379 | 376 |
| 380 DisplayConfigureSync(false); | 377 DisplayConfigureSync(false); |
| 381 } | 378 } |
| 382 | 379 |
| 383 ProfileSyncService* SyncHandler::GetSyncService() const { | 380 ProfileSyncService* PeopleHandler::GetSyncService() const { |
| 384 return profile_->IsSyncAllowed() | 381 return profile_->IsSyncAllowed() |
| 385 ? ProfileSyncServiceFactory::GetForProfile(profile_) | 382 ? ProfileSyncServiceFactory::GetForProfile(profile_) |
| 386 : nullptr; | 383 : nullptr; |
| 387 } | 384 } |
| 388 | 385 |
| 389 void SyncHandler::HandleConfigure(const base::ListValue* args) { | 386 void PeopleHandler::HandleConfigure(const base::ListValue* args) { |
| 390 DCHECK(!sync_startup_tracker_); | 387 DCHECK(!sync_startup_tracker_); |
| 391 std::string json; | 388 std::string json; |
| 392 if (!args->GetString(0, &json)) { | 389 if (!args->GetString(0, &json)) { |
| 393 NOTREACHED() << "Could not read JSON argument"; | 390 NOTREACHED() << "Could not read JSON argument"; |
| 394 return; | 391 return; |
| 395 } | 392 } |
| 396 if (json.empty()) { | 393 if (json.empty()) { |
| 397 NOTREACHED(); | 394 NOTREACHED(); |
| 398 return; | 395 return; |
| 399 } | 396 } |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 502 | 499 |
| 503 ProfileMetrics::LogProfileSyncInfo(ProfileMetrics::SYNC_CUSTOMIZE); | 500 ProfileMetrics::LogProfileSyncInfo(ProfileMetrics::SYNC_CUSTOMIZE); |
| 504 if (configuration.encrypt_all) | 501 if (configuration.encrypt_all) |
| 505 ProfileMetrics::LogProfileSyncInfo(ProfileMetrics::SYNC_ENCRYPT); | 502 ProfileMetrics::LogProfileSyncInfo(ProfileMetrics::SYNC_ENCRYPT); |
| 506 if (configuration.passphrase_is_gaia && !configuration.passphrase.empty()) | 503 if (configuration.passphrase_is_gaia && !configuration.passphrase.empty()) |
| 507 ProfileMetrics::LogProfileSyncInfo(ProfileMetrics::SYNC_PASSPHRASE); | 504 ProfileMetrics::LogProfileSyncInfo(ProfileMetrics::SYNC_PASSPHRASE); |
| 508 if (!configuration.sync_everything) | 505 if (!configuration.sync_everything) |
| 509 ProfileMetrics::LogProfileSyncInfo(ProfileMetrics::SYNC_CHOOSE); | 506 ProfileMetrics::LogProfileSyncInfo(ProfileMetrics::SYNC_CHOOSE); |
| 510 } | 507 } |
| 511 | 508 |
| 512 void SyncHandler::HandleShowSetupUI(const base::ListValue* args) { | 509 void PeopleHandler::HandleShowSetupUI(const base::ListValue* args) { |
| 513 if (!GetSyncService()) { | 510 if (!GetSyncService()) { |
| 514 CloseUI(); | 511 CloseUI(); |
| 515 return; | 512 return; |
| 516 } | 513 } |
| 517 | 514 |
| 518 SigninManagerBase* signin = SigninManagerFactory::GetForProfile(profile_); | 515 SigninManagerBase* signin = SigninManagerFactory::GetForProfile(profile_); |
| 519 if (!signin->IsAuthenticated()) { | 516 if (!signin->IsAuthenticated()) { |
| 520 // For web-based signin, the signin page is not displayed in an overlay | 517 // For web-based signin, the signin page is not displayed in an overlay |
| 521 // on the settings page. So if we get here, it must be due to the user | 518 // on the settings page. So if we get here, it must be due to the user |
| 522 // cancelling signin (by reloading the sync settings page during initial | 519 // cancelling signin (by reloading the sync settings page during initial |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 537 | 534 |
| 538 // If a setup wizard is present on this page or another, bring it to focus. | 535 // If a setup wizard is present on this page or another, bring it to focus. |
| 539 // Otherwise, display a new one on this page. | 536 // Otherwise, display a new one on this page. |
| 540 if (!FocusExistingWizardIfPresent()) | 537 if (!FocusExistingWizardIfPresent()) |
| 541 OpenSyncSetup(args); | 538 OpenSyncSetup(args); |
| 542 } | 539 } |
| 543 | 540 |
| 544 #if defined(OS_CHROMEOS) | 541 #if defined(OS_CHROMEOS) |
| 545 // On ChromeOS, we need to sign out the user session to fix an auth error, so | 542 // On ChromeOS, we need to sign out the user session to fix an auth error, so |
| 546 // the user goes through the real signin flow to generate a new auth token. | 543 // the user goes through the real signin flow to generate a new auth token. |
| 547 void SyncHandler::HandleDoSignOutOnAuthError(const base::ListValue* args) { | 544 void PeopleHandler::HandleDoSignOutOnAuthError(const base::ListValue* args) { |
| 548 DVLOG(1) << "Signing out the user to fix a sync error."; | 545 DVLOG(1) << "Signing out the user to fix a sync error."; |
| 549 chrome::AttemptUserExit(); | 546 chrome::AttemptUserExit(); |
| 550 } | 547 } |
| 551 #endif | 548 #endif |
| 552 | 549 |
| 553 #if !defined(OS_CHROMEOS) | 550 #if !defined(OS_CHROMEOS) |
| 554 void SyncHandler::HandleStartSignin(const base::ListValue* args) { | 551 void PeopleHandler::HandleStartSignin(const base::ListValue* args) { |
| 555 // Should only be called if the user is not already signed in. | 552 // Should only be called if the user is not already signed in. |
| 556 DCHECK(!SigninManagerFactory::GetForProfile(profile_)->IsAuthenticated()); | 553 DCHECK(!SigninManagerFactory::GetForProfile(profile_)->IsAuthenticated()); |
| 557 OpenSyncSetup(args); | 554 OpenSyncSetup(args); |
| 558 } | 555 } |
| 559 | 556 |
| 560 void SyncHandler::HandleStopSyncing(const base::ListValue* args) { | 557 void PeopleHandler::HandleStopSyncing(const base::ListValue* args) { |
| 561 if (GetSyncService()) | 558 if (GetSyncService()) |
| 562 ProfileSyncService::SyncEvent(ProfileSyncService::STOP_FROM_OPTIONS); | 559 ProfileSyncService::SyncEvent(ProfileSyncService::STOP_FROM_OPTIONS); |
| 563 SigninManagerFactory::GetForProfile(profile_) | 560 SigninManagerFactory::GetForProfile(profile_) |
| 564 ->SignOut(signin_metrics::USER_CLICKED_SIGNOUT_SETTINGS); | 561 ->SignOut(signin_metrics::USER_CLICKED_SIGNOUT_SETTINGS); |
| 565 | 562 |
| 566 bool delete_profile = false; | 563 bool delete_profile = false; |
| 567 if (args->GetBoolean(0, &delete_profile) && delete_profile) { | 564 if (args->GetBoolean(0, &delete_profile) && delete_profile) { |
| 568 // Do as BrowserOptionsHandler::DeleteProfile(). | 565 // Do as BrowserOptionsHandler::DeleteProfile(). |
| 569 options::helper::DeleteProfileAtPath(profile_->GetPath(), web_ui()); | 566 options::helper::DeleteProfileAtPath(profile_->GetPath(), web_ui()); |
| 570 } | 567 } |
| 571 } | 568 } |
| 572 #endif | 569 #endif |
| 573 | 570 |
| 574 void SyncHandler::HandleCloseTimeout(const base::ListValue* args) { | 571 void PeopleHandler::HandleCloseTimeout(const base::ListValue* args) { |
| 575 CloseSyncSetup(); | 572 CloseSyncSetup(); |
| 576 } | 573 } |
| 577 | 574 |
| 578 void SyncHandler::HandleGetSyncStatus(const base::ListValue* /* args */) { | 575 void PeopleHandler::HandleGetSyncStatus(const base::ListValue* /* args */) { |
| 579 UpdateSyncState(); | 576 UpdateSyncState(); |
| 580 } | 577 } |
| 581 | 578 |
| 582 void SyncHandler::HandleManageOtherPeople(const base::ListValue* /* args */) { | 579 void PeopleHandler::HandleManageOtherPeople(const base::ListValue* /* args */) { |
| 583 UserManager::Show(base::FilePath(), profiles::USER_MANAGER_NO_TUTORIAL, | 580 UserManager::Show(base::FilePath(), profiles::USER_MANAGER_NO_TUTORIAL, |
| 584 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); | 581 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); |
| 585 } | 582 } |
| 586 | 583 |
| 587 void SyncHandler::CloseSyncSetup() { | 584 void PeopleHandler::CloseSyncSetup() { |
| 588 // Stop a timer to handle timeout in waiting for checking network connection. | 585 // Stop a timer to handle timeout in waiting for checking network connection. |
| 589 backend_start_timer_.reset(); | 586 backend_start_timer_.reset(); |
| 590 | 587 |
| 591 // Clear the sync startup tracker, since the setup wizard is being closed. | 588 // Clear the sync startup tracker, since the setup wizard is being closed. |
| 592 sync_startup_tracker_.reset(); | 589 sync_startup_tracker_.reset(); |
| 593 | 590 |
| 594 ProfileSyncService* sync_service = GetSyncService(); | 591 ProfileSyncService* sync_service = GetSyncService(); |
| 595 if (IsActiveLogin()) { | 592 if (IsActiveLogin()) { |
| 596 // Don't log a cancel event if the sync setup dialog is being | 593 // Don't log a cancel event if the sync setup dialog is being |
| 597 // automatically closed due to an auth error. | 594 // automatically closed due to an auth error. |
| 598 if (!sync_service || (!sync_service->HasSyncSetupCompleted() && | 595 if (!sync_service || (!sync_service->HasSyncSetupCompleted() && |
| 599 sync_service->GetAuthError().state() == GoogleServiceAuthError::NONE)) { | 596 sync_service->GetAuthError().state() == |
| 597 GoogleServiceAuthError::NONE)) { | |
| 600 if (configuring_sync_) { | 598 if (configuring_sync_) { |
| 601 ProfileSyncService::SyncEvent( | 599 ProfileSyncService::SyncEvent( |
| 602 ProfileSyncService::CANCEL_DURING_CONFIGURE); | 600 ProfileSyncService::CANCEL_DURING_CONFIGURE); |
| 603 | 601 |
| 604 // If the user clicked "Cancel" while setting up sync, disable sync | 602 // If the user clicked "Cancel" while setting up sync, disable sync |
| 605 // because we don't want the sync backend to remain in the | 603 // because we don't want the sync backend to remain in the |
| 606 // first-setup-incomplete state. | 604 // first-setup-incomplete state. |
| 607 // Note: In order to disable sync across restarts on Chrome OS, | 605 // Note: In order to disable sync across restarts on Chrome OS, |
| 608 // we must call RequestStop(CLEAR_DATA), which suppresses sync startup | 606 // we must call RequestStop(CLEAR_DATA), which suppresses sync startup |
| 609 // in addition to disabling it. | 607 // in addition to disabling it. |
| 610 if (sync_service) { | 608 if (sync_service) { |
| 611 DVLOG(1) << "Sync setup aborted by user action"; | 609 DVLOG(1) << "Sync setup aborted by user action"; |
| 612 sync_service->RequestStop(ProfileSyncService::CLEAR_DATA); | 610 sync_service->RequestStop(ProfileSyncService::CLEAR_DATA); |
| 613 #if !defined(OS_CHROMEOS) | 611 #if !defined(OS_CHROMEOS) |
| 614 // Sign out the user on desktop Chrome if they click cancel during | 612 // Sign out the user on desktop Chrome if they click cancel during |
| 615 // initial setup. | 613 // initial setup. |
| 616 // TODO(rsimha): Revisit this for M30. See http://crbug.com/252049. | 614 // TODO(rsimha): Revisit this for M30. See http://crbug.com/252049. |
| 617 if (sync_service->IsFirstSetupInProgress()) { | 615 if (sync_service->IsFirstSetupInProgress()) { |
| 618 SigninManagerFactory::GetForProfile(profile_) | 616 SigninManagerFactory::GetForProfile(profile_) |
| 619 ->SignOut(signin_metrics::ABORT_SIGNIN); | 617 ->SignOut(signin_metrics::ABORT_SIGNIN); |
| 620 } | 618 } |
| 621 #endif | 619 #endif |
| 622 } | 620 } |
| 623 } | 621 } |
| 624 } | 622 } |
| 625 | 623 |
| 626 GetLoginUIService()->LoginUIClosed(this); | 624 GetLoginUIService()->LoginUIClosed(this); |
| 627 } | 625 } |
| 628 | 626 |
| 629 // Alert the sync service anytime the sync setup dialog is closed. This can | 627 // Alert the sync service anytime the sync setup dialog is closed. This can |
| 630 // happen due to the user clicking the OK or Cancel button, or due to the | 628 // happen due to the user clicking the OK or Cancel button, or due to the |
| 631 // dialog being closed by virtue of sync being disabled in the background. | 629 // dialog being closed by virtue of sync being disabled in the background. |
| 632 if (sync_service) | 630 if (sync_service) |
| 633 sync_service->SetSetupInProgress(false); | 631 sync_service->SetSetupInProgress(false); |
| 634 | 632 |
| 635 configuring_sync_ = false; | 633 configuring_sync_ = false; |
| 636 } | 634 } |
| 637 | 635 |
| 638 void SyncHandler::OpenSyncSetup(const base::ListValue* args) { | 636 void PeopleHandler::OpenSyncSetup(const base::ListValue* args) { |
| 639 if (!PrepareSyncSetup()) | 637 if (!PrepareSyncSetup()) |
| 640 return; | 638 return; |
| 641 | 639 |
| 642 // There are several different UI flows that can bring the user here: | 640 // There are several different UI flows that can bring the user here: |
| 643 // 1) Signin promo. | 641 // 1) Signin promo. |
| 644 // 2) Normal signin through settings page (IsAuthenticated() is false). | 642 // 2) Normal signin through settings page (IsAuthenticated() is false). |
| 645 // 3) Previously working credentials have expired. | 643 // 3) Previously working credentials have expired. |
| 646 // 4) User is signed in, but has stopped sync via the google dashboard, and | 644 // 4) User is signed in, but has stopped sync via the google dashboard, and |
| 647 // signout is prohibited by policy so we need to force a re-auth. | 645 // signout is prohibited by policy so we need to force a re-auth. |
| 648 // 5) User clicks [Advanced Settings] button on options page while already | 646 // 5) User clicks [Advanced Settings] button on options page while already |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 678 CloseUI(); | 676 CloseUI(); |
| 679 return; | 677 return; |
| 680 } | 678 } |
| 681 | 679 |
| 682 // User is already logged in. They must have brought up the config wizard | 680 // User is already logged in. They must have brought up the config wizard |
| 683 // via the "Advanced..." button or through One-Click signin (cases 4-6), or | 681 // via the "Advanced..." button or through One-Click signin (cases 4-6), or |
| 684 // they are re-enabling sync after having disabled it (case 7). | 682 // they are re-enabling sync after having disabled it (case 7). |
| 685 DisplayConfigureSync(false); | 683 DisplayConfigureSync(false); |
| 686 } | 684 } |
| 687 | 685 |
| 688 void SyncHandler::OpenConfigureSync() { | 686 void PeopleHandler::OpenConfigureSync() { |
| 689 if (!PrepareSyncSetup()) | 687 if (!PrepareSyncSetup()) |
| 690 return; | 688 return; |
| 691 | 689 |
| 692 DisplayConfigureSync(false); | 690 DisplayConfigureSync(false); |
| 693 } | 691 } |
| 694 | 692 |
| 695 void SyncHandler::FocusUI() { | 693 void PeopleHandler::FocusUI() { |
| 696 DCHECK(IsActiveLogin()); | 694 DCHECK(IsActiveLogin()); |
| 697 WebContents* web_contents = web_ui()->GetWebContents(); | 695 WebContents* web_contents = web_ui()->GetWebContents(); |
| 698 web_contents->GetDelegate()->ActivateContents(web_contents); | 696 web_contents->GetDelegate()->ActivateContents(web_contents); |
| 699 } | 697 } |
| 700 | 698 |
| 701 void SyncHandler::CloseUI() { | 699 void PeopleHandler::CloseUI() { |
| 702 CloseSyncSetup(); | 700 CloseSyncSetup(); |
| 703 base::StringValue page("done"); | 701 base::StringValue page("done"); |
| 704 web_ui()->CallJavascriptFunction("settings.SyncPrivateApi.showSyncSetupPage", | 702 web_ui()->CallJavascriptFunction("settings.SyncPrivateApi.showSyncSetupPage", |
| 705 page); | 703 page); |
| 706 } | 704 } |
| 707 | 705 |
| 708 void SyncHandler::GoogleSigninSucceeded(const std::string& /* account_id */, | 706 void PeopleHandler::GoogleSigninSucceeded(const std::string& /* account_id */, |
| 709 const std::string& /* username */, | 707 const std::string& /* username */, |
| 710 const std::string& /* password */) { | 708 const std::string& /* password */) { |
| 711 UpdateSyncState(); | 709 UpdateSyncState(); |
| 712 } | 710 } |
| 713 | 711 |
| 714 void SyncHandler::GoogleSignedOut(const std::string& /* account_id */, | 712 void PeopleHandler::GoogleSignedOut(const std::string& /* account_id */, |
| 715 const std::string& /* username */) { | 713 const std::string& /* username */) { |
| 716 UpdateSyncState(); | 714 UpdateSyncState(); |
| 717 } | 715 } |
| 718 | 716 |
| 719 void SyncHandler::OnStateChanged() { | 717 void PeopleHandler::OnStateChanged() { |
| 720 UpdateSyncState(); | 718 UpdateSyncState(); |
| 721 } | 719 } |
| 722 | 720 |
| 723 scoped_ptr<base::DictionaryValue> SyncHandler::GetSyncStateDictionary() { | 721 scoped_ptr<base::DictionaryValue> PeopleHandler::GetSyncStateDictionary() { |
| 724 // The items which are to be written into |sync_status| are also described in | 722 // The items which are to be written into |sync_status| are also described in |
| 725 // chrome/browser/resources/options/browser_options.js in @typedef | 723 // chrome/browser/resources/options/browser_options.js in @typedef |
| 726 // for SyncStatus. Please update it whenever you add or remove any keys here. | 724 // for SyncStatus. Please update it whenever you add or remove any keys here. |
| 727 scoped_ptr<base::DictionaryValue> sync_status(new base::DictionaryValue); | 725 scoped_ptr<base::DictionaryValue> sync_status(new base::DictionaryValue); |
| 728 if (profile_->IsGuestSession()) { | 726 if (profile_->IsGuestSession()) { |
| 729 // Cannot display signin status when running in guest mode on chromeos | 727 // Cannot display signin status when running in guest mode on chromeos |
| 730 // because there is no SigninManager. | 728 // because there is no SigninManager. |
| 731 sync_status->SetBoolean("signinAllowed", false); | 729 sync_status->SetBoolean("signinAllowed", false); |
| 732 return sync_status.Pass(); | 730 return sync_status.Pass(); |
| 733 } | 731 } |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 783 webui::GetBitmapDataUrl(icon.AsBitmap())); | 781 webui::GetBitmapDataUrl(icon.AsBitmap())); |
| 784 } else { | 782 } else { |
| 785 sync_status->SetString("iconURL", profiles::GetDefaultAvatarIconUrl( | 783 sync_status->SetString("iconURL", profiles::GetDefaultAvatarIconUrl( |
| 786 entry->GetAvatarIconIndex())); | 784 entry->GetAvatarIconIndex())); |
| 787 } | 785 } |
| 788 } | 786 } |
| 789 | 787 |
| 790 return sync_status.Pass(); | 788 return sync_status.Pass(); |
| 791 } | 789 } |
| 792 | 790 |
| 793 bool SyncHandler::IsExistingWizardPresent() { | 791 bool PeopleHandler::IsExistingWizardPresent() { |
| 794 LoginUIService* service = GetLoginUIService(); | 792 LoginUIService* service = GetLoginUIService(); |
| 795 DCHECK(service); | 793 DCHECK(service); |
| 796 return service->current_login_ui() != nullptr; | 794 return service->current_login_ui() != nullptr; |
| 797 } | 795 } |
| 798 | 796 |
| 799 bool SyncHandler::FocusExistingWizardIfPresent() { | 797 bool PeopleHandler::FocusExistingWizardIfPresent() { |
| 800 if (!IsExistingWizardPresent()) | 798 if (!IsExistingWizardPresent()) |
| 801 return false; | 799 return false; |
| 802 | 800 |
| 803 LoginUIService* service = GetLoginUIService(); | 801 LoginUIService* service = GetLoginUIService(); |
| 804 DCHECK(service); | 802 DCHECK(service); |
| 805 service->current_login_ui()->FocusUI(); | 803 service->current_login_ui()->FocusUI(); |
| 806 return true; | 804 return true; |
| 807 } | 805 } |
| 808 | 806 |
| 809 void SyncHandler::DisplayConfigureSync(bool passphrase_failed) { | 807 void PeopleHandler::DisplayConfigureSync(bool passphrase_failed) { |
| 810 // Should never call this when we are not signed in. | 808 // Should never call this when we are not signed in. |
| 811 DCHECK(SigninManagerFactory::GetForProfile(profile_)->IsAuthenticated()); | 809 DCHECK(SigninManagerFactory::GetForProfile(profile_)->IsAuthenticated()); |
| 812 ProfileSyncService* service = GetSyncService(); | 810 ProfileSyncService* service = GetSyncService(); |
| 813 DCHECK(service); | 811 DCHECK(service); |
| 814 if (!service->IsBackendInitialized()) { | 812 if (!service->IsBackendInitialized()) { |
| 815 service->RequestStart(); | 813 service->RequestStart(); |
| 816 | 814 |
| 817 // See if it's even possible to bring up the sync backend - if not | 815 // See if it's even possible to bring up the sync backend - if not |
| 818 // (unrecoverable error?), don't bother displaying a spinner that will be | 816 // (unrecoverable error?), don't bother displaying a spinner that will be |
| 819 // immediately closed because this leads to some ugly infinite UI loop (see | 817 // immediately closed because this leads to some ugly infinite UI loop (see |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 878 | 876 |
| 879 // To distinguish between FROZEN_IMPLICIT_PASSPHRASE and CUSTOM_PASSPHRASE | 877 // To distinguish between FROZEN_IMPLICIT_PASSPHRASE and CUSTOM_PASSPHRASE |
| 880 // we only set usePassphrase for CUSTOM_PASSPHRASE. | 878 // we only set usePassphrase for CUSTOM_PASSPHRASE. |
| 881 args.SetBoolean("usePassphrase", | 879 args.SetBoolean("usePassphrase", |
| 882 service->GetPassphraseType() == syncer::CUSTOM_PASSPHRASE); | 880 service->GetPassphraseType() == syncer::CUSTOM_PASSPHRASE); |
| 883 base::Time passphrase_time = service->GetExplicitPassphraseTime(); | 881 base::Time passphrase_time = service->GetExplicitPassphraseTime(); |
| 884 syncer::PassphraseType passphrase_type = service->GetPassphraseType(); | 882 syncer::PassphraseType passphrase_type = service->GetPassphraseType(); |
| 885 if (!passphrase_time.is_null()) { | 883 if (!passphrase_time.is_null()) { |
| 886 base::string16 passphrase_time_str = | 884 base::string16 passphrase_time_str = |
| 887 base::TimeFormatShortDate(passphrase_time); | 885 base::TimeFormatShortDate(passphrase_time); |
| 888 args.SetString( | 886 args.SetString("enterPassphraseBody", |
| 889 "enterPassphraseBody", | 887 GetStringFUTF16(IDS_SYNC_ENTER_PASSPHRASE_BODY_WITH_DATE, |
| 890 GetStringFUTF16(IDS_SYNC_ENTER_PASSPHRASE_BODY_WITH_DATE, | 888 passphrase_time_str)); |
| 891 passphrase_time_str)); | |
| 892 args.SetString( | 889 args.SetString( |
| 893 "enterGooglePassphraseBody", | 890 "enterGooglePassphraseBody", |
| 894 GetStringFUTF16(IDS_SYNC_ENTER_GOOGLE_PASSPHRASE_BODY_WITH_DATE, | 891 GetStringFUTF16(IDS_SYNC_ENTER_GOOGLE_PASSPHRASE_BODY_WITH_DATE, |
| 895 passphrase_time_str)); | 892 passphrase_time_str)); |
| 896 switch (passphrase_type) { | 893 switch (passphrase_type) { |
| 897 case syncer::FROZEN_IMPLICIT_PASSPHRASE: | 894 case syncer::FROZEN_IMPLICIT_PASSPHRASE: |
| 898 args.SetString( | 895 args.SetString( |
| 899 "fullEncryptionBody", | 896 "fullEncryptionBody", |
| 900 GetStringFUTF16(IDS_SYNC_FULL_ENCRYPTION_BODY_GOOGLE_WITH_DATE, | 897 GetStringFUTF16(IDS_SYNC_FULL_ENCRYPTION_BODY_GOOGLE_WITH_DATE, |
| 901 passphrase_time_str)); | 898 passphrase_time_str)); |
| 902 break; | 899 break; |
| 903 case syncer::CUSTOM_PASSPHRASE: | 900 case syncer::CUSTOM_PASSPHRASE: |
| 904 args.SetString( | 901 args.SetString( |
| 905 "fullEncryptionBody", | 902 "fullEncryptionBody", |
| 906 GetStringFUTF16(IDS_SYNC_FULL_ENCRYPTION_BODY_CUSTOM_WITH_DATE, | 903 GetStringFUTF16(IDS_SYNC_FULL_ENCRYPTION_BODY_CUSTOM_WITH_DATE, |
| 907 passphrase_time_str)); | 904 passphrase_time_str)); |
| 908 break; | 905 break; |
| 909 default: | 906 default: |
| 910 args.SetString( | 907 args.SetString("fullEncryptionBody", |
| 911 "fullEncryptionBody", | 908 GetStringUTF16(IDS_SYNC_FULL_ENCRYPTION_BODY_CUSTOM)); |
| 912 GetStringUTF16(IDS_SYNC_FULL_ENCRYPTION_BODY_CUSTOM)); | |
| 913 break; | 909 break; |
| 914 } | 910 } |
| 915 } else if (passphrase_type == syncer::CUSTOM_PASSPHRASE) { | 911 } else if (passphrase_type == syncer::CUSTOM_PASSPHRASE) { |
| 916 args.SetString( | 912 args.SetString("fullEncryptionBody", |
| 917 "fullEncryptionBody", | 913 GetStringUTF16(IDS_SYNC_FULL_ENCRYPTION_BODY_CUSTOM)); |
| 918 GetStringUTF16(IDS_SYNC_FULL_ENCRYPTION_BODY_CUSTOM)); | |
| 919 } else { | 914 } else { |
| 920 args.SetString( | 915 args.SetString("fullEncryptionBody", |
| 921 "fullEncryptionBody", | 916 GetStringUTF16(IDS_SYNC_FULL_ENCRYPTION_DATA)); |
| 922 GetStringUTF16(IDS_SYNC_FULL_ENCRYPTION_DATA)); | |
| 923 } | 917 } |
| 924 | 918 |
| 925 base::StringValue page("configure"); | 919 base::StringValue page("configure"); |
| 926 web_ui()->CallJavascriptFunction("settings.SyncPrivateApi.showSyncSetupPage", | 920 web_ui()->CallJavascriptFunction("settings.SyncPrivateApi.showSyncSetupPage", |
| 927 page, args); | 921 page, args); |
| 928 | 922 |
| 929 // Make sure the tab used for the Gaia sign in does not cover the settings | 923 // Make sure the tab used for the Gaia sign in does not cover the settings |
| 930 // tab. | 924 // tab. |
| 931 FocusUI(); | 925 FocusUI(); |
| 932 } | 926 } |
| 933 | 927 |
| 934 LoginUIService* SyncHandler::GetLoginUIService() const { | 928 LoginUIService* PeopleHandler::GetLoginUIService() const { |
| 935 return LoginUIServiceFactory::GetForProfile(profile_); | 929 return LoginUIServiceFactory::GetForProfile(profile_); |
| 936 } | 930 } |
| 937 | 931 |
| 938 void SyncHandler::UpdateSyncState() { | 932 void PeopleHandler::UpdateSyncState() { |
| 939 web_ui()->CallJavascriptFunction("settings.SyncPrivateApi.sendSyncStatus", | 933 web_ui()->CallJavascriptFunction("settings.SyncPrivateApi.sendSyncStatus", |
| 940 *GetSyncStateDictionary()); | 934 *GetSyncStateDictionary()); |
| 941 } | 935 } |
| 942 | 936 |
| 943 void SyncHandler::OnSigninAllowedPrefChange() { | 937 void PeopleHandler::OnSigninAllowedPrefChange() { |
| 944 UpdateSyncState(); | 938 UpdateSyncState(); |
| 945 } | 939 } |
| 946 | 940 |
| 947 } // namespace settings | 941 } // namespace settings |
| OLD | NEW |