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

Unified Diff: chrome/browser/ui/webui/md_history_ui.cc

Issue 2280513002: MD History: promote menu button to show clear browsing data in narrow mode (Closed)
Patch Set: !showingSearch_ Created 4 years, 3 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/md_history_ui.cc
diff --git a/chrome/browser/ui/webui/md_history_ui.cc b/chrome/browser/ui/webui/md_history_ui.cc
index 4f01d93968cfabadd6a4c329b4d47274adc381b9..3e6f2c7f97a7fb33a2a61f3e1f5e49307519e436 100644
--- a/chrome/browser/ui/webui/md_history_ui.cc
+++ b/chrome/browser/ui/webui/md_history_ui.cc
@@ -4,6 +4,8 @@
#include "chrome/browser/ui/webui/md_history_ui.h"
+#include "base/bind.h"
+#include "base/bind_helpers.h"
#include "base/command_line.h"
#include "build/build_config.h"
#include "chrome/browser/profiles/profile.h"
@@ -21,6 +23,7 @@
#include "chrome/grit/locale_settings.h"
#include "chrome/grit/theme_resources.h"
#include "components/grit/components_scaled_resources.h"
+#include "components/pref_registry/pref_registry_syncable.h"
#include "components/prefs/pref_service.h"
#include "components/search/search.h"
#include "components/signin/core/browser/signin_manager.h"
@@ -33,8 +36,6 @@
namespace {
content::WebUIDataSource* CreateMdHistoryUIHTMLSource(Profile* profile) {
- PrefService* prefs = profile->GetPrefs();
-
content::WebUIDataSource* source =
content::WebUIDataSource::Create(chrome::kChromeUIHistoryHost);
@@ -65,6 +66,7 @@ content::WebUIDataSource* CreateMdHistoryUIHTMLSource(Profile* profile) {
IDS_MD_HISTORY_HISTORY_MENU_ITEM);
source->AddLocalizedString("itemsSelected", IDS_MD_HISTORY_ITEMS_SELECTED);
source->AddLocalizedString("loading", IDS_HISTORY_LOADING);
+ source->AddLocalizedString("menuPromo", IDS_HISTORY_MENU_PROMO);
source->AddLocalizedString("moreActionsButton",
IDS_HISTORY_ACTION_MENU_DESCRIPTION);
source->AddLocalizedString("moreFromSite", IDS_HISTORY_MORE_FROM_SITE);
@@ -101,10 +103,14 @@ content::WebUIDataSource* CreateMdHistoryUIHTMLSource(Profile* profile) {
l10n_util::GetStringUTF16(
IDS_SETTINGS_CLEAR_DATA_WEB_HISTORY_URL_IN_HISTORY)));
+ PrefService* prefs = profile->GetPrefs();
bool allow_deleting_history =
prefs->GetBoolean(prefs::kAllowDeletingBrowserHistory);
source->AddBoolean("allowDeletingHistory", allow_deleting_history);
+ source->AddBoolean("showMenuPromo",
+ !prefs->GetBoolean(prefs::kMdHistoryMenuPromoShown));
+
bool group_by_domain = base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kHistoryEnableGroupByDomain) || profile->IsSupervised();
source->AddBoolean("groupByDomain", group_by_domain);
@@ -201,7 +207,12 @@ MdHistoryUI::MdHistoryUI(content::WebUI* web_ui) : WebUIController(web_ui) {
web_ui->AddMessageHandler(new HistoryLoginHandler());
}
- content::WebUIDataSource::Add(profile, CreateMdHistoryUIHTMLSource(profile));
+ data_source_ = CreateMdHistoryUIHTMLSource(profile);
+ content::WebUIDataSource::Add(profile, data_source_);
+
+ web_ui->RegisterMessageCallback("menuPromoShown",
+ base::Bind(&MdHistoryUI::HandleMenuPromoShown,
+ base::Unretained(this)));
}
MdHistoryUI::~MdHistoryUI() {}
@@ -231,3 +242,14 @@ base::RefCountedMemory* MdHistoryUI::GetFaviconResourceBytes(
return ResourceBundle::GetSharedInstance().LoadDataResourceBytesForScale(
IDR_HISTORY_FAVICON, scale_factor);
}
+
+void MdHistoryUI::RegisterProfilePrefs(
+ user_prefs::PrefRegistrySyncable* registry) {
+ registry->RegisterBooleanPref(prefs::kMdHistoryMenuPromoShown, false);
tsergeant 2016/09/09 06:09:39 Naive question from someone not very familiar with
Dan Beam 2016/09/16 00:01:24 probably wouldn't have
+}
+
+void MdHistoryUI::HandleMenuPromoShown(const base::ListValue* args) {
+ Profile::FromWebUI(web_ui())->GetPrefs()->SetBoolean(
+ prefs::kMdHistoryMenuPromoShown, true);
+ data_source_->AddBoolean("showMenuPromo", false);
+}

Powered by Google App Engine
This is Rietveld 408576698