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

Side by Side Diff: chrome/browser/ui/webui/options/manage_profile_handler.cc

Issue 15774008: Pass errors generated during limited-user registration up to the UI for display. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Addressed James's comments 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
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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 IDS_PROFILES_CREATE_LIMITED_NOT_SIGNED_IN_LABEL }, 96 IDS_PROFILES_CREATE_LIMITED_NOT_SIGNED_IN_LABEL },
97 { "manageProfilesLimitedNotSignedInLink", 97 { "manageProfilesLimitedNotSignedInLink",
98 IDS_PROFILES_CREATE_LIMITED_NOT_SIGNED_IN_LINK }, 98 IDS_PROFILES_CREATE_LIMITED_NOT_SIGNED_IN_LINK },
99 { "deleteProfileTitle", IDS_PROFILES_DELETE_TITLE }, 99 { "deleteProfileTitle", IDS_PROFILES_DELETE_TITLE },
100 { "deleteProfileOK", IDS_PROFILES_DELETE_OK_BUTTON_LABEL }, 100 { "deleteProfileOK", IDS_PROFILES_DELETE_OK_BUTTON_LABEL },
101 { "deleteProfileMessage", IDS_PROFILES_DELETE_MESSAGE }, 101 { "deleteProfileMessage", IDS_PROFILES_DELETE_MESSAGE },
102 { "createProfileTitle", IDS_PROFILES_CREATE_TITLE }, 102 { "createProfileTitle", IDS_PROFILES_CREATE_TITLE },
103 { "createProfileInstructions", IDS_PROFILES_CREATE_INSTRUCTIONS }, 103 { "createProfileInstructions", IDS_PROFILES_CREATE_INSTRUCTIONS },
104 { "createProfileConfirm", IDS_PROFILES_CREATE_CONFIRM }, 104 { "createProfileConfirm", IDS_PROFILES_CREATE_CONFIRM },
105 { "createProfileLocalError", IDS_PROFILES_CREATE_LOCAL_ERROR }, 105 { "createProfileLocalError", IDS_PROFILES_CREATE_LOCAL_ERROR },
106 { "createProfileRemoteError", IDS_PROFILES_CREATE_REMOTE_ERROR },
106 { "createProfileShortcut", IDS_PROFILES_CREATE_SHORTCUT }, 107 { "createProfileShortcut", IDS_PROFILES_CREATE_SHORTCUT },
107 { "removeProfileShortcut", IDS_PROFILES_REMOVE_SHORTCUT }, 108 { "removeProfileShortcut", IDS_PROFILES_REMOVE_SHORTCUT },
108 }; 109 };
109 110
110 RegisterStrings(localized_strings, resources, arraysize(resources)); 111 RegisterStrings(localized_strings, resources, arraysize(resources));
111 RegisterTitle(localized_strings, "manageProfile", 112 RegisterTitle(localized_strings, "manageProfile",
112 IDS_PROFILES_MANAGE_TITLE); 113 IDS_PROFILES_MANAGE_TITLE);
113 RegisterTitle(localized_strings, "createProfile", 114 RegisterTitle(localized_strings, "createProfile",
114 IDS_PROFILES_CREATE_TITLE); 115 IDS_PROFILES_CREATE_TITLE);
115 116
116 localized_strings->SetBoolean("profileShortcutsEnabled", 117 localized_strings->SetBoolean("profileShortcutsEnabled",
117 ProfileShortcutManager::IsFeatureEnabled()); 118 ProfileShortcutManager::IsFeatureEnabled());
118 localized_strings->SetBoolean("managedUsersEnabled", 119 localized_strings->SetBoolean("managedUsersEnabled",
119 ManagedUserService::AreManagedUsersEnabled()); 120 ManagedUserService::AreManagedUsersEnabled());
120 } 121 }
121 122
122 void ManageProfileHandler::InitializeHandler() { 123 void ManageProfileHandler::InitializeHandler() {
123 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, 124 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED,
124 content::NotificationService::AllSources()); 125 content::NotificationService::AllSources());
125 } 126 }
126 127
127 void ManageProfileHandler::InitializePage() { 128 void ManageProfileHandler::InitializePage() {
128 SendProfileNames(); 129 SendProfileNames();
129 } 130 }
130 131
131 void ManageProfileHandler::RegisterMessages() { 132 void ManageProfileHandler::RegisterMessages() {
132 web_ui()->RegisterMessageCallback("setProfileNameAndIcon", 133 web_ui()->RegisterMessageCallback("setProfileNameAndIcon",
133 base::Bind(&ManageProfileHandler::SetProfileNameAndIcon, 134 base::Bind(&ManageProfileHandler::SetProfileNameAndIcon,
134 base::Unretained(this))); 135 base::Unretained(this)));
135 web_ui()->RegisterMessageCallback("deleteProfile",
136 base::Bind(&ManageProfileHandler::DeleteProfile,
137 base::Unretained(this)));
138 web_ui()->RegisterMessageCallback("requestDefaultProfileIcons", 136 web_ui()->RegisterMessageCallback("requestDefaultProfileIcons",
139 base::Bind(&ManageProfileHandler::RequestDefaultProfileIcons, 137 base::Bind(&ManageProfileHandler::RequestDefaultProfileIcons,
140 base::Unretained(this))); 138 base::Unretained(this)));
141 web_ui()->RegisterMessageCallback("requestNewProfileDefaults", 139 web_ui()->RegisterMessageCallback("requestNewProfileDefaults",
142 base::Bind(&ManageProfileHandler::RequestNewProfileDefaults, 140 base::Bind(&ManageProfileHandler::RequestNewProfileDefaults,
143 base::Unretained(this))); 141 base::Unretained(this)));
144 web_ui()->RegisterMessageCallback("requestHasProfileShortcuts", 142 web_ui()->RegisterMessageCallback("requestHasProfileShortcuts",
145 base::Bind(&ManageProfileHandler::RequestHasProfileShortcuts, 143 base::Bind(&ManageProfileHandler::RequestHasProfileShortcuts,
146 base::Unretained(this))); 144 base::Unretained(this)));
147 web_ui()->RegisterMessageCallback("requestSignedInText", 145 web_ui()->RegisterMessageCallback("requestSignedInText",
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 ProfileMetrics::LogProfileAvatarSelection(new_icon_index); 306 ProfileMetrics::LogProfileAvatarSelection(new_icon_index);
309 PrefService* pref_service = profile->GetPrefs(); 307 PrefService* pref_service = profile->GetPrefs();
310 // Updating the profile preference will cause the cache to be updated for 308 // Updating the profile preference will cause the cache to be updated for
311 // this preference. 309 // this preference.
312 pref_service->SetInteger(prefs::kProfileAvatarIndex, new_icon_index); 310 pref_service->SetInteger(prefs::kProfileAvatarIndex, new_icon_index);
313 cache.SetIsUsingGAIAPictureOfProfileAtIndex(profile_index, false); 311 cache.SetIsUsingGAIAPictureOfProfileAtIndex(profile_index, false);
314 } 312 }
315 ProfileMetrics::LogProfileUpdate(profile_file_path); 313 ProfileMetrics::LogProfileUpdate(profile_file_path);
316 } 314 }
317 315
318 void ManageProfileHandler::DeleteProfile(const ListValue* args) {
319 DCHECK(args);
320 #if defined(ENABLE_MANAGED_USERS)
321 // This handler could have been called in managed mode, for example because
322 // the user fiddled with the web inspector. Silently return in this case.
323 ManagedUserService* service =
324 ManagedUserServiceFactory::GetForProfile(Profile::FromWebUI(web_ui()));
325 if (service->ProfileIsManaged())
326 return;
327 #endif
328
329 if (!ProfileManager::IsMultipleProfilesEnabled())
330 return;
331
332 ProfileMetrics::LogProfileDeleteUser(ProfileMetrics::PROFILE_DELETED);
333
334 base::FilePath profile_file_path;
335 if (!GetProfilePathFromArgs(args, &profile_file_path))
336 return;
337
338 Browser* browser =
339 chrome::FindBrowserWithWebContents(web_ui()->GetWebContents());
340 chrome::HostDesktopType desktop_type = chrome::HOST_DESKTOP_TYPE_NATIVE;
341 if (browser)
342 desktop_type = browser->host_desktop_type();
343
344 g_browser_process->profile_manager()->ScheduleProfileForDeletion(
345 profile_file_path,
346 base::Bind(&OnNewDefaultProfileCreated, desktop_type));
347 }
348
349 #if defined(ENABLE_SETTINGS_APP) 316 #if defined(ENABLE_SETTINGS_APP)
350 void ManageProfileHandler::SwitchAppListProfile(const ListValue* args) { 317 void ManageProfileHandler::SwitchAppListProfile(const ListValue* args) {
351 DCHECK(args); 318 DCHECK(args);
352 DCHECK(ProfileManager::IsMultipleProfilesEnabled()); 319 DCHECK(ProfileManager::IsMultipleProfilesEnabled());
353 320
354 const Value* file_path_value; 321 const Value* file_path_value;
355 base::FilePath profile_file_path; 322 base::FilePath profile_file_path;
356 if (!args->Get(0, &file_path_value) || 323 if (!args->Get(0, &file_path_value) ||
357 !base::GetValueAsFilePath(*file_path_value, &profile_file_path)) 324 !base::GetValueAsFilePath(*file_path_value, &profile_file_path))
358 return; 325 return;
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 g_browser_process->profile_manager()->profile_shortcut_manager(); 436 g_browser_process->profile_manager()->profile_shortcut_manager();
470 DCHECK(shortcut_manager); 437 DCHECK(shortcut_manager);
471 438
472 shortcut_manager->RemoveProfileShortcuts(profile_file_path); 439 shortcut_manager->RemoveProfileShortcuts(profile_file_path);
473 440
474 // Update the UI buttons. 441 // Update the UI buttons.
475 OnHasProfileShortcuts(false); 442 OnHasProfileShortcuts(false);
476 } 443 }
477 444
478 } // namespace options 445 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698