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

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: Add TODO and remove console.logs. 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"
9 #include "chrome/browser/prefs/incognito_mode_prefs.h"
8 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/ui/webui/browsing_history_handler.h" 11 #include "chrome/browser/ui/webui/browsing_history_handler.h"
10 #include "chrome/browser/ui/webui/metrics_handler.h" 12 #include "chrome/browser/ui/webui/metrics_handler.h"
13 #include "chrome/common/pref_names.h"
11 #include "chrome/common/url_constants.h" 14 #include "chrome/common/url_constants.h"
12 #include "components/search/search.h" 15 #include "components/search/search.h"
13 #include "content/public/browser/web_ui.h" 16 #include "content/public/browser/web_ui.h"
14 #include "content/public/browser/web_ui_data_source.h" 17 #include "content/public/browser/web_ui_data_source.h"
15 #include "grit/browser_resources.h" 18 #include "grit/browser_resources.h"
16 #include "grit/components_strings.h" 19 #include "grit/components_strings.h"
17 #include "grit/generated_resources.h" 20 #include "grit/generated_resources.h"
18 #include "grit/theme_resources.h" 21 #include "grit/theme_resources.h"
19 #include "ui/base/resource/resource_bundle.h" 22 #include "ui/base/resource/resource_bundle.h"
20 23
21 #if !defined(OS_ANDROID) 24 #if !defined(OS_ANDROID)
22 #include "chrome/browser/ui/webui/foreign_session_handler.h" 25 #include "chrome/browser/ui/webui/foreign_session_handler.h"
23 #include "chrome/browser/ui/webui/history_login_handler.h" 26 #include "chrome/browser/ui/webui/history_login_handler.h"
24 #endif 27 #endif
25 28
26 namespace { 29 namespace {
27 30
28 content::WebUIDataSource* CreateMdHistoryUIHTMLSource() { 31 content::WebUIDataSource* CreateMdHistoryUIHTMLSource(Profile* profile) {
32 PrefService* prefs = profile->GetPrefs();
33
29 content::WebUIDataSource* source = 34 content::WebUIDataSource* source =
30 content::WebUIDataSource::Create(chrome::kChromeUIHistoryHost); 35 content::WebUIDataSource::Create(chrome::kChromeUIHistoryHost);
31 36
32 // Localized strings (alphabetical order). 37 // Localized strings (alphabetical order).
33 source->AddLocalizedString("moreFromSite", IDS_HISTORY_MORE_FROM_SITE); 38 source->AddLocalizedString("moreFromSite", IDS_HISTORY_MORE_FROM_SITE);
34 source->AddLocalizedString("removeFromHistory", IDS_HISTORY_REMOVE_PAGE); 39 source->AddLocalizedString("removeFromHistory", IDS_HISTORY_REMOVE_PAGE);
35 source->AddLocalizedString("title", IDS_HISTORY_TITLE); 40 source->AddLocalizedString("title", IDS_HISTORY_TITLE);
36 source->AddLocalizedString("clearSearch", IDS_MD_HISTORY_CLEAR_SEARCH); 41 source->AddLocalizedString("clearSearch", IDS_MD_HISTORY_CLEAR_SEARCH);
37 source->AddLocalizedString("search", IDS_MD_HISTORY_SEARCH); 42 source->AddLocalizedString("search", IDS_MD_HISTORY_SEARCH);
38 43
39 source->AddResourcePath("history-card.html",IDR_MD_HISTORY_HISTORY_CARD_HTML); 44 source->AddResourcePath("history-card.html",IDR_MD_HISTORY_HISTORY_CARD_HTML);
40 source->AddResourcePath("history-card.js", IDR_MD_HISTORY_HISTORY_CARD_JS); 45 source->AddResourcePath("history-card.js", IDR_MD_HISTORY_HISTORY_CARD_JS);
41 source->AddResourcePath("history-card-manager.html", 46 source->AddResourcePath("history-card-manager.html",
42 IDR_MD_HISTORY_HISTORY_CARD_MANAGER_HTML); 47 IDR_MD_HISTORY_HISTORY_CARD_MANAGER_HTML);
43 source->AddResourcePath("history-card-manager.js", 48 source->AddResourcePath("history-card-manager.js",
44 IDR_MD_HISTORY_HISTORY_CARD_MANAGER_JS); 49 IDR_MD_HISTORY_HISTORY_CARD_MANAGER_JS);
45 source->AddResourcePath("history-item.html", 50 source->AddResourcePath("history-item.html",
46 IDR_MD_HISTORY_HISTORY_ITEM_HTML); 51 IDR_MD_HISTORY_HISTORY_ITEM_HTML);
47 source->AddResourcePath("history-item.js", IDR_MD_HISTORY_HISTORY_ITEM_JS); 52 source->AddResourcePath("history-item.js", IDR_MD_HISTORY_HISTORY_ITEM_JS);
48 source->AddResourcePath("history-toolbar.html", 53 source->AddResourcePath("history-toolbar.html",
49 IDR_MD_HISTORY_HISTORY_TOOLBAR_HTML); 54 IDR_MD_HISTORY_HISTORY_TOOLBAR_HTML);
50 source->AddResourcePath("history-toolbar.js", 55 source->AddResourcePath("history-toolbar.js",
51 IDR_MD_HISTORY_HISTORY_TOOLBAR_JS); 56 IDR_MD_HISTORY_HISTORY_TOOLBAR_JS);
52 source->AddResourcePath("history.js", IDR_MD_HISTORY_HISTORY_JS); 57 source->AddResourcePath("history.js", IDR_MD_HISTORY_HISTORY_JS);
53 58
54 source->SetDefaultResource(IDR_MD_HISTORY_HISTORY_HTML); 59 source->SetDefaultResource(IDR_MD_HISTORY_HISTORY_HTML);
55 source->SetJsonPath("strings.js"); 60 source->SetJsonPath("strings.js");
56 61
62 bool allow_deleting_history =
63 prefs->GetBoolean(prefs::kAllowDeletingBrowserHistory);
64 source->AddBoolean("allowDeletingHistory", allow_deleting_history);
tsergeant 2016/01/18 02:33:52 Hmmmmmmmmmm, we'd better make sure there's a test
tsergeant 2016/01/18 02:35:59 (to be extra-clear, I'd like to see a test for thi
hsampson 2016/01/19 23:41:39 Done.
65
57 return source; 66 return source;
58 } 67 }
59 68
60 } // namespace 69 } // namespace
61 70
62 MdHistoryUI::MdHistoryUI(content::WebUI* web_ui) : WebUIController(web_ui) { 71 MdHistoryUI::MdHistoryUI(content::WebUI* web_ui) : WebUIController(web_ui) {
63 web_ui->AddMessageHandler(new BrowsingHistoryHandler()); 72 web_ui->AddMessageHandler(new BrowsingHistoryHandler());
64 web_ui->AddMessageHandler(new MetricsHandler()); 73 web_ui->AddMessageHandler(new MetricsHandler());
65 74
66 // On mobile we deal with foreign sessions differently. 75 // On mobile we deal with foreign sessions differently.
67 #if !defined(OS_ANDROID) 76 #if !defined(OS_ANDROID)
68 if (search::IsInstantExtendedAPIEnabled()) { 77 if (search::IsInstantExtendedAPIEnabled()) {
69 web_ui->AddMessageHandler(new browser_sync::ForeignSessionHandler()); 78 web_ui->AddMessageHandler(new browser_sync::ForeignSessionHandler());
70 web_ui->AddMessageHandler(new HistoryLoginHandler()); 79 web_ui->AddMessageHandler(new HistoryLoginHandler());
71 } 80 }
72 #endif 81 #endif
73 82
74 Profile* profile = Profile::FromWebUI(web_ui); 83 Profile* profile = Profile::FromWebUI(web_ui);
75 content::WebUIDataSource::Add(profile, CreateMdHistoryUIHTMLSource()); 84 content::WebUIDataSource::Add(profile, CreateMdHistoryUIHTMLSource(profile));
76 } 85 }
77 86
78 MdHistoryUI::~MdHistoryUI() {} 87 MdHistoryUI::~MdHistoryUI() {}
79 88
80 base::RefCountedMemory* MdHistoryUI::GetFaviconResourceBytes( 89 base::RefCountedMemory* MdHistoryUI::GetFaviconResourceBytes(
81 ui::ScaleFactor scale_factor) { 90 ui::ScaleFactor scale_factor) {
82 return ResourceBundle::GetSharedInstance().LoadDataResourceBytesForScale( 91 return ResourceBundle::GetSharedInstance().LoadDataResourceBytesForScale(
83 IDR_HISTORY_FAVICON, scale_factor); 92 IDR_HISTORY_FAVICON, scale_factor);
84 } 93 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698