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 // Hence, |
| 55 // (a) existing enumerated constants should never be deleted or reordered, and |
| 56 // (b) new constants should only be appended at the end of the enumeration. |
| 57 // |
| 58 // Keep this in sync with SigninChoice in histograms.xml. |
| 59 enum SigninChoice { |
| 60 SIGNIN_CHOICE_CANCEL = 0, |
| 61 SIGNIN_CHOICE_CONTINUE = 1, |
| 62 SIGNIN_CHOICE_NEW_PROFILE = 2, |
| 63 // SIGNIN_CHOICE_SIZE should always be last - this is a count of the number |
| 64 // of items in this enum. |
| 65 SIGNIN_CHOICE_SIZE, |
| 66 }; |
| 67 |
| 68 void SetUserChoiceHistogram(SigninChoice choice) { |
| 69 UMA_HISTOGRAM_ENUMERATION("Enterprise.UserSigninChoice", |
| 70 choice, |
| 71 SIGNIN_CHOICE_SIZE); |
| 72 } |
| 73 |
| 74 } // namespace |
| 75 |
49 OneClickSigninSyncStarter::OneClickSigninSyncStarter( | 76 OneClickSigninSyncStarter::OneClickSigninSyncStarter( |
50 Profile* profile, | 77 Profile* profile, |
51 Browser* browser, | 78 Browser* browser, |
52 const std::string& email, | 79 const std::string& email, |
53 const std::string& password, | 80 const std::string& password, |
54 const std::string& refresh_token, | 81 const std::string& refresh_token, |
55 StartSyncMode start_mode, | 82 StartSyncMode start_mode, |
56 content::WebContents* web_contents, | 83 content::WebContents* web_contents, |
57 ConfirmationRequired confirmation_required, | 84 ConfirmationRequired confirmation_required, |
58 const GURL& continue_url, | 85 const GURL& continue_url, |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 #if defined(ENABLE_CONFIGURATION_POLICY) | 170 #if defined(ENABLE_CONFIGURATION_POLICY) |
144 OneClickSigninSyncStarter::SigninDialogDelegate::SigninDialogDelegate( | 171 OneClickSigninSyncStarter::SigninDialogDelegate::SigninDialogDelegate( |
145 base::WeakPtr<OneClickSigninSyncStarter> sync_starter) | 172 base::WeakPtr<OneClickSigninSyncStarter> sync_starter) |
146 : sync_starter_(sync_starter) { | 173 : sync_starter_(sync_starter) { |
147 } | 174 } |
148 | 175 |
149 OneClickSigninSyncStarter::SigninDialogDelegate::~SigninDialogDelegate() { | 176 OneClickSigninSyncStarter::SigninDialogDelegate::~SigninDialogDelegate() { |
150 } | 177 } |
151 | 178 |
152 void OneClickSigninSyncStarter::SigninDialogDelegate::OnCancelSignin() { | 179 void OneClickSigninSyncStarter::SigninDialogDelegate::OnCancelSignin() { |
| 180 SetUserChoiceHistogram(SIGNIN_CHOICE_CANCEL); |
153 if (sync_starter_ != NULL) | 181 if (sync_starter_ != NULL) |
154 sync_starter_->CancelSigninAndDelete(); | 182 sync_starter_->CancelSigninAndDelete(); |
155 } | 183 } |
156 | 184 |
157 void OneClickSigninSyncStarter::SigninDialogDelegate::OnContinueSignin() { | 185 void OneClickSigninSyncStarter::SigninDialogDelegate::OnContinueSignin() { |
| 186 SetUserChoiceHistogram(SIGNIN_CHOICE_CONTINUE); |
158 if (sync_starter_ != NULL) | 187 if (sync_starter_ != NULL) |
159 sync_starter_->LoadPolicyWithCachedCredentials(); | 188 sync_starter_->LoadPolicyWithCachedCredentials(); |
160 } | 189 } |
161 | 190 |
162 void OneClickSigninSyncStarter::SigninDialogDelegate::OnSigninWithNewProfile() { | 191 void OneClickSigninSyncStarter::SigninDialogDelegate::OnSigninWithNewProfile() { |
| 192 SetUserChoiceHistogram(SIGNIN_CHOICE_NEW_PROFILE); |
163 if (sync_starter_ != NULL) | 193 if (sync_starter_ != NULL) |
164 sync_starter_->CreateNewSignedInProfile(); | 194 sync_starter_->CreateNewSignedInProfile(); |
165 } | 195 } |
166 | 196 |
167 void OneClickSigninSyncStarter::OnRegisteredForPolicy( | 197 void OneClickSigninSyncStarter::OnRegisteredForPolicy( |
168 const std::string& dm_token, const std::string& client_id) { | 198 const std::string& dm_token, const std::string& client_id) { |
169 SigninManager* signin = SigninManagerFactory::GetForProfile(profile_); | 199 SigninManager* signin = SigninManagerFactory::GetForProfile(profile_); |
170 // If there's no token for the user (policy registration did not succeed) just | 200 // If there's no token for the user (policy registration did not succeed) just |
171 // finish signing in. | 201 // finish signing in. |
172 if (dm_token.empty()) { | 202 if (dm_token.empty()) { |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 false /* user_gesture */); | 579 false /* user_gesture */); |
550 } | 580 } |
551 | 581 |
552 void OneClickSigninSyncStarter::LoadContinueUrl() { | 582 void OneClickSigninSyncStarter::LoadContinueUrl() { |
553 web_contents()->GetController().LoadURL( | 583 web_contents()->GetController().LoadURL( |
554 continue_url_, | 584 continue_url_, |
555 content::Referrer(), | 585 content::Referrer(), |
556 content::PAGE_TRANSITION_AUTO_TOPLEVEL, | 586 content::PAGE_TRANSITION_AUTO_TOPLEVEL, |
557 std::string()); | 587 std::string()); |
558 } | 588 } |
OLD | NEW |