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_LOGIN_HANDLER_H_ 6 #define CHROME_BROWSER_UI_WEBUI_NTP_LOGIN_HANDLER_H_ 7 #pragma once 8 9 #include "chrome/browser/prefs/pref_member.h" 10 #include "content/browser/webui/web_ui.h" 11 #include "content/common/notification_observer.h" 12 13 // The NTP login handler currently simply displays the current logged in 14 // username at the top of the NTP (and update itself when that changes). 15 // In the future it may expand to allow users to login from the NTP. 16 class NTPLoginHandler : public WebUIMessageHandler, 17 public NotificationObserver { 18 public: 19 NTPLoginHandler(); 20 ~NTPLoginHandler(); 21 22 virtual WebUIMessageHandler* Attach(WebUI* web_ui); 23 24 // WebUIMessageHandler interface 25 virtual void RegisterMessages(); 26 27 // NotificationObserver interface 28 virtual void Observe(NotificationType type, 29 const NotificationSource& source, 30 const NotificationDetails& details); 31 32 private: 33 // Called from JS when the NTP is loaded. 34 void HandleInitializeLogin(const ListValue* args); 35 36 // Internal helper method 37 void UpdateLogin(); 38 39 StringPrefMember username_pref_; 40 }; 41 42 #endif // CHROME_BROWSER_UI_WEBUI_NTP_LOGIN_HANDLER_H_ 43