| 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" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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; |
| 65 | 65 |
| 66 // Grant before sending the event so that the permission is granted before | 66 // Grant before sending the event so that the permission is granted before |
| 67 // the extension acts on the command. | 67 // the extension acts on the command. NOTE: The Global Commands handler does |
| 68 // not set the delegate as it deals only with named commands (not page/browser |
| 69 // actions that are associated with the current page directly). |
| 68 ActiveTabPermissionGranter* granter = | 70 ActiveTabPermissionGranter* granter = |
| 69 delegate_->GetActiveTabPermissionGranter(); | 71 delegate_ ? delegate_->GetActiveTabPermissionGranter() : NULL; |
| 70 if (granter) | 72 if (granter) |
| 71 granter->GrantIfRequested(extension); | 73 granter->GrantIfRequested(extension); |
| 72 | 74 |
| 73 scoped_ptr<base::ListValue> args(new base::ListValue()); | 75 scoped_ptr<base::ListValue> args(new base::ListValue()); |
| 74 args->Append(new base::StringValue(command)); | 76 args->Append(new base::StringValue(command)); |
| 75 | 77 |
| 76 scoped_ptr<Event> event(new Event("commands.onCommand", args.Pass())); | 78 scoped_ptr<Event> event(new Event("commands.onCommand", args.Pass())); |
| 77 event->restrict_to_profile = profile_; | 79 event->restrict_to_profile = profile_; |
| 78 event->user_gesture = EventRouter::USER_GESTURE_ENABLED; | 80 event->user_gesture = EventRouter::USER_GESTURE_ENABLED; |
| 79 ExtensionSystem::Get(profile_)->event_router()-> | 81 ExtensionSystem::Get(profile_)->event_router()-> |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 return true; | 137 return true; |
| 136 case PLATFORM_APPS_ONLY: | 138 case PLATFORM_APPS_ONLY: |
| 137 return extension->is_platform_app(); | 139 return extension->is_platform_app(); |
| 138 default: | 140 default: |
| 139 NOTREACHED(); | 141 NOTREACHED(); |
| 140 } | 142 } |
| 141 return false; | 143 return false; |
| 142 } | 144 } |
| 143 | 145 |
| 144 } // namespace extensions | 146 } // namespace extensions |
| OLD | NEW |