OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_UI_WEBUI_NTP_NTP_LOGIN_HANDLER_H_ | |
6 #define CHROME_BROWSER_UI_WEBUI_NTP_NTP_LOGIN_HANDLER_H_ | |
7 | |
8 #include "base/prefs/pref_member.h" | |
9 #include "chrome/browser/profiles/profile_info_cache_observer.h" | |
10 #include "content/public/browser/web_ui_message_handler.h" | |
11 | |
12 class Profile; | |
13 | |
14 // The NTP login handler currently simply displays the current logged in | |
15 // username at the top of the NTP (and update itself when that changes). | |
16 // In the future it may expand to allow users to login from the NTP. | |
17 class NTPLoginHandler : public content::WebUIMessageHandler, | |
18 public ProfileInfoCacheObserver { | |
19 public: | |
20 NTPLoginHandler(); | |
21 ~NTPLoginHandler() override; | |
22 | |
23 // WebUIMessageHandler implementation: | |
24 void RegisterMessages() override; | |
25 | |
26 // ProfileInfoCacheObserver implementation: | |
27 void OnProfileAuthInfoChanged(const base::FilePath& profile_path) override; | |
28 | |
29 // Returns true if the login handler should be shown in a new tab page | |
30 // for the given |profile|. |profile| must not be NULL. | |
31 static bool ShouldShow(Profile* profile); | |
32 | |
33 // Registers values (strings etc.) for the page. | |
34 static void GetLocalizedValues(Profile* profile, | |
35 base::DictionaryValue* values); | |
36 | |
37 private: | |
38 // User actions while on the NTP when clicking on or viewing the sync promo. | |
39 enum NTPSignInPromoBuckets { | |
40 NTP_SIGN_IN_PROMO_VIEWED, | |
41 NTP_SIGN_IN_PROMO_CLICKED, | |
42 NTP_SIGN_IN_PROMO_BUCKET_BOUNDARY, | |
43 }; | |
44 | |
45 // Called from JS when the NTP is loaded. |args| is the list of arguments | |
46 // passed from JS and should be an empty list. | |
47 void HandleInitializeSyncLogin(const base::ListValue* args); | |
48 | |
49 // Called from JS when the user clicks the login container. It shows the | |
50 // appropriate UI based on the current sync state. |args| is the list of | |
51 // arguments passed from JS and should be an empty list. | |
52 void HandleShowSyncLoginUI(const base::ListValue* args); | |
53 | |
54 // Records actions in SyncPromo.NTPPromo histogram. | |
55 void RecordInHistogram(int type); | |
56 | |
57 // Called from JS when the sync promo NTP bubble has been displayed. |args| is | |
58 // the list of arguments passed from JS and should be an empty list. | |
59 void HandleLoginMessageSeen(const base::ListValue* args); | |
60 | |
61 // Called from JS when the user clicks on the advanced link the sync promo NTP | |
62 // bubble. Use use this to navigate to the sync settings page. |args| is the | |
63 // list of arguments passed from JS and should be an empty list. | |
64 void HandleShowAdvancedLoginUI(const base::ListValue* args); | |
65 | |
66 // Internal helper method | |
67 void UpdateLogin(); | |
68 | |
69 BooleanPrefMember signin_allowed_pref_; | |
70 }; | |
71 | |
72 #endif // CHROME_BROWSER_UI_WEBUI_NTP_NTP_LOGIN_HANDLER_H_ | |
OLD | NEW |