| 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_handler2.h" | 5 #include "chrome/browser/ui/webui/sync_setup_handler2.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/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "chrome/browser/google/google_util.h" | 13 #include "chrome/browser/google/google_util.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/profiles/profile_info_cache.h" | 15 #include "chrome/browser/profiles/profile_info_cache.h" |
| 16 #include "chrome/browser/profiles/profile_manager.h" | 16 #include "chrome/browser/profiles/profile_manager.h" |
| 17 #include "chrome/browser/profiles/profile_metrics.h" | 17 #include "chrome/browser/profiles/profile_metrics.h" |
| 18 #include "chrome/browser/sync/profile_sync_service.h" | 18 #include "chrome/browser/sync/profile_sync_service.h" |
| 19 #include "chrome/browser/sync/protocol/service_constants.h" | 19 #include "chrome/browser/sync/protocol/service_constants.h" |
| 20 #include "chrome/browser/sync/signin_manager.h" | 20 #include "chrome/browser/sync/signin_manager.h" |
| 21 #include "chrome/browser/sync/syncable/model_type.h" | 21 #include "chrome/browser/sync/syncable/model_type.h" |
| 22 #include "chrome/browser/sync/sync_setup_flow.h" | 22 #include "chrome/browser/sync/sync_setup_flow.h" |
| 23 #include "chrome/browser/sync/util/oauth.h" | 23 #include "chrome/browser/sync/util/oauth.h" |
| 24 #include "chrome/browser/ui/browser_list.h" | 24 #include "chrome/browser/ui/browser_list.h" |
| 25 #include "chrome/browser/ui/webui/sync_promo/sync_promo_trial.h" | 25 #include "chrome/browser/ui/webui/sync_promo/sync_promo_trial.h" |
| 26 #include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h" | 26 #include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h" |
| 27 #include "chrome/common/net/gaia/gaia_constants.h" | 27 #include "chrome/common/net/gaia/gaia_constants.h" |
| 28 #include "chrome/common/url_constants.h" | 28 #include "chrome/common/url_constants.h" |
| 29 #include "content/browser/tab_contents/tab_contents.h" | 29 #include "content/browser/renderer_host/render_view_host.h" |
| 30 #include "content/browser/renderer_host/render_view_host_delegate.h" |
| 31 #include "content/public/browser/web_contents.h" |
| 30 #include "grit/chromium_strings.h" | 32 #include "grit/chromium_strings.h" |
| 31 #include "grit/generated_resources.h" | 33 #include "grit/generated_resources.h" |
| 32 #include "grit/locale_settings.h" | 34 #include "grit/locale_settings.h" |
| 33 #include "ui/base/l10n/l10n_util.h" | 35 #include "ui/base/l10n/l10n_util.h" |
| 34 | 36 |
| 35 using l10n_util::GetStringFUTF16; | 37 using l10n_util::GetStringFUTF16; |
| 36 using l10n_util::GetStringUTF16; | 38 using l10n_util::GetStringUTF16; |
| 37 | 39 |
| 38 namespace { | 40 namespace { |
| 39 | 41 |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); | 242 GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); |
| 241 localized_strings->SetString( | 243 localized_strings->SetString( |
| 242 "syncEverythingHelpURL", | 244 "syncEverythingHelpURL", |
| 243 google_util::StringAppendGoogleLocaleParam( | 245 google_util::StringAppendGoogleLocaleParam( |
| 244 chrome::kSyncEverythingLearnMoreURL)); | 246 chrome::kSyncEverythingLearnMoreURL)); |
| 245 | 247 |
| 246 // The experimental body string only appears if we are on the launch page | 248 // The experimental body string only appears if we are on the launch page |
| 247 // version of the Sync Promo. | 249 // version of the Sync Promo. |
| 248 int message_body_resource_id = IDS_SYNC_PROMO_MESSAGE_BODY_A; | 250 int message_body_resource_id = IDS_SYNC_PROMO_MESSAGE_BODY_A; |
| 249 if (web_ui && SyncPromoUI::GetIsLaunchPageForSyncPromoURL( | 251 if (web_ui && SyncPromoUI::GetIsLaunchPageForSyncPromoURL( |
| 250 web_ui->tab_contents()->GetURL())) { | 252 web_ui->web_contents()->GetURL())) { |
| 251 message_body_resource_id = sync_promo_trial::GetMessageBodyResID(); | 253 message_body_resource_id = sync_promo_trial::GetMessageBodyResID(); |
| 252 } | 254 } |
| 253 localized_strings->SetString( | 255 localized_strings->SetString( |
| 254 "promoMessageBody", | 256 "promoMessageBody", |
| 255 GetStringUTF16(message_body_resource_id)); | 257 GetStringUTF16(message_body_resource_id)); |
| 256 | 258 |
| 257 std::string create_account_url = google_util::StringAppendGoogleLocaleParam( | 259 std::string create_account_url = google_util::StringAppendGoogleLocaleParam( |
| 258 chrome::kSyncCreateNewAccountURL); | 260 chrome::kSyncCreateNewAccountURL); |
| 259 string16 create_account = GetStringUTF16(IDS_SYNC_CREATE_ACCOUNT); | 261 string16 create_account = GetStringUTF16(IDS_SYNC_CREATE_ACCOUNT); |
| 260 create_account= UTF8ToUTF16("<a id='create-account-link' target='_blank' " | 262 create_account= UTF8ToUTF16("<a id='create-account-link' target='_blank' " |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 FilePath profile_file_path = profile->GetPath(); | 449 FilePath profile_file_path = profile->GetPath(); |
| 448 ProfileMetrics::LogProfileSyncSignIn(profile_file_path); | 450 ProfileMetrics::LogProfileSyncSignIn(profile_file_path); |
| 449 } | 451 } |
| 450 } | 452 } |
| 451 | 453 |
| 452 void SyncSetupHandler2::SetFlow(SyncSetupFlow* flow) { | 454 void SyncSetupHandler2::SetFlow(SyncSetupFlow* flow) { |
| 453 flow_ = flow; | 455 flow_ = flow; |
| 454 } | 456 } |
| 455 | 457 |
| 456 void SyncSetupHandler2::Focus() { | 458 void SyncSetupHandler2::Focus() { |
| 457 static_cast<RenderViewHostDelegate*>(web_ui()->tab_contents())->Activate(); | 459 web_ui()->web_contents()->GetRenderViewHost()->delegate()->Activate(); |
| 458 } | 460 } |
| 459 | 461 |
| 460 void SyncSetupHandler2::OnDidClosePage(const ListValue* args) { | 462 void SyncSetupHandler2::OnDidClosePage(const ListValue* args) { |
| 461 CloseSyncSetup(); | 463 CloseSyncSetup(); |
| 462 } | 464 } |
| 463 | 465 |
| 464 void SyncSetupHandler2::HandleSubmitAuth(const ListValue* args) { | 466 void SyncSetupHandler2::HandleSubmitAuth(const ListValue* args) { |
| 465 std::string json; | 467 std::string json; |
| 466 if (!args->GetString(0, &json)) { | 468 if (!args->GetString(0, &json)) { |
| 467 NOTREACHED() << "Could not read JSON argument"; | 469 NOTREACHED() << "Could not read JSON argument"; |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 659 void SyncSetupHandler2::ShowLoginErrorMessage(const string16& error_message) { | 661 void SyncSetupHandler2::ShowLoginErrorMessage(const string16& error_message) { |
| 660 DictionaryValue args; | 662 DictionaryValue args; |
| 661 Profile* profile = Profile::FromWebUI(web_ui()); | 663 Profile* profile = Profile::FromWebUI(web_ui()); |
| 662 ProfileSyncService* service = profile->GetProfileSyncService(); | 664 ProfileSyncService* service = profile->GetProfileSyncService(); |
| 663 SyncSetupFlow::GetArgsForGaiaLogin(service, &args); | 665 SyncSetupFlow::GetArgsForGaiaLogin(service, &args); |
| 664 args.SetString("error_message", error_message); | 666 args.SetString("error_message", error_message); |
| 665 ShowGaiaLogin(args); | 667 ShowGaiaLogin(args); |
| 666 } | 668 } |
| 667 | 669 |
| 668 } // namespace options2 | 670 } // namespace options2 |
| OLD | NEW |