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_UI_WEBUI_CHROMEOS_LOGIN_ENROLLMENT_SCREEN_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_ENROLLMENT_SCREEN_HANDLER_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_ENROLLMENT_SCREEN_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_ENROLLMENT_SCREEN_HANDLER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/callback_forward.h" | 12 #include "base/callback_forward.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
15 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 15 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
16 #include "chrome/browser/chromeos/login/enrollment/enrollment_screen_actor.h" | 16 #include "chrome/browser/chromeos/login/enrollment/enrollment_screen_actor.h" |
| 17 #include "chrome/browser/chromeos/login/ui/webui_login_view.h" |
17 #include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h" | 18 #include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h" |
| 19 #include "chrome/browser/ui/webui/chromeos/login/network_state_informer.h" |
18 | 20 |
19 namespace policy { | 21 namespace policy { |
20 class PolicyOAuth2TokenFetcher; | 22 class PolicyOAuth2TokenFetcher; |
21 } | 23 } |
22 | 24 |
23 namespace chromeos { | 25 namespace chromeos { |
24 | 26 |
25 class AuthenticatedUserEmailRetriever; | 27 class AuthenticatedUserEmailRetriever; |
26 | 28 |
27 // WebUIMessageHandler implementation which handles events occurring on the | 29 // WebUIMessageHandler implementation which handles events occurring on the |
28 // page, such as the user pressing the signin button. | 30 // page, such as the user pressing the signin button. |
29 class EnrollmentScreenHandler | 31 class EnrollmentScreenHandler |
30 : public BaseScreenHandler, | 32 : public BaseScreenHandler, |
31 public EnrollmentScreenActor, | 33 public EnrollmentScreenActor, |
32 public BrowsingDataRemover::Observer { | 34 public BrowsingDataRemover::Observer, |
| 35 public NetworkStateInformer::NetworkStateInformerObserver, |
| 36 public WebUILoginView::FrameObserver { |
33 public: | 37 public: |
34 EnrollmentScreenHandler(); | 38 EnrollmentScreenHandler( |
| 39 const scoped_refptr<NetworkStateInformer>& network_state_informer, |
| 40 ErrorScreenActor* error_screen_actor); |
35 virtual ~EnrollmentScreenHandler(); | 41 virtual ~EnrollmentScreenHandler(); |
36 | 42 |
37 // Implements WebUIMessageHandler: | 43 // Implements WebUIMessageHandler: |
38 virtual void RegisterMessages() OVERRIDE; | 44 virtual void RegisterMessages() OVERRIDE; |
39 | 45 |
40 // Implements EnrollmentScreenActor: | 46 // Implements EnrollmentScreenActor: |
41 virtual void SetParameters(Controller* controller, | 47 virtual void SetParameters(Controller* controller, |
42 EnrollmentMode enrollment_mode, | 48 EnrollmentMode enrollment_mode, |
43 const std::string& management_domain) OVERRIDE; | 49 const std::string& management_domain) OVERRIDE; |
44 virtual void PrepareToShow() OVERRIDE; | 50 virtual void PrepareToShow() OVERRIDE; |
45 virtual void Show() OVERRIDE; | 51 virtual void Show() OVERRIDE; |
46 virtual void Hide() OVERRIDE; | 52 virtual void Hide() OVERRIDE; |
47 virtual void FetchOAuthToken() OVERRIDE; | 53 virtual void FetchOAuthToken() OVERRIDE; |
48 virtual void ResetAuth(const base::Closure& callback) OVERRIDE; | 54 virtual void ResetAuth(const base::Closure& callback) OVERRIDE; |
49 virtual void ShowSigninScreen() OVERRIDE; | 55 virtual void ShowSigninScreen() OVERRIDE; |
50 virtual void ShowEnrollmentSpinnerScreen() OVERRIDE; | 56 virtual void ShowEnrollmentSpinnerScreen() OVERRIDE; |
51 virtual void ShowLoginSpinnerScreen() OVERRIDE; | 57 virtual void ShowLoginSpinnerScreen() OVERRIDE; |
52 virtual void ShowAuthError(const GoogleServiceAuthError& error) OVERRIDE; | 58 virtual void ShowAuthError(const GoogleServiceAuthError& error) OVERRIDE; |
53 virtual void ShowEnrollmentStatus(policy::EnrollmentStatus status) OVERRIDE; | 59 virtual void ShowEnrollmentStatus(policy::EnrollmentStatus status) OVERRIDE; |
54 virtual void ShowUIError(UIError error_code) OVERRIDE; | 60 virtual void ShowUIError(UIError error_code) OVERRIDE; |
55 | 61 |
56 // Implements BaseScreenHandler: | 62 // Implements BaseScreenHandler: |
57 virtual void Initialize() OVERRIDE; | 63 virtual void Initialize() OVERRIDE; |
58 virtual void DeclareLocalizedValues(LocalizedValuesBuilder* builder) OVERRIDE; | 64 virtual void DeclareLocalizedValues(LocalizedValuesBuilder* builder) OVERRIDE; |
59 | 65 |
60 // Implements BrowsingDataRemover::Observer: | 66 // Implements BrowsingDataRemover::Observer: |
61 virtual void OnBrowsingDataRemoverDone() OVERRIDE; | 67 virtual void OnBrowsingDataRemoverDone() OVERRIDE; |
62 | 68 |
| 69 // Implements NetworkStateInformer::NetworkStateInformerObserver |
| 70 virtual void UpdateState(ErrorScreenActor::ErrorReason reason) OVERRIDE; |
| 71 |
| 72 // Implements WebUILoginView::FrameObserver |
| 73 virtual void OnFrameError(const std::string& frame_unique_name) OVERRIDE; |
| 74 |
63 private: | 75 private: |
64 // Handlers for WebUI messages. | 76 // Handlers for WebUI messages. |
65 void HandleRetrieveAuthenticatedUserEmail(double attempt_token); | 77 void HandleRetrieveAuthenticatedUserEmail(double attempt_token); |
66 void HandleClose(const std::string& reason); | 78 void HandleClose(const std::string& reason); |
67 void HandleCompleteLogin(const std::string& user); | 79 void HandleCompleteLogin(const std::string& user); |
68 void HandleRetry(); | 80 void HandleRetry(); |
| 81 void HandleFrameLoadingCompleted(int status); |
69 | 82 |
| 83 void SetupAndShowOfflineMessage(NetworkStateInformer::State state, |
| 84 ErrorScreenActor::ErrorReason reason); |
| 85 void HideOfflineMessage(NetworkStateInformer::State state, |
| 86 ErrorScreenActor::ErrorReason reason); |
| 87 |
| 88 net::Error frame_error() const { return frame_error_; } |
70 // Shows a given enrollment step. | 89 // Shows a given enrollment step. |
71 void ShowStep(const char* step); | 90 void ShowStep(const char* step); |
72 | 91 |
73 // Display the given i18n resource as error message. | 92 // Display the given i18n resource as error message. |
74 void ShowError(int message_id, bool retry); | 93 void ShowError(int message_id, bool retry); |
75 | 94 |
76 // Display the given string as error message. | 95 // Display the given string as error message. |
77 void ShowErrorMessage(const std::string& message, bool retry); | 96 void ShowErrorMessage(const std::string& message, bool retry); |
78 | 97 |
79 // Display the given i18n string as a progress message. | 98 // Display the given i18n string as a progress message. |
80 void ShowWorking(int message_id); | 99 void ShowWorking(int message_id); |
81 | 100 |
82 // Handles completion of the OAuth2 token fetch attempt. | 101 // Handles completion of the OAuth2 token fetch attempt. |
83 void OnTokenFetched(const std::string& token, | 102 void OnTokenFetched(const std::string& token, |
84 const GoogleServiceAuthError& error); | 103 const GoogleServiceAuthError& error); |
85 | 104 |
86 // Shows the screen. | 105 // Shows the screen. |
87 void DoShow(); | 106 void DoShow(); |
88 | 107 |
| 108 // Returns current visible screen. |
| 109 OobeUI::Screen GetCurrentScreen() const; |
| 110 |
| 111 // Returns true if current visible screen is the enrollment sign-in page. |
| 112 bool IsOnEnrollmentScreen() const; |
| 113 |
| 114 // Returns true if current visible screen is the error screen over |
| 115 // enrollment sign-in page. |
| 116 bool IsEnrollmentScreenHiddenByError() const; |
| 117 |
89 // Keeps the controller for this actor. | 118 // Keeps the controller for this actor. |
90 Controller* controller_; | 119 Controller* controller_; |
91 | 120 |
92 bool show_on_init_; | 121 bool show_on_init_; |
93 | 122 |
94 // The enrollment mode. | 123 // The enrollment mode. |
95 EnrollmentMode enrollment_mode_; | 124 EnrollmentMode enrollment_mode_; |
96 | 125 |
97 // The management domain, if applicable. | 126 // The management domain, if applicable. |
98 std::string management_domain_; | 127 std::string management_domain_; |
99 | 128 |
100 // Whether an enrollment attempt has failed. | 129 // Whether an enrollment attempt has failed. |
101 bool enrollment_failed_once_; | 130 bool enrollment_failed_once_; |
102 | 131 |
103 // This intentionally lives here and not in the controller, since it needs to | 132 // This intentionally lives here and not in the controller, since it needs to |
104 // execute requests in the context of the profile that displays the webui. | 133 // execute requests in the context of the profile that displays the webui. |
105 scoped_ptr<policy::PolicyOAuth2TokenFetcher> oauth_fetcher_; | 134 scoped_ptr<policy::PolicyOAuth2TokenFetcher> oauth_fetcher_; |
106 | 135 |
107 // The browsing data remover instance currently active, if any. | 136 // The browsing data remover instance currently active, if any. |
108 BrowsingDataRemover* browsing_data_remover_; | 137 BrowsingDataRemover* browsing_data_remover_; |
109 | 138 |
110 // The callbacks to invoke after browsing data has been cleared. | 139 // The callbacks to invoke after browsing data has been cleared. |
111 std::vector<base::Closure> auth_reset_callbacks_; | 140 std::vector<base::Closure> auth_reset_callbacks_; |
112 | 141 |
113 // Helper that retrieves the authenticated user's e-mail address. | 142 // Helper that retrieves the authenticated user's e-mail address. |
114 scoped_ptr<AuthenticatedUserEmailRetriever> email_retriever_; | 143 scoped_ptr<AuthenticatedUserEmailRetriever> email_retriever_; |
115 | 144 |
| 145 // Latest enrollment frame error. |
| 146 net::Error frame_error_; |
| 147 |
| 148 // Network state informer used to keep signin screen up. |
| 149 scoped_refptr<NetworkStateInformer> network_state_informer_; |
| 150 |
| 151 ErrorScreenActor* error_screen_actor_; |
| 152 |
| 153 base::WeakPtrFactory<EnrollmentScreenHandler> weak_ptr_factory_; |
| 154 |
116 DISALLOW_COPY_AND_ASSIGN(EnrollmentScreenHandler); | 155 DISALLOW_COPY_AND_ASSIGN(EnrollmentScreenHandler); |
117 }; | 156 }; |
118 | 157 |
119 } // namespace chromeos | 158 } // namespace chromeos |
120 | 159 |
121 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_ENROLLMENT_SCREEN_HANDLER_H_ | 160 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_ENROLLMENT_SCREEN_HANDLER_H_ |
OLD | NEW |