Chromium Code Reviews| 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 // | |
| 73 virtual void DidFailProvisionalLoad( | |
| 74 int64 frame_id, | |
| 75 const base::string16& frame_unique_name, | |
| 76 bool is_main_frame, | |
| 77 const GURL& validated_url, | |
| 78 int error_code, | |
| 79 const base::string16& error_description, | |
| 80 content::RenderViewHost* render_view_host) OVERRIDE; | |
| 81 | |
| 63 private: | 82 private: |
| 64 // Handlers for WebUI messages. | 83 // Handlers for WebUI messages. |
| 65 void HandleRetrieveAuthenticatedUserEmail(double attempt_token); | 84 void HandleRetrieveAuthenticatedUserEmail(double attempt_token); |
| 66 void HandleClose(const std::string& reason); | 85 void HandleClose(const std::string& reason); |
| 67 void HandleCompleteLogin(const std::string& user); | 86 void HandleCompleteLogin(const std::string& user); |
| 68 void HandleRetry(); | 87 void HandleRetry(); |
| 88 void HandleFrameLoadingCompleted(int status); | |
| 69 | 89 |
| 90 void SetupAndShowOfflineMessage(NetworkStateInformer::State state, | |
| 91 ErrorScreenActor::ErrorReason reason); | |
| 92 void HideOfflineMessage(NetworkStateInformer::State state, | |
| 93 ErrorScreenActor::ErrorReason reason); | |
| 94 | |
| 95 net::Error FrameError() const { return frame_error_; } | |
| 70 // Shows a given enrollment step. | 96 // Shows a given enrollment step. |
| 71 void ShowStep(const char* step); | 97 void ShowStep(const char* step); |
| 72 | 98 |
| 73 // Display the given i18n resource as error message. | 99 // Display the given i18n resource as error message. |
| 74 void ShowError(int message_id, bool retry); | 100 void ShowError(int message_id, bool retry); |
| 75 | 101 |
| 76 // Display the given string as error message. | 102 // Display the given string as error message. |
| 77 void ShowErrorMessage(const std::string& message, bool retry); | 103 void ShowErrorMessage(const std::string& message, bool retry); |
| 78 | 104 |
| 79 // Display the given i18n string as a progress message. | 105 // Display the given i18n string as a progress message. |
| 80 void ShowWorking(int message_id); | 106 void ShowWorking(int message_id); |
| 81 | 107 |
| 82 // Handles completion of the OAuth2 token fetch attempt. | 108 // Handles completion of the OAuth2 token fetch attempt. |
| 83 void OnTokenFetched(const std::string& token, | 109 void OnTokenFetched(const std::string& token, |
| 84 const GoogleServiceAuthError& error); | 110 const GoogleServiceAuthError& error); |
| 85 | 111 |
| 86 // Shows the screen. | 112 // Shows the screen. |
| 87 void DoShow(); | 113 void DoShow(); |
| 88 | 114 |
| 115 // Returns current visible screen. | |
| 116 OobeUI::Screen GetCurrentScreen() const; | |
| 117 | |
| 118 // Returns true if current visible screen is the Enrollment sign-in page. | |
|
ygorshenin1
2014/06/19 18:28:53
nit: s/Enrollment/enrollment/
Roman Sorokin (ftl)
2014/06/23 12:58:30
Done.
| |
| 119 bool IsOnEnrollmentScreen() const; | |
| 120 | |
| 121 // Returns true if current visible screen is the error screen over | |
| 122 // Enrollment sign-in page. | |
| 123 bool IsEnrollmentScreenHiddenByError() const; | |
|
ygorshenin1
2014/06/19 18:28:53
nit: s/Enrollment/enrollment/
Roman Sorokin (ftl)
2014/06/23 12:58:30
Done.
| |
| 124 | |
| 89 // Keeps the controller for this actor. | 125 // Keeps the controller for this actor. |
| 90 Controller* controller_; | 126 Controller* controller_; |
| 91 | 127 |
| 92 bool show_on_init_; | 128 bool show_on_init_; |
| 93 | 129 |
| 94 // The enrollment mode. | 130 // The enrollment mode. |
| 95 EnrollmentMode enrollment_mode_; | 131 EnrollmentMode enrollment_mode_; |
| 96 | 132 |
| 97 // The management domain, if applicable. | 133 // The management domain, if applicable. |
| 98 std::string management_domain_; | 134 std::string management_domain_; |
| 99 | 135 |
| 100 // Whether an enrollment attempt has failed. | 136 // Whether an enrollment attempt has failed. |
| 101 bool enrollment_failed_once_; | 137 bool enrollment_failed_once_; |
| 102 | 138 |
| 103 // This intentionally lives here and not in the controller, since it needs to | 139 // 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. | 140 // execute requests in the context of the profile that displays the webui. |
| 105 scoped_ptr<policy::PolicyOAuth2TokenFetcher> oauth_fetcher_; | 141 scoped_ptr<policy::PolicyOAuth2TokenFetcher> oauth_fetcher_; |
| 106 | 142 |
| 107 // The browsing data remover instance currently active, if any. | 143 // The browsing data remover instance currently active, if any. |
| 108 BrowsingDataRemover* browsing_data_remover_; | 144 BrowsingDataRemover* browsing_data_remover_; |
| 109 | 145 |
| 110 // The callbacks to invoke after browsing data has been cleared. | 146 // The callbacks to invoke after browsing data has been cleared. |
| 111 std::vector<base::Closure> auth_reset_callbacks_; | 147 std::vector<base::Closure> auth_reset_callbacks_; |
| 112 | 148 |
| 113 // Helper that retrieves the authenticated user's e-mail address. | 149 // Helper that retrieves the authenticated user's e-mail address. |
| 114 scoped_ptr<AuthenticatedUserEmailRetriever> email_retriever_; | 150 scoped_ptr<AuthenticatedUserEmailRetriever> email_retriever_; |
| 115 | 151 |
| 152 // Latest Enrollment frame error. | |
|
ygorshenin1
2014/06/19 18:28:53
nit: s/Enrollment/enrollment/
Roman Sorokin (ftl)
2014/06/23 12:58:30
Done.
| |
| 153 net::Error frame_error_; | |
| 154 | |
| 155 // Network state informer used to keep signin screen up. | |
| 156 scoped_refptr<NetworkStateInformer> network_state_informer_; | |
| 157 | |
| 158 ErrorScreenActor* error_screen_actor_; | |
| 159 | |
| 116 DISALLOW_COPY_AND_ASSIGN(EnrollmentScreenHandler); | 160 DISALLOW_COPY_AND_ASSIGN(EnrollmentScreenHandler); |
| 117 }; | 161 }; |
| 118 | 162 |
| 119 } // namespace chromeos | 163 } // namespace chromeos |
| 120 | 164 |
| 121 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_ENROLLMENT_SCREEN_HANDLER_H_ | 165 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_ENROLLMENT_SCREEN_HANDLER_H_ |
| OLD | NEW |