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

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: Rebase. 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..b8964ef01b67a522beb866a57f58d170528da13a
--- /dev/null
+++ b/chrome/browser/ui/webui/ntp/android/promo_handler.h
@@ -0,0 +1,76 @@
+// 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 "base/memory/scoped_ptr.h"
+#include "base/values.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;
+
+// The handler for Javascript messages related to the Android NTP promo.
+class PromoHandler : public content::WebUIMessageHandler,
+ public content::NotificationObserver {
+ public:
+ PromoHandler();
+ virtual ~PromoHandler();
+
+ // WebUIMessageHandler override and 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: [ subject, body, app-chooser-message ].
Dan Beam 2012/08/25 00:48:20 nit: can you remove [ ] or just make this less amb
aruslan 2012/08/27 22:19:51 Done.
+ void HandlePromoSendEmail(const base::ListValue* args);
+
+ // Callback for the "promoActionTriggered" message.
+ // Args: [] or NULL.
+ void HandlePromoActionTriggered(const base::ListValue* args);
+
+ // Callback for the "promoDisabled" message.
+ // Args: [] or NULL.
+ void HandlePromoDisabled(const base::ListValue* args);
+
+ // Callback for the "getPromotions" message.
+ // Args: [] or NULL.
+ void InjectPromoDecorations(const base::ListValue* args);
+
+ // Callback for the "recordImpression" message.
+ // Args: [ ("most_visited" | "open_tabs" | "sync_promo") ].
Dan Beam 2012/08/25 00:48:20 probably better to just say "a page to record an i
aruslan 2012/08/27 22:19:51 Done - changed the comment.
+ void RecordImpression(const base::ListValue* args);
+
+ // 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_

Powered by Google App Engine
This is Rietveld 408576698