Chromium Code Reviews| 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/utf_string_conversions.h" | 8 #include "base/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/signin/signin_manager.h" | 20 #include "chrome/browser/signin/signin_manager.h" |
| 21 #include "chrome/browser/signin/signin_manager_factory.h" | 21 #include "chrome/browser/signin/signin_manager_factory.h" |
| 22 #include "chrome/browser/sync/profile_sync_service.h" | 22 #include "chrome/browser/sync/profile_sync_service.h" |
| 23 #include "chrome/browser/sync/profile_sync_service_factory.h" | 23 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 24 #include "chrome/browser/sync/sync_prefs.h" | 24 #include "chrome/browser/sync/sync_prefs.h" |
| 25 #include "chrome/browser/ui/browser.h" | 25 #include "chrome/browser/ui/browser.h" |
| 26 #include "chrome/browser/ui/browser_dialogs.h" | |
| 26 #include "chrome/browser/ui/browser_finder.h" | 27 #include "chrome/browser/ui/browser_finder.h" |
| 27 #include "chrome/browser/ui/browser_navigator.h" | 28 #include "chrome/browser/ui/browser_navigator.h" |
| 28 #include "chrome/browser/ui/browser_window.h" | 29 #include "chrome/browser/ui/browser_window.h" |
| 29 #include "chrome/browser/ui/chrome_pages.h" | 30 #include "chrome/browser/ui/chrome_pages.h" |
| 31 #include "chrome/browser/ui/tabs/tab_strip_model.h" | |
| 30 #include "chrome/browser/ui/webui/signin/login_ui_service.h" | 32 #include "chrome/browser/ui/webui/signin/login_ui_service.h" |
| 31 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" | 33 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
| 32 #include "chrome/browser/ui/webui/signin/profile_signin_confirmation_dialog.h" | 34 #include "chrome/browser/ui/webui/signin/profile_signin_confirmation_dialog.h" |
| 33 #include "chrome/common/url_constants.h" | 35 #include "chrome/common/url_constants.h" |
| 34 #include "grit/chromium_strings.h" | 36 #include "grit/chromium_strings.h" |
| 35 #include "grit/generated_resources.h" | 37 #include "grit/generated_resources.h" |
| 36 #include "ui/base/l10n/l10n_util.h" | 38 #include "ui/base/l10n/l10n_util.h" |
| 37 #include "ui/base/resource/resource_bundle.h" | 39 #include "ui/base/resource/resource_bundle.h" |
| 38 | 40 |
| 39 OneClickSigninSyncStarter::OneClickSigninSyncStarter( | 41 OneClickSigninSyncStarter::OneClickSigninSyncStarter( |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 90 } | 92 } |
| 91 | 93 |
| 92 void OneClickSigninSyncStarter::GaiaCredentialsValid() { | 94 void OneClickSigninSyncStarter::GaiaCredentialsValid() { |
| 93 } | 95 } |
| 94 | 96 |
| 95 void OneClickSigninSyncStarter::ConfirmSignin(const std::string& oauth_token) { | 97 void OneClickSigninSyncStarter::ConfirmSignin(const std::string& oauth_token) { |
| 96 DCHECK(!oauth_token.empty()); | 98 DCHECK(!oauth_token.empty()); |
| 97 SigninManager* signin = SigninManagerFactory::GetForProfile(profile_); | 99 SigninManager* signin = SigninManagerFactory::GetForProfile(profile_); |
| 98 // If this is a new signin (no authenticated username yet) try loading | 100 // If this is a new signin (no authenticated username yet) try loading |
| 99 // policy for this user now, before any signed in services are initialized. | 101 // policy for this user now, before any signed in services are initialized. |
| 100 // This callback is only invoked for the web-based signin flow - for the old | 102 // This callback is only invoked for the web-based signin flow - for the old |
|
Peter Kasting
2013/05/15 00:11:03
Nit: This comment is now somewhat inaccurate (in t
Andrew T Wilson (Slow)
2013/05/16 08:00:30
This comment has nothing to do with the confirmati
| |
| 101 // ClientLogin flow, policy will get loaded once the TokenService finishes | 103 // ClientLogin flow, policy will get loaded once the TokenService finishes |
| 102 // initializing (not ideal, but it's a reasonable fallback). | 104 // initializing (not ideal, but it's a reasonable fallback). |
| 103 if (signin->GetAuthenticatedUsername().empty()) { | 105 if (signin->GetAuthenticatedUsername().empty()) { |
| 104 #if defined(ENABLE_CONFIGURATION_POLICY) | 106 #if defined(ENABLE_CONFIGURATION_POLICY) |
| 105 policy::UserPolicySigninService* policy_service = | 107 policy::UserPolicySigninService* policy_service = |
| 106 policy::UserPolicySigninServiceFactory::GetForProfile(profile_); | 108 policy::UserPolicySigninServiceFactory::GetForProfile(profile_); |
| 107 policy_service->RegisterPolicyClient( | 109 policy_service->RegisterPolicyClient( |
| 108 signin->GetUsernameForAuthInProgress(), | 110 signin->GetUsernameForAuthInProgress(), |
| 109 oauth_token, | 111 oauth_token, |
| 110 base::Bind(&OneClickSigninSyncStarter::OnRegisteredForPolicy, | 112 base::Bind(&OneClickSigninSyncStarter::OnRegisteredForPolicy, |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 133 } | 135 } |
| 134 | 136 |
| 135 DCHECK(client->is_registered()); | 137 DCHECK(client->is_registered()); |
| 136 DVLOG(1) << "Policy registration succeeded: dm_token=" << client->dm_token(); | 138 DVLOG(1) << "Policy registration succeeded: dm_token=" << client->dm_token(); |
| 137 | 139 |
| 138 // Stash away a copy of our CloudPolicyClient (should not already have one). | 140 // Stash away a copy of our CloudPolicyClient (should not already have one). |
| 139 DCHECK(!policy_client_); | 141 DCHECK(!policy_client_); |
| 140 policy_client_.swap(client); | 142 policy_client_.swap(client); |
| 141 | 143 |
| 142 // Allow user to create a new profile before continuing with sign-in. | 144 // Allow user to create a new profile before continuing with sign-in. |
| 143 ProfileSigninConfirmationDialog::ShowDialog( | 145 Browser* browser = |
| 146 chrome::FindBrowserWithProfile(profile_, chrome::GetActiveDesktop()); | |
| 147 if (!browser) { | |
| 148 DLOG(WARNING) << "No browser found to display the confirmation dialog"; | |
|
Peter Kasting
2013/05/15 00:11:03
In most Chrome code we try to avoid logging becaus
Andrew T Wilson (Slow)
2013/05/16 08:00:30
Do we really have any restrictions on adding DLOGs
Peter Kasting
2013/05/16 21:57:39
In the particular code here, it seems like either
dconnelly
2013/05/17 13:01:55
Done: removed the logging and kept the handling.
| |
| 149 CancelSigninAndDelete(); | |
| 150 return; | |
| 151 } | |
| 152 content::WebContents* web_contents = | |
| 153 browser->tab_strip_model()->GetActiveWebContents(); | |
| 154 if (!web_contents) { | |
| 155 DLOG(WARNING) << "No web contents found to display the confirmation dialog"; | |
| 156 CancelSigninAndDelete(); | |
| 157 return; | |
| 158 } | |
| 159 chrome::ShowProfileSigninConfirmationDialog( | |
| 160 browser, | |
| 161 web_contents, | |
| 144 profile_, | 162 profile_, |
| 145 signin->GetUsernameForAuthInProgress(), | 163 signin->GetUsernameForAuthInProgress(), |
| 146 base::Bind(&OneClickSigninSyncStarter::CancelSigninAndDelete, | 164 base::Bind(&OneClickSigninSyncStarter::CancelSigninAndDelete, |
| 147 weak_pointer_factory_.GetWeakPtr()), | 165 weak_pointer_factory_.GetWeakPtr()), |
| 148 base::Bind(&OneClickSigninSyncStarter::CreateNewSignedInProfile, | 166 base::Bind(&OneClickSigninSyncStarter::CreateNewSignedInProfile, |
| 149 weak_pointer_factory_.GetWeakPtr()), | 167 weak_pointer_factory_.GetWeakPtr()), |
| 150 base::Bind(&OneClickSigninSyncStarter::LoadPolicyWithCachedClient, | 168 base::Bind(&OneClickSigninSyncStarter::LoadPolicyWithCachedClient, |
| 151 weak_pointer_factory_.GetWeakPtr())); | 169 weak_pointer_factory_.GetWeakPtr())); |
| 152 } | 170 } |
| 153 | 171 |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 383 | 401 |
| 384 void OneClickSigninSyncStarter::ShowSyncSettingsPageOnSameTab() { | 402 void OneClickSigninSyncStarter::ShowSyncSettingsPageOnSameTab() { |
| 385 std::string url = std::string(chrome::kChromeUISettingsURL) + | 403 std::string url = std::string(chrome::kChromeUISettingsURL) + |
| 386 chrome::kSyncSetupSubPage; | 404 chrome::kSyncSetupSubPage; |
| 387 chrome::NavigateParams params( | 405 chrome::NavigateParams params( |
| 388 browser_, GURL(url), content::PAGE_TRANSITION_AUTO_TOPLEVEL); | 406 browser_, GURL(url), content::PAGE_TRANSITION_AUTO_TOPLEVEL); |
| 389 params.disposition = CURRENT_TAB; | 407 params.disposition = CURRENT_TAB; |
| 390 params.window_action = chrome::NavigateParams::SHOW_WINDOW; | 408 params.window_action = chrome::NavigateParams::SHOW_WINDOW; |
| 391 chrome::Navigate(¶ms); | 409 chrome::Navigate(¶ms); |
| 392 } | 410 } |
| OLD | NEW |