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

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: Removing images (added separately in https://chromiumcodereview.appspot.com/10905035/) Created 8 years, 3 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 "content/public/browser/notification_observer.h"
9 #include "content/public/browser/notification_registrar.h"
10 #include "content/public/browser/web_ui_message_handler.h"
11
12 class PrefService;
13
14 namespace base {
15 class DictionaryValue;
16 class ListValue;
17 }
18
19 // The handler for JavaScript messages related to the Android NTP promo.
20 class PromoHandler : public content::WebUIMessageHandler,
21 public content::NotificationObserver {
22 public:
23 PromoHandler();
24 virtual ~PromoHandler();
25
26 // WebUIMessageHandler implementation.
27 virtual void RegisterMessages() OVERRIDE;
28
29 // Register preferences.
30 static void RegisterUserPrefs(PrefService* prefs);
31
32 private:
33 // NotificationObserver override and implementation.
34 virtual void Observe(int type,
35 const content::NotificationSource& source,
36 const content::NotificationDetails& details) OVERRIDE;
37
38 // Callback for the "promoSendEmail" message.
39 // |args| is a list [ subject, body, app-chooser-message ].
40 void HandlePromoSendEmail(const base::ListValue* args);
41
42 // Callback for the "promoActionTriggered" message.
43 // No arguments.
44 void HandlePromoActionTriggered(const base::ListValue* args);
45
46 // Callback for the "promoDisabled" message.
47 // No arguments.
48 void HandlePromoDisabled(const base::ListValue* args);
49
50 // Callback for the "getPromotions" message.
51 // No arguments.
52 void HandleGetPromotions(const base::ListValue* args);
53
54 // Callback for the "recordImpression" message.
55 // |args| is a list with a name of a page to record an impression from.
56 void HandleRecordImpression(const base::ListValue* args);
57
58 // Gathers the promotion information and updates the page.
59 void InjectPromoDecorations();
60
61 // Records an impression; could trigger a refresh if max_views are exceeded.
62 void RecordPromotionImpression(const std::string& id);
63
64 // Fetches the active promotion and defines what should be passed to JS.
65 // Returns true if the promotion should be shown and the |result| is ready.
66 bool FetchPromotion(base::DictionaryValue* result);
67
68 // Returns true if the Chrome Promo is allowed.
69 bool DoesChromePromoMatchCurrentSync(
70 bool promo_requires_sync,
71 bool promo_requires_no_active_desktop_sync_sessions);
72
73 // Updates the profile preference if any desktop session was discovered.
74 void CheckDesktopSessions();
75
76 // Registrar to receive notification on promo changes.
77 content::NotificationRegistrar registrar_;
78
79 DISALLOW_COPY_AND_ASSIGN(PromoHandler);
80 };
81
82 #endif // CHROME_BROWSER_UI_WEBUI_NTP_ANDROID_PROMO_HANDLER_H_
OLDNEW
« 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