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 "chrome/browser/browser_process.h" | 7 #include "chrome/browser/browser_process.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/browser/sync/profile_sync_service_factory.h" |
9 #include "chrome/browser/ui/webui/signin/sync_confirmation_handler.h" | 10 #include "chrome/browser/ui/webui/signin/sync_confirmation_handler.h" |
10 #include "chrome/common/url_constants.h" | 11 #include "chrome/common/url_constants.h" |
11 #include "chrome/grit/browser_resources.h" | 12 #include "chrome/grit/browser_resources.h" |
12 #include "chrome/grit/generated_resources.h" | 13 #include "chrome/grit/generated_resources.h" |
13 #include "content/public/browser/web_ui.h" | 14 #include "content/public/browser/web_ui.h" |
14 #include "content/public/browser/web_ui_data_source.h" | 15 #include "content/public/browser/web_ui_data_source.h" |
15 #include "ui/base/webui/web_ui_util.h" | 16 #include "ui/base/webui/web_ui_util.h" |
16 | 17 |
17 SyncConfirmationUI::SyncConfirmationUI(content::WebUI* web_ui) | 18 SyncConfirmationUI::SyncConfirmationUI(content::WebUI* web_ui) |
18 : SyncConfirmationUI(web_ui, new SyncConfirmationHandler) {} | 19 : SyncConfirmationUI(web_ui, new SyncConfirmationHandler) {} |
19 | 20 |
20 SyncConfirmationUI::SyncConfirmationUI( | 21 SyncConfirmationUI::SyncConfirmationUI( |
21 content::WebUI* web_ui, SyncConfirmationHandler* handler) | 22 content::WebUI* web_ui, SyncConfirmationHandler* handler) |
22 : WebDialogUI(web_ui) { | 23 : WebDialogUI(web_ui) { |
23 Profile* profile = Profile::FromWebUI(web_ui); | 24 Profile* profile = Profile::FromWebUI(web_ui); |
| 25 bool is_sync_allowed = profile->IsSyncAllowed(); |
| 26 |
24 content::WebUIDataSource* source = | 27 content::WebUIDataSource* source = |
25 content::WebUIDataSource::Create(chrome::kChromeUISyncConfirmationHost); | 28 content::WebUIDataSource::Create(chrome::kChromeUISyncConfirmationHost); |
26 source->SetJsonPath("strings.js"); | 29 source->SetJsonPath("strings.js"); |
27 source->SetDefaultResource(IDR_SYNC_CONFIRMATION_HTML); | 30 source->SetDefaultResource(IDR_SYNC_CONFIRMATION_HTML); |
28 source->AddResourcePath("sync_confirmation.css", IDR_SYNC_CONFIRMATION_CSS); | 31 source->AddResourcePath("sync_confirmation.css", IDR_SYNC_CONFIRMATION_CSS); |
29 source->AddResourcePath("sync_confirmation.js", IDR_SYNC_CONFIRMATION_JS); | 32 source->AddResourcePath("sync_confirmation.js", IDR_SYNC_CONFIRMATION_JS); |
30 source->AddResourcePath("signin_shared_css.html", IDR_SIGNIN_SHARED_CSS_HTML); | 33 source->AddResourcePath("signin_shared_css.html", IDR_SIGNIN_SHARED_CSS_HTML); |
| 34 source->AddBoolean("isSyncAllowed", is_sync_allowed); |
31 | 35 |
32 source->AddLocalizedString("syncConfirmationTitle", | |
33 IDS_SYNC_CONFIRMATION_TITLE); | |
34 source->AddLocalizedString("syncConfirmationChromeSyncTitle", | 36 source->AddLocalizedString("syncConfirmationChromeSyncTitle", |
35 IDS_SYNC_CONFIRMATION_CHROME_SYNC_TITLE); | 37 IDS_SYNC_CONFIRMATION_CHROME_SYNC_TITLE); |
36 source->AddLocalizedString("syncConfirmationChromeSyncBody", | 38 source->AddLocalizedString("syncConfirmationChromeSyncBody", |
37 IDS_SYNC_CONFIRMATION_CHROME_SYNC_MESSAGE); | 39 IDS_SYNC_CONFIRMATION_CHROME_SYNC_MESSAGE); |
38 source->AddLocalizedString("syncConfirmationPersonalizeServicesTitle", | 40 source->AddLocalizedString("syncConfirmationPersonalizeServicesTitle", |
39 IDS_SYNC_CONFIRMATION_PERSONALIZE_SERVICES_TITLE); | 41 IDS_SYNC_CONFIRMATION_PERSONALIZE_SERVICES_TITLE); |
40 source->AddLocalizedString("syncConfirmationPersonalizeServicesBody", | 42 source->AddLocalizedString("syncConfirmationPersonalizeServicesBody", |
41 IDS_SYNC_CONFIRMATION_PERSONALIZE_SERVICES_BODY); | 43 IDS_SYNC_CONFIRMATION_PERSONALIZE_SERVICES_BODY); |
42 source->AddLocalizedString("syncConfirmationSyncSettingsLinkBody", | 44 source->AddLocalizedString("syncConfirmationSyncSettingsLinkBody", |
43 IDS_SYNC_CONFIRMATION_SYNC_SETTINGS_LINK_BODY); | 45 IDS_SYNC_CONFIRMATION_SYNC_SETTINGS_LINK_BODY); |
| 46 source->AddLocalizedString("syncDisabledConfirmationDetails", |
| 47 IDS_SYNC_DISABLED_CONFIRMATION_DETAILS); |
| 48 |
| 49 int title_ids = IDS_SYNC_CONFIRMATION_TITLE; |
| 50 int confirm_button_ids = IDS_SYNC_CONFIRMATION_CONFIRM_BUTTON_LABEL; |
| 51 int undo_button_ids = IDS_SYNC_CONFIRMATION_UNDO_BUTTON_LABEL; |
| 52 if (!is_sync_allowed) { |
| 53 title_ids = IDS_SYNC_DISABLED_CONFIRMATION_CHROME_SYNC_TITLE; |
| 54 confirm_button_ids = IDS_SYNC_DISABLED_CONFIRMATION_CONFIRM_BUTTON_LABEL; |
| 55 undo_button_ids = IDS_SYNC_DISABLED_CONFIRMATION_UNDO_BUTTON_LABEL; |
| 56 } |
| 57 source->AddLocalizedString("syncConfirmationTitle", title_ids); |
44 source->AddLocalizedString("syncConfirmationConfirmLabel", | 58 source->AddLocalizedString("syncConfirmationConfirmLabel", |
45 IDS_SYNC_CONFIRMATION_CONFIRM_BUTTON_LABEL); | 59 confirm_button_ids); |
46 source->AddLocalizedString("syncConfirmationUndoLabel", | 60 source->AddLocalizedString("syncConfirmationUndoLabel", undo_button_ids); |
47 IDS_SYNC_CONFIRMATION_UNDO_BUTTON_LABEL); | |
48 | 61 |
49 base::DictionaryValue strings; | 62 base::DictionaryValue strings; |
50 webui::SetLoadTimeDataDefaults( | 63 webui::SetLoadTimeDataDefaults( |
51 g_browser_process->GetApplicationLocale(), &strings); | 64 g_browser_process->GetApplicationLocale(), &strings); |
52 source->AddLocalizedStrings(strings); | 65 source->AddLocalizedStrings(strings); |
53 | 66 |
54 content::WebUIDataSource::Add(profile, source); | 67 content::WebUIDataSource::Add(profile, source); |
55 web_ui->AddMessageHandler(handler); | 68 web_ui->AddMessageHandler(handler); |
56 } | 69 } |
OLD | NEW |