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" |
(...skipping 22 matching lines...) Expand all Loading... |
33 #include "grit/chromium_strings.h" | 33 #include "grit/chromium_strings.h" |
34 #include "grit/generated_resources.h" | 34 #include "grit/generated_resources.h" |
35 #include "grit/locale_settings.h" | 35 #include "grit/locale_settings.h" |
36 #include "ui/base/l10n/l10n_util.h" | 36 #include "ui/base/l10n/l10n_util.h" |
37 | 37 |
38 using l10n_util::GetStringFUTF16; | 38 using l10n_util::GetStringFUTF16; |
39 using l10n_util::GetStringUTF16; | 39 using l10n_util::GetStringUTF16; |
40 | 40 |
41 namespace { | 41 namespace { |
42 | 42 |
43 // TODO(jhawkins): Move these to url_constants.h. | |
44 const char* kInvalidPasswordHelpUrl = | |
45 "http://www.google.com/support/accounts/bin/answer.py?ctx=ch&answer=27444"; | |
46 const char* kCanNotAccessAccountUrl = | |
47 "http://www.google.com/support/accounts/bin/answer.py?answer=48598"; | |
48 #if defined(OS_CHROMEOS) | |
49 const char* kEncryptionHelpUrl = | |
50 "http://www.google.com/support/chromeos/bin/answer.py?answer=1181035"; | |
51 #else | |
52 const char* kEncryptionHelpUrl = | |
53 "http://www.google.com/support/chrome/bin/answer.py?answer=1181035"; | |
54 #endif | |
55 const char* kCreateNewAccountUrl = | |
56 "https://www.google.com/accounts/NewAccount?service=chromiumsync"; | |
57 | |
58 bool GetAuthData(const std::string& json, | 43 bool GetAuthData(const std::string& json, |
59 std::string* username, | 44 std::string* username, |
60 std::string* password, | 45 std::string* password, |
61 std::string* captcha, | 46 std::string* captcha, |
62 std::string* access_code) { | 47 std::string* access_code) { |
63 scoped_ptr<Value> parsed_value(base::JSONReader::Read(json, false)); | 48 scoped_ptr<Value> parsed_value(base::JSONReader::Read(json, false)); |
64 if (!parsed_value.get() || !parsed_value->IsType(Value::TYPE_DICTIONARY)) | 49 if (!parsed_value.get() || !parsed_value->IsType(Value::TYPE_DICTIONARY)) |
65 return false; | 50 return false; |
66 | 51 |
67 DictionaryValue* result = static_cast<DictionaryValue*>(parsed_value.get()); | 52 DictionaryValue* result = static_cast<DictionaryValue*>(parsed_value.get()); |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 GetStaticLocalizedValues(localized_strings, web_ui_); | 247 GetStaticLocalizedValues(localized_strings, web_ui_); |
263 } | 248 } |
264 | 249 |
265 void SyncSetupHandler::GetStaticLocalizedValues( | 250 void SyncSetupHandler::GetStaticLocalizedValues( |
266 DictionaryValue* localized_strings, | 251 DictionaryValue* localized_strings, |
267 WebUI* web_ui) { | 252 WebUI* web_ui) { |
268 DCHECK(localized_strings); | 253 DCHECK(localized_strings); |
269 | 254 |
270 localized_strings->SetString( | 255 localized_strings->SetString( |
271 "invalidPasswordHelpURL", | 256 "invalidPasswordHelpURL", |
272 google_util::StringAppendGoogleLocaleParam(kInvalidPasswordHelpUrl)); | 257 google_util::StringAppendGoogleLocaleParam( |
| 258 chrome::kInvalidPasswordHelpURL)); |
273 localized_strings->SetString( | 259 localized_strings->SetString( |
274 "cannotAccessAccountURL", | 260 "cannotAccessAccountURL", |
275 google_util::StringAppendGoogleLocaleParam(kCanNotAccessAccountUrl)); | 261 google_util::StringAppendGoogleLocaleParam( |
| 262 chrome::kCanNotAccessAccountURL)); |
276 localized_strings->SetString( | 263 localized_strings->SetString( |
277 "introduction", | 264 "introduction", |
278 GetStringFUTF16(IDS_SYNC_LOGIN_INTRODUCTION, | 265 GetStringFUTF16(IDS_SYNC_LOGIN_INTRODUCTION, |
279 GetStringUTF16(IDS_PRODUCT_NAME))); | 266 GetStringUTF16(IDS_PRODUCT_NAME))); |
280 localized_strings->SetString( | 267 localized_strings->SetString( |
281 "chooseDataTypesInstructions", | 268 "chooseDataTypesInstructions", |
282 GetStringFUTF16(IDS_SYNC_CHOOSE_DATATYPES_INSTRUCTIONS, | 269 GetStringFUTF16(IDS_SYNC_CHOOSE_DATATYPES_INSTRUCTIONS, |
283 GetStringUTF16(IDS_PRODUCT_NAME))); | 270 GetStringUTF16(IDS_PRODUCT_NAME))); |
284 localized_strings->SetString( | 271 localized_strings->SetString( |
285 "encryptionInstructions", | 272 "encryptionInstructions", |
286 GetStringFUTF16(IDS_SYNC_ENCRYPTION_INSTRUCTIONS, | 273 GetStringFUTF16(IDS_SYNC_ENCRYPTION_INSTRUCTIONS, |
287 GetStringUTF16(IDS_PRODUCT_NAME))); | 274 GetStringUTF16(IDS_PRODUCT_NAME))); |
288 localized_strings->SetString( | 275 localized_strings->SetString( |
289 "encryptionHelpURL", | 276 "encryptionHelpURL", |
290 google_util::StringAppendGoogleLocaleParam(kEncryptionHelpUrl)); | 277 google_util::StringAppendGoogleLocaleParam( |
| 278 chrome::kSyncEncryptionHelpURL)); |
291 localized_strings->SetString( | 279 localized_strings->SetString( |
292 "passphraseEncryptionMessage", | 280 "passphraseEncryptionMessage", |
293 GetStringFUTF16(IDS_SYNC_PASSPHRASE_ENCRYPTION_MESSAGE, | 281 GetStringFUTF16(IDS_SYNC_PASSPHRASE_ENCRYPTION_MESSAGE, |
294 GetStringUTF16(IDS_PRODUCT_NAME))); | 282 GetStringUTF16(IDS_PRODUCT_NAME))); |
295 localized_strings->SetString( | 283 localized_strings->SetString( |
296 "passphraseRecover", | 284 "passphraseRecover", |
297 GetStringFUTF16(IDS_SYNC_PASSPHRASE_RECOVER, | 285 GetStringFUTF16(IDS_SYNC_PASSPHRASE_RECOVER, |
298 ASCIIToUTF16(google_util::StringAppendGoogleLocaleParam( | 286 ASCIIToUTF16(google_util::StringAppendGoogleLocaleParam( |
299 chrome::kSyncGoogleDashboardURL)))); | 287 chrome::kSyncGoogleDashboardURL)))); |
300 localized_strings->SetString( | 288 localized_strings->SetString( |
301 "promoTitle", | 289 "promoTitle", |
302 GetStringFUTF16(IDS_SYNC_PROMO_TITLE, | 290 GetStringFUTF16(IDS_SYNC_PROMO_TITLE, |
303 GetStringUTF16(IDS_PRODUCT_NAME))); | 291 GetStringUTF16(IDS_PRODUCT_NAME))); |
304 localized_strings->SetString( | 292 localized_strings->SetString( |
305 "promoMessageTitle", | 293 "promoMessageTitle", |
306 GetStringFUTF16(IDS_SYNC_PROMO_MESSAGE_TITLE, | 294 GetStringFUTF16(IDS_SYNC_PROMO_MESSAGE_TITLE, |
307 GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); | 295 GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); |
| 296 localized_strings->SetString( |
| 297 "syncEverythingHelpURL", |
| 298 google_util::StringAppendGoogleLocaleParam( |
| 299 chrome::kSyncEverythingLearnMoreURL)); |
308 | 300 |
309 // The experimental body string only appears if we are on the launch page | 301 // The experimental body string only appears if we are on the launch page |
310 // version of the Sync Promo. | 302 // version of the Sync Promo. |
311 int message_body_resource_id = IDS_SYNC_PROMO_MESSAGE_BODY_A; | 303 int message_body_resource_id = IDS_SYNC_PROMO_MESSAGE_BODY_A; |
312 if (web_ui && SyncPromoUI::GetIsLaunchPageForSyncPromoURL( | 304 if (web_ui && SyncPromoUI::GetIsLaunchPageForSyncPromoURL( |
313 web_ui->tab_contents()->GetURL())) { | 305 web_ui->tab_contents()->GetURL())) { |
314 message_body_resource_id = sync_promo_trial::GetMessageBodyResID(); | 306 message_body_resource_id = sync_promo_trial::GetMessageBodyResID(); |
315 } | 307 } |
316 localized_strings->SetString( | 308 localized_strings->SetString( |
317 "promoMessageBody", | 309 "promoMessageBody", |
318 GetStringUTF16(message_body_resource_id)); | 310 GetStringUTF16(message_body_resource_id)); |
319 | 311 |
320 std::string create_account_url = | 312 std::string create_account_url = google_util::StringAppendGoogleLocaleParam( |
321 google_util::StringAppendGoogleLocaleParam(kCreateNewAccountUrl); | 313 chrome::kSyncCreateNewAccountURL); |
322 string16 create_account = GetStringUTF16(IDS_SYNC_CREATE_ACCOUNT); | 314 string16 create_account = GetStringUTF16(IDS_SYNC_CREATE_ACCOUNT); |
323 create_account= UTF8ToUTF16("<a id='create-account-link' target='_blank' " | 315 create_account= UTF8ToUTF16("<a id='create-account-link' target='_blank' " |
324 "class='account-link' href='" + create_account_url + "'>") + | 316 "class='account-link' href='" + create_account_url + "'>") + |
325 create_account + UTF8ToUTF16("</a>"); | 317 create_account + UTF8ToUTF16("</a>"); |
326 localized_strings->SetString("createAccountLinkHTML", | 318 localized_strings->SetString("createAccountLinkHTML", |
327 GetStringFUTF16(IDS_SYNC_CREATE_ACCOUNT_PREFIX, create_account)); | 319 GetStringFUTF16(IDS_SYNC_CREATE_ACCOUNT_PREFIX, create_account)); |
328 | 320 |
329 static OptionsStringResource resources[] = { | 321 static OptionsStringResource resources[] = { |
330 { "syncSetupOverlayTitle", IDS_SYNC_SETUP_TITLE }, | 322 { "syncSetupOverlayTitle", IDS_SYNC_SETUP_TITLE }, |
331 { "syncSetupConfigureTitle", IDS_SYNC_SETUP_CONFIGURE_TITLE }, | 323 { "syncSetupConfigureTitle", IDS_SYNC_SETUP_CONFIGURE_TITLE }, |
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
770 } | 762 } |
771 | 763 |
772 void SyncSetupHandler::ShowLoginErrorMessage(const string16& error_message) { | 764 void SyncSetupHandler::ShowLoginErrorMessage(const string16& error_message) { |
773 DictionaryValue args; | 765 DictionaryValue args; |
774 Profile* profile = Profile::FromWebUI(web_ui_); | 766 Profile* profile = Profile::FromWebUI(web_ui_); |
775 ProfileSyncService* service = profile->GetProfileSyncService(); | 767 ProfileSyncService* service = profile->GetProfileSyncService(); |
776 SyncSetupFlow::GetArgsForGaiaLogin(service, &args); | 768 SyncSetupFlow::GetArgsForGaiaLogin(service, &args); |
777 args.SetString("error_message", error_message); | 769 args.SetString("error_message", error_message); |
778 ShowGaiaLogin(args); | 770 ShowGaiaLogin(args); |
779 } | 771 } |
OLD | NEW |