OLD | NEW |
---|---|
(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" | |
Dan Beam
2012/08/30 18:52:26
nit: probably not needed now, eh?
aruslan
2012/08/30 21:38:17
Done.
| |
9 #include "base/values.h" | |
Dan Beam
2012/08/30 18:52:26
nit: change to forwards, i.e.
namespace base {
cl
aruslan
2012/08/30 21:38:17
Done.
| |
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. | |
Dan Beam
2012/08/30 18:52:26
nit: JavaScript
aruslan
2012/08/30 21:38:17
Done.
| |
17 class PromoHandler : public content::WebUIMessageHandler, | |
18 public content::NotificationObserver { | |
19 public: | |
20 PromoHandler(); | |
21 virtual ~PromoHandler(); | |
22 | |
23 // WebUIMessageHandler override and implementation. | |
Dan Beam
2012/08/30 18:52:26
nit: probably don't need "override and"
aruslan
2012/08/30 21:38:17
Done.
| |
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| is a list [ subject, body, app-chooser-message ]. | |
37 void HandlePromoSendEmail(const base::ListValue* args); | |
38 | |
39 // Callback for the "promoActionTriggered" message. | |
40 // |args| is not used, could be empty or NULL. | |
Dan Beam
2012/08/30 18:52:26
nit: just "No arguments."
aruslan
2012/08/30 21:38:17
Done.
| |
41 void HandlePromoActionTriggered(const base::ListValue* args); | |
42 | |
43 // Callback for the "promoDisabled" message. | |
44 // |args| is not used, could be empty or NULL. | |
45 void HandlePromoDisabled(const base::ListValue* args); | |
46 | |
47 // Callback for the "getPromotions" message. | |
48 // |args| is not used, could be empty or NULL. | |
49 void InjectPromoDecorations(const base::ListValue* args); | |
Dan Beam
2012/08/30 18:52:26
why isn't this named HandleGetPromotions?
aruslan
2012/08/30 21:38:17
Done.
| |
50 | |
51 // Callback for the "recordImpression" message. | |
52 // |args| is a list with a name of a page to record an impression from. | |
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_ | |
OLD | NEW |