Chromium Code Reviews| 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_ |