OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_CHROMEOS_LOGIN_LOGIN_DISPLAY_HOST_IMPL_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_DISPLAY_HOST_IMPL_H_ |
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_DISPLAY_HOST_IMPL_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_DISPLAY_HOST_IMPL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "chrome/browser/chromeos/login/existing_user_controller.h" |
13 #include "chrome/browser/chromeos/login/login_display.h" | 14 #include "chrome/browser/chromeos/login/login_display.h" |
14 #include "chrome/browser/chromeos/login/login_display_host.h" | 15 #include "chrome/browser/chromeos/login/login_display_host.h" |
| 16 #include "chrome/browser/chromeos/login/wizard_controller.h" |
15 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 17 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
16 #include "content/public/browser/notification_observer.h" | 18 #include "content/public/browser/notification_observer.h" |
17 #include "content/public/browser/notification_registrar.h" | 19 #include "content/public/browser/notification_registrar.h" |
| 20 #include "content/public/browser/web_contents_observer.h" |
18 #include "ui/gfx/rect.h" | 21 #include "ui/gfx/rect.h" |
19 | 22 |
20 class PrefService; | 23 class PrefService; |
21 | 24 |
22 namespace policy { | 25 namespace policy { |
23 class AutoEnrollmentClient; | 26 class AutoEnrollmentClient; |
24 } // namespace policy | 27 } // namespace policy |
25 | 28 |
26 namespace chromeos { | 29 namespace chromeos { |
27 | 30 |
28 class ExistingUserController; | 31 class OobeUI; |
29 class WizardController; | 32 class WebUILoginDisplay; |
| 33 class WebUILoginView; |
30 | 34 |
31 // An implementation class for OOBE/login screen host. | 35 // An implementation class for OOBE/login WebUI screen host. |
32 // It encapsulates controllers, background integration and flow. | 36 // It encapsulates controllers, background integration and flow. |
33 class LoginDisplayHostImpl : public LoginDisplayHost, | 37 class LoginDisplayHostImpl : public LoginDisplayHost, |
34 public content::NotificationObserver { | 38 public content::NotificationObserver, |
| 39 public content::WebContentsObserver { |
35 public: | 40 public: |
36 explicit LoginDisplayHostImpl(const gfx::Rect& background_bounds); | 41 explicit LoginDisplayHostImpl(const gfx::Rect& background_bounds); |
37 virtual ~LoginDisplayHostImpl(); | 42 virtual ~LoginDisplayHostImpl(); |
38 | 43 |
39 // Returns the default LoginDispalyHost instance if it has been created. | 44 // Returns the default LoginDispalyHost instance if it has been created. |
40 static LoginDisplayHost* default_host() { | 45 static LoginDisplayHost* default_host() { |
41 return default_host_; | 46 return default_host_; |
42 } | 47 } |
43 | 48 |
44 // LoginDisplayHost implementation: | 49 // LoginDisplayHost implementation: |
| 50 virtual LoginDisplay* CreateLoginDisplay( |
| 51 LoginDisplay::Delegate* delegate) OVERRIDE; |
| 52 virtual gfx::NativeWindow GetNativeWindow() const OVERRIDE; |
| 53 virtual WebUILoginView* GetWebUILoginView() const OVERRIDE; |
| 54 virtual views::Widget* GetWidget() const OVERRIDE; |
45 virtual void BeforeSessionStart() OVERRIDE; | 55 virtual void BeforeSessionStart() OVERRIDE; |
46 virtual void OnSessionStart() OVERRIDE; | 56 virtual void OnSessionStart() OVERRIDE; |
47 virtual void OnCompleteLogin() OVERRIDE; | 57 virtual void OnCompleteLogin() OVERRIDE; |
| 58 virtual void OpenProxySettings() OVERRIDE; |
| 59 virtual void SetOobeProgressBarVisible(bool visible) OVERRIDE; |
| 60 virtual void SetShutdownButtonEnabled(bool enable) OVERRIDE; |
| 61 virtual void SetStatusAreaVisible(bool visible) OVERRIDE; |
| 62 virtual void CheckForAutoEnrollment() OVERRIDE; |
48 virtual void StartWizard( | 63 virtual void StartWizard( |
49 const std::string& first_screen_name, | 64 const std::string& first_screen_name, |
50 DictionaryValue* screen_parameters) OVERRIDE; | 65 scoped_ptr<DictionaryValue> screen_parameters) OVERRIDE; |
| 66 virtual WizardController* GetWizardController() OVERRIDE; |
51 virtual void StartSignInScreen() OVERRIDE; | 67 virtual void StartSignInScreen() OVERRIDE; |
52 virtual void ResumeSignInScreen() OVERRIDE; | 68 virtual void ResumeSignInScreen() OVERRIDE; |
53 virtual void CheckForAutoEnrollment() OVERRIDE; | 69 virtual void OnPreferencesChanged() OVERRIDE; |
54 virtual WizardController* GetWizardController() OVERRIDE; | |
55 | 70 |
56 // Creates specific WizardController. | 71 // Creates WizardController instance. |
57 virtual WizardController* CreateWizardController() = 0; | 72 WizardController* CreateWizardController(); |
58 | 73 |
59 // Called when the first browser window is created, but before it's | 74 // Called when the first browser window is created, but before it's shown. |
60 // ready (shown). | 75 void OnBrowserCreated(); |
61 virtual void OnBrowserCreated() = 0; | 76 |
| 77 // Returns instance of the OOBE WebUI. |
| 78 OobeUI* GetOobeUI() const; |
62 | 79 |
63 const gfx::Rect& background_bounds() const { return background_bounds_; } | 80 const gfx::Rect& background_bounds() const { return background_bounds_; } |
64 | 81 |
65 protected: | 82 protected: |
66 // content::NotificationObserver implementation: | 83 // content::NotificationObserver implementation: |
67 virtual void Observe(int type, | 84 virtual void Observe(int type, |
68 const content::NotificationSource& source, | 85 const content::NotificationSource& source, |
69 const content::NotificationDetails& details) OVERRIDE; | 86 const content::NotificationDetails& details) OVERRIDE; |
70 | 87 |
| 88 // Overridden from content::WebContentsObserver: |
| 89 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE; |
| 90 |
71 private: | 91 private: |
72 // Marks display host for deletion. | 92 // Marks display host for deletion. |
73 // If |post_quit_task| is true also posts Quit task to the MessageLoop. | 93 // If |post_quit_task| is true also posts Quit task to the MessageLoop. |
74 void ShutdownDisplayHost(bool post_quit_task); | 94 void ShutdownDisplayHost(bool post_quit_task); |
75 | 95 |
76 // Start sign in transition animation. | 96 // Start sign in transition animation. |
77 void StartAnimation(); | 97 void StartAnimation(); |
78 | 98 |
79 // Callback for the ownership status check. | 99 // Callback for the ownership status check. |
80 void OnOwnershipStatusCheckDone(DeviceSettingsService::OwnershipStatus status, | 100 void OnOwnershipStatusCheckDone(DeviceSettingsService::OwnershipStatus status, |
81 bool current_user_is_owner); | 101 bool current_user_is_owner); |
82 | 102 |
83 // Callback for completion of the |auto_enrollment_client_|. | 103 // Callback for completion of the |auto_enrollment_client_|. |
84 void OnAutoEnrollmentClientDone(); | 104 void OnAutoEnrollmentClientDone(); |
85 | 105 |
86 // Forces auto-enrollment on the appropriate controller. | 106 // Forces auto-enrollment on the appropriate controller. |
87 void ForceAutoEnrollment(); | 107 void ForceAutoEnrollment(); |
88 | 108 |
| 109 // Loads given URL. Creates WebUILoginView if needed. |
| 110 void LoadURL(const GURL& url); |
| 111 |
| 112 // Shows OOBE/sign in WebUI that was previously initialized in hidden state. |
| 113 void ShowWebUI(); |
| 114 |
| 115 // Starts postponed WebUI (OOBE/sign in) if it was waiting for |
| 116 // wallpaper animation end. |
| 117 void StartPostponedWebUI(); |
| 118 |
| 119 // Initializes |login_window_| and |login_view_| fields if needed. |
| 120 void InitLoginWindowAndView(); |
| 121 |
| 122 // Closes |login_window_| and resets |login_window_| and |login_view_| fields. |
| 123 void ResetLoginWindowAndView(); |
| 124 |
89 // Used to calculate position of the screens and background. | 125 // Used to calculate position of the screens and background. |
90 gfx::Rect background_bounds_; | 126 gfx::Rect background_bounds_; |
91 | 127 |
92 content::NotificationRegistrar registrar_; | 128 content::NotificationRegistrar registrar_; |
93 | 129 |
94 base::WeakPtrFactory<LoginDisplayHostImpl> pointer_factory_; | 130 base::WeakPtrFactory<LoginDisplayHostImpl> pointer_factory_; |
95 | 131 |
96 // Default LoginDisplayHost. | 132 // Default LoginDisplayHost. |
97 static LoginDisplayHost* default_host_; | 133 static LoginDisplayHost* default_host_; |
98 | 134 |
(...skipping 10 matching lines...) Expand all Loading... |
109 // own deletion to the message loop twice if the user logs out while we're | 145 // own deletion to the message loop twice if the user logs out while we're |
110 // still in the process of cleaning up after login (http://crbug.com/134463). | 146 // still in the process of cleaning up after login (http://crbug.com/134463). |
111 bool shutting_down_; | 147 bool shutting_down_; |
112 | 148 |
113 // Whether progress bar is shown on the OOBE page. | 149 // Whether progress bar is shown on the OOBE page. |
114 bool oobe_progress_bar_visible_; | 150 bool oobe_progress_bar_visible_; |
115 | 151 |
116 // True if session start is in progress. | 152 // True if session start is in progress. |
117 bool session_starting_; | 153 bool session_starting_; |
118 | 154 |
| 155 // Container of the screen we are displaying. |
| 156 views::Widget* login_window_; |
| 157 |
| 158 // Container of the view we are displaying. |
| 159 WebUILoginView* login_view_; |
| 160 |
| 161 // Login display we are using. |
| 162 WebUILoginDisplay* webui_login_display_; |
| 163 |
| 164 // True if alternate boot animation is enabled. |
| 165 bool is_boot_animation2_enabled_; |
| 166 |
| 167 // True if the login display is the current screen. |
| 168 bool is_showing_login_; |
| 169 |
| 170 // True if NOTIFICATION_WALLPAPER_ANIMATION_FINISHED notification has been |
| 171 // received. |
| 172 bool is_wallpaper_loaded_; |
| 173 |
| 174 // Stores status area current visibility to be applied once login WebUI |
| 175 // is shown. |
| 176 bool status_area_saved_visibility_; |
| 177 |
| 178 // If true, WebUI is initialized in a hidden state and shown after the |
| 179 // wallpaper animation is finished (when it is enabled) or the user pods have |
| 180 // been loaded (otherwise). |
| 181 // By default is true. Could be used to tune performance if needed. |
| 182 bool initialize_webui_hidden_; |
| 183 |
| 184 // True if WebUI is initialized in hidden state and we're waiting for |
| 185 // wallpaper load animation to finish. |
| 186 bool waiting_for_wallpaper_load_; |
| 187 |
| 188 // True if WebUI is initialized in hidden state and we're waiting for user |
| 189 // pods to load. |
| 190 bool waiting_for_user_pods_; |
| 191 |
| 192 // How many times renderer has crashed. |
| 193 int crash_count_; |
| 194 |
| 195 // Way to restore if renderer have crashed. |
| 196 enum { |
| 197 RESTORE_UNKNOWN, |
| 198 RESTORE_WIZARD, |
| 199 RESTORE_SIGN_IN |
| 200 } restore_path_; |
| 201 |
| 202 // Stored parameters for StartWizard, required to restore in case of crash. |
| 203 std::string wizard_first_screen_name_; |
| 204 scoped_ptr<DictionaryValue> wizard_screen_parameters_; |
| 205 |
| 206 // Old value of the ash::internal::kIgnoreSoloWindowFramePainterPolicy |
| 207 // property of the root window for |login_window_|. |
| 208 bool old_ignore_solo_window_frame_painter_policy_value_; |
| 209 |
119 DISALLOW_COPY_AND_ASSIGN(LoginDisplayHostImpl); | 210 DISALLOW_COPY_AND_ASSIGN(LoginDisplayHostImpl); |
120 }; | 211 }; |
121 | 212 |
122 } // namespace chromeos | 213 } // namespace chromeos |
123 | 214 |
124 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_DISPLAY_HOST_IMPL_H_ | 215 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_DISPLAY_HOST_IMPL_H_ |
OLD | NEW |