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/api/commands/command_service.h" | 10 #include "chrome/browser/extensions/api/commands/command_service.h" |
11 #include "chrome/browser/extensions/extension_service.h" | 11 #include "chrome/browser/extensions/extension_service.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "content/public/browser/browser_context.h" |
13 #include "extensions/browser/event_router.h" | 14 #include "extensions/browser/event_router.h" |
14 #include "extensions/browser/extension_system.h" | 15 #include "extensions/browser/extension_system.h" |
15 #include "extensions/common/extension_set.h" | 16 #include "extensions/common/extension_set.h" |
16 #include "extensions/common/manifest_constants.h" | 17 #include "extensions/common/manifest_constants.h" |
17 | 18 |
18 namespace extensions { | 19 namespace extensions { |
19 | 20 |
20 ExtensionKeybindingRegistry::ExtensionKeybindingRegistry( | 21 ExtensionKeybindingRegistry::ExtensionKeybindingRegistry( |
21 Profile* profile, ExtensionFilter extension_filter, Delegate* delegate) | 22 content::BrowserContext* context, |
22 : profile_(profile), | 23 ExtensionFilter extension_filter, |
| 24 Delegate* delegate) |
| 25 : profile_(Profile::FromBrowserContext(context)), |
23 extension_filter_(extension_filter), | 26 extension_filter_(extension_filter), |
24 delegate_(delegate) { | 27 delegate_(delegate) { |
25 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, | 28 registrar_.Add(this, |
26 content::Source<Profile>(profile->GetOriginalProfile())); | 29 chrome::NOTIFICATION_EXTENSION_LOADED, |
27 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, | 30 content::Source<Profile>(profile_->GetOriginalProfile())); |
28 content::Source<Profile>(profile->GetOriginalProfile())); | 31 registrar_.Add(this, |
29 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_COMMAND_ADDED, | 32 chrome::NOTIFICATION_EXTENSION_UNLOADED, |
30 content::Source<Profile>(profile->GetOriginalProfile())); | 33 content::Source<Profile>(profile_->GetOriginalProfile())); |
31 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_COMMAND_REMOVED, | 34 registrar_.Add(this, |
32 content::Source<Profile>(profile->GetOriginalProfile())); | 35 chrome::NOTIFICATION_EXTENSION_COMMAND_ADDED, |
| 36 content::Source<Profile>(profile_->GetOriginalProfile())); |
| 37 registrar_.Add(this, |
| 38 chrome::NOTIFICATION_EXTENSION_COMMAND_REMOVED, |
| 39 content::Source<Profile>(profile_->GetOriginalProfile())); |
33 } | 40 } |
34 | 41 |
35 ExtensionKeybindingRegistry::~ExtensionKeybindingRegistry() { | 42 ExtensionKeybindingRegistry::~ExtensionKeybindingRegistry() { |
36 } | 43 } |
37 | 44 |
38 void ExtensionKeybindingRegistry::RemoveExtensionKeybinding( | 45 void ExtensionKeybindingRegistry::RemoveExtensionKeybinding( |
39 const Extension* extension, | 46 const Extension* extension, |
40 const std::string& command_name) { | 47 const std::string& command_name) { |
41 EventTargets::iterator it = event_targets_.begin(); | 48 EventTargets::iterator it = event_targets_.begin(); |
42 while (it != event_targets_.end()) { | 49 while (it != event_targets_.end()) { |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 return true; | 186 return true; |
180 case PLATFORM_APPS_ONLY: | 187 case PLATFORM_APPS_ONLY: |
181 return extension->is_platform_app(); | 188 return extension->is_platform_app(); |
182 default: | 189 default: |
183 NOTREACHED(); | 190 NOTREACHED(); |
184 } | 191 } |
185 return false; | 192 return false; |
186 } | 193 } |
187 | 194 |
188 } // namespace extensions | 195 } // namespace extensions |
OLD | NEW |