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_CHROMEOS_LOGIN_ENTERPRISE_ENROLLMENT_SCREEN_H_ 6#define CHROME_BROWSER_CHROMEOS_LOGIN_ENTERPRISE_ENROLLMENT_SCREEN_H_ 7#pragma once 8 9#include <string> 10 11#include "base/basictypes.h" 12#include "base/compiler_specific.h" 13#include "base/message_loop.h" 14#include "base/task.h" 15#include "chrome/browser/browser_process.h" 16#include "chrome/browser/chromeos/login/enterprise_enrollment_view.h" 17#include "chrome/browser/chromeos/login/view_screen.h" 18#include "chrome/browser/policy/cloud_policy_subsystem.h" 19#include "chrome/common/net/gaia/gaia_auth_fetcher.h" 20 21namespace chromeos { 22 23// Controller interface for driving the enterprise enrollment UI. 24class EnterpriseEnrollmentController { 25 public: 26 // Runs authentication with the given parameters. 27 virtual void Authenticate(const std::string& user, 28 const std::string& password, 29 const std::string& captcha, 30 const std::string& access_code) = 0; 31 32 // Cancels the enrollment operation. 33 virtual void CancelEnrollment() = 0; 34 35 // Closes the confirmation window. 36 virtual void CloseConfirmation() = 0; 37 38 // Returns whether the GAIA login should be prepolutated with an user and if 39 // yes which one. 40 virtual bool GetInitialUser(std::string* user) = 0; 41}; 42 43// The screen implementation that links the enterprise enrollment UI into the 44// OOBE wizard. 45class EnterpriseEnrollmentScreen 46 : public ViewScreen<EnterpriseEnrollmentView>, 47 public EnterpriseEnrollmentController, 48 public GaiaAuthConsumer, 49 public policy::CloudPolicySubsystem::Observer { 50 public: 51 explicit EnterpriseEnrollmentScreen(WizardScreenDelegate* delegate); 52 virtual ~EnterpriseEnrollmentScreen(); 53 54 // EnterpriseEnrollmentController implementation: 55 virtual void Authenticate(const std::string& user, 56 const std::string& password, 57 const std::string& captcha, 58 const std::string& access_code) OVERRIDE; 59 virtual void CancelEnrollment() OVERRIDE; 60 virtual void CloseConfirmation() OVERRIDE; 61 virtual bool GetInitialUser(std::string* user) OVERRIDE; 62 63 // GaiaAuthConsumer implementation: 64 virtual void OnClientLoginSuccess(const ClientLoginResult& result) OVERRIDE; 65 virtual void OnClientLoginFailure( 66 const GoogleServiceAuthError& error) OVERRIDE; 67 68 virtual void OnIssueAuthTokenSuccess(const std::string& service, 69 const std::string& auth_token) OVERRIDE; 70 virtual void OnIssueAuthTokenFailure( 71 const std::string& service, 72 const GoogleServiceAuthError& error) OVERRIDE; 73 74 // CloudPolicySubsystem::Observer implementation: 75 virtual void OnPolicyStateChanged( 76 policy::CloudPolicySubsystem::PolicySubsystemState state, 77 policy::CloudPolicySubsystem::ErrorDetails error_details) OVERRIDE; 78 79 protected: 80 // Overriden from ViewScreen: 81 virtual EnterpriseEnrollmentView* AllocateView() OVERRIDE; 82 83 private: 84 void HandleAuthError(const GoogleServiceAuthError& error); 85 86 // Starts the Lockbox storage process. 87 void WriteInstallAttributesData(); 88 89 scoped_ptr<GaiaAuthFetcher> auth_fetcher_; 90 std::string user_; 91 std::string captcha_token_; 92 scoped_ptr<policy::CloudPolicySubsystem::ObserverRegistrar> registrar_; 93 ScopedRunnableMethodFactory<EnterpriseEnrollmentScreen> 94 runnable_method_factory_; 95 96 DISALLOW_COPY_AND_ASSIGN(EnterpriseEnrollmentScreen); 97}; 98 99} // namespace chromeos 100 101#endif // CHROME_BROWSER_CHROMEOS_LOGIN_ENTERPRISE_ENROLLMENT_SCREEN_H_ 102