| 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" |
| 19 #include "ios/chrome/browser/history/web_history_service_factory.h" | 21 #include "ios/chrome/browser/history/web_history_service_factory.h" |
| 22 #include "ios/chrome/browser/pref_names.h" |
| 20 #include "ios/chrome/browser/signin/signin_manager_factory.h" | 23 #include "ios/chrome/browser/signin/signin_manager_factory.h" |
| 21 #include "ios/chrome/browser/ui/webui/history/browsing_history_handler.h" | 24 #include "ios/chrome/browser/ui/webui/history/browsing_history_handler.h" |
| 22 #include "ios/chrome/browser/ui/webui/history/metrics_handler.h" | 25 #include "ios/chrome/browser/ui/webui/history/metrics_handler.h" |
| 23 #include "ios/chrome/grit/ios_resources.h" | 26 #include "ios/chrome/grit/ios_resources.h" |
| 24 #include "ios/public/provider/web/web_ui_ios.h" | 27 #include "ios/public/provider/web/web_ui_ios.h" |
| 28 #include "ios/web/public/web_state/web_state.h" |
| 25 #include "ios/web/public/web_ui_ios_data_source.h" | 29 #include "ios/web/public/web_ui_ios_data_source.h" |
| 26 #include "ui/base/l10n/l10n_util.h" | 30 #include "ui/base/l10n/l10n_util.h" |
| 27 #include "ui/base/resource/resource_bundle.h" | 31 #include "ui/base/resource/resource_bundle.h" |
| 28 | 32 |
| 29 static const char kStringsJsFile[] = "strings.js"; | 33 static const char kStringsJsFile[] = "strings.js"; |
| 30 static const char kHistoryJsFile[] = "history.js"; | 34 static const char kHistoryJsFile[] = "history.js"; |
| 31 static const char kOtherDevicesJsFile[] = "other_devices.js"; | 35 static const char kOtherDevicesJsFile[] = "other_devices.js"; |
| 32 | 36 |
| 33 namespace { | 37 namespace { |
| 34 | 38 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 | 139 |
| 136 return source; | 140 return source; |
| 137 } | 141 } |
| 138 | 142 |
| 139 } // namespace | 143 } // namespace |
| 140 | 144 |
| 141 HistoryUI::HistoryUI(web::WebUIIOS* web_ui) : web::WebUIIOSController(web_ui) { | 145 HistoryUI::HistoryUI(web::WebUIIOS* web_ui) : web::WebUIIOSController(web_ui) { |
| 142 web_ui->AddMessageHandler(new BrowsingHistoryHandler()); | 146 web_ui->AddMessageHandler(new BrowsingHistoryHandler()); |
| 143 web_ui->AddMessageHandler(new MetricsHandler()); | 147 web_ui->AddMessageHandler(new MetricsHandler()); |
| 144 | 148 |
| 149 // TODO(crbug.com/595332): Since the API to query other forms of browsing |
| 150 // history is not ready yet, make it possible to test the history UI as if |
| 151 // it were. If the user opens chrome://history/?reset_ofbh, we will assume |
| 152 // that other forms of browsing history exist (for all accounts), and we will |
| 153 // also reset the one-time notice shown in the Clear Browsing Data dialog. |
| 154 // This code should be removed as soon as the API is ready. |
| 155 GURL url = web_ui->GetWebState()->GetVisibleURL(); |
| 156 if (url.has_query() && url.query() == "reset_ofbh") { |
| 157 ios::ChromeBrowserState::FromWebUIIOS(web_ui)->GetPrefs()->SetInteger( |
| 158 prefs::kClearBrowsingDataHistoryNoticeShownTimes, 0); |
| 159 browsing_data_ui::testing:: |
| 160 g_override_other_forms_of_browsing_history_query = true; |
| 161 } |
| 162 |
| 145 // Set up the chrome://history-frame/ source. | 163 // Set up the chrome://history-frame/ source. |
| 146 ios::ChromeBrowserState* browser_state = | 164 ios::ChromeBrowserState* browser_state = |
| 147 ios::ChromeBrowserState::FromWebUIIOS(web_ui); | 165 ios::ChromeBrowserState::FromWebUIIOS(web_ui); |
| 148 web::WebUIIOSDataSource::Add(browser_state, | 166 web::WebUIIOSDataSource::Add(browser_state, |
| 149 CreateHistoryUIHTMLSource(browser_state)); | 167 CreateHistoryUIHTMLSource(browser_state)); |
| 150 } | 168 } |
| 151 | 169 |
| 152 HistoryUI::~HistoryUI() {} | 170 HistoryUI::~HistoryUI() {} |
| 153 | 171 |
| 154 // static | 172 // static |
| 155 base::RefCountedMemory* HistoryUI::GetFaviconResourceBytes( | 173 base::RefCountedMemory* HistoryUI::GetFaviconResourceBytes( |
| 156 ui::ScaleFactor scale_factor) { | 174 ui::ScaleFactor scale_factor) { |
| 157 return ResourceBundle::GetSharedInstance().LoadDataResourceBytesForScale( | 175 return ResourceBundle::GetSharedInstance().LoadDataResourceBytesForScale( |
| 158 IDR_HISTORY_FAVICON, scale_factor); | 176 IDR_HISTORY_FAVICON, scale_factor); |
| 159 } | 177 } |
| OLD | NEW |