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

Unified Diff: chrome/browser/ui/webui/ntp/android/promo_handler.h

Issue 10882024: Add webui handler for promotions on Android NTP. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Removing images (added separately in https://chromiumcodereview.appspot.com/10905035/) Created 8 years, 4 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/ntp/android/promo_handler.h
diff --git a/chrome/browser/ui/webui/ntp/android/promo_handler.h b/chrome/browser/ui/webui/ntp/android/promo_handler.h
new file mode 100644
index 0000000000000000000000000000000000000000..4cd52714c114b7e03eff4e95f5fcb59f91e88d7c
--- /dev/null
+++ b/chrome/browser/ui/webui/ntp/android/promo_handler.h
@@ -0,0 +1,82 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_NTP_ANDROID_PROMO_HANDLER_H_
+#define CHROME_BROWSER_UI_WEBUI_NTP_ANDROID_PROMO_HANDLER_H_
+
+#include "content/public/browser/notification_observer.h"
+#include "content/public/browser/notification_registrar.h"
+#include "content/public/browser/web_ui_message_handler.h"
+
+class PrefService;
+
+namespace base {
+ class DictionaryValue;
+ class ListValue;
+}
+
+// The handler for JavaScript messages related to the Android NTP promo.
+class PromoHandler : public content::WebUIMessageHandler,
+ public content::NotificationObserver {
+ public:
+ PromoHandler();
+ virtual ~PromoHandler();
+
+ // WebUIMessageHandler implementation.
+ virtual void RegisterMessages() OVERRIDE;
+
+ // Register preferences.
+ static void RegisterUserPrefs(PrefService* prefs);
+
+ private:
+ // NotificationObserver override and implementation.
+ virtual void Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) OVERRIDE;
+
+ // Callback for the "promoSendEmail" message.
+ // |args| is a list [ subject, body, app-chooser-message ].
+ void HandlePromoSendEmail(const base::ListValue* args);
+
+ // Callback for the "promoActionTriggered" message.
+ // No arguments.
+ void HandlePromoActionTriggered(const base::ListValue* args);
+
+ // Callback for the "promoDisabled" message.
+ // No arguments.
+ void HandlePromoDisabled(const base::ListValue* args);
+
+ // Callback for the "getPromotions" message.
+ // No arguments.
+ void HandleGetPromotions(const base::ListValue* args);
+
+ // Callback for the "recordImpression" message.
+ // |args| is a list with a name of a page to record an impression from.
+ void HandleRecordImpression(const base::ListValue* args);
+
+ // Gathers the promotion information and updates the page.
+ void InjectPromoDecorations();
+
+ // Records an impression; could trigger a refresh if max_views are exceeded.
+ void RecordPromotionImpression(const std::string& id);
+
+ // Fetches the active promotion and defines what should be passed to JS.
+ // Returns true if the promotion should be shown and the |result| is ready.
+ bool FetchPromotion(base::DictionaryValue* result);
+
+ // Returns true if the Chrome Promo is allowed.
+ bool DoesChromePromoMatchCurrentSync(
+ bool promo_requires_sync,
+ bool promo_requires_no_active_desktop_sync_sessions);
+
+ // Updates the profile preference if any desktop session was discovered.
+ void CheckDesktopSessions();
+
+ // Registrar to receive notification on promo changes.
+ content::NotificationRegistrar registrar_;
+
+ DISALLOW_COPY_AND_ASSIGN(PromoHandler);
+};
+
+#endif // CHROME_BROWSER_UI_WEBUI_NTP_ANDROID_PROMO_HANDLER_H_
« no previous file with comments | « chrome/browser/resources/ntp_android/ntp_android.js ('k') | chrome/browser/ui/webui/ntp/android/promo_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698