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_SYNC_STARTER_H_ 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define CHROME_BROWSER_UI_SYNC_ONE_CLICK_SIGNIN_SYNC_STARTER_H_ 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <string> 95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 10a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)#include "base/callback_forward.h" 11a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)#include "base/gtest_prod_util.h" 12a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)#include "base/memory/scoped_ptr.h" 13c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "base/memory/weak_ptr.h" 14c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "chrome/browser/profiles/profile.h" 15868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "chrome/browser/ui/browser_list_observer.h" 16c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "chrome/browser/ui/host_desktop.h" 17868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "chrome/browser/ui/sync/profile_signin_confirmation_helper.h" 185f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "chrome/browser/ui/webui/signin/login_ui_service.h" 19c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch#include "components/signin/core/browser/signin_tracker.h" 20ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch#include "content/public/browser/web_contents_observer.h" 215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class Browser; 232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class ProfileSyncService; 245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 25ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdochnamespace content { 26ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdochclass WebContents; 27ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch} // namespace content 28ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch 2923730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)// Waits for successful sign-in notification from the signin manager and then 305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// starts the sync machine. Instances of this class delete themselves once 315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// the job is done. 32868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)class OneClickSigninSyncStarter : public SigninTracker::Observer, 33ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch public chrome::BrowserListObserver, 345f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) public content::WebContentsObserver, 355f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) public LoginUIService::Observer { 365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public: 372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) enum StartSyncMode { 382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Starts the process of signing the user in with the SigninManager, and 392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // once completed automatically starts sync with all data types enabled. 402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) SYNC_WITH_DEFAULT_SETTINGS, 415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Starts the process of signing the user in with the SigninManager, and 435f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) // once completed shows an inline confirmation UI for sync settings. If the 445f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) // user dismisses the confirmation UI, sync will start immediately. If the 455f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) // user clicks the settings link, Chrome will reidrect to the sync settings 465f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) // page. 475f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) CONFIRM_SYNC_SETTINGS_FIRST, 485f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) 495f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) // Starts the process of signing the user in with the SigninManager, and 502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // once completed redirects the user to the settings page to allow them 512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // to configure which data types to sync before sync is enabled. 522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) CONFIGURE_SYNC_FIRST, 532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 54ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch // Starts the process of re-authenticating the user via SigninManager, 55ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch // and once completed, redirects the user to the settings page, but doesn't 56ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch // display the configure sync UI. 57ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch SHOW_SETTINGS_WITHOUT_CONFIGURE, 58ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch 592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // The process should be aborted because the undo button has been pressed. 602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) UNDO_SYNC 612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) }; 622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 63b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) enum ConfirmationRequired { 64b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) // No need to display a "post-signin" confirmation bubble (for example, if 65b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) // the user was doing a re-auth flow). 66b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) NO_CONFIRMATION, 67b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) 68b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) // Signin flow redirected outside of trusted domains, so ask the user to 69b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) // confirm before signing in. 70b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) CONFIRM_UNTRUSTED_SIGNIN, 71b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) 72b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) // Display a confirmation after signing in. 73b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) CONFIRM_AFTER_SIGNIN 74b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) }; 75b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) 76a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) // Result of the sync setup. 77a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) enum SyncSetupResult { 78a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) SYNC_SETUP_SUCCESS, 79a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) SYNC_SETUP_FAILURE 80a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) }; 81a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) 82a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) typedef base::Callback<void(SyncSetupResult)> Callback; 83a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) 842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // |profile| must not be NULL, however |browser| can be. When using the 852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // OneClickSigninSyncStarter from a browser, provide both. 86c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // If |display_confirmation| is true, the user will be prompted to confirm the 87c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // signin before signin completes. 883551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) // |web_contents| is used to show the sync UI if it's showing a blank page 893551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) // and not about to be closed. It can be NULL. 90010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) // If |web_contents| is non-NULL and the |continue_url| is non-empty, the 91010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) // |web_contents| will be navigated to the |continue_url| once both signin and 92010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) // Sync setup are complete. 93a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) // |callback| is always executed before OneClickSigninSyncStarter is deleted. 94a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) // It can be empty. 952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) OneClickSigninSyncStarter(Profile* profile, 962a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Browser* browser, 975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const std::string& email, 985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const std::string& password, 99a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) const std::string& refresh_token, 1002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) StartSyncMode start_mode, 101ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch content::WebContents* web_contents, 102eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch ConfirmationRequired display_confirmation, 103010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) const GURL& continue_url, 104a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) Callback callback); 1055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 106868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // chrome::BrowserListObserver override. 107868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) virtual void OnBrowserRemoved(Browser* browser) OVERRIDE; 108868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 109a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // If the |browser| argument is non-null, returns the pointer directly. 110a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Otherwise creates a new browser for the given profile on the given 111a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // desktop, adds an empty tab and makes sure the browser is visible. 112a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) static Browser* EnsureBrowser(Browser* browser, 113a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) Profile* profile, 114a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) chrome::HostDesktopType desktop_type); 115a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 1165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) private: 117a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) friend class OneClickSigninSyncStarterTest; 118010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) FRIEND_TEST_ALL_PREFIXES(OneClickSigninSyncStarterTest, CallbackSigninFailed); 119010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) FRIEND_TEST_ALL_PREFIXES(OneClickSigninSyncStarterTest, CallbackNull); 120010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) FRIEND_TEST_ALL_PREFIXES(OneClickSigninSyncStarterTest, LoadContinueUrl); 121a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) 1225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual ~OneClickSigninSyncStarter(); 1235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 124c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // Initializes the internals of the OneClickSigninSyncStarter object. Can also 125c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // be used to re-initialize the object to refer to a newly created profile. 126c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) void Initialize(Profile* profile, Browser* browser); 127c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 1285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // SigninTracker::Observer override. 1295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void SigninFailed(const GoogleServiceAuthError& error) OVERRIDE; 1305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void SigninSuccess() OVERRIDE; 1315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual void MergeSessionComplete( 1325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const GoogleServiceAuthError& error) OVERRIDE; 1335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1345f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) // LoginUIService::Observer override. 1355f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) virtual void OnSyncConfirmationUIClosed(bool configure_sync_first) OVERRIDE; 1365f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) 137c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#if defined(ENABLE_CONFIGURATION_POLICY) 138868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // User input handler for the signin confirmation dialog. 139868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) class SigninDialogDelegate 140868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) : public ui::ProfileSigninConfirmationDelegate { 141868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) public: 142868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) SigninDialogDelegate( 143868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) base::WeakPtr<OneClickSigninSyncStarter> sync_starter); 144868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) virtual ~SigninDialogDelegate(); 145868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) virtual void OnCancelSignin() OVERRIDE; 146868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) virtual void OnContinueSignin() OVERRIDE; 147868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) virtual void OnSigninWithNewProfile() OVERRIDE; 148868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) private: 149868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) base::WeakPtr<OneClickSigninSyncStarter> sync_starter_; 150868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) }; 151868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) friend class SigninDialogDelegate; 152868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 153c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // Callback invoked once policy registration is complete. If registration 154f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // fails, |dm_token| and |client_id| will be empty. 155f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) void OnRegisteredForPolicy(const std::string& dm_token, 156f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) const std::string& client_id); 157c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 158c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // Callback invoked when a policy fetch request has completed. |success| is 159c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // true if policy was successfully fetched. 160c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) void OnPolicyFetchComplete(bool success); 161c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 162c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // Called to create a new profile, which is then signed in with the 163c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // in-progress auth credentials currently stored in this object. 164c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) void CreateNewSignedInProfile(); 165c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 166f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // Helper function that loads policy with the cached |dm_token_| and 167f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // |client_id|, then completes the signin process. 168f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) void LoadPolicyWithCachedCredentials(); 169c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 170c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // Callback invoked once a profile is created, so we can complete the 171868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // credentials transfer, load policy, and open the first window. 172868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) void CompleteInitForNewProfile(chrome::HostDesktopType desktop_type, 173868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) Profile* profile, 174868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) Profile::CreateStatus status); 175c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 1760f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)#endif // defined(ENABLE_CONFIGURATION_POLICY) 1770f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) 178c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // Cancels the in-progress signin for this profile. 179c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) void CancelSigninAndDelete(); 180c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 181c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // Callback invoked to check whether the user needs policy or if a 182c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // confirmation is required (in which case we have to prompt the user first). 183c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) void ConfirmSignin(const std::string& oauth_token); 184c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 185b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) // Displays confirmation UI to the user if confirmation_required_ == 186b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) // CONFIRM_UNTRUSTED_SIGNIN, otherwise completes the pending signin process. 187b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) void ConfirmAndSignin(); 188c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 189c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // Callback invoked once the user has responded to the signin confirmation UI. 190c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // If response == UNDO_SYNC, the signin is cancelled, otherwise the pending 191c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // signin is completed. 192b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) void UntrustedSigninConfirmed(StartSyncMode response); 193c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 194868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // GetProfileSyncService returns non-NULL pointer if sync is enabled. 195868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // There is a scenario when when ProfileSyncService discovers that sync is 196868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // disabled during setup. In this case GetProfileSyncService will return NULL, 197868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // but we still need to call PSS::SetSetupInProgress(false). For this purpose 198868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // call FinishProfileSyncServiceSetup() function. 1992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ProfileSyncService* GetProfileSyncService(); 2002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 201868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) void FinishProfileSyncServiceSetup(); 202868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 2033551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) // Displays the settings UI and brings up the advanced sync settings 2043551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) // dialog if |configure_sync| is true. The web contents provided to the 2053551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) // constructor is used if it's showing a blank page and not about to be 2063551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) // closed. Otherwise, a new tab or an existing settings tab is used. 2073551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) void ShowSettingsPage(bool configure_sync); 208ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch 2093551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) // Displays a settings page in the provided web contents. |sub_page| can be 2103551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) // empty to show the main settings page. 2113551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) void ShowSettingsPageInWebContents(content::WebContents* contents, 2123551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) const std::string& sub_page); 2132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 214b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) // Shows the post-signin confirmation bubble. If |custom_message| is empty, 215b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) // the default "You are signed in" message is displayed. 216a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) void DisplayFinalConfirmationBubble(const base::string16& custom_message); 217b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) 218010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) // Loads the |continue_url_| in the current tab. 219010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) void LoadContinueUrl(); 220010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) 2212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Profile* profile_; 2225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Browser* browser_; 223c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) scoped_ptr<SigninTracker> signin_tracker_; 2245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) StartSyncMode start_mode_; 225c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) chrome::HostDesktopType desktop_type_; 2262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) bool force_same_tab_navigation_; 227b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) ConfirmationRequired confirmation_required_; 228010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) GURL continue_url_; 229a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) 230a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) // Callback executed when sync setup succeeds or fails. 231a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) Callback sync_setup_completed_callback_; 232a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) 233c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#if defined(ENABLE_CONFIGURATION_POLICY) 234f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // Policy credentials we keep while determining whether to create 235c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // a new profile for an enterprise user or not. 236f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) std::string dm_token_; 237f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) std::string client_id_; 238c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#endif 2395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2404e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) base::WeakPtrFactory<OneClickSigninSyncStarter> weak_pointer_factory_; 2414e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 2425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(OneClickSigninSyncStarter); 2435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 2445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif // CHROME_BROWSER_UI_SYNC_ONE_CLICK_SIGNIN_SYNC_STARTER_H_ 247