| 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/cocoa/extensions/extension_keybinding_registry_cocoa
.h" | 5 #include "chrome/browser/ui/cocoa/extensions/extension_keybinding_registry_cocoa
.h" |
| 6 | 6 |
| 7 #include "chrome/browser/extensions/api/commands/command_service.h" | 7 #include "chrome/browser/extensions/api/commands/command_service.h" |
| 8 #include "chrome/browser/extensions/api/commands/command_service_factory.h" | 8 #include "chrome/browser/extensions/api/commands/command_service_factory.h" |
| 9 #include "chrome/browser/extensions/browser_event_router.h" | |
| 10 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/common/extensions/extension.h" | 11 #include "chrome/common/extensions/extension.h" |
| 13 #include "chrome/common/chrome_notification_types.h" | 12 #include "chrome/common/chrome_notification_types.h" |
| 14 #include "chrome/common/extensions/extension_manifest_constants.h" | 13 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 15 #include "content/public/browser/native_web_keyboard_event.h" | 14 #include "content/public/browser/native_web_keyboard_event.h" |
| 16 #include "content/public/browser/notification_service.h" | 15 #include "content/public/browser/notification_service.h" |
| 17 | 16 |
| 18 namespace values = extension_manifest_values; | 17 namespace values = extension_manifest_values; |
| 19 | 18 |
| 20 // static | 19 // static |
| 21 void extensions::ExtensionKeybindingRegistry::SetShortcutHandlingSuspended( | 20 void extensions::ExtensionKeybindingRegistry::SetShortcutHandlingSuspended( |
| 22 bool suspended) { | 21 bool suspended) { |
| 23 ExtensionKeybindingRegistryCocoa::set_shortcut_handling_suspended(suspended); | 22 ExtensionKeybindingRegistryCocoa::set_shortcut_handling_suspended(suspended); |
| 24 } | 23 } |
| 25 | 24 |
| 26 bool ExtensionKeybindingRegistryCocoa::shortcut_handling_suspended_ = false; | 25 bool ExtensionKeybindingRegistryCocoa::shortcut_handling_suspended_ = false; |
| 27 | 26 |
| 28 ExtensionKeybindingRegistryCocoa::ExtensionKeybindingRegistryCocoa( | 27 ExtensionKeybindingRegistryCocoa::ExtensionKeybindingRegistryCocoa( |
| 29 Profile* profile, | 28 Profile* profile, |
| 30 gfx::NativeWindow window, | 29 gfx::NativeWindow window, |
| 31 ExtensionFilter extension_filter) | 30 ExtensionFilter extension_filter, |
| 32 : ExtensionKeybindingRegistry(profile, extension_filter), | 31 Delegate* delegate) |
| 32 : ExtensionKeybindingRegistry(profile, extension_filter, delegate), |
| 33 profile_(profile), | 33 profile_(profile), |
| 34 window_(window) { | 34 window_(window) { |
| 35 Init(); | 35 Init(); |
| 36 } | 36 } |
| 37 | 37 |
| 38 ExtensionKeybindingRegistryCocoa::~ExtensionKeybindingRegistryCocoa() { | 38 ExtensionKeybindingRegistryCocoa::~ExtensionKeybindingRegistryCocoa() { |
| 39 } | 39 } |
| 40 | 40 |
| 41 bool ExtensionKeybindingRegistryCocoa::ProcessKeyEvent( | 41 bool ExtensionKeybindingRegistryCocoa::ProcessKeyEvent( |
| 42 const content::NativeWebKeyboardEvent& event) { | 42 const content::NativeWebKeyboardEvent& event) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 55 int type = 0; | 55 int type = 0; |
| 56 if (command_name == values::kPageActionCommandEvent) { | 56 if (command_name == values::kPageActionCommandEvent) { |
| 57 type = chrome::NOTIFICATION_EXTENSION_COMMAND_PAGE_ACTION_MAC; | 57 type = chrome::NOTIFICATION_EXTENSION_COMMAND_PAGE_ACTION_MAC; |
| 58 } else if (command_name == values::kBrowserActionCommandEvent) { | 58 } else if (command_name == values::kBrowserActionCommandEvent) { |
| 59 type = chrome::NOTIFICATION_EXTENSION_COMMAND_BROWSER_ACTION_MAC; | 59 type = chrome::NOTIFICATION_EXTENSION_COMMAND_BROWSER_ACTION_MAC; |
| 60 } else if (command_name == values::kScriptBadgeCommandEvent) { | 60 } else if (command_name == values::kScriptBadgeCommandEvent) { |
| 61 type = chrome::NOTIFICATION_EXTENSION_COMMAND_SCRIPT_BADGE_MAC; | 61 type = chrome::NOTIFICATION_EXTENSION_COMMAND_SCRIPT_BADGE_MAC; |
| 62 } else { | 62 } else { |
| 63 // Not handled by using notifications. Route it through the Browser Event | 63 // Not handled by using notifications. Route it through the Browser Event |
| 64 // Router. | 64 // Router. |
| 65 ExtensionService* service = profile_->GetExtensionService(); | 65 CommandExecuted(extension_id, command_name); |
| 66 service->browser_event_router()->CommandExecuted( | |
| 67 profile_, extension_id, command_name); | |
| 68 return true; | 66 return true; |
| 69 } | 67 } |
| 70 | 68 |
| 71 std::pair<const std::string, gfx::NativeWindow> details = | 69 std::pair<const std::string, gfx::NativeWindow> details = |
| 72 std::make_pair(extension_id, window_); | 70 std::make_pair(extension_id, window_); |
| 73 content::NotificationService::current()->Notify( | 71 content::NotificationService::current()->Notify( |
| 74 type, | 72 type, |
| 75 content::Source<Profile>(profile_), | 73 content::Source<Profile>(profile_), |
| 76 content::Details< | 74 content::Details< |
| 77 std::pair<const std::string, gfx::NativeWindow> >(&details)); | 75 std::pair<const std::string, gfx::NativeWindow> >(&details)); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 const extensions::Extension* extension, | 140 const extensions::Extension* extension, |
| 143 const std::string& command_name) { | 141 const std::string& command_name) { |
| 144 EventTargets::iterator iter = event_targets_.begin(); | 142 EventTargets::iterator iter = event_targets_.begin(); |
| 145 while (iter != event_targets_.end()) { | 143 while (iter != event_targets_.end()) { |
| 146 EventTargets::iterator old = iter++; | 144 EventTargets::iterator old = iter++; |
| 147 if (old->second.first == extension->id() && | 145 if (old->second.first == extension->id() && |
| 148 (command_name.empty() || (old->second.second == command_name))) | 146 (command_name.empty() || (old->second.second == command_name))) |
| 149 event_targets_.erase(old); | 147 event_targets_.erase(old); |
| 150 } | 148 } |
| 151 } | 149 } |
| OLD | NEW |