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

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: add tests for deletion and logic for supervised users. 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"
calamity 2016/01/21 00:11:09 Unneeded?
hsampson 2016/01/21 05:34:47 Done.
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("clearSearch", IDS_MD_HISTORY_CLEAR_SEARCH); 38 source->AddLocalizedString("clearSearch", IDS_MD_HISTORY_CLEAR_SEARCH);
34 source->AddLocalizedString("moreFromSite", IDS_HISTORY_MORE_FROM_SITE); 39 source->AddLocalizedString("moreFromSite", IDS_HISTORY_MORE_FROM_SITE);
35 source->AddLocalizedString("removeFromHistory", IDS_HISTORY_REMOVE_PAGE); 40 source->AddLocalizedString("removeFromHistory", IDS_HISTORY_REMOVE_PAGE);
36 source->AddLocalizedString("search", IDS_MD_HISTORY_SEARCH); 41 source->AddLocalizedString("search", IDS_MD_HISTORY_SEARCH);
37 source->AddLocalizedString("title", IDS_HISTORY_TITLE); 42 source->AddLocalizedString("title", IDS_HISTORY_TITLE);
38 43
39 source->AddResourcePath("history_card.html", 44 source->AddResourcePath("history_card.html",
40 IDR_MD_HISTORY_HISTORY_CARD_HTML); 45 IDR_MD_HISTORY_HISTORY_CARD_HTML);
41 source->AddResourcePath("history_card.js", IDR_MD_HISTORY_HISTORY_CARD_JS); 46 source->AddResourcePath("history_card.js", IDR_MD_HISTORY_HISTORY_CARD_JS);
42 source->AddResourcePath("history_card_manager.html", 47 source->AddResourcePath("history_card_manager.html",
43 IDR_MD_HISTORY_HISTORY_CARD_MANAGER_HTML); 48 IDR_MD_HISTORY_HISTORY_CARD_MANAGER_HTML);
44 source->AddResourcePath("history_card_manager.js", 49 source->AddResourcePath("history_card_manager.js",
45 IDR_MD_HISTORY_HISTORY_CARD_MANAGER_JS); 50 IDR_MD_HISTORY_HISTORY_CARD_MANAGER_JS);
46 source->AddResourcePath("history_item.html", 51 source->AddResourcePath("history_item.html",
47 IDR_MD_HISTORY_HISTORY_ITEM_HTML); 52 IDR_MD_HISTORY_HISTORY_ITEM_HTML);
48 source->AddResourcePath("history_item.js", IDR_MD_HISTORY_HISTORY_ITEM_JS); 53 source->AddResourcePath("history_item.js", IDR_MD_HISTORY_HISTORY_ITEM_JS);
49 source->AddResourcePath("history_toolbar.html", 54 source->AddResourcePath("history_toolbar.html",
50 IDR_MD_HISTORY_HISTORY_TOOLBAR_HTML); 55 IDR_MD_HISTORY_HISTORY_TOOLBAR_HTML);
51 source->AddResourcePath("history_toolbar.js", 56 source->AddResourcePath("history_toolbar.js",
52 IDR_MD_HISTORY_HISTORY_TOOLBAR_JS); 57 IDR_MD_HISTORY_HISTORY_TOOLBAR_JS);
53 source->AddResourcePath("history.js", IDR_MD_HISTORY_HISTORY_JS); 58 source->AddResourcePath("history.js", IDR_MD_HISTORY_HISTORY_JS);
54 59
55 source->SetDefaultResource(IDR_MD_HISTORY_HISTORY_HTML); 60 source->SetDefaultResource(IDR_MD_HISTORY_HISTORY_HTML);
56 source->SetJsonPath("strings.js"); 61 source->SetJsonPath("strings.js");
57 62
63 bool allow_deleting_history =
64 prefs->GetBoolean(prefs::kAllowDeletingBrowserHistory);
65 source->AddBoolean("allowDeletingHistory", allow_deleting_history);
66
58 return source; 67 return source;
59 } 68 }
60 69
61 } // namespace 70 } // namespace
62 71
63 MdHistoryUI::MdHistoryUI(content::WebUI* web_ui) : WebUIController(web_ui) { 72 MdHistoryUI::MdHistoryUI(content::WebUI* web_ui) : WebUIController(web_ui) {
64 web_ui->AddMessageHandler(new BrowsingHistoryHandler()); 73 web_ui->AddMessageHandler(new BrowsingHistoryHandler());
65 web_ui->AddMessageHandler(new MetricsHandler()); 74 web_ui->AddMessageHandler(new MetricsHandler());
66 75
67 // On mobile we deal with foreign sessions differently. 76 // On mobile we deal with foreign sessions differently.
68 #if !defined(OS_ANDROID) 77 #if !defined(OS_ANDROID)
69 if (search::IsInstantExtendedAPIEnabled()) { 78 if (search::IsInstantExtendedAPIEnabled()) {
70 web_ui->AddMessageHandler(new browser_sync::ForeignSessionHandler()); 79 web_ui->AddMessageHandler(new browser_sync::ForeignSessionHandler());
71 web_ui->AddMessageHandler(new HistoryLoginHandler()); 80 web_ui->AddMessageHandler(new HistoryLoginHandler());
72 } 81 }
73 #endif 82 #endif
74 83
75 Profile* profile = Profile::FromWebUI(web_ui); 84 Profile* profile = Profile::FromWebUI(web_ui);
76 content::WebUIDataSource::Add(profile, CreateMdHistoryUIHTMLSource()); 85 content::WebUIDataSource::Add(profile, CreateMdHistoryUIHTMLSource(profile));
77 } 86 }
78 87
79 MdHistoryUI::~MdHistoryUI() {} 88 MdHistoryUI::~MdHistoryUI() {}
80 89
81 base::RefCountedMemory* MdHistoryUI::GetFaviconResourceBytes( 90 base::RefCountedMemory* MdHistoryUI::GetFaviconResourceBytes(
82 ui::ScaleFactor scale_factor) { 91 ui::ScaleFactor scale_factor) {
83 return ResourceBundle::GetSharedInstance().LoadDataResourceBytesForScale( 92 return ResourceBundle::GetSharedInstance().LoadDataResourceBytesForScale(
84 IDR_HISTORY_FAVICON, scale_factor); 93 IDR_HISTORY_FAVICON, scale_factor);
85 } 94 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698