Popular sites on the NTP: check that experiment group StartsWith (rather than IS...
[chromium-blink-merge.git] / chrome / browser / ui / webui / app_launcher_login_handler.h
blobea2b0e74b55b976496e08d99af8594d9a49789a2
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.
5 #ifndef CHROME_BROWSER_UI_WEBUI_APP_LAUNCHER_LOGIN_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_APP_LAUNCHER_LOGIN_HANDLER_H_
8 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "content/public/browser/web_ui_message_handler.h"
12 class Profile;
13 class ProfileInfoWatcher;
15 // The login handler currently simply displays the current logged in
16 // 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 class AppLauncherLoginHandler : public content::WebUIMessageHandler {
19 public:
20 AppLauncherLoginHandler();
21 ~AppLauncherLoginHandler() override;
23 // WebUIMessageHandler implementation:
24 void RegisterMessages() override;
26 // Returns true if the login handler should be shown in a new tab page
27 // for the given |profile|. |profile| must not be NULL.
28 static bool ShouldShow(Profile* profile);
30 // Registers values (strings etc.) for the page.
31 static void GetLocalizedValues(Profile* profile,
32 base::DictionaryValue* values);
34 private:
35 // User actions while on the NTP when clicking on or viewing the sync promo.
36 enum NTPSignInPromoBuckets {
37 NTP_SIGN_IN_PROMO_VIEWED,
38 NTP_SIGN_IN_PROMO_CLICKED,
39 NTP_SIGN_IN_PROMO_BUCKET_BOUNDARY,
42 // Called from JS when the NTP is loaded. |args| is the list of arguments
43 // passed from JS and should be an empty list.
44 void HandleInitializeSyncLogin(const base::ListValue* args);
46 // Called from JS when the user clicks the login container. It shows the
47 // appropriate UI based on the current sync state. |args| is the list of
48 // arguments passed from JS and should be an empty list.
49 void HandleShowSyncLoginUI(const base::ListValue* args);
51 // Records actions in SyncPromo.NTPPromo histogram.
52 void RecordInHistogram(int type);
54 // Called from JS when the sync promo NTP bubble has been displayed. |args| is
55 // the list of arguments passed from JS and should be an empty list.
56 void HandleLoginMessageSeen(const base::ListValue* args);
58 // Called from JS when the user clicks on the advanced link the sync promo NTP
59 // bubble. Use use this to navigate to the sync settings page. |args| is the
60 // list of arguments passed from JS and should be an empty list.
61 void HandleShowAdvancedLoginUI(const base::ListValue* args);
63 // Internal helper method
64 void UpdateLogin();
66 // Watches this web UI's profile for info changes (e.g. authenticated username
67 // changes).
68 scoped_ptr<ProfileInfoWatcher> profile_info_watcher_;
70 DISALLOW_COPY_AND_ASSIGN(AppLauncherLoginHandler);
73 #endif // CHROME_BROWSER_UI_WEBUI_APP_LAUNCHER_LOGIN_HANDLER_H_