OLD | NEW |
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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
11 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 11 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/search/search.h" | 13 #include "chrome/browser/search/search.h" |
14 #include "chrome/common/pref_names.h" | 14 #include "chrome/common/pref_names.h" |
15 #include "chrome/common/url_constants.h" | 15 #include "chrome/common/url_constants.h" |
16 #include "components/bookmarks/browser/bookmark_model.h" | 16 #include "components/bookmarks/browser/bookmark_model.h" |
17 #include "components/bookmarks/browser/bookmark_node_data.h" | 17 #include "components/bookmarks/browser/bookmark_node_data.h" |
18 #include "components/bookmarks/common/bookmark_pref_names.h" | 18 #include "components/bookmarks/common/bookmark_pref_names.h" |
19 #include "components/prefs/pref_service.h" | 19 #include "components/prefs/pref_service.h" |
20 #include "components/search/search.h" | 20 #include "components/search/search.h" |
21 #include "components/url_formatter/url_formatter.h" | 21 #include "components/url_formatter/url_formatter.h" |
22 #include "components/user_prefs/user_prefs.h" | 22 #include "components/user_prefs/user_prefs.h" |
23 #include "content/public/browser/web_contents.h" | 23 #include "content/public/browser/web_contents.h" |
| 24 #include "extensions/features/features.h" |
24 #include "ui/base/dragdrop/drag_drop_types.h" | 25 #include "ui/base/dragdrop/drag_drop_types.h" |
25 #include "ui/base/dragdrop/drop_target_event.h" | 26 #include "ui/base/dragdrop/drop_target_event.h" |
26 | 27 |
27 #if defined(ENABLE_EXTENSIONS) | 28 #if BUILDFLAG(ENABLE_EXTENSIONS) |
28 #include "chrome/browser/extensions/api/commands/command_service.h" | 29 #include "chrome/browser/extensions/api/commands/command_service.h" |
29 #include "extensions/browser/extension_registry.h" | 30 #include "extensions/browser/extension_registry.h" |
30 #include "extensions/common/extension_set.h" | 31 #include "extensions/common/extension_set.h" |
31 #endif | 32 #endif |
32 | 33 |
33 #if defined(TOOLKIT_VIEWS) | 34 #if defined(TOOLKIT_VIEWS) |
34 #include "ui/gfx/color_utils.h" | 35 #include "ui/gfx/color_utils.h" |
35 #include "ui/gfx/paint_vector_icon.h" | 36 #include "ui/gfx/paint_vector_icon.h" |
36 #include "ui/gfx/vector_icons_public.h" | 37 #include "ui/gfx/vector_icons_public.h" |
37 #endif | 38 #endif |
(...skipping 14 matching lines...) Expand all Loading... |
52 // The ways in which extensions may customize the bookmark shortcut. | 53 // The ways in which extensions may customize the bookmark shortcut. |
53 enum BookmarkShortcutDisposition { | 54 enum BookmarkShortcutDisposition { |
54 BOOKMARK_SHORTCUT_DISPOSITION_UNCHANGED, | 55 BOOKMARK_SHORTCUT_DISPOSITION_UNCHANGED, |
55 BOOKMARK_SHORTCUT_DISPOSITION_REMOVED, | 56 BOOKMARK_SHORTCUT_DISPOSITION_REMOVED, |
56 BOOKMARK_SHORTCUT_DISPOSITION_OVERRIDE_REQUESTED | 57 BOOKMARK_SHORTCUT_DISPOSITION_OVERRIDE_REQUESTED |
57 }; | 58 }; |
58 | 59 |
59 // Indicates how the bookmark shortcut has been changed by extensions associated | 60 // Indicates how the bookmark shortcut has been changed by extensions associated |
60 // with |profile|, if at all. | 61 // with |profile|, if at all. |
61 BookmarkShortcutDisposition GetBookmarkShortcutDisposition(Profile* profile) { | 62 BookmarkShortcutDisposition GetBookmarkShortcutDisposition(Profile* profile) { |
62 #if defined(ENABLE_EXTENSIONS) | 63 #if BUILDFLAG(ENABLE_EXTENSIONS) |
63 extensions::CommandService* command_service = | 64 extensions::CommandService* command_service = |
64 extensions::CommandService::Get(profile); | 65 extensions::CommandService::Get(profile); |
65 | 66 |
66 extensions::ExtensionRegistry* registry = | 67 extensions::ExtensionRegistry* registry = |
67 extensions::ExtensionRegistry::Get(profile); | 68 extensions::ExtensionRegistry::Get(profile); |
68 if (!registry) | 69 if (!registry) |
69 return BOOKMARK_SHORTCUT_DISPOSITION_UNCHANGED; | 70 return BOOKMARK_SHORTCUT_DISPOSITION_UNCHANGED; |
70 | 71 |
71 const extensions::ExtensionSet& extension_set = | 72 const extensions::ExtensionSet& extension_set = |
72 registry->enabled_extensions(); | 73 registry->enabled_extensions(); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 profile->GetPrefs()->GetBoolean( | 162 profile->GetPrefs()->GetBoolean( |
162 bookmarks::prefs::kShowAppsShortcutInBookmarkBar); | 163 bookmarks::prefs::kShowAppsShortcutInBookmarkBar); |
163 } | 164 } |
164 | 165 |
165 bool ShouldRemoveBookmarkThisPageUI(Profile* profile) { | 166 bool ShouldRemoveBookmarkThisPageUI(Profile* profile) { |
166 return GetBookmarkShortcutDisposition(profile) == | 167 return GetBookmarkShortcutDisposition(profile) == |
167 BOOKMARK_SHORTCUT_DISPOSITION_REMOVED; | 168 BOOKMARK_SHORTCUT_DISPOSITION_REMOVED; |
168 } | 169 } |
169 | 170 |
170 bool ShouldRemoveBookmarkOpenPagesUI(Profile* profile) { | 171 bool ShouldRemoveBookmarkOpenPagesUI(Profile* profile) { |
171 #if defined(ENABLE_EXTENSIONS) | 172 #if BUILDFLAG(ENABLE_EXTENSIONS) |
172 extensions::ExtensionRegistry* registry = | 173 extensions::ExtensionRegistry* registry = |
173 extensions::ExtensionRegistry::Get(profile); | 174 extensions::ExtensionRegistry::Get(profile); |
174 if (!registry) | 175 if (!registry) |
175 return false; | 176 return false; |
176 | 177 |
177 const extensions::ExtensionSet& extension_set = | 178 const extensions::ExtensionSet& extension_set = |
178 registry->enabled_extensions(); | 179 registry->enabled_extensions(); |
179 | 180 |
180 for (extensions::ExtensionSet::const_iterator i = extension_set.begin(); | 181 for (extensions::ExtensionSet::const_iterator i = extension_set.begin(); |
181 i != extension_set.end(); | 182 i != extension_set.end(); |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 #if defined(OS_WIN) | 315 #if defined(OS_WIN) |
315 return *ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 316 return *ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
316 IDR_BOOKMARK_BAR_FOLDER_MANAGED); | 317 IDR_BOOKMARK_BAR_FOLDER_MANAGED); |
317 #else | 318 #else |
318 return GetFolderIcon(gfx::VectorIconId::FOLDER_MANAGED, text_color); | 319 return GetFolderIcon(gfx::VectorIconId::FOLDER_MANAGED, text_color); |
319 #endif | 320 #endif |
320 } | 321 } |
321 #endif | 322 #endif |
322 | 323 |
323 } // namespace chrome | 324 } // namespace chrome |
OLD | NEW |