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/extension_keybinding_registry.h" | 5 #include "chrome/browser/extensions/extension_keybinding_registry.h" |
6 | 6 |
7 #include "base/values.h" | 7 #include "base/values.h" |
8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
9 #include "chrome/browser/extensions/active_tab_permission_granter.h" | 9 #include "chrome/browser/extensions/active_tab_permission_granter.h" |
10 #include "chrome/browser/extensions/event_router.h" | 10 #include "chrome/browser/extensions/event_router.h" |
11 #include "chrome/browser/extensions/extension_service.h" | 11 #include "chrome/browser/extensions/extension_service.h" |
12 #include "chrome/browser/extensions/extension_system.h" | 12 #include "chrome/browser/extensions/extension_system.h" |
13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/common/extensions/extension_manifest_constants.h" | |
15 #include "chrome/common/extensions/extension_set.h" | 14 #include "chrome/common/extensions/extension_set.h" |
| 15 #include "extensions/common/manifest_constants.h" |
16 | 16 |
17 namespace extensions { | 17 namespace extensions { |
18 | 18 |
19 ExtensionKeybindingRegistry::ExtensionKeybindingRegistry( | 19 ExtensionKeybindingRegistry::ExtensionKeybindingRegistry( |
20 Profile* profile, ExtensionFilter extension_filter, Delegate* delegate) | 20 Profile* profile, ExtensionFilter extension_filter, Delegate* delegate) |
21 : profile_(profile), | 21 : profile_(profile), |
22 extension_filter_(extension_filter), | 22 extension_filter_(extension_filter), |
23 delegate_(delegate) { | 23 delegate_(delegate) { |
24 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, | 24 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, |
25 content::Source<Profile>(profile->GetOriginalProfile())); | 25 content::Source<Profile>(profile->GetOriginalProfile())); |
(...skipping 16 matching lines...) Expand all Loading... |
42 | 42 |
43 const ExtensionSet* extensions = service->extensions(); | 43 const ExtensionSet* extensions = service->extensions(); |
44 ExtensionSet::const_iterator iter = extensions->begin(); | 44 ExtensionSet::const_iterator iter = extensions->begin(); |
45 for (; iter != extensions->end(); ++iter) | 45 for (; iter != extensions->end(); ++iter) |
46 if (ExtensionMatchesFilter(iter->get())) | 46 if (ExtensionMatchesFilter(iter->get())) |
47 AddExtensionKeybinding(iter->get(), std::string()); | 47 AddExtensionKeybinding(iter->get(), std::string()); |
48 } | 48 } |
49 | 49 |
50 bool ExtensionKeybindingRegistry::ShouldIgnoreCommand( | 50 bool ExtensionKeybindingRegistry::ShouldIgnoreCommand( |
51 const std::string& command) const { | 51 const std::string& command) const { |
52 return command == extension_manifest_values::kPageActionCommandEvent || | 52 return command == manifest_values::kPageActionCommandEvent || |
53 command == extension_manifest_values::kBrowserActionCommandEvent || | 53 command == manifest_values::kBrowserActionCommandEvent || |
54 command == extension_manifest_values::kScriptBadgeCommandEvent; | 54 command == manifest_values::kScriptBadgeCommandEvent; |
55 } | 55 } |
56 | 56 |
57 void ExtensionKeybindingRegistry::CommandExecuted( | 57 void ExtensionKeybindingRegistry::CommandExecuted( |
58 const std::string& extension_id, const std::string& command) { | 58 const std::string& extension_id, const std::string& command) { |
59 ExtensionService* service = | 59 ExtensionService* service = |
60 ExtensionSystem::Get(profile_)->extension_service(); | 60 ExtensionSystem::Get(profile_)->extension_service(); |
61 | 61 |
62 const Extension* extension = service->extensions()->GetByID(extension_id); | 62 const Extension* extension = service->extensions()->GetByID(extension_id); |
63 if (!extension) | 63 if (!extension) |
64 return; | 64 return; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 return true; | 135 return true; |
136 case PLATFORM_APPS_ONLY: | 136 case PLATFORM_APPS_ONLY: |
137 return extension->is_platform_app(); | 137 return extension->is_platform_app(); |
138 default: | 138 default: |
139 NOTREACHED(); | 139 NOTREACHED(); |
140 } | 140 } |
141 return false; | 141 return false; |
142 } | 142 } |
143 | 143 |
144 } // namespace extensions | 144 } // namespace extensions |
OLD | NEW |