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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_UI_WEBUI_NTP_ANDROID_PROMO_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_NTP_ANDROID_PROMO_HANDLER_H_
7
8 #include "base/memory/scoped_ptr.h"
9 #include "base/values.h"
10 #include "content/public/browser/notification_observer.h"
11 #include "content/public/browser/notification_registrar.h"
12 #include "content/public/browser/web_ui_message_handler.h"
13
14 class PrefService;
15
16 // The handler for Javascript messages related to the Android NTP promo.
17 class PromoHandler : public content::WebUIMessageHandler,
18 public content::NotificationObserver {
19 public:
20 PromoHandler();
21 virtual ~PromoHandler();
22
23 // WebUIMessageHandler override and implementation.
24 virtual void RegisterMessages() OVERRIDE;
25
26 // Register preferences.
27 static void RegisterUserPrefs(PrefService* prefs);
28
29 private:
30 // NotificationObserver override and implementation.
31 virtual void Observe(int type,
32 const content::NotificationSource& source,
33 const content::NotificationDetails& details) OVERRIDE;
34
35 // Callback for the "promoSendEmail" message.
36 // 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.
37 void HandlePromoSendEmail(const base::ListValue* args);
38
39 // Callback for the "promoActionTriggered" message.
40 // Args: [] or NULL.
41 void HandlePromoActionTriggered(const base::ListValue* args);
42
43 // Callback for the "promoDisabled" message.
44 // Args: [] or NULL.
45 void HandlePromoDisabled(const base::ListValue* args);
46
47 // Callback for the "getPromotions" message.
48 // Args: [] or NULL.
49 void InjectPromoDecorations(const base::ListValue* args);
50
51 // Callback for the "recordImpression" message.
52 // 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.
53 void RecordImpression(const base::ListValue* args);
54
55 // Records an impression; could trigger a refresh if max_views are exceeded.
56 void RecordPromotionImpression(const std::string& id);
57
58 // Fetches the active promotion and defines what should be passed to JS.
59 // Returns true if the promotion should be shown and the |result| is ready.
60 bool FetchPromotion(base::DictionaryValue* result);
61
62 // Returns true if the Chrome Promo is allowed.
63 bool DoesChromePromoMatchCurrentSync(
64 bool promo_requires_sync,
65 bool promo_requires_no_active_desktop_sync_sessions);
66
67 // Updates the profile preference if any desktop session was discovered.
68 void CheckDesktopSessions();
69
70 // Registrar to receive notification on promo changes.
71 content::NotificationRegistrar registrar_;
72
73 DISALLOW_COPY_AND_ASSIGN(PromoHandler);
74 };
75
76 #endif // CHROME_BROWSER_UI_WEBUI_NTP_ANDROID_PROMO_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698