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

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

Issue 2525783002: MD Settings: Hide Profile Shortcut switch for single-profile machines. (Closed)
Patch Set: one more fix to make it actually work 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 82384e694a6f18b5a0c002fab0ab85c8de94574f..6a00c7c38215f08076b8bd6bf83333c982e3294f 100644
--- a/chrome/browser/ui/webui/settings/settings_manage_profile_handler.cc
+++ b/chrome/browser/ui/webui/settings/settings_manage_profile_handler.cc
@@ -43,6 +43,14 @@
namespace settings {
+namespace {
+
+const char kProfileShortcutSettingHidden[] = "profileShortcutSettingHidden";
+const char kProfileShortcutFound[] = "profileShortcutFound";
+const char kProfileShortcutNotFound[] = "profileShortcutNotFound";
+
+} // namespace
+
ManageProfileHandler::ManageProfileHandler(Profile* profile)
: profile_(profile), observer_(this), weak_factory_(this) {}
@@ -58,8 +66,8 @@ void ManageProfileHandler::RegisterMessages() {
base::Bind(&ManageProfileHandler::HandleSetProfileIconAndName,
base::Unretained(this)));
web_ui()->RegisterMessageCallback(
- "requestHasProfileShortcuts",
- base::Bind(&ManageProfileHandler::HandleRequestHasProfileShortcuts,
+ "requestProfileShortcutStatus",
+ base::Bind(&ManageProfileHandler::HandleRequestProfileShortcutStatus,
base::Unretained(this)));
web_ui()->RegisterMessageCallback(
"addProfileShortcut",
@@ -172,7 +180,7 @@ void ManageProfileHandler::HandleSetProfileIconAndName(
profiles::UpdateProfileName(profile_, new_profile_name);
}
-void ManageProfileHandler::HandleRequestHasProfileShortcuts(
+void ManageProfileHandler::HandleRequestProfileShortcutStatus(
const base::ListValue* args) {
AllowJavascript();
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
@@ -182,15 +190,14 @@ void ManageProfileHandler::HandleRequestHasProfileShortcuts(
std::string callback_id;
CHECK(args->GetString(0, &callback_id));
+ // Don't show the add/remove desktop shortcut button in the single user case.
ProfileAttributesStorage& storage =
g_browser_process->profile_manager()->GetProfileAttributesStorage();
- ProfileAttributesEntry* entry;
- if (!storage.GetProfileAttributesWithPath(profile_->GetPath(), &entry))
- return;
-
- // Don't show the add/remove desktop shortcut button in the single user case.
- if (storage.GetNumberOfProfiles() <= 1u)
+ if (storage.GetNumberOfProfiles() <= 1u) {
+ ResolveJavascriptCallback(base::StringValue(callback_id),
+ base::StringValue(kProfileShortcutSettingHidden));
return;
+ }
ProfileShortcutManager* shortcut_manager =
g_browser_process->profile_manager()->profile_shortcut_manager();
@@ -204,8 +211,10 @@ void ManageProfileHandler::HandleRequestHasProfileShortcuts(
void ManageProfileHandler::OnHasProfileShortcuts(
const std::string& callback_id, bool has_shortcuts) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
- ResolveJavascriptCallback(base::StringValue(callback_id),
- base::FundamentalValue(has_shortcuts));
+ ResolveJavascriptCallback(
+ base::StringValue(callback_id),
+ base::StringValue(has_shortcuts ? kProfileShortcutFound
+ : kProfileShortcutNotFound));
}
void ManageProfileHandler::HandleAddProfileShortcut(

Powered by Google App Engine
This is Rietveld 408576698