| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/sync_setup_handler.h" | 5 #include "chrome/browser/ui/webui/sync_setup_handler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
| 11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
| 12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "chrome/browser/google/google_util.h" | 14 #include "chrome/browser/google/google_util.h" |
| 15 #include "chrome/browser/prefs/pref_service.h" | 15 #include "chrome/browser/prefs/pref_service.h" |
| 16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 17 #include "chrome/browser/profiles/profile_info_cache.h" | 17 #include "chrome/browser/profiles/profile_info_cache.h" |
| 18 #include "chrome/browser/profiles/profile_manager.h" | 18 #include "chrome/browser/profiles/profile_manager.h" |
| 19 #include "chrome/browser/profiles/profile_metrics.h" | 19 #include "chrome/browser/profiles/profile_metrics.h" |
| 20 #include "chrome/browser/sync/profile_sync_service.h" | 20 #include "chrome/browser/sync/profile_sync_service.h" |
| 21 #include "chrome/browser/sync/protocol/service_constants.h" | 21 #include "chrome/browser/sync/protocol/service_constants.h" |
| 22 #include "chrome/browser/sync/signin_manager.h" | 22 #include "chrome/browser/sync/signin_manager.h" |
| 23 #include "chrome/browser/sync/sync_setup_flow.h" | 23 #include "chrome/browser/sync/sync_setup_flow.h" |
| 24 #include "chrome/browser/sync/util/oauth.h" | 24 #include "chrome/browser/sync/util/oauth.h" |
| 25 #include "chrome/browser/ui/browser_list.h" | 25 #include "chrome/browser/ui/browser_list.h" |
| 26 #include "chrome/browser/ui/webui/sync_promo_trial.h" |
| 26 #include "chrome/browser/ui/webui/sync_promo_ui.h" | 27 #include "chrome/browser/ui/webui/sync_promo_ui.h" |
| 27 #include "chrome/common/net/gaia/gaia_constants.h" | 28 #include "chrome/common/net/gaia/gaia_constants.h" |
| 28 #include "chrome/common/pref_names.h" | 29 #include "chrome/common/pref_names.h" |
| 29 #include "chrome/common/url_constants.h" | 30 #include "chrome/common/url_constants.h" |
| 30 #include "content/browser/tab_contents/tab_contents.h" | 31 #include "content/browser/tab_contents/tab_contents.h" |
| 31 #include "grit/chromium_strings.h" | 32 #include "grit/chromium_strings.h" |
| 32 #include "grit/generated_resources.h" | 33 #include "grit/generated_resources.h" |
| 33 #include "grit/locale_settings.h" | 34 #include "grit/locale_settings.h" |
| 34 #include "ui/base/l10n/l10n_util.h" | 35 #include "ui/base/l10n/l10n_util.h" |
| 35 | 36 |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 profile_manager_(profile_manager) { | 251 profile_manager_(profile_manager) { |
| 251 } | 252 } |
| 252 | 253 |
| 253 SyncSetupHandler::~SyncSetupHandler() { | 254 SyncSetupHandler::~SyncSetupHandler() { |
| 254 // This case is hit when the user performs a back navigation. | 255 // This case is hit when the user performs a back navigation. |
| 255 if (flow_) | 256 if (flow_) |
| 256 flow_->OnDialogClosed(""); | 257 flow_->OnDialogClosed(""); |
| 257 } | 258 } |
| 258 | 259 |
| 259 void SyncSetupHandler::GetLocalizedValues(DictionaryValue* localized_strings) { | 260 void SyncSetupHandler::GetLocalizedValues(DictionaryValue* localized_strings) { |
| 260 GetStaticLocalizedValues(localized_strings); | 261 GetStaticLocalizedValues(localized_strings, web_ui_); |
| 261 } | 262 } |
| 262 | 263 |
| 263 void SyncSetupHandler::GetStaticLocalizedValues( | 264 void SyncSetupHandler::GetStaticLocalizedValues( |
| 264 DictionaryValue* localized_strings) { | 265 DictionaryValue* localized_strings, |
| 266 WebUI* web_ui) { |
| 265 DCHECK(localized_strings); | 267 DCHECK(localized_strings); |
| 266 | 268 |
| 267 localized_strings->SetString( | 269 localized_strings->SetString( |
| 268 "invalidPasswordHelpURL", | 270 "invalidPasswordHelpURL", |
| 269 google_util::StringAppendGoogleLocaleParam(kInvalidPasswordHelpUrl)); | 271 google_util::StringAppendGoogleLocaleParam(kInvalidPasswordHelpUrl)); |
| 270 localized_strings->SetString( | 272 localized_strings->SetString( |
| 271 "cannotAccessAccountURL", | 273 "cannotAccessAccountURL", |
| 272 google_util::StringAppendGoogleLocaleParam(kCanNotAccessAccountUrl)); | 274 google_util::StringAppendGoogleLocaleParam(kCanNotAccessAccountUrl)); |
| 273 localized_strings->SetString( | 275 localized_strings->SetString( |
| 274 "introduction", | 276 "introduction", |
| (...skipping 21 matching lines...) Expand all Loading... |
| 296 chrome::kSyncGoogleDashboardURL)))); | 298 chrome::kSyncGoogleDashboardURL)))); |
| 297 localized_strings->SetString( | 299 localized_strings->SetString( |
| 298 "promoTitle", | 300 "promoTitle", |
| 299 GetStringFUTF16(IDS_SYNC_PROMO_TITLE, | 301 GetStringFUTF16(IDS_SYNC_PROMO_TITLE, |
| 300 GetStringUTF16(IDS_PRODUCT_NAME))); | 302 GetStringUTF16(IDS_PRODUCT_NAME))); |
| 301 localized_strings->SetString( | 303 localized_strings->SetString( |
| 302 "promoMessageTitle", | 304 "promoMessageTitle", |
| 303 GetStringFUTF16(IDS_SYNC_PROMO_MESSAGE_TITLE, | 305 GetStringFUTF16(IDS_SYNC_PROMO_MESSAGE_TITLE, |
| 304 GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); | 306 GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); |
| 305 | 307 |
| 308 // The experimental body string only appears if we are on the launch page |
| 309 // version of the Sync Promo. |
| 310 int message_body_resource_id = IDS_SYNC_PROMO_MESSAGE_BODY_A; |
| 311 if (web_ui && SyncPromoUI::GetIsLaunchPageForSyncPromoURL( |
| 312 web_ui->tab_contents()->GetURL())) { |
| 313 message_body_resource_id = sync_promo_trial::GetMessageBodyResID(); |
| 314 } |
| 315 localized_strings->SetString( |
| 316 "promoMessageBody", |
| 317 GetStringUTF16(message_body_resource_id)); |
| 318 |
| 306 std::string create_account_url = | 319 std::string create_account_url = |
| 307 google_util::StringAppendGoogleLocaleParam(kCreateNewAccountUrl); | 320 google_util::StringAppendGoogleLocaleParam(kCreateNewAccountUrl); |
| 308 string16 create_account = GetStringUTF16(IDS_SYNC_CREATE_ACCOUNT); | 321 string16 create_account = GetStringUTF16(IDS_SYNC_CREATE_ACCOUNT); |
| 309 create_account= UTF8ToUTF16("<a id='create-account-link' target='_blank' " | 322 create_account= UTF8ToUTF16("<a id='create-account-link' target='_blank' " |
| 310 "class='account-link' href='" + create_account_url + "'>") + | 323 "class='account-link' href='" + create_account_url + "'>") + |
| 311 create_account + UTF8ToUTF16("</a>"); | 324 create_account + UTF8ToUTF16("</a>"); |
| 312 localized_strings->SetString("createAccountLinkHTML", | 325 localized_strings->SetString("createAccountLinkHTML", |
| 313 GetStringFUTF16(IDS_SYNC_CREATE_ACCOUNT_PREFIX, create_account)); | 326 GetStringFUTF16(IDS_SYNC_CREATE_ACCOUNT_PREFIX, create_account)); |
| 314 | 327 |
| 315 static OptionsStringResource resources[] = { | 328 static OptionsStringResource resources[] = { |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 { "no", IDS_SYNC_PASSPHRASE_CANCEL_NO }, | 389 { "no", IDS_SYNC_PASSPHRASE_CANCEL_NO }, |
| 377 { "sectionExplicitMessagePrefix", IDS_SYNC_PASSPHRASE_MSG_EXPLICIT_PREFIX }, | 390 { "sectionExplicitMessagePrefix", IDS_SYNC_PASSPHRASE_MSG_EXPLICIT_PREFIX }, |
| 378 { "sectionExplicitMessagePostfix", | 391 { "sectionExplicitMessagePostfix", |
| 379 IDS_SYNC_PASSPHRASE_MSG_EXPLICIT_POSTFIX }, | 392 IDS_SYNC_PASSPHRASE_MSG_EXPLICIT_POSTFIX }, |
| 380 { "encryptedDataTypesTitle", IDS_SYNC_ENCRYPTION_DATA_TYPES_TITLE }, | 393 { "encryptedDataTypesTitle", IDS_SYNC_ENCRYPTION_DATA_TYPES_TITLE }, |
| 381 { "encryptSensitiveOption", IDS_SYNC_ENCRYPT_SENSITIVE_DATA }, | 394 { "encryptSensitiveOption", IDS_SYNC_ENCRYPT_SENSITIVE_DATA }, |
| 382 { "encryptAllOption", IDS_SYNC_ENCRYPT_ALL_DATA }, | 395 { "encryptAllOption", IDS_SYNC_ENCRYPT_ALL_DATA }, |
| 383 { "encryptAllOption", IDS_SYNC_ENCRYPT_ALL_DATA }, | 396 { "encryptAllOption", IDS_SYNC_ENCRYPT_ALL_DATA }, |
| 384 { "aspWarningText", IDS_SYNC_ASP_PASSWORD_WARNING_TEXT }, | 397 { "aspWarningText", IDS_SYNC_ASP_PASSWORD_WARNING_TEXT }, |
| 385 { "promoPageTitle", IDS_SYNC_PROMO_TAB_TITLE}, | 398 { "promoPageTitle", IDS_SYNC_PROMO_TAB_TITLE}, |
| 386 { "promoMessageBody", IDS_SYNC_PROMO_MESSAGE_BODY}, | |
| 387 { "promoSkipButton", IDS_SYNC_PROMO_SKIP_BUTTON}, | 399 { "promoSkipButton", IDS_SYNC_PROMO_SKIP_BUTTON}, |
| 388 { "promoAdvanced", IDS_SYNC_PROMO_ADVANCED}, | 400 { "promoAdvanced", IDS_SYNC_PROMO_ADVANCED}, |
| 389 { "promoLearnMoreShow", IDS_SYNC_PROMO_LEARN_MORE_SHOW}, | 401 { "promoLearnMoreShow", IDS_SYNC_PROMO_LEARN_MORE_SHOW}, |
| 390 { "promoLearnMoreHide", IDS_SYNC_PROMO_LEARN_MORE_HIDE}, | 402 { "promoLearnMoreHide", IDS_SYNC_PROMO_LEARN_MORE_HIDE}, |
| 391 { "promoInformation", IDS_SYNC_PROMO_INFORMATION}, | 403 { "promoInformation", IDS_SYNC_PROMO_INFORMATION}, |
| 392 }; | 404 }; |
| 393 | 405 |
| 394 RegisterStrings(localized_strings, resources, arraysize(resources)); | 406 RegisterStrings(localized_strings, resources, arraysize(resources)); |
| 395 } | 407 } |
| 396 | 408 |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 744 } | 756 } |
| 745 | 757 |
| 746 void SyncSetupHandler::ShowLoginErrorMessage(const string16& error_message) { | 758 void SyncSetupHandler::ShowLoginErrorMessage(const string16& error_message) { |
| 747 DictionaryValue args; | 759 DictionaryValue args; |
| 748 Profile* profile = Profile::FromWebUI(web_ui_); | 760 Profile* profile = Profile::FromWebUI(web_ui_); |
| 749 ProfileSyncService* service = profile->GetProfileSyncService(); | 761 ProfileSyncService* service = profile->GetProfileSyncService(); |
| 750 SyncSetupFlow::GetArgsForGaiaLogin(service, &args); | 762 SyncSetupFlow::GetArgsForGaiaLogin(service, &args); |
| 751 args.SetString("error_message", error_message); | 763 args.SetString("error_message", error_message); |
| 752 ShowGaiaLogin(args); | 764 ShowGaiaLogin(args); |
| 753 } | 765 } |
| OLD | NEW |