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 a06cdf6bba9d6174e70c0f0af021f6b13ac270b3..9d963b7f8a0ed4a08923258329ded880062ca646 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" |
@@ -17,6 +19,7 @@ |
#include "chrome/common/pref_names.h" |
#include "chrome/common/url_constants.h" |
#include "chrome/grit/locale_settings.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); |
@@ -63,6 +64,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); |
@@ -99,10 +101,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); |
@@ -115,6 +121,7 @@ content::WebUIDataSource* CreateMdHistoryUIHTMLSource(Profile* profile) { |
signin_manager->IsAuthenticated(); |
source->AddBoolean("isUserSignedIn", is_authenticated); |
+ |
source->AddResourcePath("constants.html", IDR_MD_HISTORY_CONSTANTS_HTML); |
source->AddResourcePath("constants.js", IDR_MD_HISTORY_CONSTANTS_JS); |
source->AddResourcePath("images/100/sign_in_promo.png", |
@@ -199,7 +206,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() {} |
@@ -227,3 +239,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); |
+} |
+ |
+void MdHistoryUI::HandleMenuPromoShown(const base::ListValue* args) { |
+ Profile::FromWebUI(web_ui())->GetPrefs()->SetBoolean( |
+ prefs::kMdHistoryMenuPromoShown, true); |
+ data_source_->AddBoolean("showMenuPromo", false); |
+} |