| 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 #endif // BUILDFLAG(USE_VULCANIZE) | 200 #endif // BUILDFLAG(USE_VULCANIZE) |
| 197 | 201 |
| 198 source->SetDefaultResource(IDR_MD_HISTORY_HISTORY_HTML); | 202 source->SetDefaultResource(IDR_MD_HISTORY_HISTORY_HTML); |
| 199 source->SetJsonPath("strings.js"); | 203 source->SetJsonPath("strings.js"); |
| 200 | 204 |
| 201 return source; | 205 return source; |
| 202 } | 206 } |
| 203 | 207 |
| 204 } // namespace | 208 } // namespace |
| 205 | 209 |
| 210 bool MdHistoryUI::use_test_title_ = false; |
| 211 |
| 206 MdHistoryUI::MdHistoryUI(content::WebUI* web_ui) : WebUIController(web_ui) { | 212 MdHistoryUI::MdHistoryUI(content::WebUI* web_ui) : WebUIController(web_ui) { |
| 207 Profile* profile = Profile::FromWebUI(web_ui); | 213 Profile* profile = Profile::FromWebUI(web_ui); |
| 208 web_ui->AddMessageHandler(new BrowsingHistoryHandler()); | 214 web_ui->AddMessageHandler(new BrowsingHistoryHandler()); |
| 209 web_ui->AddMessageHandler(new MetricsHandler()); | 215 web_ui->AddMessageHandler(new MetricsHandler()); |
| 210 | 216 |
| 211 if (search::IsInstantExtendedAPIEnabled()) { | 217 if (search::IsInstantExtendedAPIEnabled()) { |
| 212 web_ui->AddMessageHandler(new browser_sync::ForeignSessionHandler()); | 218 web_ui->AddMessageHandler(new browser_sync::ForeignSessionHandler()); |
| 213 web_ui->AddMessageHandler(new HistoryLoginHandler()); | 219 web_ui->AddMessageHandler(new HistoryLoginHandler()); |
| 214 } | 220 } |
| 215 | 221 |
| 216 data_source_ = CreateMdHistoryUIHTMLSource(profile); | 222 data_source_ = CreateMdHistoryUIHTMLSource(profile, use_test_title_); |
| 217 content::WebUIDataSource::Add(profile, data_source_); | 223 content::WebUIDataSource::Add(profile, data_source_); |
| 218 | 224 |
| 219 web_ui->RegisterMessageCallback("menuPromoShown", | 225 web_ui->RegisterMessageCallback("menuPromoShown", |
| 220 base::Bind(&MdHistoryUI::HandleMenuPromoShown, base::Unretained(this))); | 226 base::Bind(&MdHistoryUI::HandleMenuPromoShown, base::Unretained(this))); |
| 221 } | 227 } |
| 222 | 228 |
| 223 MdHistoryUI::~MdHistoryUI() {} | 229 MdHistoryUI::~MdHistoryUI() {} |
| 224 | 230 |
| 225 // static | 231 // static |
| 226 bool MdHistoryUI::IsEnabled(Profile* profile) { | 232 bool MdHistoryUI::IsEnabled(Profile* profile) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 252 user_prefs::PrefRegistrySyncable* registry) { | 258 user_prefs::PrefRegistrySyncable* registry) { |
| 253 registry->RegisterBooleanPref(prefs::kMdHistoryMenuPromoShown, false, | 259 registry->RegisterBooleanPref(prefs::kMdHistoryMenuPromoShown, false, |
| 254 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | 260 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
| 255 } | 261 } |
| 256 | 262 |
| 257 void MdHistoryUI::HandleMenuPromoShown(const base::ListValue* args) { | 263 void MdHistoryUI::HandleMenuPromoShown(const base::ListValue* args) { |
| 258 Profile::FromWebUI(web_ui())->GetPrefs()->SetBoolean( | 264 Profile::FromWebUI(web_ui())->GetPrefs()->SetBoolean( |
| 259 prefs::kMdHistoryMenuPromoShown, true); | 265 prefs::kMdHistoryMenuPromoShown, true); |
| 260 data_source_->AddBoolean("showMenuPromo", false); | 266 data_source_->AddBoolean("showMenuPromo", false); |
| 261 } | 267 } |
| OLD | NEW |