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

Unified Diff: chrome/browser/ui/webui/settings/settings_manage_profile_handler.cc

Issue 2498153002: [MD Settings][MD User Manager] create/manage profile desktop shortcut (Windows only) (Closed)
Patch Set: Addressed comments Created 4 years, 1 month 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/settings/settings_manage_profile_handler.cc
diff --git a/chrome/browser/ui/webui/settings/settings_manage_profile_handler.cc b/chrome/browser/ui/webui/settings/settings_manage_profile_handler.cc
index 7d796d2d94a4946116621e69e99e9dc126692cfb..c02005ed8c1bc8fc9cadcfe4a360ee180bf3dae4 100644
--- a/chrome/browser/ui/webui/settings/settings_manage_profile_handler.cc
+++ b/chrome/browser/ui/webui/settings/settings_manage_profile_handler.cc
@@ -174,9 +174,14 @@ void ManageProfileHandler::HandleSetProfileIconAndName(
void ManageProfileHandler::HandleRequestHasProfileShortcuts(
const base::ListValue* args) {
+ AllowJavascript();
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
DCHECK(ProfileShortcutManager::IsFeatureEnabled());
+ CHECK_EQ(1U, args->GetSize());
+ const base::Value* callback_id;
+ CHECK(args->Get(0, &callback_id));
+
ProfileAttributesStorage& storage =
g_browser_process->profile_manager()->GetProfileAttributesStorage();
ProfileAttributesEntry* entry;
@@ -189,18 +194,18 @@ void ManageProfileHandler::HandleRequestHasProfileShortcuts(
ProfileShortcutManager* shortcut_manager =
g_browser_process->profile_manager()->profile_shortcut_manager();
+ DCHECK(shortcut_manager);
shortcut_manager->HasProfileShortcuts(
profile_->GetPath(),
base::Bind(&ManageProfileHandler::OnHasProfileShortcuts,
- weak_factory_.GetWeakPtr()));
+ weak_factory_.GetWeakPtr(), callback_id));
}
-void ManageProfileHandler::OnHasProfileShortcuts(bool has_shortcuts) {
+void ManageProfileHandler::OnHasProfileShortcuts(
+ const base::Value* callback_id, bool has_shortcuts) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
-
- const base::FundamentalValue has_shortcuts_value(has_shortcuts);
- CallJavascriptFunction("settings.SyncPrivateApi.receiveHasProfileShortcuts",
- has_shortcuts_value);
+ ResolveJavascriptCallback(*callback_id,
+ base::FundamentalValue(has_shortcuts));
}
void ManageProfileHandler::HandleAddProfileShortcut(
@@ -211,9 +216,6 @@ void ManageProfileHandler::HandleAddProfileShortcut(
DCHECK(shortcut_manager);
shortcut_manager->CreateProfileShortcut(profile_->GetPath());
-
- // Update the UI buttons.
- OnHasProfileShortcuts(true);
}
void ManageProfileHandler::HandleRemoveProfileShortcut(
@@ -224,9 +226,6 @@ void ManageProfileHandler::HandleRemoveProfileShortcut(
DCHECK(shortcut_manager);
shortcut_manager->RemoveProfileShortcuts(profile_->GetPath());
-
- // Update the UI buttons.
- OnHasProfileShortcuts(false);
}
} // namespace settings

Powered by Google App Engine
This is Rietveld 408576698