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/command_line.h" | 7 #include "base/command_line.h" |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/ui/webui/browsing_history_handler.h" | 10 #include "chrome/browser/ui/webui/browsing_history_handler.h" |
11 #include "chrome/browser/ui/webui/foreign_session_handler.h" | 11 #include "chrome/browser/ui/webui/foreign_session_handler.h" |
12 #include "chrome/browser/ui/webui/history_login_handler.h" | 12 #include "chrome/browser/ui/webui/history_login_handler.h" |
13 #include "chrome/browser/ui/webui/metrics_handler.h" | 13 #include "chrome/browser/ui/webui/metrics_handler.h" |
| 14 #include "chrome/common/chrome_features.h" |
14 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
15 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
16 #include "chrome/common/url_constants.h" | 17 #include "chrome/common/url_constants.h" |
17 #include "components/prefs/pref_service.h" | 18 #include "components/prefs/pref_service.h" |
18 #include "components/search/search.h" | 19 #include "components/search/search.h" |
19 #include "content/public/browser/web_ui.h" | 20 #include "content/public/browser/web_ui.h" |
20 #include "content/public/browser/web_ui_data_source.h" | 21 #include "content/public/browser/web_ui_data_source.h" |
21 #include "grit/browser_resources.h" | 22 #include "grit/browser_resources.h" |
22 #include "grit/components_scaled_resources.h" | 23 #include "grit/components_scaled_resources.h" |
23 #include "grit/components_strings.h" | 24 #include "grit/components_strings.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 source->AddLocalizedString("searchPrompt", IDS_MD_HISTORY_SEARCH_PROMPT); | 63 source->AddLocalizedString("searchPrompt", IDS_MD_HISTORY_SEARCH_PROMPT); |
63 source->AddLocalizedString("searchResult", IDS_HISTORY_SEARCH_RESULT); | 64 source->AddLocalizedString("searchResult", IDS_HISTORY_SEARCH_RESULT); |
64 source->AddLocalizedString("searchResults", IDS_HISTORY_SEARCH_RESULTS); | 65 source->AddLocalizedString("searchResults", IDS_HISTORY_SEARCH_RESULTS); |
65 source->AddLocalizedString("title", IDS_HISTORY_TITLE); | 66 source->AddLocalizedString("title", IDS_HISTORY_TITLE); |
66 | 67 |
67 bool allow_deleting_history = | 68 bool allow_deleting_history = |
68 prefs->GetBoolean(prefs::kAllowDeletingBrowserHistory); | 69 prefs->GetBoolean(prefs::kAllowDeletingBrowserHistory); |
69 source->AddBoolean("allowDeletingHistory", allow_deleting_history); | 70 source->AddBoolean("allowDeletingHistory", allow_deleting_history); |
70 | 71 |
71 bool group_by_domain = base::CommandLine::ForCurrentProcess()->HasSwitch( | 72 bool group_by_domain = base::CommandLine::ForCurrentProcess()->HasSwitch( |
72 switches::kHistoryEnableGroupByDomain); | 73 switches::kHistoryEnableGroupByDomain) || profile->IsSupervised(); |
73 source->AddBoolean("groupByDomain", group_by_domain); | 74 source->AddBoolean("groupByDomain", group_by_domain); |
74 | 75 |
75 source->AddResourcePath("app.html", IDR_MD_HISTORY_APP_HTML); | 76 source->AddResourcePath("app.html", IDR_MD_HISTORY_APP_HTML); |
76 source->AddResourcePath("app.js", IDR_MD_HISTORY_APP_JS); | 77 source->AddResourcePath("app.js", IDR_MD_HISTORY_APP_JS); |
77 source->AddResourcePath("browser_service.html", | 78 source->AddResourcePath("browser_service.html", |
78 IDR_MD_HISTORY_BROWSER_SERVICE_HTML); | 79 IDR_MD_HISTORY_BROWSER_SERVICE_HTML); |
79 source->AddResourcePath("browser_service.js", | 80 source->AddResourcePath("browser_service.js", |
80 IDR_MD_HISTORY_BROWSER_SERVICE_JS); | 81 IDR_MD_HISTORY_BROWSER_SERVICE_JS); |
81 source->AddResourcePath("constants.html", IDR_MD_HISTORY_CONSTANTS_HTML); | 82 source->AddResourcePath("constants.html", IDR_MD_HISTORY_CONSTANTS_HTML); |
82 source->AddResourcePath("constants.js", IDR_MD_HISTORY_CONSTANTS_JS); | 83 source->AddResourcePath("constants.js", IDR_MD_HISTORY_CONSTANTS_JS); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 web_ui->AddMessageHandler(new browser_sync::ForeignSessionHandler()); | 125 web_ui->AddMessageHandler(new browser_sync::ForeignSessionHandler()); |
125 web_ui->AddMessageHandler(new HistoryLoginHandler()); | 126 web_ui->AddMessageHandler(new HistoryLoginHandler()); |
126 } | 127 } |
127 | 128 |
128 Profile* profile = Profile::FromWebUI(web_ui); | 129 Profile* profile = Profile::FromWebUI(web_ui); |
129 content::WebUIDataSource::Add(profile, CreateMdHistoryUIHTMLSource(profile)); | 130 content::WebUIDataSource::Add(profile, CreateMdHistoryUIHTMLSource(profile)); |
130 } | 131 } |
131 | 132 |
132 MdHistoryUI::~MdHistoryUI() {} | 133 MdHistoryUI::~MdHistoryUI() {} |
133 | 134 |
| 135 // static |
| 136 bool MdHistoryUI::IsEnabled(Profile* profile) { |
| 137 return base::FeatureList::IsEnabled( |
| 138 features::kMaterialDesignHistoryFeature) && |
| 139 !base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 140 switches::kHistoryEnableGroupByDomain) && |
| 141 !profile->IsSupervised(); |
| 142 } |
| 143 |
| 144 // static |
134 base::RefCountedMemory* MdHistoryUI::GetFaviconResourceBytes( | 145 base::RefCountedMemory* MdHistoryUI::GetFaviconResourceBytes( |
135 ui::ScaleFactor scale_factor) { | 146 ui::ScaleFactor scale_factor) { |
136 return ResourceBundle::GetSharedInstance().LoadDataResourceBytesForScale( | 147 return ResourceBundle::GetSharedInstance().LoadDataResourceBytesForScale( |
137 IDR_HISTORY_FAVICON, scale_factor); | 148 IDR_HISTORY_FAVICON, scale_factor); |
138 } | 149 } |
OLD | NEW |