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/command_line.h" | 7 #include "base/command_line.h" |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/signin/signin_manager_factory.h" | 10 #include "chrome/browser/signin/signin_manager_factory.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "components/search/search.h" | 25 #include "components/search/search.h" |
26 #include "components/signin/core/browser/signin_manager.h" | 26 #include "components/signin/core/browser/signin_manager.h" |
27 #include "components/strings/grit/components_strings.h" | 27 #include "components/strings/grit/components_strings.h" |
28 #include "content/public/browser/web_ui.h" | 28 #include "content/public/browser/web_ui.h" |
29 #include "content/public/browser/web_ui_data_source.h" | 29 #include "content/public/browser/web_ui_data_source.h" |
30 #include "ui/base/l10n/l10n_util.h" | 30 #include "ui/base/l10n/l10n_util.h" |
31 #include "ui/base/resource/resource_bundle.h" | 31 #include "ui/base/resource/resource_bundle.h" |
32 | 32 |
33 namespace { | 33 namespace { |
34 | 34 |
35 content::WebUIDataSource* CreateMdHistoryUIHTMLSource(Profile* profile) { | 35 content::WebUIDataSource* CreateMdHistoryUIHTMLSource(Profile* profile, |
| 36 bool use_test_title) { |
36 PrefService* prefs = profile->GetPrefs(); | 37 PrefService* prefs = profile->GetPrefs(); |
37 | 38 |
38 content::WebUIDataSource* source = | 39 content::WebUIDataSource* source = |
39 content::WebUIDataSource::Create(chrome::kChromeUIHistoryHost); | 40 content::WebUIDataSource::Create(chrome::kChromeUIHistoryHost); |
40 | 41 |
41 // Localized strings (alphabetical order). | 42 // Localized strings (alphabetical order). |
42 source->AddLocalizedString("bookmarked", IDS_HISTORY_ENTRY_BOOKMARKED); | 43 source->AddLocalizedString("bookmarked", IDS_HISTORY_ENTRY_BOOKMARKED); |
43 source->AddLocalizedString("cancel", IDS_CANCEL); | 44 source->AddLocalizedString("cancel", IDS_CANCEL); |
44 source->AddLocalizedString("clearBrowsingData", | 45 source->AddLocalizedString("clearBrowsingData", |
45 IDS_CLEAR_BROWSING_DATA_TITLE); | 46 IDS_CLEAR_BROWSING_DATA_TITLE); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 source->AddLocalizedString("removeFromHistory", IDS_HISTORY_REMOVE_PAGE); | 90 source->AddLocalizedString("removeFromHistory", IDS_HISTORY_REMOVE_PAGE); |
90 source->AddLocalizedString("removeSelected", | 91 source->AddLocalizedString("removeSelected", |
91 IDS_HISTORY_REMOVE_SELECTED_ITEMS); | 92 IDS_HISTORY_REMOVE_SELECTED_ITEMS); |
92 source->AddLocalizedString("searchPrompt", IDS_MD_HISTORY_SEARCH_PROMPT); | 93 source->AddLocalizedString("searchPrompt", IDS_MD_HISTORY_SEARCH_PROMPT); |
93 source->AddLocalizedString("searchResult", IDS_HISTORY_SEARCH_RESULT); | 94 source->AddLocalizedString("searchResult", IDS_HISTORY_SEARCH_RESULT); |
94 source->AddLocalizedString("searchResults", IDS_HISTORY_SEARCH_RESULTS); | 95 source->AddLocalizedString("searchResults", IDS_HISTORY_SEARCH_RESULTS); |
95 source->AddLocalizedString("signInButton", IDS_MD_HISTORY_SIGN_IN_BUTTON); | 96 source->AddLocalizedString("signInButton", IDS_MD_HISTORY_SIGN_IN_BUTTON); |
96 source->AddLocalizedString("signInPromo", IDS_MD_HISTORY_SIGN_IN_PROMO); | 97 source->AddLocalizedString("signInPromo", IDS_MD_HISTORY_SIGN_IN_PROMO); |
97 source->AddLocalizedString("signInPromoDesc", | 98 source->AddLocalizedString("signInPromoDesc", |
98 IDS_MD_HISTORY_SIGN_IN_PROMO_DESC); | 99 IDS_MD_HISTORY_SIGN_IN_PROMO_DESC); |
99 source->AddLocalizedString("title", IDS_HISTORY_TITLE); | 100 if (use_test_title) |
| 101 source->AddString("title", "MD History"); |
| 102 else |
| 103 source->AddLocalizedString("title", IDS_HISTORY_TITLE); |
100 | 104 |
101 source->AddString( | 105 source->AddString( |
102 "sidebarFooter", | 106 "sidebarFooter", |
103 l10n_util::GetStringFUTF16( | 107 l10n_util::GetStringFUTF16( |
104 IDS_HISTORY_OTHER_FORMS_OF_HISTORY, | 108 IDS_HISTORY_OTHER_FORMS_OF_HISTORY, |
105 l10n_util::GetStringUTF16( | 109 l10n_util::GetStringUTF16( |
106 IDS_SETTINGS_CLEAR_DATA_WEB_HISTORY_URL_IN_HISTORY))); | 110 IDS_SETTINGS_CLEAR_DATA_WEB_HISTORY_URL_IN_HISTORY))); |
107 | 111 |
108 bool allow_deleting_history = | 112 bool allow_deleting_history = |
109 prefs->GetBoolean(prefs::kAllowDeletingBrowserHistory); | 113 prefs->GetBoolean(prefs::kAllowDeletingBrowserHistory); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 #endif // BUILDFLAG(USE_VULCANIZE) | 188 #endif // BUILDFLAG(USE_VULCANIZE) |
185 | 189 |
186 source->SetDefaultResource(IDR_MD_HISTORY_HISTORY_HTML); | 190 source->SetDefaultResource(IDR_MD_HISTORY_HISTORY_HTML); |
187 source->SetJsonPath("strings.js"); | 191 source->SetJsonPath("strings.js"); |
188 | 192 |
189 return source; | 193 return source; |
190 } | 194 } |
191 | 195 |
192 } // namespace | 196 } // namespace |
193 | 197 |
| 198 bool MdHistoryUI::use_test_title_ = false; |
| 199 |
194 MdHistoryUI::MdHistoryUI(content::WebUI* web_ui) : WebUIController(web_ui) { | 200 MdHistoryUI::MdHistoryUI(content::WebUI* web_ui) : WebUIController(web_ui) { |
195 Profile* profile = Profile::FromWebUI(web_ui); | 201 Profile* profile = Profile::FromWebUI(web_ui); |
196 web_ui->AddMessageHandler(new BrowsingHistoryHandler()); | 202 web_ui->AddMessageHandler(new BrowsingHistoryHandler()); |
197 web_ui->AddMessageHandler(new MetricsHandler()); | 203 web_ui->AddMessageHandler(new MetricsHandler()); |
198 | 204 |
199 if (search::IsInstantExtendedAPIEnabled()) { | 205 if (search::IsInstantExtendedAPIEnabled()) { |
200 web_ui->AddMessageHandler(new browser_sync::ForeignSessionHandler()); | 206 web_ui->AddMessageHandler(new browser_sync::ForeignSessionHandler()); |
201 web_ui->AddMessageHandler(new HistoryLoginHandler()); | 207 web_ui->AddMessageHandler(new HistoryLoginHandler()); |
202 } | 208 } |
203 | 209 |
204 content::WebUIDataSource::Add(profile, CreateMdHistoryUIHTMLSource(profile)); | 210 content::WebUIDataSource::Add( |
| 211 profile, CreateMdHistoryUIHTMLSource(profile, use_test_title_)); |
205 } | 212 } |
206 | 213 |
207 MdHistoryUI::~MdHistoryUI() {} | 214 MdHistoryUI::~MdHistoryUI() {} |
208 | 215 |
209 // static | 216 // static |
210 bool MdHistoryUI::IsEnabled(Profile* profile) { | 217 bool MdHistoryUI::IsEnabled(Profile* profile) { |
211 return base::FeatureList::IsEnabled(features::kMaterialDesignHistory) && | 218 return base::FeatureList::IsEnabled(features::kMaterialDesignHistory) && |
212 !base::CommandLine::ForCurrentProcess()->HasSwitch( | 219 !base::CommandLine::ForCurrentProcess()->HasSwitch( |
213 switches::kHistoryEnableGroupByDomain) && | 220 switches::kHistoryEnableGroupByDomain) && |
214 !profile->IsSupervised(); | 221 !profile->IsSupervised(); |
215 } | 222 } |
216 | 223 |
217 // static | 224 // static |
218 void MdHistoryUI::SetEnabledForTesting(bool enabled) { | 225 void MdHistoryUI::SetEnabledForTesting(bool enabled) { |
219 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList); | 226 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList); |
220 | 227 |
221 const std::string& name = features::kMaterialDesignHistory.name; | 228 const std::string& name = features::kMaterialDesignHistory.name; |
222 feature_list->InitializeFromCommandLine(enabled ? name : "", | 229 feature_list->InitializeFromCommandLine(enabled ? name : "", |
223 enabled ? "" : name); | 230 enabled ? "" : name); |
224 base::FeatureList::ClearInstanceForTesting(); | 231 base::FeatureList::ClearInstanceForTesting(); |
225 base::FeatureList::SetInstance(std::move(feature_list)); | 232 base::FeatureList::SetInstance(std::move(feature_list)); |
226 } | 233 } |
227 | 234 |
228 // static | 235 // static |
229 base::RefCountedMemory* MdHistoryUI::GetFaviconResourceBytes( | 236 base::RefCountedMemory* MdHistoryUI::GetFaviconResourceBytes( |
230 ui::ScaleFactor scale_factor) { | 237 ui::ScaleFactor scale_factor) { |
231 return ResourceBundle::GetSharedInstance().LoadDataResourceBytesForScale( | 238 return ResourceBundle::GetSharedInstance().LoadDataResourceBytesForScale( |
232 IDR_HISTORY_FAVICON, scale_factor); | 239 IDR_HISTORY_FAVICON, scale_factor); |
233 } | 240 } |
OLD | NEW |