OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ios/chrome/browser/ui/webui/history/history_ui.h" | 5 #include "ios/chrome/browser/ui/webui/history/history_ui.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/memory/ref_counted_memory.h" | 8 #include "base/memory/ref_counted_memory.h" |
9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "components/browsing_data_ui/history_notice_utils.h" |
11 #include "components/grit/components_scaled_resources.h" | 12 #include "components/grit/components_scaled_resources.h" |
12 #include "components/keyed_service/core/service_access_type.h" | 13 #include "components/keyed_service/core/service_access_type.h" |
| 14 #include "components/prefs/pref_service.h" |
13 #include "components/search/search.h" | 15 #include "components/search/search.h" |
14 #include "components/signin/core/browser/signin_manager.h" | 16 #include "components/signin/core/browser/signin_manager.h" |
15 #include "components/strings/grit/components_strings.h" | 17 #include "components/strings/grit/components_strings.h" |
16 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" | 18 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" |
17 #include "ios/chrome/browser/chrome_switches.h" | 19 #include "ios/chrome/browser/chrome_switches.h" |
18 #include "ios/chrome/browser/chrome_url_constants.h" | 20 #include "ios/chrome/browser/chrome_url_constants.h" |
| 21 #include "ios/chrome/browser/pref_names.h" |
19 #include "ios/chrome/browser/signin/signin_manager_factory.h" | 22 #include "ios/chrome/browser/signin/signin_manager_factory.h" |
20 #include "ios/chrome/browser/ui/webui/history/browsing_history_handler.h" | 23 #include "ios/chrome/browser/ui/webui/history/browsing_history_handler.h" |
21 #include "ios/chrome/browser/ui/webui/history/metrics_handler.h" | 24 #include "ios/chrome/browser/ui/webui/history/metrics_handler.h" |
22 #include "ios/chrome/grit/ios_resources.h" | 25 #include "ios/chrome/grit/ios_resources.h" |
23 #include "ios/public/provider/web/web_ui_ios.h" | 26 #include "ios/public/provider/web/web_ui_ios.h" |
| 27 #include "ios/web/public/web_state/web_state.h" |
24 #include "ios/web/public/web_ui_ios_data_source.h" | 28 #include "ios/web/public/web_ui_ios_data_source.h" |
25 #include "ui/base/l10n/l10n_util.h" | 29 #include "ui/base/l10n/l10n_util.h" |
26 #include "ui/base/resource/resource_bundle.h" | 30 #include "ui/base/resource/resource_bundle.h" |
27 | 31 |
28 static const char kStringsJsFile[] = "strings.js"; | 32 static const char kStringsJsFile[] = "strings.js"; |
29 static const char kHistoryJsFile[] = "history.js"; | 33 static const char kHistoryJsFile[] = "history.js"; |
30 static const char kOtherDevicesJsFile[] = "other_devices.js"; | 34 static const char kOtherDevicesJsFile[] = "other_devices.js"; |
31 | 35 |
32 namespace { | 36 namespace { |
33 | 37 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 | 129 |
126 return source; | 130 return source; |
127 } | 131 } |
128 | 132 |
129 } // namespace | 133 } // namespace |
130 | 134 |
131 HistoryUI::HistoryUI(web::WebUIIOS* web_ui) : web::WebUIIOSController(web_ui) { | 135 HistoryUI::HistoryUI(web::WebUIIOS* web_ui) : web::WebUIIOSController(web_ui) { |
132 web_ui->AddMessageHandler(new BrowsingHistoryHandler()); | 136 web_ui->AddMessageHandler(new BrowsingHistoryHandler()); |
133 web_ui->AddMessageHandler(new MetricsHandler()); | 137 web_ui->AddMessageHandler(new MetricsHandler()); |
134 | 138 |
| 139 // TODO(crbug.com/595332): Since the API to query other forms of browsing |
| 140 // history is not ready yet, make it possible to test the history UI as if |
| 141 // it were. If the user opens chrome://history/?reset_ofbh, we will assume |
| 142 // that other forms of browsing history exist (for all accounts), and we will |
| 143 // also reset the one-time notice shown in the Clear Browsing Data dialog. |
| 144 // This code should be removed as soon as the API is ready. |
| 145 GURL url = web_ui->GetWebState()->GetVisibleURL(); |
| 146 if (url.has_query() && url.query() == "reset_ofbh") { |
| 147 ios::ChromeBrowserState::FromWebUIIOS(web_ui)->GetPrefs()->SetInteger( |
| 148 prefs::kClearBrowsingDataHistoryNoticeShownTimes, 0); |
| 149 browsing_data_ui::testing:: |
| 150 g_override_other_forms_of_browsing_history_query = true; |
| 151 } |
| 152 |
135 // Set up the chrome://history-frame/ source. | 153 // Set up the chrome://history-frame/ source. |
136 ios::ChromeBrowserState* browser_state = | 154 ios::ChromeBrowserState* browser_state = |
137 ios::ChromeBrowserState::FromWebUIIOS(web_ui); | 155 ios::ChromeBrowserState::FromWebUIIOS(web_ui); |
138 web::WebUIIOSDataSource::Add(browser_state, | 156 web::WebUIIOSDataSource::Add(browser_state, |
139 CreateHistoryUIHTMLSource(browser_state)); | 157 CreateHistoryUIHTMLSource(browser_state)); |
140 } | 158 } |
141 | 159 |
142 HistoryUI::~HistoryUI() {} | 160 HistoryUI::~HistoryUI() {} |
143 | 161 |
144 // static | 162 // static |
145 base::RefCountedMemory* HistoryUI::GetFaviconResourceBytes( | 163 base::RefCountedMemory* HistoryUI::GetFaviconResourceBytes( |
146 ui::ScaleFactor scale_factor) { | 164 ui::ScaleFactor scale_factor) { |
147 return ResourceBundle::GetSharedInstance().LoadDataResourceBytesForScale( | 165 return ResourceBundle::GetSharedInstance().LoadDataResourceBytesForScale( |
148 IDR_HISTORY_FAVICON, scale_factor); | 166 IDR_HISTORY_FAVICON, scale_factor); |
149 } | 167 } |
OLD | NEW |