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_REMOTING_SETUP_FLOW_LOGIN_STEP_H_
6#define CHROME_BROWSER_REMOTING_SETUP_FLOW_LOGIN_STEP_H_
7
8#include "chrome/browser/remoting/setup_flow.h"
9#include "chrome/common/net/gaia/gaia_auth_consumer.h"
10#include "chrome/common/net/gaia/gaia_auth_fetcher.h"
11
12namespace remoting {
13
14// Implementation of login step for remoting setup flow.
15class SetupFlowLoginStep : public SetupFlowStepBase, public GaiaAuthConsumer {
16 public:
17  SetupFlowLoginStep();
18  SetupFlowLoginStep(const string16& error_message);
19  virtual ~SetupFlowLoginStep();
20
21  // SetupFlowStep implementation.
22  virtual void HandleMessage(const std::string& message, const Value* arg);
23  virtual void Cancel();
24
25  // GaiaAuthConsumer implementation.
26  virtual void OnClientLoginSuccess(
27      const GaiaAuthConsumer::ClientLoginResult& credentials);
28  virtual void OnClientLoginFailure(const GoogleServiceAuthError& error);
29  virtual void OnIssueAuthTokenSuccess(const std::string& service,
30                                       const std::string& auth_token);
31  virtual void OnIssueAuthTokenFailure(const std::string& service,
32                                       const GoogleServiceAuthError& error);
33
34 protected:
35  virtual void DoStart();
36
37 private:
38  void OnUserSubmittedAuth(const std::string& user,
39                           const std::string& password,
40                           const std::string& captcha,
41                           const std::string& access_code);
42
43  void ShowGaiaLogin(const DictionaryValue& args);
44  void ShowGaiaSuccessAndSettingUp();
45  void ShowGaiaFailed(const GoogleServiceAuthError& error);
46
47  string16 error_message_;
48
49  // Fetcher to obtain the Chromoting Directory token.
50  scoped_ptr<GaiaAuthFetcher> authenticator_;
51
52  DISALLOW_COPY_AND_ASSIGN(SetupFlowLoginStep);
53};
54
55}  // namespace remoting
56
57#endif  // CHROME_BROWSER_REMOTING_SETUP_FLOW_LOGIN_STEP_H_
58