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/md_history_ui.h" | 5 #include "chrome/browser/ui/webui/md_history_ui.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/command_line.h" | 9 #include "base/command_line.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 #include "components/search/search.h" | 28 #include "components/search/search.h" |
29 #include "components/signin/core/browser/signin_manager.h" | 29 #include "components/signin/core/browser/signin_manager.h" |
30 #include "components/strings/grit/components_strings.h" | 30 #include "components/strings/grit/components_strings.h" |
31 #include "content/public/browser/web_ui.h" | 31 #include "content/public/browser/web_ui.h" |
32 #include "content/public/browser/web_ui_data_source.h" | 32 #include "content/public/browser/web_ui_data_source.h" |
33 #include "ui/base/l10n/l10n_util.h" | 33 #include "ui/base/l10n/l10n_util.h" |
34 #include "ui/base/resource/resource_bundle.h" | 34 #include "ui/base/resource/resource_bundle.h" |
35 | 35 |
36 namespace { | 36 namespace { |
37 | 37 |
38 content::WebUIDataSource* CreateMdHistoryUIHTMLSource(Profile* profile) { | 38 content::WebUIDataSource* CreateMdHistoryUIHTMLSource(Profile* profile, |
| 39 bool use_test_title) { |
39 content::WebUIDataSource* source = | 40 content::WebUIDataSource* source = |
40 content::WebUIDataSource::Create(chrome::kChromeUIHistoryHost); | 41 content::WebUIDataSource::Create(chrome::kChromeUIHistoryHost); |
41 | 42 |
42 // Localized strings (alphabetical order). | 43 // Localized strings (alphabetical order). |
43 source->AddLocalizedString("bookmarked", IDS_HISTORY_ENTRY_BOOKMARKED); | 44 source->AddLocalizedString("bookmarked", IDS_HISTORY_ENTRY_BOOKMARKED); |
44 source->AddLocalizedString("cancel", IDS_CANCEL); | 45 source->AddLocalizedString("cancel", IDS_CANCEL); |
45 source->AddLocalizedString("clearBrowsingData", | 46 source->AddLocalizedString("clearBrowsingData", |
46 IDS_CLEAR_BROWSING_DATA_TITLE); | 47 IDS_CLEAR_BROWSING_DATA_TITLE); |
47 source->AddLocalizedString("clearSearch", IDS_MD_HISTORY_CLEAR_SEARCH); | 48 source->AddLocalizedString("clearSearch", IDS_MD_HISTORY_CLEAR_SEARCH); |
48 source->AddLocalizedString("closeMenuPromo", IDS_MD_HISTORY_CLOSE_MENU_PROMO); | 49 source->AddLocalizedString("closeMenuPromo", IDS_MD_HISTORY_CLOSE_MENU_PROMO); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 source->AddLocalizedString("removeFromHistory", IDS_HISTORY_REMOVE_PAGE); | 93 source->AddLocalizedString("removeFromHistory", IDS_HISTORY_REMOVE_PAGE); |
93 source->AddLocalizedString("removeSelected", | 94 source->AddLocalizedString("removeSelected", |
94 IDS_HISTORY_REMOVE_SELECTED_ITEMS); | 95 IDS_HISTORY_REMOVE_SELECTED_ITEMS); |
95 source->AddLocalizedString("searchPrompt", IDS_MD_HISTORY_SEARCH_PROMPT); | 96 source->AddLocalizedString("searchPrompt", IDS_MD_HISTORY_SEARCH_PROMPT); |
96 source->AddLocalizedString("searchResult", IDS_HISTORY_SEARCH_RESULT); | 97 source->AddLocalizedString("searchResult", IDS_HISTORY_SEARCH_RESULT); |
97 source->AddLocalizedString("searchResults", IDS_HISTORY_SEARCH_RESULTS); | 98 source->AddLocalizedString("searchResults", IDS_HISTORY_SEARCH_RESULTS); |
98 source->AddLocalizedString("signInButton", IDS_MD_HISTORY_SIGN_IN_BUTTON); | 99 source->AddLocalizedString("signInButton", IDS_MD_HISTORY_SIGN_IN_BUTTON); |
99 source->AddLocalizedString("signInPromo", IDS_MD_HISTORY_SIGN_IN_PROMO); | 100 source->AddLocalizedString("signInPromo", IDS_MD_HISTORY_SIGN_IN_PROMO); |
100 source->AddLocalizedString("signInPromoDesc", | 101 source->AddLocalizedString("signInPromoDesc", |
101 IDS_MD_HISTORY_SIGN_IN_PROMO_DESC); | 102 IDS_MD_HISTORY_SIGN_IN_PROMO_DESC); |
102 source->AddLocalizedString("title", IDS_HISTORY_TITLE); | 103 if (use_test_title) |
| 104 source->AddString("title", "MD History"); |
| 105 else |
| 106 source->AddLocalizedString("title", IDS_HISTORY_TITLE); |
103 | 107 |
104 source->AddString( | 108 source->AddString( |
105 "sidebarFooter", | 109 "sidebarFooter", |
106 l10n_util::GetStringFUTF16( | 110 l10n_util::GetStringFUTF16( |
107 IDS_HISTORY_OTHER_FORMS_OF_HISTORY, | 111 IDS_HISTORY_OTHER_FORMS_OF_HISTORY, |
108 l10n_util::GetStringUTF16( | 112 l10n_util::GetStringUTF16( |
109 IDS_SETTINGS_CLEAR_DATA_WEB_HISTORY_URL_IN_HISTORY))); | 113 IDS_SETTINGS_CLEAR_DATA_WEB_HISTORY_URL_IN_HISTORY))); |
110 | 114 |
111 PrefService* prefs = profile->GetPrefs(); | 115 PrefService* prefs = profile->GetPrefs(); |
112 bool allow_deleting_history = | 116 bool allow_deleting_history = |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 #endif // BUILDFLAG(USE_VULCANIZE) | 195 #endif // BUILDFLAG(USE_VULCANIZE) |
192 | 196 |
193 source->SetDefaultResource(IDR_MD_HISTORY_HISTORY_HTML); | 197 source->SetDefaultResource(IDR_MD_HISTORY_HISTORY_HTML); |
194 source->SetJsonPath("strings.js"); | 198 source->SetJsonPath("strings.js"); |
195 | 199 |
196 return source; | 200 return source; |
197 } | 201 } |
198 | 202 |
199 } // namespace | 203 } // namespace |
200 | 204 |
| 205 bool MdHistoryUI::use_test_title_ = false; |
| 206 |
201 MdHistoryUI::MdHistoryUI(content::WebUI* web_ui) : WebUIController(web_ui) { | 207 MdHistoryUI::MdHistoryUI(content::WebUI* web_ui) : WebUIController(web_ui) { |
202 Profile* profile = Profile::FromWebUI(web_ui); | 208 Profile* profile = Profile::FromWebUI(web_ui); |
203 web_ui->AddMessageHandler(new BrowsingHistoryHandler()); | 209 web_ui->AddMessageHandler(new BrowsingHistoryHandler()); |
204 web_ui->AddMessageHandler(new MetricsHandler()); | 210 web_ui->AddMessageHandler(new MetricsHandler()); |
205 | 211 |
206 if (search::IsInstantExtendedAPIEnabled()) { | 212 if (search::IsInstantExtendedAPIEnabled()) { |
207 web_ui->AddMessageHandler(new browser_sync::ForeignSessionHandler()); | 213 web_ui->AddMessageHandler(new browser_sync::ForeignSessionHandler()); |
208 web_ui->AddMessageHandler(new HistoryLoginHandler()); | 214 web_ui->AddMessageHandler(new HistoryLoginHandler()); |
209 } | 215 } |
210 | 216 |
211 data_source_ = CreateMdHistoryUIHTMLSource(profile); | 217 data_source_ = CreateMdHistoryUIHTMLSource(profile, use_test_title_); |
212 content::WebUIDataSource::Add(profile, data_source_); | 218 content::WebUIDataSource::Add(profile, data_source_); |
213 | 219 |
214 web_ui->RegisterMessageCallback("menuPromoShown", | 220 web_ui->RegisterMessageCallback("menuPromoShown", |
215 base::Bind(&MdHistoryUI::HandleMenuPromoShown, base::Unretained(this))); | 221 base::Bind(&MdHistoryUI::HandleMenuPromoShown, base::Unretained(this))); |
216 } | 222 } |
217 | 223 |
218 MdHistoryUI::~MdHistoryUI() {} | 224 MdHistoryUI::~MdHistoryUI() {} |
219 | 225 |
220 // static | 226 // static |
221 bool MdHistoryUI::IsEnabled(Profile* profile) { | 227 bool MdHistoryUI::IsEnabled(Profile* profile) { |
(...skipping 25 matching lines...) Expand all Loading... |
247 user_prefs::PrefRegistrySyncable* registry) { | 253 user_prefs::PrefRegistrySyncable* registry) { |
248 registry->RegisterBooleanPref(prefs::kMdHistoryMenuPromoShown, false, | 254 registry->RegisterBooleanPref(prefs::kMdHistoryMenuPromoShown, false, |
249 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | 255 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
250 } | 256 } |
251 | 257 |
252 void MdHistoryUI::HandleMenuPromoShown(const base::ListValue* args) { | 258 void MdHistoryUI::HandleMenuPromoShown(const base::ListValue* args) { |
253 Profile::FromWebUI(web_ui())->GetPrefs()->SetBoolean( | 259 Profile::FromWebUI(web_ui())->GetPrefs()->SetBoolean( |
254 prefs::kMdHistoryMenuPromoShown, true); | 260 prefs::kMdHistoryMenuPromoShown, true); |
255 data_source_->AddBoolean("showMenuPromo", false); | 261 data_source_->AddBoolean("showMenuPromo", false); |
256 } | 262 } |
OLD | NEW |