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

Side by Side 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: Minor cleanup. 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" 5 #include "chrome/browser/ui/bookmarks/bookmark_utils.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
11 #include "chrome/browser/bookmarks/bookmark_model.h" 11 #include "chrome/browser/bookmarks/bookmark_model.h"
12 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 12 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
13 #include "chrome/browser/extensions/api/commands/command_service.h" 13 #include "chrome/browser/extensions/api/commands/command_service.h"
14 #include "chrome/browser/extensions/extension_service.h"
14 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/search/search.h" 16 #include "chrome/browser/search/search.h"
16 #include "chrome/browser/ui/app_list/app_list_util.h" 17 #include "chrome/browser/ui/app_list/app_list_util.h"
17 #include "chrome/browser/ui/bookmarks/bookmark_editor.h" 18 #include "chrome/browser/ui/bookmarks/bookmark_editor.h"
18 #include "chrome/browser/ui/browser.h" 19 #include "chrome/browser/ui/browser.h"
19 #include "chrome/browser/ui/browser_navigator.h" 20 #include "chrome/browser/ui/browser_navigator.h"
20 #include "chrome/browser/ui/browser_window.h" 21 #include "chrome/browser/ui/browser_window.h"
21 #include "chrome/browser/ui/simple_message_box.h" 22 #include "chrome/browser/ui/simple_message_box.h"
22 #include "chrome/browser/ui/tabs/tab_strip_model.h" 23 #include "chrome/browser/ui/tabs/tab_strip_model.h"
23 #include "chrome/common/pref_names.h" 24 #include "chrome/common/pref_names.h"
24 #include "chrome/common/url_constants.h" 25 #include "chrome/common/url_constants.h"
25 #include "components/user_prefs/user_prefs.h" 26 #include "components/user_prefs/user_prefs.h"
26 #include "content/public/browser/web_contents.h" 27 #include "content/public/browser/web_contents.h"
28 #include "extensions/browser/extension_system.h"
29 #include "extensions/common/extension_set.h"
27 #include "grit/chromium_strings.h" 30 #include "grit/chromium_strings.h"
28 #include "grit/generated_resources.h" 31 #include "grit/generated_resources.h"
29 #include "net/base/net_util.h" 32 #include "net/base/net_util.h"
30 #include "ui/base/l10n/l10n_util.h" 33 #include "ui/base/l10n/l10n_util.h"
31 34
32 namespace chrome { 35 namespace chrome {
33 36
34 int num_bookmark_urls_before_prompting = 15; 37 int num_bookmark_urls_before_prompting = 15;
35 38
36 namespace { 39 namespace {
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 return chrome::IsInstantExtendedAPIEnabled() && !profile->IsOffTheRecord(); 291 return chrome::IsInstantExtendedAPIEnabled() && !profile->IsOffTheRecord();
289 } 292 }
290 293
291 bool ShouldShowAppsShortcutInBookmarkBar( 294 bool ShouldShowAppsShortcutInBookmarkBar(
292 Profile* profile, 295 Profile* profile,
293 chrome::HostDesktopType host_desktop_type) { 296 chrome::HostDesktopType host_desktop_type) {
294 return IsAppsShortcutEnabled(profile, host_desktop_type) && 297 return IsAppsShortcutEnabled(profile, host_desktop_type) &&
295 profile->GetPrefs()->GetBoolean(prefs::kShowAppsShortcutInBookmarkBar); 298 profile->GetPrefs()->GetBoolean(prefs::kShowAppsShortcutInBookmarkBar);
296 } 299 }
297 300
298 BookmarkShortcutDisposition GetBookmarkShortcutDisposition( 301 BookmarkShortcutDisposition GetBookmarkShortcutDisposition(Profile* profile) {
299 const extensions::CommandService* command_service, 302 extensions::CommandService* command_service =
300 const extensions::Extension* extension) { 303 extensions::CommandService::Get(profile);
301 if (command_service->OverridesBookmarkShortcut(extension))
302 return BOOKMARK_SHORTCUT_DISPOSITION_OVERRIDDEN;
303 304
304 return extensions::CommandService::RemovesBookmarkShortcut(extension) ? 305 const extensions::ExtensionSet* extension_set =
305 BOOKMARK_SHORTCUT_DISPOSITION_REMOVED : 306 extensions::ExtensionSystem::Get(profile)
306 BOOKMARK_SHORTCUT_DISPOSITION_UNCHANGED; 307 ->extension_service()
Robert Sesek 2014/02/26 18:05:13 It's more common to put the pointer indirection op
erikchen 2014/02/26 19:58:23 Done. I was using the output of clang-format, fyi.
Robert Sesek 2014/02/26 20:30:00 Weird, Rietveld double-percent-escapes them. It's
308 ->extensions();
Robert Sesek 2014/02/26 18:05:13 This will fit on the previous line.
erikchen 2014/02/26 19:58:23 ditto On 2014/02/26 18:05:13, rsesek wrote:
309 for (extensions::ExtensionSet::const_iterator i = extension_set->begin();
erikchen 2014/02/26 01:08:19 The extension proposal: https://docs.google.com/a/
Robert Sesek 2014/02/26 18:05:13 This approach is probably fine, but you may want t
Mike Wittman 2014/02/26 18:29:05 The extension keybinding behavior is that the firs
erikchen 2014/02/26 19:58:23 Done.
310 i != extension_set->end();
311 ++i) {
312 if (command_service->OverridesBookmarkShortcut(*i))
313 return BOOKMARK_SHORTCUT_DISPOSITION_OVERRIDDEN;
314
315 if (extensions::CommandService::RemovesBookmarkShortcut(*i))
316 return BOOKMARK_SHORTCUT_DISPOSITION_REMOVED;
317 }
318 return BOOKMARK_SHORTCUT_DISPOSITION_UNCHANGED;
319 }
320
321 bool ShouldShowBookmarkPageMenuItem(Profile* profile) {
322 return GetBookmarkShortcutDisposition(profile) !=
323 BOOKMARK_SHORTCUT_DISPOSITION_REMOVED;
307 } 324 }
308 325
309 } // namespace chrome 326 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698