OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/sync/one_click_signin_sync_starter.h" | 5 #include "chrome/browser/ui/sync/one_click_signin_sync_starter.h" |
6 | 6 |
7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 | 10 |
11 #if defined(ENABLE_CONFIGURATION_POLICY) | 11 #if defined(ENABLE_CONFIGURATION_POLICY) |
12 #include "chrome/browser/policy/cloud/user_policy_signin_service.h" | 12 #include "chrome/browser/policy/cloud/user_policy_signin_service.h" |
13 #include "chrome/browser/policy/cloud/user_policy_signin_service_factory.h" | 13 #include "chrome/browser/policy/cloud/user_policy_signin_service_factory.h" |
14 #endif | 14 #endif |
15 | 15 |
16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/browser/profiles/profile_info_cache.h" | 17 #include "chrome/browser/profiles/profile_info_cache.h" |
18 #include "chrome/browser/profiles/profile_io_data.h" | 18 #include "chrome/browser/profiles/profile_io_data.h" |
19 #include "chrome/browser/profiles/profile_manager.h" | 19 #include "chrome/browser/profiles/profile_manager.h" |
20 #include "chrome/browser/profiles/profile_window.h" | 20 #include "chrome/browser/profiles/profile_window.h" |
21 #include "chrome/browser/signin/signin_manager.h" | 21 #include "chrome/browser/signin/signin_manager.h" |
22 #include "chrome/browser/signin/signin_manager_factory.h" | 22 #include "chrome/browser/signin/signin_manager_factory.h" |
23 #include "chrome/browser/sync/profile_sync_service.h" | 23 #include "chrome/browser/sync/profile_sync_service.h" |
24 #include "chrome/browser/sync/profile_sync_service_factory.h" | 24 #include "chrome/browser/sync/profile_sync_service_factory.h" |
25 #include "chrome/browser/sync/sync_prefs.h" | |
26 #include "chrome/browser/ui/browser.h" | 25 #include "chrome/browser/ui/browser.h" |
27 #include "chrome/browser/ui/browser_dialogs.h" | 26 #include "chrome/browser/ui/browser_dialogs.h" |
28 #include "chrome/browser/ui/browser_finder.h" | 27 #include "chrome/browser/ui/browser_finder.h" |
29 #include "chrome/browser/ui/browser_list.h" | 28 #include "chrome/browser/ui/browser_list.h" |
30 #include "chrome/browser/ui/browser_navigator.h" | 29 #include "chrome/browser/ui/browser_navigator.h" |
31 #include "chrome/browser/ui/browser_tabstrip.h" | 30 #include "chrome/browser/ui/browser_tabstrip.h" |
32 #include "chrome/browser/ui/browser_window.h" | 31 #include "chrome/browser/ui/browser_window.h" |
33 #include "chrome/browser/ui/chrome_pages.h" | 32 #include "chrome/browser/ui/chrome_pages.h" |
34 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 33 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
35 #include "chrome/browser/ui/webui/signin/login_ui_service.h" | 34 #include "chrome/browser/ui/webui/signin/login_ui_service.h" |
36 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" | 35 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
37 #include "chrome/browser/ui/webui/signin/profile_signin_confirmation_dialog.h" | 36 #include "chrome/browser/ui/webui/signin/profile_signin_confirmation_dialog.h" |
38 #include "chrome/common/profile_management_switches.h" | 37 #include "chrome/common/profile_management_switches.h" |
39 #include "chrome/common/url_constants.h" | 38 #include "chrome/common/url_constants.h" |
| 39 #include "components/sync_driver/sync_prefs.h" |
40 #include "grit/chromium_strings.h" | 40 #include "grit/chromium_strings.h" |
41 #include "grit/generated_resources.h" | 41 #include "grit/generated_resources.h" |
42 #include "ui/base/l10n/l10n_util.h" | 42 #include "ui/base/l10n/l10n_util.h" |
43 #include "ui/base/resource/resource_bundle.h" | 43 #include "ui/base/resource/resource_bundle.h" |
44 | 44 |
45 OneClickSigninSyncStarter::OneClickSigninSyncStarter( | 45 OneClickSigninSyncStarter::OneClickSigninSyncStarter( |
46 Profile* profile, | 46 Profile* profile, |
47 Browser* browser, | 47 Browser* browser, |
48 const std::string& email, | 48 const std::string& email, |
49 const std::string& password, | 49 const std::string& password, |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 signin_tracker_.reset(new SigninTracker(profile_, this)); | 97 signin_tracker_.reset(new SigninTracker(profile_, this)); |
98 | 98 |
99 // Let the sync service know that setup is in progress so it doesn't start | 99 // Let the sync service know that setup is in progress so it doesn't start |
100 // syncing until the user has finished any configuration. | 100 // syncing until the user has finished any configuration. |
101 ProfileSyncService* profile_sync_service = GetProfileSyncService(); | 101 ProfileSyncService* profile_sync_service = GetProfileSyncService(); |
102 if (profile_sync_service) | 102 if (profile_sync_service) |
103 profile_sync_service->SetSetupInProgress(true); | 103 profile_sync_service->SetSetupInProgress(true); |
104 | 104 |
105 // Make sure the syncing is not suppressed, otherwise the SigninManager | 105 // Make sure the syncing is not suppressed, otherwise the SigninManager |
106 // will not be able to complete sucessfully. | 106 // will not be able to complete sucessfully. |
107 browser_sync::SyncPrefs sync_prefs(profile_->GetPrefs()); | 107 sync_driver::SyncPrefs sync_prefs(profile_->GetPrefs()); |
108 sync_prefs.SetStartSuppressed(false); | 108 sync_prefs.SetStartSuppressed(false); |
109 } | 109 } |
110 | 110 |
111 void OneClickSigninSyncStarter::ConfirmSignin(const std::string& oauth_token) { | 111 void OneClickSigninSyncStarter::ConfirmSignin(const std::string& oauth_token) { |
112 DCHECK(!oauth_token.empty()); | 112 DCHECK(!oauth_token.empty()); |
113 SigninManager* signin = SigninManagerFactory::GetForProfile(profile_); | 113 SigninManager* signin = SigninManagerFactory::GetForProfile(profile_); |
114 // If this is a new signin (no authenticated username yet) try loading | 114 // If this is a new signin (no authenticated username yet) try loading |
115 // policy for this user now, before any signed in services are initialized. | 115 // policy for this user now, before any signed in services are initialized. |
116 if (signin->GetAuthenticatedUsername().empty()) { | 116 if (signin->GetAuthenticatedUsername().empty()) { |
117 #if defined(ENABLE_CONFIGURATION_POLICY) | 117 #if defined(ENABLE_CONFIGURATION_POLICY) |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 false); | 516 false); |
517 contents->OpenURL(params); | 517 contents->OpenURL(params); |
518 | 518 |
519 // Activate the tab. | 519 // Activate the tab. |
520 Browser* browser = chrome::FindBrowserWithWebContents(contents); | 520 Browser* browser = chrome::FindBrowserWithWebContents(contents); |
521 int content_index = | 521 int content_index = |
522 browser->tab_strip_model()->GetIndexOfWebContents(contents); | 522 browser->tab_strip_model()->GetIndexOfWebContents(contents); |
523 browser->tab_strip_model()->ActivateTabAt(content_index, | 523 browser->tab_strip_model()->ActivateTabAt(content_index, |
524 false /* user_gesture */); | 524 false /* user_gesture */); |
525 } | 525 } |
OLD | NEW |