| 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/signin/sync_confirmation_ui.h" | 5 #include "chrome/browser/ui/webui/signin/sync_confirmation_ui.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/sync/profile_sync_service_factory.h" | 10 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 11 #include "chrome/browser/ui/webui/signin/sync_confirmation_handler.h" | 11 #include "chrome/browser/ui/webui/signin/sync_confirmation_handler.h" |
| 12 #include "chrome/common/url_constants.h" | 12 #include "chrome/common/url_constants.h" |
| 13 #include "chrome/grit/browser_resources.h" | 13 #include "chrome/grit/browser_resources.h" |
| 14 #include "chrome/grit/generated_resources.h" | 14 #include "chrome/grit/generated_resources.h" |
| 15 #include "content/public/browser/web_ui.h" | 15 #include "content/public/browser/web_ui.h" |
| 16 #include "content/public/browser/web_ui_data_source.h" | 16 #include "content/public/browser/web_ui_data_source.h" |
| 17 #include "ui/base/webui/web_ui_util.h" | 17 #include "ui/base/webui/web_ui_util.h" |
| 18 | 18 |
| 19 SyncConfirmationUI::SyncConfirmationUI(content::WebUI* web_ui) | 19 SyncConfirmationUI::SyncConfirmationUI(content::WebUI* web_ui) |
| 20 : SyncConfirmationUI(web_ui, base::MakeUnique<SyncConfirmationHandler>()) {} | |
| 21 | |
| 22 SyncConfirmationUI::SyncConfirmationUI( | |
| 23 content::WebUI* web_ui, | |
| 24 std::unique_ptr<SyncConfirmationHandler> handler) | |
| 25 : WebDialogUI(web_ui) { | 20 : WebDialogUI(web_ui) { |
| 26 Profile* profile = Profile::FromWebUI(web_ui); | 21 Profile* profile = Profile::FromWebUI(web_ui); |
| 27 bool is_sync_allowed = profile->IsSyncAllowed(); | 22 bool is_sync_allowed = profile->IsSyncAllowed(); |
| 28 | 23 |
| 29 content::WebUIDataSource* source = | 24 content::WebUIDataSource* source = |
| 30 content::WebUIDataSource::Create(chrome::kChromeUISyncConfirmationHost); | 25 content::WebUIDataSource::Create(chrome::kChromeUISyncConfirmationHost); |
| 31 source->SetJsonPath("strings.js"); | 26 source->SetJsonPath("strings.js"); |
| 32 source->SetDefaultResource(IDR_SYNC_CONFIRMATION_HTML); | 27 source->SetDefaultResource(IDR_SYNC_CONFIRMATION_HTML); |
| 33 source->AddResourcePath("sync_confirmation.css", IDR_SYNC_CONFIRMATION_CSS); | 28 source->AddResourcePath("sync_confirmation.css", IDR_SYNC_CONFIRMATION_CSS); |
| 34 source->AddResourcePath("sync_confirmation.js", IDR_SYNC_CONFIRMATION_JS); | 29 source->AddResourcePath("sync_confirmation.js", IDR_SYNC_CONFIRMATION_JS); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 60 source->AddLocalizedString("syncConfirmationConfirmLabel", | 55 source->AddLocalizedString("syncConfirmationConfirmLabel", |
| 61 confirm_button_ids); | 56 confirm_button_ids); |
| 62 source->AddLocalizedString("syncConfirmationUndoLabel", undo_button_ids); | 57 source->AddLocalizedString("syncConfirmationUndoLabel", undo_button_ids); |
| 63 | 58 |
| 64 base::DictionaryValue strings; | 59 base::DictionaryValue strings; |
| 65 webui::SetLoadTimeDataDefaults( | 60 webui::SetLoadTimeDataDefaults( |
| 66 g_browser_process->GetApplicationLocale(), &strings); | 61 g_browser_process->GetApplicationLocale(), &strings); |
| 67 source->AddLocalizedStrings(strings); | 62 source->AddLocalizedStrings(strings); |
| 68 | 63 |
| 69 content::WebUIDataSource::Add(profile, source); | 64 content::WebUIDataSource::Add(profile, source); |
| 70 web_ui->AddMessageHandler(std::move(handler)); | |
| 71 } | 65 } |
| 66 |
| 67 void SyncConfirmationUI::InitializeMessageHandlerWithBrowser(Browser* browser) { |
| 68 web_ui()->AddMessageHandler( |
| 69 base::MakeUnique<SyncConfirmationHandler>(browser)); |
| 70 } |
| OLD | NEW |