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

Side by Side Diff: chrome/browser/ui/webui/ntp/android/promo_handler.h

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

Powered by Google App Engine
This is Rietveld 408576698