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

Side by Side Diff: chrome/browser/ui/webui/history_ui.cc

Issue 1915473002: Add a testing switch to override the query for other forms of browsing history (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: Created 4 years, 8 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
« no previous file with comments | « no previous file | components/browsing_data_ui/history_notice_utils.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/history_ui.h" 5 #include "chrome/browser/ui/webui/history_ui.h"
6 6
7 #include <string>
8
7 #include "base/command_line.h" 9 #include "base/command_line.h"
8 #include "base/memory/ref_counted_memory.h" 10 #include "base/memory/ref_counted_memory.h"
9 #include "base/strings/string16.h" 11 #include "base/strings/string16.h"
10 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
11 #include "build/build_config.h" 13 #include "build/build_config.h"
12 #include "chrome/browser/history/web_history_service_factory.h" 14 #include "chrome/browser/history/web_history_service_factory.h"
13 #include "chrome/browser/prefs/incognito_mode_prefs.h" 15 #include "chrome/browser/prefs/incognito_mode_prefs.h"
14 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/signin/signin_manager_factory.h" 17 #include "chrome/browser/signin/signin_manager_factory.h"
16 #include "chrome/browser/ui/webui/browsing_history_handler.h" 18 #include "chrome/browser/ui/webui/browsing_history_handler.h"
17 #include "chrome/browser/ui/webui/metrics_handler.h" 19 #include "chrome/browser/ui/webui/metrics_handler.h"
18 #include "chrome/common/chrome_switches.h" 20 #include "chrome/common/chrome_switches.h"
19 #include "chrome/common/pref_names.h" 21 #include "chrome/common/pref_names.h"
20 #include "chrome/common/url_constants.h" 22 #include "chrome/common/url_constants.h"
21 #include "chrome/grit/generated_resources.h" 23 #include "chrome/grit/generated_resources.h"
24 #include "components/browsing_data_ui/history_notice_utils.h"
22 #include "components/prefs/pref_service.h" 25 #include "components/prefs/pref_service.h"
23 #include "components/search/search.h" 26 #include "components/search/search.h"
24 #include "components/signin/core/browser/signin_manager.h" 27 #include "components/signin/core/browser/signin_manager.h"
28 #include "content/public/browser/web_contents.h"
25 #include "content/public/browser/web_ui.h" 29 #include "content/public/browser/web_ui.h"
26 #include "content/public/browser/web_ui_data_source.h" 30 #include "content/public/browser/web_ui_data_source.h"
27 #include "grit/browser_resources.h" 31 #include "grit/browser_resources.h"
28 #include "grit/components_scaled_resources.h" 32 #include "grit/components_scaled_resources.h"
29 #include "grit/components_strings.h" 33 #include "grit/components_strings.h"
30 #include "grit/theme_resources.h" 34 #include "grit/theme_resources.h"
31 #include "ui/base/l10n/l10n_util.h" 35 #include "ui/base/l10n/l10n_util.h"
32 #include "ui/base/resource/resource_bundle.h" 36 #include "ui/base/resource/resource_bundle.h"
33 37
34 #if !defined(OS_ANDROID) 38 #if !defined(OS_ANDROID)
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 web_ui->AddMessageHandler(new MetricsHandler()); 179 web_ui->AddMessageHandler(new MetricsHandler());
176 180
177 // On mobile we deal with foreign sessions differently. 181 // On mobile we deal with foreign sessions differently.
178 #if !defined(OS_ANDROID) 182 #if !defined(OS_ANDROID)
179 if (search::IsInstantExtendedAPIEnabled()) { 183 if (search::IsInstantExtendedAPIEnabled()) {
180 web_ui->AddMessageHandler(new browser_sync::ForeignSessionHandler()); 184 web_ui->AddMessageHandler(new browser_sync::ForeignSessionHandler());
181 web_ui->AddMessageHandler(new HistoryLoginHandler()); 185 web_ui->AddMessageHandler(new HistoryLoginHandler());
182 } 186 }
183 #endif 187 #endif
184 188
189 // TODO(crbug.com/595332): Since the API to query other forms of browsing
190 // history is not ready yet, make it possible to test the history UI as if
191 // it were. If the user opens chrome://history/?reset_ofbh, we will assume
192 // that other forms of browsing history exist (for all accounts), and we will
193 // also reset the one-time notice shown in the Clear Browsing Data dialog.
194 // This code should be removed as soon as the API is ready.
195 GURL url = web_ui->GetWebContents()->GetVisibleURL();
196 if (url.has_query() && url.query() == "reset_ofbh") {
197 Profile::FromWebUI(web_ui)->GetPrefs()->SetInteger(
198 prefs::kClearBrowsingDataHistoryNoticeShownTimes, 0);
199 browsing_data_ui::testing::
200 g_override_other_forms_of_browsing_history_query = true;
201 }
202
185 // Set up the chrome://history-frame/ source. 203 // Set up the chrome://history-frame/ source.
186 Profile* profile = Profile::FromWebUI(web_ui); 204 Profile* profile = Profile::FromWebUI(web_ui);
187 content::WebUIDataSource::Add(profile, CreateHistoryUIHTMLSource(profile)); 205 content::WebUIDataSource::Add(profile, CreateHistoryUIHTMLSource(profile));
188 } 206 }
189 207
190 HistoryUI::~HistoryUI() {} 208 HistoryUI::~HistoryUI() {}
191 209
192 // static 210 // static
193 base::RefCountedMemory* HistoryUI::GetFaviconResourceBytes( 211 base::RefCountedMemory* HistoryUI::GetFaviconResourceBytes(
194 ui::ScaleFactor scale_factor) { 212 ui::ScaleFactor scale_factor) {
195 return ResourceBundle::GetSharedInstance(). 213 return ResourceBundle::GetSharedInstance().
196 LoadDataResourceBytesForScale(IDR_HISTORY_FAVICON, scale_factor); 214 LoadDataResourceBytesForScale(IDR_HISTORY_FAVICON, scale_factor);
197 } 215 }
OLDNEW
« no previous file with comments | « no previous file | components/browsing_data_ui/history_notice_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698