15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef CHROME_BROWSER_UI_SYNC_ONE_CLICK_SIGNIN_HELPER_H_
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define CHROME_BROWSER_UI_SYNC_ONE_CLICK_SIGNIN_HELPER_H_
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <string>
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/gtest_prod_util.h"
11a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)#include "base/memory/weak_ptr.h"
12a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)#include "chrome/browser/signin/signin_promo.h"
13b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)#include "chrome/browser/sync/profile_sync_service_observer.h"
14a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)#include "chrome/browser/ui/sync/one_click_signin_sync_starter.h"
15c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch#include "components/signin/core/browser/signin_oauth_helper.h"
162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "content/public/browser/navigation_controller.h"
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/web_contents_observer.h"
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/web_contents_user_data.h"
192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "google_apis/gaia/google_service_auth_error.h"
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
21a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)class Browser;
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class GURL;
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class ProfileIOData;
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)namespace autofill {
2658537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)struct PasswordForm;
2758537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)}
2858537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace content {
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class WebContents;
31eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdochstruct FrameNavigateParams;
32eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdochstruct LoadCommittedDetails;
335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace net {
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class URLRequest;
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
39c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdochnamespace password_manager {
40c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdochclass PasswordManager;
41c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch}
42c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Per-tab one-click signin helper.  When a user signs in to a Google service
445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// and the profile is not yet connected to a Google account, will start the
455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// process of helping the user connect his profile with one click.  The process
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// begins with an infobar and is followed with a confirmation dialog explaining
475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// more about what this means.
485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class OneClickSigninHelper
495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    : public content::WebContentsObserver,
50c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch      public content::WebContentsUserData<OneClickSigninHelper> {
515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public:
522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Represents user's decision about sign in process.
535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  enum AutoAccept {
542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    // User decision not yet known.  Assume cancel.
552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    AUTO_ACCEPT_NONE,
562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    // User has explicitly accepted to sign in.  A bubble is shown with the
582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    // option to start sync, configure it first, or abort.
592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    AUTO_ACCEPT_ACCEPTED,
602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    // User has explicitly accepted to sign in, but wants to configure sync
62ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch    // settings before turning it on.
632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    AUTO_ACCEPT_CONFIGURE,
642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    // User has explicitly rejected to sign in.  Furthermore, the user does
662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    // not want to be prompted to see the interstitial again in this profile.
672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    AUTO_ACCEPT_REJECTED_FOR_PROFILE,
682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    // This is an explicit sign in from either first run, NTP, wrench menu,
702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    // or settings page.  The user will be signed in automatically with sync
712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    // enabled using default settings.
722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    AUTO_ACCEPT_EXPLICIT
735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  };
745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Return value of CanOfferOnIOThread().
762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  enum Offer {
772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    CAN_OFFER,
782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    DONT_OFFER,
792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    IGNORE_REQUEST
802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  };
812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Argument to CanOffer().
832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  enum CanOfferFor {
842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    CAN_OFFER_FOR_ALL,
85a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)    CAN_OFFER_FOR_INTERSTITAL_ONLY,
86a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)    CAN_OFFER_FOR_SECONDARY_ACCOUNT
87a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)    // TODO(guohui): needs to handle adding secondary account through
88a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)    // interstitial.
892a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  };
905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
91a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // Arguments used with StartSync function.  base::Bind() cannot support too
92a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // many args for performance reasons, so they are packaged up into a struct.
93a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  struct StartSyncArgs {
94a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    // Default contructor for testing only.
95a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    StartSyncArgs();
96a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    StartSyncArgs(Profile* profile,
97a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                  Browser* browser,
98a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                  OneClickSigninHelper::AutoAccept auto_accept,
99a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                  const std::string& session_index,
100a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                  const std::string& email,
101a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                  const std::string& password,
102a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                  const std::string& refresh_token,
103a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                  content::WebContents* web_contents,
104a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                  bool untrusted_confirmation_required,
105a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                  signin::Source source,
106a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                  OneClickSigninSyncStarter::Callback callback);
107a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    ~StartSyncArgs();
108a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
109a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    Profile* profile;
110a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    Browser* browser;
111a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    OneClickSigninHelper::AutoAccept auto_accept;
112a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    std::string session_index;
113a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    std::string email;
114a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    std::string password;
115a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    std::string refresh_token;
116a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
117a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    // Web contents in which the sync setup page should be displayed,
118a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    // if necessary. Can be NULL.
119a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    content::WebContents* web_contents;
120a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
121a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    OneClickSigninSyncStarter::ConfirmationRequired confirmation_required;
122a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    signin::Source source;
123a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    OneClickSigninSyncStarter::Callback callback;
124a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  };
125a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
12623730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  // Wrapper to call OneClickSigninSyncStarter after fetching the refresh token
12723730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  // if needed.  Also verifies that the cookies are correct if no password is
12823730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  // specified, and checks that the email from the cookies match the expected
129a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // email address.
130a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  class SyncStarterWrapper : public SigninOAuthHelper::Consumer,
131a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                             public chrome::BrowserListObserver {
132a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)   public:
133a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    SyncStarterWrapper(
134a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)        const OneClickSigninHelper::StartSyncArgs& args,
135a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)        OneClickSigninSyncStarter::StartSyncMode start_mode);
136a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    virtual ~SyncStarterWrapper();
137a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
138a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    void Start();
139a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
140a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)   private:
141a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    void VerifyGaiaCookiesBeforeSignIn();
142a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    void OnGaiaCookiesFetched(const std::string session_index,
143a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                              const net::CookieList& cookie_list);
144a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
145a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    // Virtual to be overridden in tests.
146a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    virtual void DisplayErrorBubble(const std::string& error_message);
147a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    virtual void StartSigninOAuthHelper();
148a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    virtual void StartOneClickSigninSyncStarter(
149a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)        const std::string& email,
150a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)        const std::string& refresh_token);
151a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
152a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    // Overriden from SigninOAuthHelper::Consumer.
153a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    virtual void OnSigninOAuthInformationAvailable(
154a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)        const std::string& email,
155a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)        const std::string& display_email,
156a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)        const std::string& refresh_token) OVERRIDE;
157a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    virtual void OnSigninOAuthInformationFailure(
158a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)        const GoogleServiceAuthError& error) OVERRIDE;
159a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
160a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    // Overriden from chrome::BrowserListObserver.
161a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    virtual void OnBrowserRemoved(Browser* browser) OVERRIDE;
162a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
163a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    OneClickSigninHelper::StartSyncArgs args_;
164a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    chrome::HostDesktopType desktop_type_;
165a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    OneClickSigninSyncStarter::StartSyncMode start_mode_;
166a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    scoped_ptr<SigninOAuthHelper> signin_oauth_helper_;
167a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    base::WeakPtrFactory<SyncStarterWrapper> weak_pointer_factory_;
168a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
169a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    DISALLOW_COPY_AND_ASSIGN(SyncStarterWrapper);
170a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  };
171a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
172a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  static void LogHistogramValue(signin::Source source, int action);
173a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
1743551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  static void CreateForWebContentsWithPasswordManager(
1753551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)      content::WebContents* contents,
176c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch      password_manager::PasswordManager* password_manager);
1773551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)
1785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns true if the one-click signin feature can be offered at this time.
1792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // If |email| is not empty, then the profile is checked to see if it's
1805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // already connected to a google account or if the user has already rejected
1815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // one-click sign-in with this email, in which cases a one click signin
1825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // should not be offered.
1832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  //
1842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // If |can_offer_for| is |CAN_OFFER_FOR_INTERSTITAL_ONLY|, then only do the
1852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // checks that would affect the interstitial page.  Otherwise, do the checks
1862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // that would affect the interstitial and the explicit sign ins.
1872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  //
1882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Returns in |error_message_id| an explanation as a string resource ID for
1892a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // why one-clicked cannot be offered.  |error_message_id| is valid only if
1902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // the return value is false.  If no explanation is needed, |error_message_id|
1912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // may be null.
1925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static bool CanOffer(content::WebContents* web_contents,
1932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                       CanOfferFor can_offer_for,
1945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                       const std::string& email,
1952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                       std::string* error_message);
1965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns true if the one-click signin feature can be offered at this time.
1985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // It can be offered if the io_data is not in an incognito window and if the
1995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // origin of |url| is a valid Gaia sign in origin.  This function is meant
2005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // to called only from the IO thread.
2012a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  static Offer CanOfferOnIOThread(net::URLRequest* request,
2022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                                  ProfileIOData* io_data);
2035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Looks for the Google-Accounts-SignIn response header, and if found,
2055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // tries to display an infobar in the tab contents identified by the
2065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // child/route id.
2075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static void ShowInfoBarIfPossible(net::URLRequest* request,
2082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                                    ProfileIOData* io_data,
2095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                    int child_id,
2105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                    int route_id);
2115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Handles cross account sign in error. If the supplied |email| does not match
2135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // the last signed in email of the current profile, then Chrome will show a
2145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // confirmation dialog before starting sync. It returns true if there is a
215116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  // cross account error, and false otherwise.
2165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  static bool HandleCrossAccountError(
2175f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)      Profile* profile,
2185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      const std::string& session_index,
2195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      const std::string& email,
2205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      const std::string& password,
221a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      const std::string& refresh_token,
2225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      OneClickSigninHelper::AutoAccept auto_accept,
2235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      signin::Source source,
2245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      OneClickSigninSyncStarter::StartSyncMode start_mode,
2255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      OneClickSigninSyncStarter::Callback sync_callback);
2265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
227a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  static void RedirectToNtpOrAppsPage(
228a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      content::WebContents* contents, signin::Source source);
229a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
230a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  // If the |source| is not settings page/webstore, redirects to
231a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  // the NTP/Apps page.
232a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  static void RedirectToNtpOrAppsPageIfNecessary(
233a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)      content::WebContents* contents, signin::Source source);
234a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
2357dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  // Remove the item currently at the top of the history list if it's
2367dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  // the Gaia redirect URL. Due to limitations of the NavigationController
2377dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  // this cannot be done until a new page becomes "current".
2387dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  static void RemoveSigninRedirectURLHistoryItem(
2397dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch      content::WebContents* web_contents);
240c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
241c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  static void LogConfirmHistogramValue(int action);
242c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
2435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) private:
2445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  friend class content::WebContentsUserData<OneClickSigninHelper>;
2452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  friend class OneClickSigninHelperTest;
2463551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(OneClickSigninHelperIncognitoTest,
2472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                           ShowInfoBarUIThreadIncognito);
2482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(OneClickSigninHelperTest,
2492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                           SigninFromWebstoreWithConfigSyncfirst);
2502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(OneClickSigninHelperTest,
2512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                           ShowSigninBubbleAfterSigninComplete);
252c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(OneClickSigninHelperTest, SigninCancelled);
253c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(OneClickSigninHelperTest, SigninFailed);
254ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch  FRIEND_TEST_ALL_PREFIXES(OneClickSigninHelperTest,
255ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch                           CleanTransientStateOnNavigate);
2562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(OneClickSigninHelperIOTest, CanOfferOnIOThread);
2572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(OneClickSigninHelperIOTest,
2582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                           CanOfferOnIOThreadIncognito);
2592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(OneClickSigninHelperIOTest,
2602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                           CanOfferOnIOThreadNoIOData);
2612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(OneClickSigninHelperIOTest,
2622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                           CanOfferOnIOThreadBadURL);
2632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(OneClickSigninHelperIOTest,
2642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                           CanOfferOnIOThreadDisabled);
2652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(OneClickSigninHelperIOTest,
2662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                           CanOfferOnIOThreadSignedIn);
2672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(OneClickSigninHelperIOTest,
2682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                           CanOfferOnIOThreadEmailNotAllowed);
2692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(OneClickSigninHelperIOTest,
2702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                           CanOfferOnIOThreadEmailAlreadyUsed);
2712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(OneClickSigninHelperIOTest,
2722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                           CreateTestProfileIOData);
2732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(OneClickSigninHelperIOTest,
2742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                           CanOfferOnIOThreadWithRejectedEmail);
2752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(OneClickSigninHelperIOTest,
2762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                           CanOfferOnIOThreadNoSigninCookies);
2772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(OneClickSigninHelperIOTest,
2782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                           CanOfferOnIOThreadDisabledByPolicy);
2792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
280c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // Maximum number of navigations away from the set of valid Gaia URLs before
281c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // clearing the internal state of the helper.  This is necessary to support
282c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // SAML-based accounts, but causes bug crbug.com/181163.
283c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  static const int kMaxNavigationsSince;
284c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
2853551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  OneClickSigninHelper(content::WebContents* web_contents,
286c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch                       password_manager::PasswordManager* password_manager);
287c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
288424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  virtual ~OneClickSigninHelper();
289424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
2902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Returns true if the one-click signin feature can be offered at this time.
2912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // It can be offered if the io_data is not in an incognito window and if the
2922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // origin of |url| is a valid Gaia sign in origin.  This function is meant
2932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // to called only from the IO thread.
2942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  static Offer CanOfferOnIOThreadImpl(const GURL& url,
2952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                                      base::SupportsUserData* request,
2962a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                                      ProfileIOData* io_data);
2975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The portion of ShowInfoBarIfPossible() that needs to run on the UI thread.
2992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // |session_index| and |email| are extracted from the Google-Accounts-SignIn
3002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // header.  |auto_accept| is extracted from the Google-Chrome-SignIn header.
3012a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // |source| is used to determine which of the explicit sign in mechanism is
3022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // being used.
3032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  //
3042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // |continue_url| is where Gaia will continue to when the sign in process is
3052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // done.  For explicit sign ins, this is a URL chrome controls. For one-click
3062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // sign in, this could be any google property.  This URL is used to know
3072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // when the sign process is over and to collect infomation from the user
3082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // entered on the Gaia sign in page (for explicit sign ins).
3095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static void ShowInfoBarUIThread(const std::string& session_index,
3105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                  const std::string& email,
3115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                  AutoAccept auto_accept,
312a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)                                  signin::Source source,
3132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                                  const GURL& continue_url,
3145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                  int child_id,
3155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                  int route_id);
3165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void RedirectToSignin();
3182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
3192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Clear all data member of the helper, except for the error.
3202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void CleanTransientState();
3212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
322868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  // Unitests that use a TestingProfile should call this.
323868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  // Otherwise, clearing the pending e-mail crashes because the code expects
324868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  // a real ResourceContext rather than the MockResourceContext a
325868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  // TestingProfile provides.
326868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  void SetDoNotClearPendingEmailForTesting();
327868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
32858537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)  // In unit tests, disable starting the actual sync.
32958537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)  void set_do_not_start_sync_for_testing();
33058537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)
3313551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  // Called when password has been submitted.
33258537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)  void PasswordSubmitted(const autofill::PasswordForm& form);
3332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
3345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // content::WebContentsObserver overrides.
335f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  virtual void DidStartNavigationToPendingEntry(
3362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      const GURL& url,
3372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      content::NavigationController::ReloadType reload_type) OVERRIDE;
338eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  virtual void DidNavigateMainFrame(
339eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch      const content::LoadCommittedDetails& details,
340eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch      const content::FrameNavigateParams& params) OVERRIDE;
3415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void DidStopLoading(
3425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      content::RenderViewHost* render_view_host) OVERRIDE;
3435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
344a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  OneClickSigninSyncStarter::Callback CreateSyncStarterCallback();
345a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
346a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  // Callback invoked when OneClickSigninSyncStarter completes sync setup.
347a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  void SyncSetupCompletedCallback(
348a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)      OneClickSigninSyncStarter::SyncSetupResult result);
349a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
3502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Tracks if we are in the process of showing the signin or one click
3512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // interstitial page. It's set to true the first time we load one of those
3522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // pages and set to false when transient state is cleaned.
353c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // Note: This should only be used for logging purposes.
3542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool showing_signin_;
3555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Information about the account that has just logged in.
3575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  std::string session_index_;
3585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  std::string email_;
3595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  std::string password_;
3605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  AutoAccept auto_accept_;
361a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  signin::Source source_;
3622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool switched_to_advanced_;
3632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  GURL continue_url_;
364558790d6acca3451cf3a6b497803a5f07d0bec58Ben Murdoch  // The orignal continue URL after sync setup is complete.
365558790d6acca3451cf3a6b497803a5f07d0bec58Ben Murdoch  GURL original_continue_url_;
3662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  std::string error_message_;
3675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
368c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // Number of navigations since starting a sign in that is outside the
369c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // the set of trusted Gaia URLs.  Sign in attempts that include visits to
370c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // one more untrusted will cause a modal dialog to appear asking the user
371c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // to confirm, similar to the interstitial flow.
372c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  int untrusted_navigations_since_signin_visit_;
373c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
374c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // Whether a Gaia URL during the sign in process was not handled by the
375c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // dedicated sign in process (e.g. SAML login, which redirects to a
376c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // non-google-controlled domain).
377c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // This is set to true if at least one such URL is detected.
378b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  bool untrusted_confirmation_required_;
379c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
380868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  // Allows unittests to avoid accessing the ResourceContext for clearing a
381868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  // pending e-mail.
382868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  bool do_not_clear_pending_email_;
383868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
38458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)  // Allows unittest to avoid starting sync for real.
38558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)  bool do_not_start_sync_for_testing_;
38658537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)
387a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  base::WeakPtrFactory<OneClickSigninHelper> weak_pointer_factory_;
388a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
3895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(OneClickSigninHelper);
3905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
3915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif  // CHROME_BROWSER_UI_SYNC_ONE_CLICK_SIGNIN_HELPER_H_
393