OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_ENTERPRISE_OAUTH_ENROLLMENT_SCREE
N_HANDLER_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_ENTERPRISE_OAUTH_ENROLLMENT_SCREE
N_HANDLER_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <string> |
| 10 |
| 11 #include "base/basictypes.h" |
| 12 #include "base/scoped_ptr.h" |
| 13 #include "base/values.h" |
| 14 #include "chrome/browser/chromeos/login/enterprise_enrollment_screen_actor.h" |
| 15 #include "chrome/browser/net/gaia/gaia_oauth_consumer.h" |
| 16 #include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h" |
| 17 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" |
| 18 |
| 19 class GaiaOAuthFetcher; |
| 20 |
| 21 namespace chromeos { |
| 22 |
| 23 // WebUIMessageHandler implementation which handles events occurring on the |
| 24 // page, such as the user pressing the signin button. |
| 25 class EnterpriseOAuthEnrollmentScreenHandler |
| 26 : public BaseScreenHandler, |
| 27 public EnterpriseEnrollmentScreenActor, |
| 28 public GaiaOAuthConsumer { |
| 29 public: |
| 30 EnterpriseOAuthEnrollmentScreenHandler(); |
| 31 virtual ~EnterpriseOAuthEnrollmentScreenHandler(); |
| 32 |
| 33 // Implements WebUIMessageHandler: |
| 34 virtual void RegisterMessages() OVERRIDE; |
| 35 |
| 36 // Implements EnterpriseEnrollmentScreenActor: |
| 37 virtual void SetController(Controller* controller); |
| 38 virtual void PrepareToShow() OVERRIDE; |
| 39 virtual void Show() OVERRIDE; |
| 40 virtual void Hide() OVERRIDE; |
| 41 virtual void SetEditableUser(bool editable) OVERRIDE; |
| 42 virtual void ShowConfirmationScreen() OVERRIDE; |
| 43 virtual void ShowAuthError(const GoogleServiceAuthError& error) OVERRIDE; |
| 44 virtual void ShowAccountError() OVERRIDE; |
| 45 virtual void ShowFatalAuthError() OVERRIDE; |
| 46 virtual void ShowFatalEnrollmentError() OVERRIDE; |
| 47 virtual void ShowNetworkEnrollmentError() OVERRIDE; |
| 48 |
| 49 // Implements BaseScreenHandler: |
| 50 virtual void GetLocalizedStrings( |
| 51 base::DictionaryValue* localized_strings) OVERRIDE; |
| 52 |
| 53 // Implements GaiaOAuthConsumer: |
| 54 virtual void OnGetOAuthTokenFailure() OVERRIDE; |
| 55 virtual void OnOAuthGetAccessTokenFailure( |
| 56 const GoogleServiceAuthError& error) OVERRIDE; |
| 57 virtual void OnOAuthWrapBridgeSuccess(const std::string& service_scope, |
| 58 const std::string& token, |
| 59 const std::string& expires_in) OVERRIDE; |
| 60 virtual void OnOAuthWrapBridgeFailure( |
| 61 const std::string& service_scope, |
| 62 const GoogleServiceAuthError& error) OVERRIDE; |
| 63 virtual void OnUserInfoSuccess(const std::string& email) OVERRIDE; |
| 64 virtual void OnUserInfoFailure(const GoogleServiceAuthError& error) OVERRIDE; |
| 65 |
| 66 protected: |
| 67 // Implements BaseScreenHandler: |
| 68 virtual void Initialize() OVERRIDE; |
| 69 |
| 70 // Keeps the controller for this actor. |
| 71 Controller* controller_; |
| 72 |
| 73 private: |
| 74 // Handlers for WebUI messages. |
| 75 void HandleClose(const base::ListValue* args); |
| 76 void HandleCompleteLogin(const base::ListValue* args); |
| 77 void HandleRetry(const base::ListValue* args); |
| 78 |
| 79 // Shows a given enrollment step. |
| 80 void ShowStep(const char* step); |
| 81 |
| 82 // Display the given i18n string as error message. |
| 83 void ShowError(int message_id, bool retry); |
| 84 |
| 85 // Resets the authentication machinery and clears cookies, so other screens |
| 86 // (like the actual login screen) find a clean slate and don't pick up our |
| 87 // auth state. |
| 88 void ResetAuth(); |
| 89 |
| 90 bool editable_user_; |
| 91 bool show_on_init_; |
| 92 |
| 93 // Username of the user signing in. |
| 94 std::string user_; |
| 95 |
| 96 // This intentionally lives here and not in the controller, since it needs to |
| 97 // execute requests in the context of the profile that displays the webui. |
| 98 scoped_ptr<GaiaOAuthFetcher> oauth_fetcher_; |
| 99 |
| 100 DISALLOW_COPY_AND_ASSIGN(EnterpriseOAuthEnrollmentScreenHandler); |
| 101 }; |
| 102 |
| 103 } // namespace chromeos |
| 104 |
| 105 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_ENTERPRISE_OAUTH_ENROLLMENT_SC
REEN_HANDLER_H_ |
OLD | NEW |