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

Unified Diff: chrome/browser/dom_ui/new_tab_ui.cc

Issue 4804001: Add new promotional line for NTP.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month 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
« no previous file with comments | « no previous file | chrome/browser/dom_ui/ntp_resource_cache.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/dom_ui/new_tab_ui.cc
===================================================================
--- chrome/browser/dom_ui/new_tab_ui.cc (revision 67122)
+++ chrome/browser/dom_ui/new_tab_ui.cc (working copy)
@@ -303,6 +303,41 @@
dom_ui_->CallJavascriptFunction(L"onHomePageSet", list_value);
}
+///////////////////////////////////////////////////////////////////////////////
+// NewTabPageClosePromoHandler
+
+// Turns off the promo line permanently when it has been explicitly closed by
+// the user.
+class NewTabPageClosePromoHandler : public DOMMessageHandler {
+ public:
+ NewTabPageClosePromoHandler() {}
+ virtual ~NewTabPageClosePromoHandler() {}
+
+ // DOMMessageHandler implementation.
+ virtual void RegisterMessages();
+
+ // Callback for "closePromo".
+ void HandleClosePromo(const ListValue* args);
+
+ private:
+
+ DISALLOW_COPY_AND_ASSIGN(NewTabPageClosePromoHandler);
+};
+
+void NewTabPageClosePromoHandler::RegisterMessages() {
+ dom_ui_->RegisterMessageCallback("closePromo", NewCallback(
+ this, &NewTabPageClosePromoHandler::HandleClosePromo));
+}
+
+void NewTabPageClosePromoHandler::HandleClosePromo(
+ const ListValue* args) {
+ dom_ui_->GetProfile()->GetPrefs()->SetBoolean(prefs::kNTPPromoClosed, true);
+ NotificationService* service = NotificationService::current();
+ service->Notify(NotificationType::WEB_RESOURCE_STATE_CHANGED,
+ Source<NewTabPageClosePromoHandler>(this),
+ NotificationService::NoDetails());
+}
+
} // namespace
///////////////////////////////////////////////////////////////////////////////
@@ -348,6 +383,7 @@
AddMessageHandler((new AppLauncherHandler(service))->Attach(this));
AddMessageHandler((new NewTabPageSetHomePageHandler())->Attach(this));
+ AddMessageHandler((new NewTabPageClosePromoHandler())->Attach(this));
}
// Initializing the CSS and HTML can require some CPU, so do it after
« no previous file with comments | « no previous file | chrome/browser/dom_ui/ntp_resource_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698