| 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)
|
|
|