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_NTP_NTP_LOGIN_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_NTP_NTP_LOGIN_HANDLER_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_NTP_NTP_LOGIN_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_NTP_NTP_LOGIN_HANDLER_H_ |
7 | 7 |
| 8 #include "base/prefs/public/pref_observer.h" |
8 #include "chrome/browser/api/prefs/pref_member.h" | 9 #include "chrome/browser/api/prefs/pref_member.h" |
9 #include "content/public/browser/notification_observer.h" | 10 #include "content/public/browser/notification_observer.h" |
10 #include "content/public/browser/notification_registrar.h" | 11 #include "content/public/browser/notification_registrar.h" |
11 #include "content/public/browser/web_ui_message_handler.h" | 12 #include "content/public/browser/web_ui_message_handler.h" |
12 | 13 |
13 class Profile; | 14 class Profile; |
14 | 15 |
15 // The NTP login handler currently simply displays the current logged in | 16 // The NTP login handler currently simply displays the current logged in |
16 // username at the top of the NTP (and update itself when that changes). | 17 // username at the top of the NTP (and update itself when that changes). |
17 // In the future it may expand to allow users to login from the NTP. | 18 // In the future it may expand to allow users to login from the NTP. |
18 class NTPLoginHandler : public content::WebUIMessageHandler, | 19 class NTPLoginHandler : public content::WebUIMessageHandler, |
19 public content::NotificationObserver { | 20 public content::NotificationObserver, |
| 21 public PrefObserver { |
20 public: | 22 public: |
21 NTPLoginHandler(); | 23 NTPLoginHandler(); |
22 virtual ~NTPLoginHandler(); | 24 virtual ~NTPLoginHandler(); |
23 | 25 |
24 // WebUIMessageHandler interface | 26 // WebUIMessageHandler interface |
25 virtual void RegisterMessages() OVERRIDE; | 27 virtual void RegisterMessages() OVERRIDE; |
26 | 28 |
27 // content::NotificationObserver interface | 29 // content::NotificationObserver interface |
28 virtual void Observe(int type, | 30 virtual void Observe(int type, |
29 const content::NotificationSource& source, | 31 const content::NotificationSource& source, |
30 const content::NotificationDetails& details) OVERRIDE; | 32 const content::NotificationDetails& details) OVERRIDE; |
31 | 33 |
| 34 // PrefObserver interface |
| 35 virtual void OnPreferenceChanged(PrefServiceBase* service, |
| 36 const std::string& pref_name) OVERRIDE; |
| 37 |
32 // Returns true if the login handler should be shown in a new tab page | 38 // Returns true if the login handler should be shown in a new tab page |
33 // for the given |profile|. |profile| must not be NULL. | 39 // for the given |profile|. |profile| must not be NULL. |
34 static bool ShouldShow(Profile* profile); | 40 static bool ShouldShow(Profile* profile); |
35 | 41 |
36 // Registers values (strings etc.) for the page. | 42 // Registers values (strings etc.) for the page. |
37 static void GetLocalizedValues(Profile* profile, DictionaryValue* values); | 43 static void GetLocalizedValues(Profile* profile, DictionaryValue* values); |
38 | 44 |
39 private: | 45 private: |
40 // User actions while on the NTP when clicking on or viewing the sync promo. | 46 // User actions while on the NTP when clicking on or viewing the sync promo. |
41 enum NTPSignInPromoBuckets { | 47 enum NTPSignInPromoBuckets { |
(...skipping 24 matching lines...) Expand all Loading... |
66 void HandleShowAdvancedLoginUI(const ListValue* args); | 72 void HandleShowAdvancedLoginUI(const ListValue* args); |
67 | 73 |
68 // Internal helper method | 74 // Internal helper method |
69 void UpdateLogin(); | 75 void UpdateLogin(); |
70 | 76 |
71 StringPrefMember username_pref_; | 77 StringPrefMember username_pref_; |
72 content::NotificationRegistrar registrar_; | 78 content::NotificationRegistrar registrar_; |
73 }; | 79 }; |
74 | 80 |
75 #endif // CHROME_BROWSER_UI_WEBUI_NTP_NTP_LOGIN_HANDLER_H_ | 81 #endif // CHROME_BROWSER_UI_WEBUI_NTP_NTP_LOGIN_HANDLER_H_ |
OLD | NEW |