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

Side by Side Diff: chrome/browser/ui/webui/sync_setup_handler.cc

Issue 8689006: Create a field test for sync sign in promo strings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: addressed nits and removed NTP cache stuff Created 9 years 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 (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
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
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 // TODO(stevet): This doesn't jive well with
311 // NTPResourceCache::CreateNewTabHTML, which is incapable of passing the
sail 2011/11/28 20:44:04 I think you can remove this comment now.
SteveT 2011/11/28 22:11:15 Done.
312 // web_ui member to us. Either confirm that this doesn't matter (we don't show
313 // this string in the NTP, anyway) or find a way to make this cacheable.
314 int message_body_resource_id = IDS_SYNC_PROMO_MESSAGE_BODY_A;
315 if (web_ui && SyncPromoUI::GetIsLaunchPageForSyncPromoURL(
316 web_ui->tab_contents()->GetURL())) {
317 message_body_resource_id = SyncPromoTrial::GetMessageBodyResID();
318 }
319 localized_strings->SetString(
320 "promoMessageBody",
321 GetStringUTF16(message_body_resource_id));
322
306 std::string create_account_url = 323 std::string create_account_url =
307 google_util::StringAppendGoogleLocaleParam(kCreateNewAccountUrl); 324 google_util::StringAppendGoogleLocaleParam(kCreateNewAccountUrl);
308 string16 create_account = GetStringUTF16(IDS_SYNC_CREATE_ACCOUNT); 325 string16 create_account = GetStringUTF16(IDS_SYNC_CREATE_ACCOUNT);
309 create_account= UTF8ToUTF16("<a id='create-account-link' target='_blank' " 326 create_account= UTF8ToUTF16("<a id='create-account-link' target='_blank' "
310 "class='account-link' href='" + create_account_url + "'>") + 327 "class='account-link' href='" + create_account_url + "'>") +
311 create_account + UTF8ToUTF16("</a>"); 328 create_account + UTF8ToUTF16("</a>");
312 localized_strings->SetString("createAccountLinkHTML", 329 localized_strings->SetString("createAccountLinkHTML",
313 GetStringFUTF16(IDS_SYNC_CREATE_ACCOUNT_PREFIX, create_account)); 330 GetStringFUTF16(IDS_SYNC_CREATE_ACCOUNT_PREFIX, create_account));
314 331
315 static OptionsStringResource resources[] = { 332 static OptionsStringResource resources[] = {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 { "no", IDS_SYNC_PASSPHRASE_CANCEL_NO }, 393 { "no", IDS_SYNC_PASSPHRASE_CANCEL_NO },
377 { "sectionExplicitMessagePrefix", IDS_SYNC_PASSPHRASE_MSG_EXPLICIT_PREFIX }, 394 { "sectionExplicitMessagePrefix", IDS_SYNC_PASSPHRASE_MSG_EXPLICIT_PREFIX },
378 { "sectionExplicitMessagePostfix", 395 { "sectionExplicitMessagePostfix",
379 IDS_SYNC_PASSPHRASE_MSG_EXPLICIT_POSTFIX }, 396 IDS_SYNC_PASSPHRASE_MSG_EXPLICIT_POSTFIX },
380 { "encryptedDataTypesTitle", IDS_SYNC_ENCRYPTION_DATA_TYPES_TITLE }, 397 { "encryptedDataTypesTitle", IDS_SYNC_ENCRYPTION_DATA_TYPES_TITLE },
381 { "encryptSensitiveOption", IDS_SYNC_ENCRYPT_SENSITIVE_DATA }, 398 { "encryptSensitiveOption", IDS_SYNC_ENCRYPT_SENSITIVE_DATA },
382 { "encryptAllOption", IDS_SYNC_ENCRYPT_ALL_DATA }, 399 { "encryptAllOption", IDS_SYNC_ENCRYPT_ALL_DATA },
383 { "encryptAllOption", IDS_SYNC_ENCRYPT_ALL_DATA }, 400 { "encryptAllOption", IDS_SYNC_ENCRYPT_ALL_DATA },
384 { "aspWarningText", IDS_SYNC_ASP_PASSWORD_WARNING_TEXT }, 401 { "aspWarningText", IDS_SYNC_ASP_PASSWORD_WARNING_TEXT },
385 { "promoPageTitle", IDS_SYNC_PROMO_TAB_TITLE}, 402 { "promoPageTitle", IDS_SYNC_PROMO_TAB_TITLE},
386 { "promoMessageBody", IDS_SYNC_PROMO_MESSAGE_BODY},
387 { "promoSkipButton", IDS_SYNC_PROMO_SKIP_BUTTON}, 403 { "promoSkipButton", IDS_SYNC_PROMO_SKIP_BUTTON},
388 { "promoAdvanced", IDS_SYNC_PROMO_ADVANCED}, 404 { "promoAdvanced", IDS_SYNC_PROMO_ADVANCED},
389 { "promoLearnMoreShow", IDS_SYNC_PROMO_LEARN_MORE_SHOW}, 405 { "promoLearnMoreShow", IDS_SYNC_PROMO_LEARN_MORE_SHOW},
390 { "promoLearnMoreHide", IDS_SYNC_PROMO_LEARN_MORE_HIDE}, 406 { "promoLearnMoreHide", IDS_SYNC_PROMO_LEARN_MORE_HIDE},
391 { "promoInformation", IDS_SYNC_PROMO_INFORMATION}, 407 { "promoInformation", IDS_SYNC_PROMO_INFORMATION},
392 }; 408 };
393 409
394 RegisterStrings(localized_strings, resources, arraysize(resources)); 410 RegisterStrings(localized_strings, resources, arraysize(resources));
395 } 411 }
396 412
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 } 760 }
745 761
746 void SyncSetupHandler::ShowLoginErrorMessage(const string16& error_message) { 762 void SyncSetupHandler::ShowLoginErrorMessage(const string16& error_message) {
747 DictionaryValue args; 763 DictionaryValue args;
748 Profile* profile = Profile::FromWebUI(web_ui_); 764 Profile* profile = Profile::FromWebUI(web_ui_);
749 ProfileSyncService* service = profile->GetProfileSyncService(); 765 ProfileSyncService* service = profile->GetProfileSyncService();
750 SyncSetupFlow::GetArgsForGaiaLogin(service, &args); 766 SyncSetupFlow::GetArgsForGaiaLogin(service, &args);
751 args.SetString("error_message", error_message); 767 args.SetString("error_message", error_message);
752 ShowGaiaLogin(args); 768 ShowGaiaLogin(args);
753 } 769 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698