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 OobeUI::Screen GetCurrentScreen() const; | |
ygorshenin1
2014/06/18 13:11:35
nit: add comment to each of these three methods.
Roman Sorokin (ftl)
2014/06/19 11:57:38
Done.
| |
116 bool IsOnEnrollmentScreen() const; | |
117 bool IsEnrollmentScreenHiddenByError() const; | |
118 | |
89 // Keeps the controller for this actor. | 119 // Keeps the controller for this actor. |
90 Controller* controller_; | 120 Controller* controller_; |
91 | 121 |
92 bool show_on_init_; | 122 bool show_on_init_; |
93 | 123 |
94 // The enrollment mode. | 124 // The enrollment mode. |
95 EnrollmentMode enrollment_mode_; | 125 EnrollmentMode enrollment_mode_; |
96 | 126 |
97 // The management domain, if applicable. | 127 // The management domain, if applicable. |
98 std::string management_domain_; | 128 std::string management_domain_; |
99 | 129 |
100 // Whether an enrollment attempt has failed. | 130 // Whether an enrollment attempt has failed. |
101 bool enrollment_failed_once_; | 131 bool enrollment_failed_once_; |
102 | 132 |
103 // This intentionally lives here and not in the controller, since it needs to | 133 // 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. | 134 // execute requests in the context of the profile that displays the webui. |
105 scoped_ptr<policy::PolicyOAuth2TokenFetcher> oauth_fetcher_; | 135 scoped_ptr<policy::PolicyOAuth2TokenFetcher> oauth_fetcher_; |
106 | 136 |
107 // The browsing data remover instance currently active, if any. | 137 // The browsing data remover instance currently active, if any. |
108 BrowsingDataRemover* browsing_data_remover_; | 138 BrowsingDataRemover* browsing_data_remover_; |
109 | 139 |
110 // The callbacks to invoke after browsing data has been cleared. | 140 // The callbacks to invoke after browsing data has been cleared. |
111 std::vector<base::Closure> auth_reset_callbacks_; | 141 std::vector<base::Closure> auth_reset_callbacks_; |
112 | 142 |
113 // Helper that retrieves the authenticated user's e-mail address. | 143 // Helper that retrieves the authenticated user's e-mail address. |
114 scoped_ptr<AuthenticatedUserEmailRetriever> email_retriever_; | 144 scoped_ptr<AuthenticatedUserEmailRetriever> email_retriever_; |
115 | 145 |
146 net::Error frame_error_; | |
ygorshenin1
2014/06/18 13:11:35
nit: add comment to |frame_error_|.
Roman Sorokin (ftl)
2014/06/19 11:57:38
Done.
| |
147 | |
148 // Network state informer used to keep signin screen up. | |
149 scoped_refptr<NetworkStateInformer> network_state_informer_; | |
150 ErrorScreenActor* error_screen_actor_; | |
ygorshenin1
2014/06/18 13:11:35
nit: insert an empty line after #149.
Roman Sorokin (ftl)
2014/06/19 11:57:38
Done.
| |
151 | |
116 DISALLOW_COPY_AND_ASSIGN(EnrollmentScreenHandler); | 152 DISALLOW_COPY_AND_ASSIGN(EnrollmentScreenHandler); |
117 }; | 153 }; |
118 | 154 |
119 } // namespace chromeos | 155 } // namespace chromeos |
120 | 156 |
121 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_ENROLLMENT_SCREEN_HANDLER_H_ | 157 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_ENROLLMENT_SCREEN_HANDLER_H_ |
OLD | NEW |