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

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: Make sure changes only apply to OSX. 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
« no previous file with comments | « chrome/browser/ui/bookmarks/bookmark_utils.h ('k') | chrome/browser/ui/cocoa/browser_window_cocoa.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..fd188cbb56d2f580b134469ea8e02219cb212211 100644
--- a/chrome/browser/ui/bookmarks/bookmark_utils.cc
+++ b/chrome/browser/ui/bookmarks/bookmark_utils.cc
@@ -24,6 +24,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_registry.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 +297,40 @@ 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);
+
+ extensions::ExtensionRegistry* registry =
+ extensions::ExtensionRegistry::Get(profile);
+ if (!registry)
+ return BOOKMARK_SHORTCUT_DISPOSITION_UNCHANGED;
+
+ const extensions::ExtensionSet& extension_set =
+ registry->enabled_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)
+ 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
« no previous file with comments | « chrome/browser/ui/bookmarks/bookmark_utils.h ('k') | chrome/browser/ui/cocoa/browser_window_cocoa.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698