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 |