OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_UI_WEBUI_SYNC_PROMO_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_SYNC_PROMO_HANDLER_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_SYNC_PROMO_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_SYNC_PROMO_HANDLER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "chrome/browser/ui/webui/sync_setup_handler.h" | 9 #include "chrome/browser/ui/webui/sync_setup_handler.h" |
10 | 10 |
11 class PrefService; | 11 class PrefService; |
12 | 12 |
13 // The handler for Javascript messages related to the "sync promo" page. | 13 // The handler for JavaScript messages related to the "sync promo" page. |
14 class SyncPromoHandler : public SyncSetupHandler { | 14 class SyncPromoHandler : public SyncSetupHandler { |
15 public: | 15 public: |
16 explicit SyncPromoHandler(ProfileManager* profile_manager); | 16 explicit SyncPromoHandler(ProfileManager* profile_manager); |
17 virtual ~SyncPromoHandler(); | 17 virtual ~SyncPromoHandler(); |
18 | 18 |
19 // Called to register our preferences before we use them (so there will be a | 19 // Called to register our preferences before we use them (so there will be a |
20 // default if not present yet). | 20 // default if not present yet). |
21 static void RegisterUserPrefs(PrefService* prefs); | 21 static void RegisterUserPrefs(PrefService* prefs); |
22 | 22 |
23 // WebUIMessageHandler implementation. | 23 // WebUIMessageHandler implementation. |
24 virtual WebUIMessageHandler* Attach(WebUI* web_ui) OVERRIDE; | 24 virtual WebUIMessageHandler* Attach(WebUI* web_ui) OVERRIDE; |
25 virtual void RegisterMessages() OVERRIDE; | 25 virtual void RegisterMessages() OVERRIDE; |
26 | 26 |
27 // SyncSetupFlowHandler implementation. | 27 // SyncSetupFlowHandler implementation. |
28 virtual void ShowConfigure(const base::DictionaryValue& args) OVERRIDE; | 28 virtual void ShowConfigure(const base::DictionaryValue& args) OVERRIDE; |
29 | 29 |
30 // content::NotificationObserver implementation. | 30 // content::NotificationObserver implementation. |
31 virtual void Observe(int type, | 31 virtual void Observe(int type, |
32 const content::NotificationSource& source, | 32 const content::NotificationSource& source, |
33 const content::NotificationDetails& details) OVERRIDE; | 33 const content::NotificationDetails& details) OVERRIDE; |
34 | 34 |
35 protected: | 35 protected: |
36 virtual void ShowSetupUI() OVERRIDE; | 36 virtual void ShowSetupUI() OVERRIDE; |
37 | 37 |
38 private: | 38 private: |
39 // Javascript callback handler to close the sync promo. | 39 // JavaScript callback handler to close the sync promo. |
40 void HandleCloseSyncPromo(const base::ListValue* args); | 40 void HandleCloseSyncPromo(const base::ListValue* args); |
41 | 41 |
42 // Javascript callback handler to initialize the sync promo. | 42 // JavaScript callback handler to initialize the sync promo. |
43 void HandleInitializeSyncPromo(const base::ListValue* args); | 43 void HandleInitializeSyncPromo(const base::ListValue* args); |
44 | 44 |
45 // Javascript callback handler to switch the advanced sync settings. |args| is | 45 // JavaScript handler to record the duration for which the throbber was |
| 46 // visible during an attempted sign-in flow. |
| 47 void HandleRecordThrobberTime(const base::ListValue* args); |
| 48 |
| 49 // JavaScript handler to record the number of times a user attempted to sign |
| 50 // in to chrome while they were on the sync promo page. |
| 51 void HandleRecordSignInAttempts(const base::ListValue* args); |
| 52 |
| 53 // JavaScript callback handler to switch the advanced sync settings. |args| is |
46 // the list of arguments passed from JS and should be an empty list. | 54 // the list of arguments passed from JS and should be an empty list. |
47 void HandleShowAdvancedSettings(const base::ListValue* args); | 55 void HandleShowAdvancedSettings(const base::ListValue* args); |
48 | 56 |
49 // Javascript callback handler to record user actions on the sync promo. | 57 // JavaScript callback handler to record user actions on the sync promo. |
50 void HandleUserFlowAction(const base::ListValue* args); | 58 void HandleUserFlowAction(const base::ListValue* args); |
51 | 59 |
| 60 // JavaScript callback handler for when a user clicks skip. |
| 61 void HandleUserSkipped(const base::ListValue* args); |
| 62 |
52 // Return the number of times the user with the current profile has seen the | 63 // Return the number of times the user with the current profile has seen the |
53 // sync promo. | 64 // sync promo. |
54 int GetViewCount() const; | 65 int GetViewCount() const; |
55 | 66 |
56 // Increment the local view count by the specified non-negative integer | 67 // Increment the local view count by the specified non-negative integer |
57 // amount. Returns the new total view count. | 68 // amount. Returns the new total view count. |
58 int IncrementViewCountBy(unsigned int amount); | 69 int IncrementViewCountBy(unsigned int amount); |
59 | 70 |
60 // Record a user's flow through the promo to our histogram in UMA. | 71 // Record a user's flow through the promo to our histogram in UMA. |
61 void RecordUserFlowAction(int action); | 72 void RecordUserFlowAction(int action); |
62 | 73 |
63 // Use this to register for certain notifications (currently when tabs or | 74 // Use this to register for certain notifications (currently when tabs or |
64 // windows close). | 75 // windows close). |
65 content::NotificationRegistrar registrar_; | 76 content::NotificationRegistrar registrar_; |
66 | 77 |
67 // Weak reference that's initialized and checked in Attach() (after that | 78 // Weak reference that's initialized and checked in Attach() (after that |
68 // guaranteed to be non-NULL). | 79 // guaranteed to be non-NULL). |
69 PrefService* prefs_; | 80 PrefService* prefs_; |
70 | 81 |
71 // If the user closes the whole window we'll get a close notification from the | 82 // If the user closes the whole window we'll get a close notification from the |
72 // tab as well, so this bool acts as a small mutex to only report the close | 83 // tab as well, so this bool acts as a small mutex to only report the close |
73 // method once. | 84 // method once. |
74 bool window_already_closed_; | 85 bool window_already_closed_; |
75 | 86 |
76 DISALLOW_COPY_AND_ASSIGN(SyncPromoHandler); | 87 DISALLOW_COPY_AND_ASSIGN(SyncPromoHandler); |
77 }; | 88 }; |
78 | 89 |
79 #endif // CHROME_BROWSER_UI_WEBUI_SYNC_PROMO_HANDLER_H_ | 90 #endif // CHROME_BROWSER_UI_WEBUI_SYNC_PROMO_HANDLER_H_ |
OLD | NEW |