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

Unified 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: Updated bug number. 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/history_ui.cc
diff --git a/chrome/browser/ui/webui/history_ui.cc b/chrome/browser/ui/webui/history_ui.cc
index 8f4e094299b65ff449e53d1c23d6a00180e30ab7..d0ce92d10e30a75ddb8ff7d308c0c5dd21a1e071 100644
--- a/chrome/browser/ui/webui/history_ui.cc
+++ b/chrome/browser/ui/webui/history_ui.cc
@@ -19,16 +19,20 @@
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/generated_resources.h"
+#include "components/browsing_data_ui/history_notice_utils.h"
#include "components/prefs/pref_service.h"
#include "components/search/search.h"
#include "components/signin/core/browser/signin_manager.h"
+#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h"
+#include "content/public/common/referrer.h"
#include "grit/browser_resources.h"
#include "grit/components_scaled_resources.h"
#include "grit/components_strings.h"
#include "grit/theme_resources.h"
#include "ui/base/l10n/l10n_util.h"
+#include "ui/base/page_transition_types.h"
#include "ui/base/resource/resource_bundle.h"
#if !defined(OS_ANDROID)
@@ -170,7 +174,9 @@ content::WebUIDataSource* CreateHistoryUIHTMLSource(Profile* profile) {
} // namespace
-HistoryUI::HistoryUI(content::WebUI* web_ui) : WebUIController(web_ui) {
+HistoryUI::HistoryUI(content::WebUI* web_ui)
+ : WebUIController(web_ui),
+ WebContentsObserver(web_ui->GetWebContents()) {
web_ui->AddMessageHandler(new BrowsingHistoryHandler());
web_ui->AddMessageHandler(new MetricsHandler());
@@ -195,3 +201,25 @@ base::RefCountedMemory* HistoryUI::GetFaviconResourceBytes(
return ResourceBundle::GetSharedInstance().
LoadDataResourceBytesForScale(IDR_HISTORY_FAVICON, scale_factor);
}
+
+void HistoryUI::DidStopLoading() {
+ // TODO(crbug.com/595332): Since the API to query other forms of browsing
+ // history is not ready yet, make it possible to test the history UI as if
+ // it were. If the user opens chrome://history/?reset_ofbh, we will assume
+ // that other forms of browsing history exist (for all accounts), and we will
+ // also reset the one-time notice shown in the Clear Browsing Data dialog.
+ // This code should be removed as soon as the API is ready.
+ GURL url = web_ui()->GetWebContents()->GetVisibleURL();
+ if (!url.is_valid() || url.query() != "reset_ofbh")
+ return;
+
+ Profile::FromWebUI(web_ui())->GetPrefs()->SetInteger(
+ prefs::kClearBrowsingDataHistoryNoticeShownTimes, 0);
+ base::CommandLine::ForCurrentProcess()->AppendSwitch(
+ browsing_data_ui::switches::kOverrideOtherFormsOfBrowsingHistoryQuery);
+ web_ui()->GetWebContents()->GetController().LoadURL(
+ GURL(chrome::kChromeUIHistoryURL),
+ content::Referrer(),
+ ui::PAGE_TRANSITION_CLIENT_REDIRECT,
+ std::string());
+}

Powered by Google App Engine
This is Rietveld 408576698