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

Unified Diff: chrome/browser/ui/bookmarks/bookmark_utils.cc

Issue 161293002: mac: Allows extensions to hide the bookmark page menu item. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Respond to remaining rsesek/wittman comments. Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/bookmarks/bookmark_utils.cc
diff --git a/chrome/browser/ui/bookmarks/bookmark_utils.cc b/chrome/browser/ui/bookmarks/bookmark_utils.cc
index 132bfd424a382028d346f6ca4e2a0477b560b899..165d22b55b09b273a9638da8f0895cf6a18d83f2 100644
--- a/chrome/browser/ui/bookmarks/bookmark_utils.cc
+++ b/chrome/browser/ui/bookmarks/bookmark_utils.cc
@@ -11,6 +11,7 @@
#include "chrome/browser/bookmarks/bookmark_model.h"
#include "chrome/browser/bookmarks/bookmark_model_factory.h"
#include "chrome/browser/extensions/api/commands/command_service.h"
+#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search/search.h"
#include "chrome/browser/ui/app_list/app_list_util.h"
@@ -24,6 +25,8 @@
#include "chrome/common/url_constants.h"
#include "components/user_prefs/user_prefs.h"
#include "content/public/browser/web_contents.h"
+#include "extensions/browser/extension_system.h"
+#include "extensions/common/extension_set.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
#include "net/base/net_util.h"
@@ -295,15 +298,35 @@ bool ShouldShowAppsShortcutInBookmarkBar(
profile->GetPrefs()->GetBoolean(prefs::kShowAppsShortcutInBookmarkBar);
}
-BookmarkShortcutDisposition GetBookmarkShortcutDisposition(
- const extensions::CommandService* command_service,
- const extensions::Extension* extension) {
- if (command_service->OverridesBookmarkShortcut(extension))
- return BOOKMARK_SHORTCUT_DISPOSITION_OVERRIDDEN;
+BookmarkShortcutDisposition GetBookmarkShortcutDisposition(Profile* profile) {
+ extensions::CommandService* command_service =
+ extensions::CommandService::Get(profile);
+
+ const extensions::ExtensionSet* extension_set =
+ extensions::ExtensionSystem::Get(profile)->
+ extension_service()->extensions();
+ // This flag tracks whether any extension wants the disposition to be
+ // removed.
+ bool removed = false;
+ for (extensions::ExtensionSet::const_iterator i = extension_set->begin();
+ i != extension_set->end();
+ ++i) {
+ // Use the overridden disposition if any extension wants it.
+ if (command_service->OverridesBookmarkShortcut(*i))
+ return BOOKMARK_SHORTCUT_DISPOSITION_OVERRIDDEN;
+
+ if (!removed && extensions::CommandService::RemovesBookmarkShortcut(*i))
+ removed = true;
+ }
+
+ if (removed)
erikchen 2014/02/26 19:58:23 I consider this form to be slightly clearer than t
+ return BOOKMARK_SHORTCUT_DISPOSITION_REMOVED;
+ return BOOKMARK_SHORTCUT_DISPOSITION_UNCHANGED;
+}
- return extensions::CommandService::RemovesBookmarkShortcut(extension) ?
- BOOKMARK_SHORTCUT_DISPOSITION_REMOVED :
- BOOKMARK_SHORTCUT_DISPOSITION_UNCHANGED;
+bool ShouldShowBookmarkPageMenuItem(Profile* profile) {
+ return GetBookmarkShortcutDisposition(profile) !=
+ BOOKMARK_SHORTCUT_DISPOSITION_REMOVED;
}
} // namespace chrome

Powered by Google App Engine
This is Rietveld 408576698