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

Side by Side Diff: chrome/browser/ui/webui/options/manage_profile_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, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/webui/options/browser_options_handler.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/webui/options/manage_profile_handler.h" 5 #include "chrome/browser/ui/webui/options/manage_profile_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 // Given |args| from the WebUI, parses value 0 as a FilePath |profile_file_path| 53 // Given |args| from the WebUI, parses value 0 as a FilePath |profile_file_path|
54 // and returns true on success. 54 // and returns true on success.
55 bool GetProfilePathFromArgs(const ListValue* args, 55 bool GetProfilePathFromArgs(const ListValue* args,
56 base::FilePath* profile_file_path) { 56 base::FilePath* profile_file_path) {
57 const Value* file_path_value; 57 const Value* file_path_value;
58 if (!args->Get(0, &file_path_value)) 58 if (!args->Get(0, &file_path_value))
59 return false; 59 return false;
60 return base::GetValueAsFilePath(*file_path_value, profile_file_path); 60 return base::GetValueAsFilePath(*file_path_value, profile_file_path);
61 } 61 }
62 62
63 void OnNewDefaultProfileCreated(
64 chrome::HostDesktopType desktop_type,
65 Profile* profile,
66 Profile::CreateStatus status) {
67 if (status == Profile::CREATE_STATUS_INITIALIZED) {
68 ProfileManager::FindOrCreateNewWindowForProfile(
69 profile,
70 chrome::startup::IS_PROCESS_STARTUP,
71 chrome::startup::IS_FIRST_RUN,
72 desktop_type,
73 false);
74 }
75 }
76
63 } // namespace 77 } // namespace
64 78
65 ManageProfileHandler::ManageProfileHandler() 79 ManageProfileHandler::ManageProfileHandler()
66 : weak_factory_(this) { 80 : weak_factory_(this) {
67 } 81 }
68 82
69 ManageProfileHandler::~ManageProfileHandler() { 83 ManageProfileHandler::~ManageProfileHandler() {
70 } 84 }
71 85
72 void ManageProfileHandler::GetLocalizedValues( 86 void ManageProfileHandler::GetLocalizedValues(
73 DictionaryValue* localized_strings) { 87 DictionaryValue* localized_strings) {
74 DCHECK(localized_strings); 88 DCHECK(localized_strings);
75 89
76 static OptionsStringResource resources[] = { 90 static OptionsStringResource resources[] = {
77 { "manageProfilesNameLabel", IDS_PROFILES_MANAGE_NAME_LABEL }, 91 { "manageProfilesNameLabel", IDS_PROFILES_MANAGE_NAME_LABEL },
78 { "manageProfilesDuplicateNameError", 92 { "manageProfilesDuplicateNameError",
79 IDS_PROFILES_MANAGE_DUPLICATE_NAME_ERROR }, 93 IDS_PROFILES_MANAGE_DUPLICATE_NAME_ERROR },
80 { "manageProfilesIconLabel", IDS_PROFILES_MANAGE_ICON_LABEL }, 94 { "manageProfilesIconLabel", IDS_PROFILES_MANAGE_ICON_LABEL },
81 { "manageProfilesLimitedNotSignedInLabel", 95 { "manageProfilesLimitedNotSignedInLabel",
82 IDS_PROFILES_CREATE_LIMITED_NOT_SIGNED_IN_LABEL }, 96 IDS_PROFILES_CREATE_LIMITED_NOT_SIGNED_IN_LABEL },
83 { "manageProfilesLimitedNotSignedInLink", 97 { "manageProfilesLimitedNotSignedInLink",
84 IDS_PROFILES_CREATE_LIMITED_NOT_SIGNED_IN_LINK }, 98 IDS_PROFILES_CREATE_LIMITED_NOT_SIGNED_IN_LINK },
85 { "deleteProfileTitle", IDS_PROFILES_DELETE_TITLE }, 99 { "deleteProfileTitle", IDS_PROFILES_DELETE_TITLE },
86 { "deleteProfileOK", IDS_PROFILES_DELETE_OK_BUTTON_LABEL }, 100 { "deleteProfileOK", IDS_PROFILES_DELETE_OK_BUTTON_LABEL },
87 { "deleteProfileMessage", IDS_PROFILES_DELETE_MESSAGE }, 101 { "deleteProfileMessage", IDS_PROFILES_DELETE_MESSAGE },
88 { "createProfileTitle", IDS_PROFILES_CREATE_TITLE }, 102 { "createProfileTitle", IDS_PROFILES_CREATE_TITLE },
89 { "createProfileInstructions", IDS_PROFILES_CREATE_INSTRUCTIONS }, 103 { "createProfileInstructions", IDS_PROFILES_CREATE_INSTRUCTIONS },
90 { "createProfileConfirm", IDS_PROFILES_CREATE_CONFIRM }, 104 { "createProfileConfirm", IDS_PROFILES_CREATE_CONFIRM },
105 { "createProfileLocalError", IDS_PROFILES_CREATE_LOCAL_ERROR },
91 { "createProfileShortcut", IDS_PROFILES_CREATE_SHORTCUT }, 106 { "createProfileShortcut", IDS_PROFILES_CREATE_SHORTCUT },
92 { "removeProfileShortcut", IDS_PROFILES_REMOVE_SHORTCUT }, 107 { "removeProfileShortcut", IDS_PROFILES_REMOVE_SHORTCUT },
93 }; 108 };
94 109
95 RegisterStrings(localized_strings, resources, arraysize(resources)); 110 RegisterStrings(localized_strings, resources, arraysize(resources));
96 RegisterTitle(localized_strings, "manageProfile", 111 RegisterTitle(localized_strings, "manageProfile",
97 IDS_PROFILES_MANAGE_TITLE); 112 IDS_PROFILES_MANAGE_TITLE);
98 RegisterTitle(localized_strings, "createProfile", 113 RegisterTitle(localized_strings, "createProfile",
99 IDS_PROFILES_CREATE_TITLE); 114 IDS_PROFILES_CREATE_TITLE);
100 115
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 if (!GetProfilePathFromArgs(args, &profile_file_path)) 336 if (!GetProfilePathFromArgs(args, &profile_file_path))
322 return; 337 return;
323 338
324 Browser* browser = 339 Browser* browser =
325 chrome::FindBrowserWithWebContents(web_ui()->GetWebContents()); 340 chrome::FindBrowserWithWebContents(web_ui()->GetWebContents());
326 chrome::HostDesktopType desktop_type = chrome::HOST_DESKTOP_TYPE_NATIVE; 341 chrome::HostDesktopType desktop_type = chrome::HOST_DESKTOP_TYPE_NATIVE;
327 if (browser) 342 if (browser)
328 desktop_type = browser->host_desktop_type(); 343 desktop_type = browser->host_desktop_type();
329 344
330 g_browser_process->profile_manager()->ScheduleProfileForDeletion( 345 g_browser_process->profile_manager()->ScheduleProfileForDeletion(
331 profile_file_path, desktop_type); 346 profile_file_path,
347 base::Bind(&OnNewDefaultProfileCreated, desktop_type));
332 } 348 }
333 349
334 #if defined(ENABLE_SETTINGS_APP) 350 #if defined(ENABLE_SETTINGS_APP)
335 void ManageProfileHandler::SwitchAppListProfile(const ListValue* args) { 351 void ManageProfileHandler::SwitchAppListProfile(const ListValue* args) {
336 DCHECK(args); 352 DCHECK(args);
337 DCHECK(ProfileManager::IsMultipleProfilesEnabled()); 353 DCHECK(ProfileManager::IsMultipleProfilesEnabled());
338 354
339 const Value* file_path_value; 355 const Value* file_path_value;
340 base::FilePath profile_file_path; 356 base::FilePath profile_file_path;
341 if (!args->Get(0, &file_path_value) || 357 if (!args->Get(0, &file_path_value) ||
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 g_browser_process->profile_manager()->profile_shortcut_manager(); 470 g_browser_process->profile_manager()->profile_shortcut_manager();
455 DCHECK(shortcut_manager); 471 DCHECK(shortcut_manager);
456 472
457 shortcut_manager->RemoveProfileShortcuts(profile_file_path); 473 shortcut_manager->RemoveProfileShortcuts(profile_file_path);
458 474
459 // Update the UI buttons. 475 // Update the UI buttons.
460 OnHasProfileShortcuts(false); 476 OnHasProfileShortcuts(false);
461 } 477 }
462 478
463 } // namespace options 479 } // namespace options
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/browser_options_handler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698