Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(260)

Side by Side Diff: chrome/browser/ui/webui/md_history_ui.cc

Issue 2830983005: Remove old webui History page on desktop and mobile (Closed)
Patch Set: merge Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/webui/md_history_ui.h ('k') | chrome/browser/ui/webui/uber/uber_ui.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "build/build_config.h" 12 #include "build/build_config.h"
13 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/signin/signin_manager_factory.h" 14 #include "chrome/browser/signin/signin_manager_factory.h"
15 #include "chrome/browser/ui/webui/browsing_history_handler.h" 15 #include "chrome/browser/ui/webui/browsing_history_handler.h"
16 #include "chrome/browser/ui/webui/foreign_session_handler.h" 16 #include "chrome/browser/ui/webui/foreign_session_handler.h"
17 #include "chrome/browser/ui/webui/history_login_handler.h" 17 #include "chrome/browser/ui/webui/history_login_handler.h"
18 #include "chrome/browser/ui/webui/metrics_handler.h" 18 #include "chrome/browser/ui/webui/metrics_handler.h"
19 #include "chrome/common/pref_names.h" 19 #include "chrome/common/pref_names.h"
20 #include "chrome/common/url_constants.h" 20 #include "chrome/common/url_constants.h"
21 #include "chrome/grit/browser_resources.h" 21 #include "chrome/grit/browser_resources.h"
22 #include "chrome/grit/generated_resources.h" 22 #include "chrome/grit/generated_resources.h"
23 #include "chrome/grit/locale_settings.h" 23 #include "chrome/grit/locale_settings.h"
24 #include "chrome/grit/theme_resources.h" 24 #include "chrome/grit/theme_resources.h"
25 #include "components/grit/components_scaled_resources.h"
26 #include "components/pref_registry/pref_registry_syncable.h" 25 #include "components/pref_registry/pref_registry_syncable.h"
27 #include "components/prefs/pref_service.h" 26 #include "components/prefs/pref_service.h"
28 #include "components/search/search.h" 27 #include "components/search/search.h"
29 #include "components/signin/core/browser/signin_manager.h" 28 #include "components/signin/core/browser/signin_manager.h"
30 #include "components/strings/grit/components_strings.h" 29 #include "components/strings/grit/components_strings.h"
31 #include "content/public/browser/web_ui.h" 30 #include "content/public/browser/web_ui.h"
32 #include "content/public/browser/web_ui_data_source.h" 31 #include "content/public/browser/web_ui_data_source.h"
33 #include "ui/base/l10n/l10n_util.h" 32 #include "ui/base/l10n/l10n_util.h"
34 #include "ui/base/resource/resource_bundle.h"
35 33
36 namespace { 34 namespace {
37 35
38 constexpr char kIsUserSignedInKey[] = "isUserSignedIn"; 36 constexpr char kIsUserSignedInKey[] = "isUserSignedIn";
39 constexpr char kShowMenuPromoKey[] = "showMenuPromo"; 37 constexpr char kShowMenuPromoKey[] = "showMenuPromo";
40 38
41 bool IsUserSignedIn(Profile* profile) { 39 bool IsUserSignedIn(Profile* profile) {
42 SigninManagerBase* signin_manager = 40 SigninManagerBase* signin_manager =
43 SigninManagerFactory::GetForProfile(profile); 41 SigninManagerFactory::GetForProfile(profile);
44 return signin_manager && signin_manager->IsAuthenticated(); 42 return signin_manager && signin_manager->IsAuthenticated();
(...skipping 15 matching lines...) Expand all
60 IDS_CLEAR_BROWSING_DATA_TITLE); 58 IDS_CLEAR_BROWSING_DATA_TITLE);
61 source->AddLocalizedString("clearSearch", IDS_MD_HISTORY_CLEAR_SEARCH); 59 source->AddLocalizedString("clearSearch", IDS_MD_HISTORY_CLEAR_SEARCH);
62 source->AddLocalizedString("closeMenuPromo", IDS_MD_HISTORY_CLOSE_MENU_PROMO); 60 source->AddLocalizedString("closeMenuPromo", IDS_MD_HISTORY_CLOSE_MENU_PROMO);
63 source->AddLocalizedString("collapseSessionButton", 61 source->AddLocalizedString("collapseSessionButton",
64 IDS_HISTORY_OTHER_SESSIONS_COLLAPSE_SESSION); 62 IDS_HISTORY_OTHER_SESSIONS_COLLAPSE_SESSION);
65 source->AddLocalizedString("delete", IDS_MD_HISTORY_DELETE); 63 source->AddLocalizedString("delete", IDS_MD_HISTORY_DELETE);
66 source->AddLocalizedString("deleteConfirm", 64 source->AddLocalizedString("deleteConfirm",
67 IDS_HISTORY_DELETE_PRIOR_VISITS_CONFIRM_BUTTON); 65 IDS_HISTORY_DELETE_PRIOR_VISITS_CONFIRM_BUTTON);
68 source->AddLocalizedString("deleteSession", 66 source->AddLocalizedString("deleteSession",
69 IDS_HISTORY_OTHER_SESSIONS_HIDE_FOR_NOW); 67 IDS_HISTORY_OTHER_SESSIONS_HIDE_FOR_NOW);
70 source->AddLocalizedString( 68 source->AddLocalizedString("deleteWarning",
71 "deleteWarning", IDS_HISTORY_DELETE_PRIOR_VISITS_WARNING_NO_INCOGNITO); 69 IDS_HISTORY_DELETE_PRIOR_VISITS_WARNING);
72 source->AddLocalizedString("entrySummary", IDS_HISTORY_ENTRY_SUMMARY); 70 source->AddLocalizedString("entrySummary", IDS_HISTORY_ENTRY_SUMMARY);
73 source->AddLocalizedString("expandSessionButton", 71 source->AddLocalizedString("expandSessionButton",
74 IDS_HISTORY_OTHER_SESSIONS_EXPAND_SESSION); 72 IDS_HISTORY_OTHER_SESSIONS_EXPAND_SESSION);
75 source->AddLocalizedString("foundSearchResults", 73 source->AddLocalizedString("foundSearchResults",
76 IDS_HISTORY_FOUND_SEARCH_RESULTS); 74 IDS_HISTORY_FOUND_SEARCH_RESULTS);
77 source->AddLocalizedString("hasSyncedResults", 75 source->AddLocalizedString("hasSyncedResults",
78 IDS_MD_HISTORY_HAS_SYNCED_RESULTS); 76 IDS_MD_HISTORY_HAS_SYNCED_RESULTS);
79 source->AddLocalizedString("hasSyncedResultsDescription", 77 source->AddLocalizedString("hasSyncedResultsDescription",
80 IDS_MD_HISTORY_HAS_SYNCED_RESULTS_DESCRIPTION); 78 IDS_MD_HISTORY_HAS_SYNCED_RESULTS_DESCRIPTION);
81 source->AddLocalizedString("historyMenuButton", 79 source->AddLocalizedString("historyMenuButton",
82 IDS_MD_HISTORY_HISTORY_MENU_DESCRIPTION); 80 IDS_MD_HISTORY_HISTORY_MENU_DESCRIPTION);
83 source->AddLocalizedString("historyMenuItem", 81 source->AddLocalizedString("historyMenuItem",
84 IDS_MD_HISTORY_HISTORY_MENU_ITEM); 82 IDS_MD_HISTORY_HISTORY_MENU_ITEM);
85 source->AddLocalizedString("itemsSelected", IDS_MD_HISTORY_ITEMS_SELECTED); 83 source->AddLocalizedString("itemsSelected", IDS_MD_HISTORY_ITEMS_SELECTED);
86 source->AddLocalizedString("loading", IDS_HISTORY_LOADING); 84 source->AddLocalizedString("loading", IDS_HISTORY_LOADING);
87 source->AddLocalizedString("menuPromo", IDS_MD_HISTORY_MENU_PROMO); 85 source->AddLocalizedString("menuPromo", IDS_MD_HISTORY_MENU_PROMO);
88 source->AddLocalizedString("moreActionsButton", 86 source->AddLocalizedString("moreActionsButton",
89 IDS_HISTORY_ACTION_MENU_DESCRIPTION); 87 IDS_HISTORY_ACTION_MENU_DESCRIPTION);
90 source->AddLocalizedString("moreFromSite", IDS_HISTORY_MORE_FROM_SITE); 88 source->AddLocalizedString("moreFromSite", IDS_HISTORY_MORE_FROM_SITE);
91 source->AddLocalizedString("openAll", IDS_HISTORY_OTHER_SESSIONS_OPEN_ALL); 89 source->AddLocalizedString("openAll", IDS_HISTORY_OTHER_SESSIONS_OPEN_ALL);
92 source->AddLocalizedString("openTabsMenuItem", 90 source->AddLocalizedString("openTabsMenuItem",
93 IDS_MD_HISTORY_OPEN_TABS_MENU_ITEM); 91 IDS_MD_HISTORY_OPEN_TABS_MENU_ITEM);
94 source->AddLocalizedString("noResults", IDS_HISTORY_NO_RESULTS); 92 source->AddLocalizedString("noResults", IDS_HISTORY_NO_RESULTS);
95 source->AddLocalizedString("noSearchResults", IDS_HISTORY_NO_SEARCH_RESULTS); 93 source->AddLocalizedString("noSearchResults", IDS_HISTORY_NO_SEARCH_RESULTS);
96 source->AddLocalizedString("noSyncedResults", 94 source->AddLocalizedString("noSyncedResults",
97 IDS_MD_HISTORY_NO_SYNCED_RESULTS); 95 IDS_MD_HISTORY_NO_SYNCED_RESULTS);
98 source->AddLocalizedString("rangeAllTime", IDS_HISTORY_RANGE_ALL_TIME);
99 source->AddLocalizedString("rangeWeek", IDS_HISTORY_RANGE_WEEK);
100 source->AddLocalizedString("rangeMonth", IDS_HISTORY_RANGE_MONTH);
101 source->AddLocalizedString("rangeToday", IDS_HISTORY_RANGE_TODAY);
102 source->AddLocalizedString("rangeNext", IDS_HISTORY_RANGE_NEXT);
103 source->AddLocalizedString("rangePrevious", IDS_HISTORY_RANGE_PREVIOUS);
104 source->AddLocalizedString("removeBookmark", IDS_HISTORY_REMOVE_BOOKMARK); 96 source->AddLocalizedString("removeBookmark", IDS_HISTORY_REMOVE_BOOKMARK);
105 source->AddLocalizedString("removeFromHistory", IDS_HISTORY_REMOVE_PAGE); 97 source->AddLocalizedString("removeFromHistory", IDS_HISTORY_REMOVE_PAGE);
106 source->AddLocalizedString("removeSelected", 98 source->AddLocalizedString("removeSelected",
107 IDS_HISTORY_REMOVE_SELECTED_ITEMS); 99 IDS_HISTORY_REMOVE_SELECTED_ITEMS);
108 source->AddLocalizedString("searchPrompt", IDS_MD_HISTORY_SEARCH_PROMPT); 100 source->AddLocalizedString("searchPrompt", IDS_MD_HISTORY_SEARCH_PROMPT);
109 source->AddLocalizedString("searchResult", IDS_HISTORY_SEARCH_RESULT); 101 source->AddLocalizedString("searchResult", IDS_HISTORY_SEARCH_RESULT);
110 source->AddLocalizedString("searchResults", IDS_HISTORY_SEARCH_RESULTS); 102 source->AddLocalizedString("searchResults", IDS_HISTORY_SEARCH_RESULTS);
111 source->AddLocalizedString("signInButton", IDS_MD_HISTORY_SIGN_IN_BUTTON); 103 source->AddLocalizedString("signInButton", IDS_MD_HISTORY_SIGN_IN_BUTTON);
112 source->AddLocalizedString("signInPromo", IDS_MD_HISTORY_SIGN_IN_PROMO); 104 source->AddLocalizedString("signInPromo", IDS_MD_HISTORY_SIGN_IN_PROMO);
113 source->AddLocalizedString("signInPromoDesc", 105 source->AddLocalizedString("signInPromoDesc",
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 web_ui->AddMessageHandler(base::MakeUnique<HistoryLoginHandler>( 212 web_ui->AddMessageHandler(base::MakeUnique<HistoryLoginHandler>(
221 base::Bind(&MdHistoryUI::UpdateDataSource, base::Unretained(this)))); 213 base::Bind(&MdHistoryUI::UpdateDataSource, base::Unretained(this))));
222 } 214 }
223 215
224 web_ui->RegisterMessageCallback("menuPromoShown", 216 web_ui->RegisterMessageCallback("menuPromoShown",
225 base::Bind(&MdHistoryUI::HandleMenuPromoShown, base::Unretained(this))); 217 base::Bind(&MdHistoryUI::HandleMenuPromoShown, base::Unretained(this)));
226 } 218 }
227 219
228 MdHistoryUI::~MdHistoryUI() {} 220 MdHistoryUI::~MdHistoryUI() {}
229 221
230 // static
231 base::RefCountedMemory* MdHistoryUI::GetFaviconResourceBytes(
232 ui::ScaleFactor scale_factor) {
233 return ResourceBundle::GetSharedInstance().LoadDataResourceBytesForScale(
234 IDR_HISTORY_FAVICON, scale_factor);
235 }
236
237 void MdHistoryUI::RegisterProfilePrefs( 222 void MdHistoryUI::RegisterProfilePrefs(
238 user_prefs::PrefRegistrySyncable* registry) { 223 user_prefs::PrefRegistrySyncable* registry) {
239 registry->RegisterBooleanPref(prefs::kMdHistoryMenuPromoShown, false, 224 registry->RegisterBooleanPref(prefs::kMdHistoryMenuPromoShown, false,
240 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); 225 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
241 } 226 }
242 227
243 void MdHistoryUI::UpdateDataSource() { 228 void MdHistoryUI::UpdateDataSource() {
244 CHECK(web_ui()); 229 CHECK(web_ui());
245 230
246 Profile* profile = Profile::FromWebUI(web_ui()); 231 Profile* profile = Profile::FromWebUI(web_ui());
247 232
248 std::unique_ptr<base::DictionaryValue> update(new base::DictionaryValue); 233 std::unique_ptr<base::DictionaryValue> update(new base::DictionaryValue);
249 update->SetBoolean(kIsUserSignedInKey, IsUserSignedIn(profile)); 234 update->SetBoolean(kIsUserSignedInKey, IsUserSignedIn(profile));
250 update->SetBoolean(kShowMenuPromoKey, !MenuPromoShown(profile)); 235 update->SetBoolean(kShowMenuPromoKey, !MenuPromoShown(profile));
251 236
252 content::WebUIDataSource::Update(profile, chrome::kChromeUIHistoryHost, 237 content::WebUIDataSource::Update(profile, chrome::kChromeUIHistoryHost,
253 std::move(update)); 238 std::move(update));
254 } 239 }
255 240
256 void MdHistoryUI::HandleMenuPromoShown(const base::ListValue* args) { 241 void MdHistoryUI::HandleMenuPromoShown(const base::ListValue* args) {
257 Profile::FromWebUI(web_ui())->GetPrefs()->SetBoolean( 242 Profile::FromWebUI(web_ui())->GetPrefs()->SetBoolean(
258 prefs::kMdHistoryMenuPromoShown, true); 243 prefs::kMdHistoryMenuPromoShown, true);
259 UpdateDataSource(); 244 UpdateDataSource();
260 } 245 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/md_history_ui.h ('k') | chrome/browser/ui/webui/uber/uber_ui.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698