summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/webui/options/browser_options_handler.cc
diff options
context:
space:
mode:
authorpam@chromium.org <pam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-10 08:40:23 +0000
committerpam@chromium.org <pam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-10 08:40:23 +0000
commit54d016d20fd5cf15877b06ac6a7b535bd65ec53b (patch)
tree027e3d59bf6740f9f666281be8b5a9ef767fd97d /chrome/browser/ui/webui/options/browser_options_handler.cc
parentd5ae778e9c061b37d1683d35aa50201a044ba31c (diff)
downloadchromium_src-54d016d20fd5cf15877b06ac6a7b535bd65ec53b.zip
chromium_src-54d016d20fd5cf15877b06ac6a7b535bd65ec53b.tar.gz
chromium_src-54d016d20fd5cf15877b06ac6a7b535bd65ec53b.tar.bz2
Distinguish manual cancellation of profile creation from error conditions.
Since manual cancellation comes from the same place as the original registration request, there's no need to use a callback to tell the caller that registration has been cancelled: just do any necessary cleanup right away. This is needed because some OAuth problems can also result in the GoogleServiceAuthError::REQUEST_CANCELED error, and it's important to distinguish those actual errors from user-initiated cancellation. Also some additional cleanup and bug-fixing for metrics. TBR=sail@chromium.org BUG=244418 Review URL: https://chromiumcodereview.appspot.com/16576011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@205168 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/webui/options/browser_options_handler.cc')
-rw-r--r--chrome/browser/ui/webui/options/browser_options_handler.cc91
1 files changed, 47 insertions, 44 deletions
diff --git a/chrome/browser/ui/webui/options/browser_options_handler.cc b/chrome/browser/ui/webui/options/browser_options_handler.cc
index fa4a088..ec5e69d 100644
--- a/chrome/browser/ui/webui/options/browser_options_handler.cc
+++ b/chrome/browser/ui/webui/options/browser_options_handler.cc
@@ -198,7 +198,7 @@ BrowserOptionsHandler::BrowserOptionsHandler()
}
BrowserOptionsHandler::~BrowserOptionsHandler() {
- CancelProfileCreation();
+ CancelProfileRegistration(false);
ProfileSyncService* sync_service(ProfileSyncServiceFactory::
GetInstance()->GetForProfile(Profile::FromWebUI(web_ui())));
if (sync_service)
@@ -1098,6 +1098,15 @@ void BrowserOptionsHandler::SendProfilesInfo() {
*GetProfilesInfoList());
}
+chrome::HostDesktopType BrowserOptionsHandler::GetDesktopType() {
+ Browser* browser =
+ chrome::FindBrowserWithWebContents(web_ui()->GetWebContents());
+ chrome::HostDesktopType desktop_type = chrome::HOST_DESKTOP_TYPE_NATIVE;
+ if (browser)
+ desktop_type = browser->host_desktop_type();
+ return desktop_type;
+}
+
void BrowserOptionsHandler::CreateProfile(const ListValue* args) {
#if defined(ENABLE_MANAGED_USERS)
// This handler could have been called in managed mode, for example because
@@ -1111,15 +1120,8 @@ void BrowserOptionsHandler::CreateProfile(const ListValue* args) {
return;
DCHECK(profile_path_being_created_.empty());
-
profile_creation_start_time_ = base::TimeTicks::Now();
- Browser* browser =
- chrome::FindBrowserWithWebContents(web_ui()->GetWebContents());
- chrome::HostDesktopType desktop_type = chrome::HOST_DESKTOP_TYPE_NATIVE;
- if (browser)
- desktop_type = browser->host_desktop_type();
-
string16 name;
string16 icon;
bool create_shortcut = false;
@@ -1137,7 +1139,8 @@ void BrowserOptionsHandler::CreateProfile(const ListValue* args) {
ProfileManager::CreateCallback show_user_feedback =
base::Bind(&BrowserOptionsHandler::ShowProfileCreationFeedback,
- weak_ptr_factory_.GetWeakPtr(), desktop_type, managed_user);
+ weak_ptr_factory_.GetWeakPtr(), GetDesktopType(),
+ managed_user);
if (managed_user && ManagedUserService::AreManagedUsersEnabled()) {
#if defined(ENABLE_MANAGED_USERS)
@@ -1175,22 +1178,26 @@ void BrowserOptionsHandler::RegisterNewManagedUser(
callback);
}
+void BrowserOptionsHandler::RecordProfileCreationMetrics(
+ Profile::CreateStatus status) {
+ UMA_HISTOGRAM_ENUMERATION("Profile.CreateResult",
+ status,
+ Profile::MAX_CREATE_STATUS);
+ UMA_HISTOGRAM_CUSTOM_TIMES("Profile.CreateTime",
+ base::TimeTicks::Now() - profile_creation_start_time_,
+ base::TimeDelta::FromMilliseconds(1),
+ base::TimeDelta::FromSeconds(30), // From kRegistrationTimeoutMS.
+ 100);
+}
+
void BrowserOptionsHandler::ShowProfileCreationFeedback(
chrome::HostDesktopType desktop_type,
bool is_managed,
Profile* profile,
Profile::CreateStatus status) {
DCHECK(profile_path_being_created_ == profile->GetPath());
- if (status != Profile::CREATE_STATUS_CREATED) {
- UMA_HISTOGRAM_ENUMERATION("Profile.CreateResult",
- status,
- Profile::MAX_CREATE_STATUS);
- UMA_HISTOGRAM_CUSTOM_TIMES("Profile.CreateTime",
- base::TimeTicks::Now() - profile_creation_start_time_,
- base::TimeDelta::FromMilliseconds(1),
- base::TimeDelta::FromSeconds(30), // From kRegistrationTimeoutMS.
- 100);
- }
+ if (status != Profile::CREATE_STATUS_CREATED)
+ RecordProfileCreationMetrics(status);
switch (status) {
case Profile::CREATE_STATUS_LOCAL_FAIL: {
@@ -1233,11 +1240,9 @@ void BrowserOptionsHandler::ShowProfileCreationFeedback(
}
break;
}
- case Profile::CREATE_STATUS_CANCELED: {
- profile_path_being_created_.clear();
- DeleteProfileAtPath(profile->GetPath());
- break;
- }
+ // User-initiated cancellation is handled in CancelProfileRegistration and
+ // does not call this callback.
+ case Profile::CREATE_STATUS_CANCELED:
case Profile::MAX_CREATE_STATUS: {
NOTREACHED();
break;
@@ -1270,30 +1275,16 @@ void BrowserOptionsHandler::DeleteProfileAtPath(base::FilePath file_path) {
ProfileMetrics::LogProfileDeleteUser(ProfileMetrics::PROFILE_DELETED);
- Browser* browser =
- chrome::FindBrowserWithWebContents(web_ui()->GetWebContents());
- chrome::HostDesktopType desktop_type = chrome::HOST_DESKTOP_TYPE_NATIVE;
- if (browser)
- desktop_type = browser->host_desktop_type();
-
g_browser_process->profile_manager()->ScheduleProfileForDeletion(
file_path,
- base::Bind(&OpenNewWindowForProfile, desktop_type));
+ base::Bind(&OpenNewWindowForProfile, GetDesktopType()));
}
void BrowserOptionsHandler::HandleCancelProfileCreation(const ListValue* args) {
- CancelProfileCreation();
-
- UMA_HISTOGRAM_CUSTOM_TIMES("Profile.CreateTimeCanceled",
- base::TimeTicks::Now() - profile_creation_start_time_,
- base::TimeDelta::FromMilliseconds(1),
- base::TimeDelta::FromSeconds(30), // From kRegistrationTimeoutMS.
- 100);
+ CancelProfileRegistration(true);
}
-void BrowserOptionsHandler::CancelProfileCreation() {
- // UI code may call this any time "Cancel" is clicked in the dialog,
- // whether profile creation is in progress or not.
+void BrowserOptionsHandler::CancelProfileRegistration(bool user_initiated) {
if (profile_path_being_created_.empty())
return;
@@ -1302,18 +1293,30 @@ void BrowserOptionsHandler::CancelProfileCreation() {
if (!new_profile)
return;
- // Non-managed user creation cannot be cancelled. (Creating a non-managed
+ // Non-managed user creation cannot be canceled. (Creating a non-managed
// profile shouldn't take significant time, and it can easily be deleted
// afterward.)
if (!ManagedUserService::ProfileIsManaged(new_profile))
return;
+ if (user_initiated) {
+ UMA_HISTOGRAM_CUSTOM_TIMES("Profile.CreateTimeCanceled",
+ base::TimeTicks::Now() - profile_creation_start_time_,
+ base::TimeDelta::FromMilliseconds(1),
+ base::TimeDelta::FromSeconds(30), // From kRegistrationTimeoutMS.
+ 100);
+ RecordProfileCreationMetrics(Profile::CREATE_STATUS_CANCELED);
+ }
+
ManagedUserRegistrationService* registration_service =
ManagedUserRegistrationServiceFactory::GetForProfile(
Profile::FromWebUI(web_ui()));
- // The ManagedUserRegistrationService will send a cancellation error to the
- // callback provided in CreateProfile, i.e. to ShowProfileCreationFeedback.
registration_service->CancelPendingRegistration();
+
+ // Cancelling registration means the callback passed into
+ // RegisterAndInitSync() won't be called, so the cleanup must be done here.
+ profile_path_being_created_.clear();
+ DeleteProfileAtPath(new_profile->GetPath());
}
void BrowserOptionsHandler::ObserveThemeChanged() {