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

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

Issue 1884553002: Add a testing switch to override the query for other forms of browsing history (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Renamed the switch. 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/prefs/incognito_mode_prefs.h" 14 #include "chrome/browser/prefs/incognito_mode_prefs.h"
13 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/signin/signin_manager_factory.h" 16 #include "chrome/browser/signin/signin_manager_factory.h"
15 #include "chrome/browser/ui/webui/browsing_history_handler.h" 17 #include "chrome/browser/ui/webui/browsing_history_handler.h"
16 #include "chrome/browser/ui/webui/metrics_handler.h" 18 #include "chrome/browser/ui/webui/metrics_handler.h"
17 #include "chrome/common/chrome_switches.h" 19 #include "chrome/common/chrome_switches.h"
18 #include "chrome/common/pref_names.h" 20 #include "chrome/common/pref_names.h"
19 #include "chrome/common/url_constants.h" 21 #include "chrome/common/url_constants.h"
20 #include "chrome/grit/generated_resources.h" 22 #include "chrome/grit/generated_resources.h"
23 #include "components/browsing_data_ui/history_notice_utils.h"
21 #include "components/prefs/pref_service.h" 24 #include "components/prefs/pref_service.h"
22 #include "components/search/search.h" 25 #include "components/search/search.h"
23 #include "components/signin/core/browser/signin_manager.h" 26 #include "components/signin/core/browser/signin_manager.h"
27 #include "content/public/browser/web_contents.h"
24 #include "content/public/browser/web_ui.h" 28 #include "content/public/browser/web_ui.h"
25 #include "content/public/browser/web_ui_data_source.h" 29 #include "content/public/browser/web_ui_data_source.h"
26 #include "grit/browser_resources.h" 30 #include "grit/browser_resources.h"
27 #include "grit/components_scaled_resources.h" 31 #include "grit/components_scaled_resources.h"
28 #include "grit/components_strings.h" 32 #include "grit/components_strings.h"
29 #include "grit/theme_resources.h" 33 #include "grit/theme_resources.h"
30 #include "ui/base/l10n/l10n_util.h" 34 #include "ui/base/l10n/l10n_util.h"
31 #include "ui/base/resource/resource_bundle.h" 35 #include "ui/base/resource/resource_bundle.h"
32 36
33 #if !defined(OS_ANDROID) 37 #if !defined(OS_ANDROID)
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 web_ui->AddMessageHandler(new MetricsHandler()); 170 web_ui->AddMessageHandler(new MetricsHandler());
167 171
168 // On mobile we deal with foreign sessions differently. 172 // On mobile we deal with foreign sessions differently.
169 #if !defined(OS_ANDROID) 173 #if !defined(OS_ANDROID)
170 if (search::IsInstantExtendedAPIEnabled()) { 174 if (search::IsInstantExtendedAPIEnabled()) {
171 web_ui->AddMessageHandler(new browser_sync::ForeignSessionHandler()); 175 web_ui->AddMessageHandler(new browser_sync::ForeignSessionHandler());
172 web_ui->AddMessageHandler(new HistoryLoginHandler()); 176 web_ui->AddMessageHandler(new HistoryLoginHandler());
173 } 177 }
174 #endif 178 #endif
175 179
180 // TODO(crbug.com/595332): Since the API to query other forms of browsing
181 // history is not ready yet, make it possible to test the history UI as if
182 // it were. If the user opens chrome://history/?reset_ofbh, we will assume
183 // that other forms of browsing history exist (for all accounts), and we will
184 // also reset the one-time notice shown in the Clear Browsing Data dialog.
185 // This code should be removed as soon as the API is ready.
186 GURL url = web_ui->GetWebContents()->GetVisibleURL();
187 if (url.has_query() && url.query() == "reset_ofbh") {
188 Profile::FromWebUI(web_ui)->GetPrefs()->SetInteger(
189 prefs::kClearBrowsingDataHistoryNoticeShownTimes, 0);
190 browsing_data_ui::testing::
191 g_override_other_forms_of_browsing_history_query = true;
192 }
193
176 // Set up the chrome://history-frame/ source. 194 // Set up the chrome://history-frame/ source.
177 Profile* profile = Profile::FromWebUI(web_ui); 195 Profile* profile = Profile::FromWebUI(web_ui);
178 content::WebUIDataSource::Add(profile, CreateHistoryUIHTMLSource(profile)); 196 content::WebUIDataSource::Add(profile, CreateHistoryUIHTMLSource(profile));
179 } 197 }
180 198
181 HistoryUI::~HistoryUI() {} 199 HistoryUI::~HistoryUI() {}
182 200
183 // static 201 // static
184 base::RefCountedMemory* HistoryUI::GetFaviconResourceBytes( 202 base::RefCountedMemory* HistoryUI::GetFaviconResourceBytes(
185 ui::ScaleFactor scale_factor) { 203 ui::ScaleFactor scale_factor) {
186 return ResourceBundle::GetSharedInstance(). 204 return ResourceBundle::GetSharedInstance().
187 LoadDataResourceBytesForScale(IDR_HISTORY_FAVICON, scale_factor); 205 LoadDataResourceBytesForScale(IDR_HISTORY_FAVICON, scale_factor);
188 } 206 }
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