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.
5 #ifndef CHROME_BROWSER_UI_WEBUI_SIGNIN_INLINE_LOGIN_HANDLER_IMPL_H_
6 #define CHROME_BROWSER_UI_WEBUI_SIGNIN_INLINE_LOGIN_HANDLER_IMPL_H_
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"
15 class GaiaAuthFetcher
;
17 // Implementation for the inline login WebUI handler on desktop Chrome. Once
18 // CrOS migrates to the same webview approach as desktop Chrome, much of the
19 // code in this class should move to its base class |InlineLoginHandler|.
20 class InlineLoginHandlerImpl
: public InlineLoginHandler
,
21 public content::WebContentsObserver
{
23 InlineLoginHandlerImpl();
24 ~InlineLoginHandlerImpl() override
;
26 using InlineLoginHandler::web_ui
;
28 base::WeakPtr
<InlineLoginHandlerImpl
> GetWeakPtr() {
29 return weak_factory_
.GetWeakPtr();
32 Browser
* GetDesktopBrowser();
33 void SyncStarterCallback(OneClickSigninSyncStarter::SyncSetupResult result
);
34 // Closes the current tab and shows the account management view of the avatar
35 // bubble if |show_account_management| is true.
36 void CloseTab(bool show_account_management
);
37 void HandleLoginError(const std::string
& error_msg
);
40 friend class InlineLoginUIBrowserTest
;
41 FRIEND_TEST_ALL_PREFIXES(InlineLoginUIBrowserTest
, CanOfferNoProfile
);
42 FRIEND_TEST_ALL_PREFIXES(InlineLoginUIBrowserTest
, CanOffer
);
43 FRIEND_TEST_ALL_PREFIXES(InlineLoginUIBrowserTest
, CanOfferProfileConnected
);
44 FRIEND_TEST_ALL_PREFIXES(InlineLoginUIBrowserTest
,
45 CanOfferUsernameNotAllowed
);
46 FRIEND_TEST_ALL_PREFIXES(InlineLoginUIBrowserTest
, CanOfferWithRejectedEmail
);
47 FRIEND_TEST_ALL_PREFIXES(InlineLoginUIBrowserTest
, CanOfferNoSigninCookies
);
49 // Argument to CanOffer().
52 CAN_OFFER_FOR_SECONDARY_ACCOUNT
55 static bool CanOffer(Profile
* profile
,
56 CanOfferFor can_offer_for
,
57 const std::string
& gaia_id
,
58 const std::string
& email
,
59 std::string
* error_message
);
61 // InlineLoginHandler overrides:
62 void SetExtraInitParams(base::DictionaryValue
& params
) override
;
63 void CompleteLogin(const base::ListValue
* args
) override
;
65 // Overridden from content::WebContentsObserver overrides.
66 void DidCommitProvisionalLoadForFrame(
67 content::RenderFrameHost
* render_frame_host
,
69 ui::PageTransition transition_type
) override
;
71 // True if the user has navigated to untrusted domains during the signin
73 bool confirm_untrusted_signin_
;
75 base::WeakPtrFactory
<InlineLoginHandlerImpl
> weak_factory_
;
77 DISALLOW_COPY_AND_ASSIGN(InlineLoginHandlerImpl
);
80 #endif // CHROME_BROWSER_UI_WEBUI_SIGNIN_INLINE_LOGIN_HANDLER_IMPL_H_