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/metrics/histogram.h" | |
| 7 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| 10 | 11 |
| 11 #if defined(ENABLE_CONFIGURATION_POLICY) | 12 #if defined(ENABLE_CONFIGURATION_POLICY) |
| 12 #include "chrome/browser/policy/cloud/user_policy_signin_service.h" | 13 #include "chrome/browser/policy/cloud/user_policy_signin_service.h" |
| 13 #include "chrome/browser/policy/cloud/user_policy_signin_service_factory.h" | 14 #include "chrome/browser/policy/cloud/user_policy_signin_service_factory.h" |
| 14 #endif | 15 #endif |
| 15 | 16 |
| 16 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 39 #include "chrome/common/url_constants.h" | 40 #include "chrome/common/url_constants.h" |
| 40 #include "components/signin/core/browser/signin_manager.h" | 41 #include "components/signin/core/browser/signin_manager.h" |
| 41 #include "components/signin/core/browser/signin_metrics.h" | 42 #include "components/signin/core/browser/signin_metrics.h" |
| 42 #include "components/signin/core/common/profile_management_switches.h" | 43 #include "components/signin/core/common/profile_management_switches.h" |
| 43 #include "components/sync_driver/sync_prefs.h" | 44 #include "components/sync_driver/sync_prefs.h" |
| 44 #include "grit/chromium_strings.h" | 45 #include "grit/chromium_strings.h" |
| 45 #include "grit/generated_resources.h" | 46 #include "grit/generated_resources.h" |
| 46 #include "ui/base/l10n/l10n_util.h" | 47 #include "ui/base/l10n/l10n_util.h" |
| 47 #include "ui/base/resource/resource_bundle.h" | 48 #include "ui/base/resource/resource_bundle.h" |
| 48 | 49 |
| 50 namespace { | |
| 51 | |
| 52 // UMA histogram for tracking what users do when presented with the signin | |
| 53 // screen. | |
| 54 enum SigninChoice { | |
| 55 SIGNIN_CHOICE_CANCEL, | |
|
Thiemo Nagel
2014/07/18 12:12:26
I'd suggest adding explicit integer values because
Andrew T Wilson (Slow)
2014/07/24 15:25:56
Done.
| |
| 56 SIGNIN_CHOICE_CONTINUE, | |
| 57 SIGNIN_CHOICE_NEW_PROFILE, | |
| 58 SIGNIN_CHOICE_SIZE, | |
|
Thiemo Nagel
2014/07/18 12:12:26
Could you please document that this is a counter a
Andrew T Wilson (Slow)
2014/07/24 15:25:56
Done.
| |
| 59 }; | |
| 60 | |
| 61 void SetUserChoiceHistogram(SigninChoice choice) { | |
| 62 UMA_HISTOGRAM_ENUMERATION("Enterprise.UserSigninChoice", | |
| 63 choice, | |
| 64 SIGNIN_CHOICE_SIZE); | |
| 65 } | |
| 66 | |
| 67 } // namespace | |
| 68 | |
| 49 OneClickSigninSyncStarter::OneClickSigninSyncStarter( | 69 OneClickSigninSyncStarter::OneClickSigninSyncStarter( |
| 50 Profile* profile, | 70 Profile* profile, |
| 51 Browser* browser, | 71 Browser* browser, |
| 52 const std::string& email, | 72 const std::string& email, |
| 53 const std::string& password, | 73 const std::string& password, |
| 54 const std::string& refresh_token, | 74 const std::string& refresh_token, |
| 55 StartSyncMode start_mode, | 75 StartSyncMode start_mode, |
| 56 content::WebContents* web_contents, | 76 content::WebContents* web_contents, |
| 57 ConfirmationRequired confirmation_required, | 77 ConfirmationRequired confirmation_required, |
| 58 const GURL& continue_url, | 78 const GURL& continue_url, |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 143 #if defined(ENABLE_CONFIGURATION_POLICY) | 163 #if defined(ENABLE_CONFIGURATION_POLICY) |
| 144 OneClickSigninSyncStarter::SigninDialogDelegate::SigninDialogDelegate( | 164 OneClickSigninSyncStarter::SigninDialogDelegate::SigninDialogDelegate( |
| 145 base::WeakPtr<OneClickSigninSyncStarter> sync_starter) | 165 base::WeakPtr<OneClickSigninSyncStarter> sync_starter) |
| 146 : sync_starter_(sync_starter) { | 166 : sync_starter_(sync_starter) { |
| 147 } | 167 } |
| 148 | 168 |
| 149 OneClickSigninSyncStarter::SigninDialogDelegate::~SigninDialogDelegate() { | 169 OneClickSigninSyncStarter::SigninDialogDelegate::~SigninDialogDelegate() { |
| 150 } | 170 } |
| 151 | 171 |
| 152 void OneClickSigninSyncStarter::SigninDialogDelegate::OnCancelSignin() { | 172 void OneClickSigninSyncStarter::SigninDialogDelegate::OnCancelSignin() { |
| 173 SetUserChoiceHistogram(SIGNIN_CHOICE_CANCEL); | |
| 153 if (sync_starter_ != NULL) | 174 if (sync_starter_ != NULL) |
| 154 sync_starter_->CancelSigninAndDelete(); | 175 sync_starter_->CancelSigninAndDelete(); |
| 155 } | 176 } |
| 156 | 177 |
| 157 void OneClickSigninSyncStarter::SigninDialogDelegate::OnContinueSignin() { | 178 void OneClickSigninSyncStarter::SigninDialogDelegate::OnContinueSignin() { |
| 179 SetUserChoiceHistogram(SIGNIN_CHOICE_CONTINUE); | |
| 158 if (sync_starter_ != NULL) | 180 if (sync_starter_ != NULL) |
| 159 sync_starter_->LoadPolicyWithCachedCredentials(); | 181 sync_starter_->LoadPolicyWithCachedCredentials(); |
| 160 } | 182 } |
| 161 | 183 |
| 162 void OneClickSigninSyncStarter::SigninDialogDelegate::OnSigninWithNewProfile() { | 184 void OneClickSigninSyncStarter::SigninDialogDelegate::OnSigninWithNewProfile() { |
| 185 SetUserChoiceHistogram(SIGNIN_CHOICE_NEW_PROFILE); | |
| 163 if (sync_starter_ != NULL) | 186 if (sync_starter_ != NULL) |
| 164 sync_starter_->CreateNewSignedInProfile(); | 187 sync_starter_->CreateNewSignedInProfile(); |
| 165 } | 188 } |
| 166 | 189 |
| 167 void OneClickSigninSyncStarter::OnRegisteredForPolicy( | 190 void OneClickSigninSyncStarter::OnRegisteredForPolicy( |
| 168 const std::string& dm_token, const std::string& client_id) { | 191 const std::string& dm_token, const std::string& client_id) { |
| 169 SigninManager* signin = SigninManagerFactory::GetForProfile(profile_); | 192 SigninManager* signin = SigninManagerFactory::GetForProfile(profile_); |
| 170 // If there's no token for the user (policy registration did not succeed) just | 193 // If there's no token for the user (policy registration did not succeed) just |
| 171 // finish signing in. | 194 // finish signing in. |
| 172 if (dm_token.empty()) { | 195 if (dm_token.empty()) { |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 549 false /* user_gesture */); | 572 false /* user_gesture */); |
| 550 } | 573 } |
| 551 | 574 |
| 552 void OneClickSigninSyncStarter::LoadContinueUrl() { | 575 void OneClickSigninSyncStarter::LoadContinueUrl() { |
| 553 web_contents()->GetController().LoadURL( | 576 web_contents()->GetController().LoadURL( |
| 554 continue_url_, | 577 continue_url_, |
| 555 content::Referrer(), | 578 content::Referrer(), |
| 556 content::PAGE_TRANSITION_AUTO_TOPLEVEL, | 579 content::PAGE_TRANSITION_AUTO_TOPLEVEL, |
| 557 std::string()); | 580 std::string()); |
| 558 } | 581 } |
| OLD | NEW |