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

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

Issue 1586373002: MD History: Delete button in the toolbar allows deletion of multiple history-items. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@patch_to_be_uploaded
Patch Set: Address reviewer comments. Created 4 years, 11 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
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/prefs/pref_service.h"
7 #include "build/build_config.h" 8 #include "build/build_config.h"
8 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/ui/webui/browsing_history_handler.h" 10 #include "chrome/browser/ui/webui/browsing_history_handler.h"
10 #include "chrome/browser/ui/webui/metrics_handler.h" 11 #include "chrome/browser/ui/webui/metrics_handler.h"
12 #include "chrome/common/pref_names.h"
11 #include "chrome/common/url_constants.h" 13 #include "chrome/common/url_constants.h"
12 #include "components/search/search.h" 14 #include "components/search/search.h"
13 #include "content/public/browser/web_ui.h" 15 #include "content/public/browser/web_ui.h"
14 #include "content/public/browser/web_ui_data_source.h" 16 #include "content/public/browser/web_ui_data_source.h"
15 #include "grit/browser_resources.h" 17 #include "grit/browser_resources.h"
16 #include "grit/components_strings.h" 18 #include "grit/components_strings.h"
17 #include "grit/generated_resources.h" 19 #include "grit/generated_resources.h"
18 #include "grit/theme_resources.h" 20 #include "grit/theme_resources.h"
19 #include "ui/base/resource/resource_bundle.h" 21 #include "ui/base/resource/resource_bundle.h"
20 22
21 #if !defined(OS_ANDROID) 23 #if !defined(OS_ANDROID)
22 #include "chrome/browser/ui/webui/foreign_session_handler.h" 24 #include "chrome/browser/ui/webui/foreign_session_handler.h"
23 #include "chrome/browser/ui/webui/history_login_handler.h" 25 #include "chrome/browser/ui/webui/history_login_handler.h"
24 #endif 26 #endif
25 27
26 namespace { 28 namespace {
27 29
28 content::WebUIDataSource* CreateMdHistoryUIHTMLSource() { 30 content::WebUIDataSource* CreateMdHistoryUIHTMLSource(Profile* profile) {
31 PrefService* prefs = profile->GetPrefs();
32
29 content::WebUIDataSource* source = 33 content::WebUIDataSource* source =
30 content::WebUIDataSource::Create(chrome::kChromeUIHistoryHost); 34 content::WebUIDataSource::Create(chrome::kChromeUIHistoryHost);
31 35
32 // Localized strings (alphabetical order). 36 // Localized strings (alphabetical order).
33 source->AddLocalizedString("clearSearch", IDS_MD_HISTORY_CLEAR_SEARCH); 37 source->AddLocalizedString("clearSearch", IDS_MD_HISTORY_CLEAR_SEARCH);
34 source->AddLocalizedString("moreFromSite", IDS_HISTORY_MORE_FROM_SITE); 38 source->AddLocalizedString("moreFromSite", IDS_HISTORY_MORE_FROM_SITE);
35 source->AddLocalizedString("removeFromHistory", IDS_HISTORY_REMOVE_PAGE); 39 source->AddLocalizedString("removeFromHistory", IDS_HISTORY_REMOVE_PAGE);
36 source->AddLocalizedString("search", IDS_MD_HISTORY_SEARCH); 40 source->AddLocalizedString("search", IDS_MD_HISTORY_SEARCH);
37 source->AddLocalizedString("title", IDS_HISTORY_TITLE); 41 source->AddLocalizedString("title", IDS_HISTORY_TITLE);
38 42
39 source->AddResourcePath("history_card.html", 43 source->AddResourcePath("history_card.html",
40 IDR_MD_HISTORY_HISTORY_CARD_HTML); 44 IDR_MD_HISTORY_HISTORY_CARD_HTML);
41 source->AddResourcePath("history_card.js", IDR_MD_HISTORY_HISTORY_CARD_JS); 45 source->AddResourcePath("history_card.js", IDR_MD_HISTORY_HISTORY_CARD_JS);
42 source->AddResourcePath("history_card_manager.html", 46 source->AddResourcePath("history_card_manager.html",
43 IDR_MD_HISTORY_HISTORY_CARD_MANAGER_HTML); 47 IDR_MD_HISTORY_HISTORY_CARD_MANAGER_HTML);
44 source->AddResourcePath("history_card_manager.js", 48 source->AddResourcePath("history_card_manager.js",
45 IDR_MD_HISTORY_HISTORY_CARD_MANAGER_JS); 49 IDR_MD_HISTORY_HISTORY_CARD_MANAGER_JS);
46 source->AddResourcePath("history_item.html", 50 source->AddResourcePath("history_item.html",
47 IDR_MD_HISTORY_HISTORY_ITEM_HTML); 51 IDR_MD_HISTORY_HISTORY_ITEM_HTML);
48 source->AddResourcePath("history_item.js", IDR_MD_HISTORY_HISTORY_ITEM_JS); 52 source->AddResourcePath("history_item.js", IDR_MD_HISTORY_HISTORY_ITEM_JS);
49 source->AddResourcePath("history_toolbar.html", 53 source->AddResourcePath("history_toolbar.html",
50 IDR_MD_HISTORY_HISTORY_TOOLBAR_HTML); 54 IDR_MD_HISTORY_HISTORY_TOOLBAR_HTML);
51 source->AddResourcePath("history_toolbar.js", 55 source->AddResourcePath("history_toolbar.js",
52 IDR_MD_HISTORY_HISTORY_TOOLBAR_JS); 56 IDR_MD_HISTORY_HISTORY_TOOLBAR_JS);
53 source->AddResourcePath("history.js", IDR_MD_HISTORY_HISTORY_JS); 57 source->AddResourcePath("history.js", IDR_MD_HISTORY_HISTORY_JS);
54 58
55 source->SetDefaultResource(IDR_MD_HISTORY_HISTORY_HTML); 59 source->SetDefaultResource(IDR_MD_HISTORY_HISTORY_HTML);
56 source->SetJsonPath("strings.js"); 60 source->SetJsonPath("strings.js");
57 61
62 bool allow_deleting_history =
63 prefs->GetBoolean(prefs::kAllowDeletingBrowserHistory);
64 source->AddBoolean("allowDeletingHistory", allow_deleting_history);
tsergeant 2016/01/25 01:43:15 Move this up to between AddLocalizedString and Add
hsampson 2016/01/25 04:15:42 Done.
65
58 return source; 66 return source;
59 } 67 }
60 68
61 } // namespace 69 } // namespace
62 70
63 MdHistoryUI::MdHistoryUI(content::WebUI* web_ui) : WebUIController(web_ui) { 71 MdHistoryUI::MdHistoryUI(content::WebUI* web_ui) : WebUIController(web_ui) {
64 web_ui->AddMessageHandler(new BrowsingHistoryHandler()); 72 web_ui->AddMessageHandler(new BrowsingHistoryHandler());
65 web_ui->AddMessageHandler(new MetricsHandler()); 73 web_ui->AddMessageHandler(new MetricsHandler());
66 74
67 // On mobile we deal with foreign sessions differently. 75 // On mobile we deal with foreign sessions differently.
68 #if !defined(OS_ANDROID) 76 #if !defined(OS_ANDROID)
69 if (search::IsInstantExtendedAPIEnabled()) { 77 if (search::IsInstantExtendedAPIEnabled()) {
70 web_ui->AddMessageHandler(new browser_sync::ForeignSessionHandler()); 78 web_ui->AddMessageHandler(new browser_sync::ForeignSessionHandler());
71 web_ui->AddMessageHandler(new HistoryLoginHandler()); 79 web_ui->AddMessageHandler(new HistoryLoginHandler());
72 } 80 }
73 #endif 81 #endif
74 82
75 Profile* profile = Profile::FromWebUI(web_ui); 83 Profile* profile = Profile::FromWebUI(web_ui);
76 content::WebUIDataSource::Add(profile, CreateMdHistoryUIHTMLSource()); 84 content::WebUIDataSource::Add(profile, CreateMdHistoryUIHTMLSource(profile));
77 } 85 }
78 86
79 MdHistoryUI::~MdHistoryUI() {} 87 MdHistoryUI::~MdHistoryUI() {}
80 88
81 base::RefCountedMemory* MdHistoryUI::GetFaviconResourceBytes( 89 base::RefCountedMemory* MdHistoryUI::GetFaviconResourceBytes(
82 ui::ScaleFactor scale_factor) { 90 ui::ScaleFactor scale_factor) {
83 return ResourceBundle::GetSharedInstance().LoadDataResourceBytesForScale( 91 return ResourceBundle::GetSharedInstance().LoadDataResourceBytesForScale(
84 IDR_HISTORY_FAVICON, scale_factor); 92 IDR_HISTORY_FAVICON, scale_factor);
85 } 93 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698