1// Copyright 2013 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_SIGNIN_INLINE_LOGIN_HANDLER_IMPL_H_
6#define CHROME_BROWSER_UI_WEBUI_SIGNIN_INLINE_LOGIN_HANDLER_IMPL_H_
7
8#include <string>
9
10#include "base/memory/scoped_ptr.h"
11#include "base/memory/weak_ptr.h"
12#include "chrome/browser/ui/sync/one_click_signin_sync_starter.h"
13#include "chrome/browser/ui/webui/signin/inline_login_handler.h"
14#include "content/public/browser/web_contents_delegate.h"
15
16class GaiaAuthFetcher;
17
18// Implementation for the inline login WebUI handler on desktop Chrome. Once
19// CrOS migrates to the same webview approach as desktop Chrome, much of the
20// code in this class should move to its base class |InlineLoginHandler|.
21class InlineLoginHandlerImpl : public InlineLoginHandler,
22                               public content::WebContentsDelegate {
23 public:
24  InlineLoginHandlerImpl();
25  virtual ~InlineLoginHandlerImpl();
26
27  using InlineLoginHandler::web_ui;
28
29  base::WeakPtr<InlineLoginHandlerImpl> GetWeakPtr() {
30    return weak_factory_.GetWeakPtr();
31  }
32
33  Browser* GetDesktopBrowser();
34  void SyncStarterCallback(OneClickSigninSyncStarter::SyncSetupResult result);
35  // Closes the current tab and shows the account management view of the avatar
36  // bubble if |show_account_management| is true.
37  void CloseTab(bool show_account_management);
38  void HandleLoginError(const std::string& error_msg);
39
40 private:
41  // InlineLoginHandler overrides:
42  virtual void SetExtraInitParams(base::DictionaryValue& params) OVERRIDE;
43  virtual void CompleteLogin(const base::ListValue* args) OVERRIDE;
44
45  // Overridden from content::WebContentsDelegate.
46  virtual bool HandleContextMenu(
47      const content::ContextMenuParams& params) OVERRIDE;
48
49  base::WeakPtrFactory<InlineLoginHandlerImpl> weak_factory_;
50  std::string email_;
51  std::string password_;
52  std::string session_index_;
53  bool choose_what_to_sync_;
54
55  DISALLOW_COPY_AND_ASSIGN(InlineLoginHandlerImpl);
56};
57
58#endif  // CHROME_BROWSER_UI_WEBUI_SIGNIN_INLINE_LOGIN_HANDLER_IMPL_H_
59