Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1880)

Unified Diff: chrome/browser/ui/webui/options/browser_options_handler.cc

Issue 15734006: Restructure user-creation flow and surface errors (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Removed log; patch for commit. Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/options/browser_options_handler.cc
===================================================================
--- chrome/browser/ui/webui/options/browser_options_handler.cc (revision 202001)
+++ chrome/browser/ui/webui/options/browser_options_handler.cc (working copy)
@@ -34,7 +34,6 @@
#include "chrome/browser/printing/cloud_print/cloud_print_url.h"
#include "chrome/browser/profiles/profile_info_cache.h"
#include "chrome/browser/profiles/profile_info_util.h"
-#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/profiles/profile_shortcut_manager.h"
#include "chrome/browser/search/search.h"
#include "chrome/browser/search_engines/template_url.h"
@@ -146,16 +145,6 @@
shortcut_manager->CreateProfileShortcut(profile->GetPath());
}
-void OnProfileCreated(
- const std::vector<ProfileManager::CreateCallback>& callbacks,
- Profile* profile,
- Profile::CreateStatus status) {
- std::vector<ProfileManager::CreateCallback>::const_iterator it;
- for (it = callbacks.begin(); it != callbacks.end(); ++it) {
- it->Run(profile, status);
- }
-}
-
} // namespace
BrowserOptionsHandler::BrowserOptionsHandler()
@@ -1123,10 +1112,52 @@
}
ProfileManager::CreateMultiProfileAsync(
- name, icon, base::Bind(&OnProfileCreated, callbacks),
- desktop_type, managed_user);
+ name, icon, base::Bind(&BrowserOptionsHandler::OnProfileCreated,
+ weak_ptr_factory_.GetWeakPtr(),
+ desktop_type, managed_user, callbacks),
+ managed_user);
}
+void BrowserOptionsHandler::OnProfileCreated(
+ chrome::HostDesktopType desktop_type,
+ bool is_managed,
+ const std::vector<ProfileManager::CreateCallback>& callbacks,
+ Profile* profile,
+ Profile::CreateStatus status) {
+ std::vector<ProfileManager::CreateCallback>::const_iterator it;
+ for (it = callbacks.begin(); it != callbacks.end(); ++it) {
+ it->Run(profile, status);
+ }
+
+ switch (status) {
+ case Profile::CREATE_STATUS_FAIL: {
+ web_ui()->CallJavascriptFunction(
+ "BrowserOptions.showCreateProfileLocalError");
+ break;
+ }
+ case Profile::CREATE_STATUS_CREATED: {
+ // Do nothing for an intermediate status.
+ break;
+ }
+ case Profile::CREATE_STATUS_INITIALIZED: {
+ base::FundamentalValue is_managed_value(is_managed);
+ web_ui()->CallJavascriptFunction(
+ "BrowserOptions.showCreateProfileSuccess",
+ is_managed_value);
+
+ // Opening the new window must be the last action, after all callbacks
+ // have been run, to give them a chance to initialize the profile.
+ ProfileManager::FindOrCreateNewWindowForProfile(
+ profile,
+ chrome::startup::IS_PROCESS_STARTUP,
+ chrome::startup::IS_FIRST_RUN,
+ desktop_type,
+ false);
+ break;
+ }
+ }
+}
+
void BrowserOptionsHandler::ObserveThemeChanged() {
Profile* profile = Profile::FromWebUI(web_ui());
#if defined(TOOLKIT_GTK)
« no previous file with comments | « chrome/browser/ui/webui/options/browser_options_handler.h ('k') | chrome/browser/ui/webui/options/manage_profile_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698