Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / ui / webui / options / manage_profile_handler.cc
blob056c20c5bfd704e443821ca171cbe06bb766c4f4
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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/webui/options/manage_profile_handler.h"
7 #include "base/bind.h"
8 #include "base/bind_helpers.h"
9 #include "base/prefs/pref_service.h"
10 #include "base/prefs/scoped_user_pref_update.h"
11 #include "base/strings/string_number_conversions.h"
12 #include "base/strings/string_util.h"
13 #include "base/strings/utf_string_conversions.h"
14 #include "base/value_conversions.h"
15 #include "base/values.h"
16 #include "chrome/browser/browser_process.h"
17 #include "chrome/browser/chrome_notification_types.h"
18 #include "chrome/browser/profiles/gaia_info_update_service.h"
19 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/browser/profiles/profile_avatar_icon_util.h"
21 #include "chrome/browser/profiles/profile_info_cache.h"
22 #include "chrome/browser/profiles/profile_manager.h"
23 #include "chrome/browser/profiles/profile_metrics.h"
24 #include "chrome/browser/profiles/profile_shortcut_manager.h"
25 #include "chrome/browser/profiles/profile_window.h"
26 #include "chrome/browser/profiles/profiles_state.h"
27 #include "chrome/browser/signin/signin_manager_factory.h"
28 #include "chrome/browser/sync/profile_sync_service.h"
29 #include "chrome/browser/sync/profile_sync_service_factory.h"
30 #include "chrome/browser/ui/browser_finder.h"
31 #include "chrome/browser/ui/webui/options/options_handlers_helper.h"
32 #include "chrome/common/pref_names.h"
33 #include "chrome/common/url_constants.h"
34 #include "chrome/grit/chromium_strings.h"
35 #include "chrome/grit/generated_resources.h"
36 #include "components/signin/core/browser/signin_manager.h"
37 #include "components/signin/core/common/profile_management_switches.h"
38 #include "content/public/browser/browser_thread.h"
39 #include "content/public/browser/notification_service.h"
40 #include "content/public/browser/web_ui.h"
41 #include "google_apis/gaia/gaia_auth_util.h"
42 #include "ui/base/l10n/l10n_util.h"
43 #include "ui/base/webui/web_ui_util.h"
45 #if defined(ENABLE_SETTINGS_APP)
46 #include "chrome/browser/ui/app_list/app_list_service.h"
47 #include "content/public/browser/web_contents.h"
48 #endif
50 namespace options {
52 namespace {
54 const char kCreateProfileIdentifier[] = "create";
55 const char kManageProfileIdentifier[] = "manage";
57 // Given |args| from the WebUI, parses value 0 as a FilePath |profile_file_path|
58 // and returns true on success.
59 bool GetProfilePathFromArgs(const base::ListValue* args,
60 base::FilePath* profile_file_path) {
61 const base::Value* file_path_value;
62 if (!args->Get(0, &file_path_value))
63 return false;
64 return base::GetValueAsFilePath(*file_path_value, profile_file_path);
67 void HandleLogDeleteUserDialogShown(const base::ListValue* args) {
68 ProfileMetrics::LogProfileDeleteUser(
69 ProfileMetrics::DELETE_PROFILE_SETTINGS_SHOW_WARNING);
72 } // namespace
74 ManageProfileHandler::ManageProfileHandler()
75 : weak_factory_(this) {
78 ManageProfileHandler::~ManageProfileHandler() {
79 ProfileSyncService* service =
80 ProfileSyncServiceFactory::GetForProfile(Profile::FromWebUI(web_ui()));
81 // Sync may be disabled in tests.
82 if (service)
83 service->RemoveObserver(this);
86 void ManageProfileHandler::GetLocalizedValues(
87 base::DictionaryValue* localized_strings) {
88 DCHECK(localized_strings);
90 static OptionsStringResource resources[] = {
91 { "manageProfilesNameLabel", IDS_PROFILES_MANAGE_NAME_LABEL },
92 { "manageProfilesIconLabel", IDS_PROFILES_MANAGE_ICON_LABEL },
93 { "manageProfilesExistingSupervisedUser",
94 IDS_PROFILES_CREATE_EXISTING_LEGACY_SUPERVISED_USER_ERROR },
95 { "manageProfilesSupervisedSignedInLabel",
96 IDS_PROFILES_CREATE_SUPERVISED_SIGNED_IN_LABEL },
97 { "manageProfilesSupervisedNotSignedIn",
98 IDS_PROFILES_CREATE_SUPERVISED_NOT_SIGNED_IN_HTML },
99 { "manageProfilesSupervisedAccountDetailsOutOfDate",
100 IDS_PROFILES_CREATE_SUPERVISED_ACCOUNT_DETAILS_OUT_OF_DATE_LABEL },
101 { "manageProfilesSupervisedSignInAgainLink",
102 IDS_PROFILES_GAIA_REAUTH_TITLE },
103 { "manageProfilesConfirm", IDS_SAVE },
104 { "deleteProfileTitle", IDS_PROFILES_DELETE_TITLE },
105 { "deleteProfileOK", IDS_PROFILES_DELETE_OK_BUTTON_LABEL },
106 { "deleteProfileMessage", IDS_PROFILES_DELETE_MESSAGE },
107 { "disconnectManagedProfileTitle",
108 IDS_PROFILES_DISCONNECT_MANAGED_PROFILE_TITLE },
109 { "disconnectManagedProfileOK",
110 IDS_PROFILES_DISCONNECT_MANAGED_PROFILE_OK_BUTTON_LABEL },
111 { "createProfileTitle", IDS_PROFILES_CREATE_TITLE },
112 { "createProfileInstructions", IDS_PROFILES_CREATE_INSTRUCTIONS },
113 { "createProfileConfirm", IDS_ADD },
114 { "createProfileShortcutCheckbox", IDS_PROFILES_CREATE_SHORTCUT_CHECKBOX },
115 { "createProfileShortcutButton", IDS_PROFILES_CREATE_SHORTCUT_BUTTON },
116 { "removeProfileShortcutButton", IDS_PROFILES_REMOVE_SHORTCUT_BUTTON },
117 { "importExistingSupervisedUserLink",
118 IDS_IMPORT_EXISTING_LEGACY_SUPERVISED_USER_TITLE },
121 RegisterStrings(localized_strings, resources, arraysize(resources));
122 RegisterTitle(localized_strings, "manageProfile", IDS_PROFILES_MANAGE_TITLE);
123 RegisterTitle(localized_strings, "createProfile", IDS_PROFILES_CREATE_TITLE);
125 base::string16 supervised_user_dashboard_url =
126 base::ASCIIToUTF16(chrome::kLegacySupervisedUserManagementURL);
127 base::string16 supervised_user_dashboard_display =
128 base::ASCIIToUTF16(chrome::kLegacySupervisedUserManagementDisplayURL);
129 localized_strings->SetString("deleteSupervisedProfileAddendum",
130 l10n_util::GetStringFUTF16(IDS_PROFILES_DELETE_LEGACY_SUPERVISED_ADDENDUM,
131 supervised_user_dashboard_url,
132 supervised_user_dashboard_display));
134 localized_strings->SetBoolean("newAvatarMenuEnabled",
135 switches::IsNewAvatarMenu());
136 localized_strings->SetBoolean("profileShortcutsEnabled",
137 ProfileShortcutManager::IsFeatureEnabled());
139 GenerateSignedinUserSpecificStrings(localized_strings);
142 void ManageProfileHandler::InitializeHandler() {
143 g_browser_process->profile_manager()->GetProfileInfoCache().AddObserver(this);
145 Profile* profile = Profile::FromWebUI(web_ui());
146 pref_change_registrar_.Init(profile->GetPrefs());
147 pref_change_registrar_.Add(
148 prefs::kSupervisedUserCreationAllowed,
149 base::Bind(&ManageProfileHandler::OnCreateSupervisedUserPrefChange,
150 base::Unretained(this)));
151 ProfileSyncService* service =
152 ProfileSyncServiceFactory::GetForProfile(profile);
153 // Sync may be disabled for tests.
154 if (service)
155 service->AddObserver(this);
158 void ManageProfileHandler::InitializePage() {
159 SendExistingProfileNames();
160 OnCreateSupervisedUserPrefChange();
163 void ManageProfileHandler::RegisterMessages() {
164 web_ui()->RegisterMessageCallback("setProfileIconAndName",
165 base::Bind(&ManageProfileHandler::SetProfileIconAndName,
166 base::Unretained(this)));
167 web_ui()->RegisterMessageCallback("requestDefaultProfileIcons",
168 base::Bind(&ManageProfileHandler::RequestDefaultProfileIcons,
169 base::Unretained(this)));
170 web_ui()->RegisterMessageCallback("requestNewProfileDefaults",
171 base::Bind(&ManageProfileHandler::RequestNewProfileDefaults,
172 base::Unretained(this)));
173 web_ui()->RegisterMessageCallback("requestHasProfileShortcuts",
174 base::Bind(&ManageProfileHandler::RequestHasProfileShortcuts,
175 base::Unretained(this)));
176 web_ui()->RegisterMessageCallback("requestCreateProfileUpdate",
177 base::Bind(&ManageProfileHandler::RequestCreateProfileUpdate,
178 base::Unretained(this)));
179 web_ui()->RegisterMessageCallback("profileIconSelectionChanged",
180 base::Bind(&ManageProfileHandler::ProfileIconSelectionChanged,
181 base::Unretained(this)));
182 #if defined(ENABLE_SETTINGS_APP)
183 web_ui()->RegisterMessageCallback("switchAppListProfile",
184 base::Bind(&ManageProfileHandler::SwitchAppListProfile,
185 base::Unretained(this)));
186 #endif
187 web_ui()->RegisterMessageCallback("addProfileShortcut",
188 base::Bind(&ManageProfileHandler::AddProfileShortcut,
189 base::Unretained(this)));
190 web_ui()->RegisterMessageCallback("removeProfileShortcut",
191 base::Bind(&ManageProfileHandler::RemoveProfileShortcut,
192 base::Unretained(this)));
193 web_ui()->RegisterMessageCallback("refreshGaiaPicture",
194 base::Bind(&ManageProfileHandler::RefreshGaiaPicture,
195 base::Unretained(this)));
196 web_ui()->RegisterMessageCallback(
197 "showDisconnectManagedProfileDialog",
198 base::Bind(&ManageProfileHandler::ShowDisconnectManagedProfileDialog,
199 base::Unretained(this)));
200 web_ui()->RegisterMessageCallback("logDeleteUserDialogShown",
201 base::Bind(&HandleLogDeleteUserDialogShown));
204 void ManageProfileHandler::Uninitialize() {
205 g_browser_process->profile_manager()->
206 GetProfileInfoCache().RemoveObserver(this);
209 void ManageProfileHandler::OnProfileAdded(const base::FilePath& profile_path) {
210 SendExistingProfileNames();
213 void ManageProfileHandler::OnProfileWasRemoved(
214 const base::FilePath& profile_path,
215 const base::string16& profile_name) {
216 SendExistingProfileNames();
219 void ManageProfileHandler::OnProfileNameChanged(
220 const base::FilePath& profile_path,
221 const base::string16& old_profile_name) {
222 base::StringValue value(kManageProfileIdentifier);
223 SendProfileIconsAndNames(value);
226 void ManageProfileHandler::OnProfileAvatarChanged(
227 const base::FilePath& profile_path) {
228 base::StringValue value(kManageProfileIdentifier);
229 SendProfileIconsAndNames(value);
232 void ManageProfileHandler::OnStateChanged() {
233 RequestCreateProfileUpdate(NULL);
236 void ManageProfileHandler::GenerateSignedinUserSpecificStrings(
237 base::DictionaryValue* dictionary) {
238 std::string username;
239 std::string domain_name;
241 #if !defined(OS_CHROMEOS)
242 Profile* profile = Profile::FromWebUI(web_ui());
243 DCHECK(profile);
244 SigninManagerBase* manager = SigninManagerFactory::GetForProfile(profile);
245 if (manager) {
246 username = manager->GetAuthenticatedAccountInfo().email;
247 // If there is no one logged in or if the profile name is empty then the
248 // domain name is empty. This happens in browser tests.
249 if (!username.empty()) {
250 domain_name = "<span id=disconnect-managed-profile-domain-name>" +
251 gaia::ExtractDomainName(username) + "</span>";
254 #endif
256 dictionary->SetString(
257 "disconnectManagedProfileDomainInformation",
258 l10n_util::GetStringFUTF16(
259 IDS_PROFILES_DISCONNECT_MANAGED_PROFILE_DOMAIN_INFORMATION,
260 base::ASCIIToUTF16(domain_name)));
262 dictionary->SetString(
263 "disconnectManagedProfileText",
264 l10n_util::GetStringFUTF16(
265 IDS_PROFILES_DISCONNECT_MANAGED_PROFILE_TEXT,
266 base::UTF8ToUTF16(username),
267 base::UTF8ToUTF16(chrome::kSyncGoogleDashboardURL)));
270 void ManageProfileHandler::RequestDefaultProfileIcons(
271 const base::ListValue* args) {
272 std::string mode;
273 bool ok = args->GetString(0, &mode);
274 DCHECK(ok);
275 DCHECK(mode == kCreateProfileIdentifier || mode == kManageProfileIdentifier);
276 if (ok) {
277 base::StringValue value(mode);
278 SendProfileIconsAndNames(value);
282 void ManageProfileHandler::RequestNewProfileDefaults(
283 const base::ListValue* args) {
284 const ProfileInfoCache& cache =
285 g_browser_process->profile_manager()->GetProfileInfoCache();
286 const size_t icon_index = cache.ChooseAvatarIconIndexForNewProfile();
288 base::DictionaryValue profile_info;
289 profile_info.SetString("name", cache.ChooseNameForNewProfile(icon_index));
290 profile_info.SetString("iconURL",
291 profiles::GetDefaultAvatarIconUrl(icon_index));
293 web_ui()->CallJavascriptFunction(
294 "ManageProfileOverlay.receiveNewProfileDefaults", profile_info);
297 void ManageProfileHandler::SendProfileIconsAndNames(
298 const base::StringValue& mode) {
299 base::ListValue image_url_list;
300 base::ListValue default_name_list;
302 // First add the GAIA picture if it's available.
303 const ProfileInfoCache& cache =
304 g_browser_process->profile_manager()->GetProfileInfoCache();
305 Profile* profile = Profile::FromWebUI(web_ui());
306 size_t profile_index = cache.GetIndexOfProfileWithPath(profile->GetPath());
307 if (profile_index != std::string::npos) {
308 const gfx::Image* icon =
309 cache.GetGAIAPictureOfProfileAtIndex(profile_index);
310 if (icon) {
311 gfx::Image icon2 = profiles::GetAvatarIconForWebUI(*icon, true);
312 gaia_picture_url_ = webui::GetBitmapDataUrl(icon2.AsBitmap());
313 image_url_list.AppendString(gaia_picture_url_);
314 default_name_list.AppendString(std::string());
318 // Next add the default avatar icons and names.
319 for (size_t i = 0; i < profiles::GetDefaultAvatarIconCount(); i++) {
320 std::string url = profiles::GetDefaultAvatarIconUrl(i);
321 image_url_list.AppendString(url);
322 default_name_list.AppendString(cache.ChooseNameForNewProfile(i));
325 web_ui()->CallJavascriptFunction(
326 "ManageProfileOverlay.receiveDefaultProfileIconsAndNames", mode,
327 image_url_list, default_name_list);
330 void ManageProfileHandler::SendExistingProfileNames() {
331 const ProfileInfoCache& cache =
332 g_browser_process->profile_manager()->GetProfileInfoCache();
333 base::DictionaryValue profile_name_dict;
334 for (size_t i = 0, e = cache.GetNumberOfProfiles(); i < e; ++i) {
335 profile_name_dict.SetBoolean(
336 base::UTF16ToUTF8(cache.GetNameOfProfileAtIndex(i)), true);
339 web_ui()->CallJavascriptFunction(
340 "ManageProfileOverlay.receiveExistingProfileNames", profile_name_dict);
343 void ManageProfileHandler::ShowDisconnectManagedProfileDialog(
344 const base::ListValue* args) {
345 base::DictionaryValue replacements;
346 GenerateSignedinUserSpecificStrings(&replacements);
347 web_ui()->CallJavascriptFunction(
348 "ManageProfileOverlay.showDisconnectManagedProfileDialog", replacements);
351 void ManageProfileHandler::SetProfileIconAndName(const base::ListValue* args) {
352 DCHECK(args);
354 base::FilePath profile_file_path;
355 if (!GetProfilePathFromArgs(args, &profile_file_path))
356 return;
358 Profile* profile =
359 g_browser_process->profile_manager()->GetProfile(profile_file_path);
360 if (!profile)
361 return;
363 std::string icon_url;
364 if (!args->GetString(1, &icon_url))
365 return;
367 PrefService* pref_service = profile->GetPrefs();
368 // Updating the profile preferences will cause the cache to be updated.
370 // Metrics logging variable.
371 bool previously_using_gaia_icon =
372 pref_service->GetBoolean(prefs::kProfileUsingGAIAAvatar);
374 size_t new_icon_index;
375 if (icon_url == gaia_picture_url_) {
376 pref_service->SetBoolean(prefs::kProfileUsingDefaultAvatar, false);
377 pref_service->SetBoolean(prefs::kProfileUsingGAIAAvatar, true);
378 if (!previously_using_gaia_icon) {
379 // Only log if they changed to the GAIA photo.
380 // Selection of GAIA photo as avatar is logged as part of the function
381 // below.
382 ProfileMetrics::LogProfileSwitchGaia(ProfileMetrics::GAIA_OPT_IN);
384 } else if (profiles::IsDefaultAvatarIconUrl(icon_url, &new_icon_index)) {
385 ProfileMetrics::LogProfileAvatarSelection(new_icon_index);
386 pref_service->SetInteger(prefs::kProfileAvatarIndex, new_icon_index);
387 pref_service->SetBoolean(prefs::kProfileUsingDefaultAvatar, false);
388 pref_service->SetBoolean(prefs::kProfileUsingGAIAAvatar, false);
389 } else {
390 // Only default avatars and Gaia account photos are supported.
391 CHECK(false);
393 ProfileMetrics::LogProfileUpdate(profile_file_path);
395 if (profile->IsLegacySupervised())
396 return;
398 base::string16 new_profile_name;
399 if (!args->GetString(2, &new_profile_name))
400 return;
402 base::TrimWhitespace(new_profile_name, base::TRIM_ALL, &new_profile_name);
403 CHECK(!new_profile_name.empty());
404 profiles::UpdateProfileName(profile, new_profile_name);
407 #if defined(ENABLE_SETTINGS_APP)
408 void ManageProfileHandler::SwitchAppListProfile(const base::ListValue* args) {
409 DCHECK(args);
410 DCHECK(profiles::IsMultipleProfilesEnabled());
412 const base::Value* file_path_value;
413 base::FilePath profile_file_path;
414 if (!args->Get(0, &file_path_value) ||
415 !base::GetValueAsFilePath(*file_path_value, &profile_file_path))
416 return;
418 AppListService* app_list_service = AppListService::Get(
419 options::helper::GetDesktopType(web_ui()));
420 app_list_service->SetProfilePath(profile_file_path);
421 app_list_service->Show();
423 // Close the settings app, since it will now be for the wrong profile.
424 web_ui()->GetWebContents()->Close();
426 #endif // defined(ENABLE_SETTINGS_APP)
428 void ManageProfileHandler::ProfileIconSelectionChanged(
429 const base::ListValue* args) {
430 DCHECK(args);
432 base::FilePath profile_file_path;
433 if (!GetProfilePathFromArgs(args, &profile_file_path))
434 return;
436 // Currently this only supports editing the current profile's info.
437 if (profile_file_path != Profile::FromWebUI(web_ui())->GetPath())
438 return;
440 std::string icon_url;
441 if (!args->GetString(1, &icon_url))
442 return;
444 if (icon_url != gaia_picture_url_)
445 return;
447 // If the selection is the GAIA picture then also show the profile name in the
448 // text field. This will display either the GAIA given name, if available,
449 // or the first name.
450 ProfileInfoCache& cache =
451 g_browser_process->profile_manager()->GetProfileInfoCache();
452 size_t profile_index = cache.GetIndexOfProfileWithPath(profile_file_path);
453 if (profile_index == std::string::npos)
454 return;
455 base::string16 gaia_name = cache.GetNameOfProfileAtIndex(profile_index);
456 if (gaia_name.empty())
457 return;
459 base::StringValue gaia_name_value(gaia_name);
460 base::StringValue mode_value(kManageProfileIdentifier);
461 web_ui()->CallJavascriptFunction("ManageProfileOverlay.setProfileName",
462 gaia_name_value, mode_value);
465 void ManageProfileHandler::RequestHasProfileShortcuts(
466 const base::ListValue* args) {
467 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
468 DCHECK(ProfileShortcutManager::IsFeatureEnabled());
470 base::FilePath profile_file_path;
471 if (!GetProfilePathFromArgs(args, &profile_file_path))
472 return;
474 const ProfileInfoCache& cache =
475 g_browser_process->profile_manager()->GetProfileInfoCache();
476 size_t profile_index = cache.GetIndexOfProfileWithPath(profile_file_path);
477 if (profile_index == std::string::npos)
478 return;
480 // Don't show the add/remove desktop shortcut button in the single user case.
481 if (cache.GetNumberOfProfiles() <= 1)
482 return;
484 const base::FilePath profile_path =
485 cache.GetPathOfProfileAtIndex(profile_index);
486 ProfileShortcutManager* shortcut_manager =
487 g_browser_process->profile_manager()->profile_shortcut_manager();
488 shortcut_manager->HasProfileShortcuts(
489 profile_path, base::Bind(&ManageProfileHandler::OnHasProfileShortcuts,
490 weak_factory_.GetWeakPtr()));
493 void ManageProfileHandler::RequestCreateProfileUpdate(
494 const base::ListValue* args) {
495 Profile* profile = Profile::FromWebUI(web_ui());
496 SigninManagerBase* manager =
497 SigninManagerFactory::GetForProfile(profile);
498 base::string16 username =
499 base::UTF8ToUTF16(manager->GetAuthenticatedAccountInfo().email);
500 ProfileSyncService* service =
501 ProfileSyncServiceFactory::GetForProfile(profile);
502 GoogleServiceAuthError::State state = GoogleServiceAuthError::NONE;
504 // |service| might be null if Sync is disabled from the command line.
505 if (service)
506 state = service->GetAuthError().state();
508 bool has_error = (!service ||
509 state == GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS ||
510 state == GoogleServiceAuthError::USER_NOT_SIGNED_UP ||
511 state == GoogleServiceAuthError::ACCOUNT_DELETED ||
512 state == GoogleServiceAuthError::ACCOUNT_DISABLED);
513 web_ui()->CallJavascriptFunction("CreateProfileOverlay.updateSignedInStatus",
514 base::StringValue(username),
515 base::FundamentalValue(has_error));
517 OnCreateSupervisedUserPrefChange();
520 void ManageProfileHandler::OnCreateSupervisedUserPrefChange() {
521 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs();
522 base::FundamentalValue allowed(
523 prefs->GetBoolean(prefs::kSupervisedUserCreationAllowed));
524 web_ui()->CallJavascriptFunction(
525 "CreateProfileOverlay.updateSupervisedUsersAllowed", allowed);
528 void ManageProfileHandler::OnHasProfileShortcuts(bool has_shortcuts) {
529 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
531 const base::FundamentalValue has_shortcuts_value(has_shortcuts);
532 web_ui()->CallJavascriptFunction(
533 "ManageProfileOverlay.receiveHasProfileShortcuts", has_shortcuts_value);
536 void ManageProfileHandler::AddProfileShortcut(const base::ListValue* args) {
537 base::FilePath profile_file_path;
538 if (!GetProfilePathFromArgs(args, &profile_file_path))
539 return;
541 DCHECK(ProfileShortcutManager::IsFeatureEnabled());
542 ProfileShortcutManager* shortcut_manager =
543 g_browser_process->profile_manager()->profile_shortcut_manager();
544 DCHECK(shortcut_manager);
546 shortcut_manager->CreateProfileShortcut(profile_file_path);
548 // Update the UI buttons.
549 OnHasProfileShortcuts(true);
552 void ManageProfileHandler::RemoveProfileShortcut(const base::ListValue* args) {
553 base::FilePath profile_file_path;
554 if (!GetProfilePathFromArgs(args, &profile_file_path))
555 return;
557 DCHECK(ProfileShortcutManager::IsFeatureEnabled());
558 ProfileShortcutManager* shortcut_manager =
559 g_browser_process->profile_manager()->profile_shortcut_manager();
560 DCHECK(shortcut_manager);
562 shortcut_manager->RemoveProfileShortcuts(profile_file_path);
564 // Update the UI buttons.
565 OnHasProfileShortcuts(false);
568 void ManageProfileHandler::RefreshGaiaPicture(const base::ListValue* args) {
569 profiles::UpdateGaiaProfileInfoIfNeeded(Profile::FromWebUI(web_ui()));
572 } // namespace options