| 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/extensions/api/commands/command_service.h" | 5 #include "chrome/browser/extensions/api/commands/command_service.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/prefs/scoped_user_pref_update.h" | 10 #include "base/prefs/scoped_user_pref_update.h" |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 // static | 164 // static |
| 165 bool CommandService::RemovesBookmarkShortcut(const Extension* extension) { | 165 bool CommandService::RemovesBookmarkShortcut(const Extension* extension) { |
| 166 const UIOverrides* ui_overrides = UIOverrides::Get(extension); | 166 const UIOverrides* ui_overrides = UIOverrides::Get(extension); |
| 167 const SettingsOverrides* settings_overrides = | 167 const SettingsOverrides* settings_overrides = |
| 168 SettingsOverrides::Get(extension); | 168 SettingsOverrides::Get(extension); |
| 169 | 169 |
| 170 return ((settings_overrides && | 170 return ((settings_overrides && |
| 171 SettingsOverrides::RemovesBookmarkShortcut(*settings_overrides)) || | 171 SettingsOverrides::RemovesBookmarkShortcut(*settings_overrides)) || |
| 172 (ui_overrides && | 172 (ui_overrides && |
| 173 UIOverrides::RemovesBookmarkShortcut(*ui_overrides))) && | 173 UIOverrides::RemovesBookmarkShortcut(*ui_overrides))) && |
| 174 (PermissionsData::ForExtension(extension) | 174 (extension->permissions_data()->HasAPIPermission( |
| 175 ->HasAPIPermission(APIPermission::kBookmarkManagerPrivate) || | 175 APIPermission::kBookmarkManagerPrivate) || |
| 176 FeatureSwitch::enable_override_bookmarks_ui()->IsEnabled()); | 176 FeatureSwitch::enable_override_bookmarks_ui()->IsEnabled()); |
| 177 } | 177 } |
| 178 | 178 |
| 179 // static | 179 // static |
| 180 bool CommandService::RemovesBookmarkOpenPagesShortcut( | 180 bool CommandService::RemovesBookmarkOpenPagesShortcut( |
| 181 const Extension* extension) { | 181 const Extension* extension) { |
| 182 const UIOverrides* ui_overrides = UIOverrides::Get(extension); | 182 const UIOverrides* ui_overrides = UIOverrides::Get(extension); |
| 183 const SettingsOverrides* settings_overrides = | 183 const SettingsOverrides* settings_overrides = |
| 184 SettingsOverrides::Get(extension); | 184 SettingsOverrides::Get(extension); |
| 185 | 185 |
| 186 return ((settings_overrides && | 186 return ((settings_overrides && |
| 187 SettingsOverrides::RemovesBookmarkOpenPagesShortcut( | 187 SettingsOverrides::RemovesBookmarkOpenPagesShortcut( |
| 188 *settings_overrides)) || | 188 *settings_overrides)) || |
| 189 (ui_overrides && | 189 (ui_overrides && |
| 190 UIOverrides::RemovesBookmarkOpenPagesShortcut(*ui_overrides))) && | 190 UIOverrides::RemovesBookmarkOpenPagesShortcut(*ui_overrides))) && |
| 191 (PermissionsData::ForExtension(extension) | 191 (extension->permissions_data()->HasAPIPermission( |
| 192 ->HasAPIPermission(APIPermission::kBookmarkManagerPrivate) || | 192 APIPermission::kBookmarkManagerPrivate) || |
| 193 FeatureSwitch::enable_override_bookmarks_ui()->IsEnabled()); | 193 FeatureSwitch::enable_override_bookmarks_ui()->IsEnabled()); |
| 194 } | 194 } |
| 195 | 195 |
| 196 bool CommandService::GetBrowserActionCommand(const std::string& extension_id, | 196 bool CommandService::GetBrowserActionCommand(const std::string& extension_id, |
| 197 QueryType type, | 197 QueryType type, |
| 198 Command* command, | 198 Command* command, |
| 199 bool* active) const { | 199 bool* active) const { |
| 200 return GetExtensionActionCommand( | 200 return GetExtensionActionCommand( |
| 201 extension_id, type, command, active, BROWSER_ACTION); | 201 extension_id, type, command, active, BROWSER_ACTION); |
| 202 } | 202 } |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 return true; | 599 return true; |
| 600 } | 600 } |
| 601 | 601 |
| 602 template <> | 602 template <> |
| 603 void | 603 void |
| 604 BrowserContextKeyedAPIFactory<CommandService>::DeclareFactoryDependencies() { | 604 BrowserContextKeyedAPIFactory<CommandService>::DeclareFactoryDependencies() { |
| 605 DependsOn(ExtensionCommandsGlobalRegistry::GetFactoryInstance()); | 605 DependsOn(ExtensionCommandsGlobalRegistry::GetFactoryInstance()); |
| 606 } | 606 } |
| 607 | 607 |
| 608 } // namespace extensions | 608 } // namespace extensions |
| OLD | NEW |