Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: chrome/browser/ui/cocoa/extensions/extension_keybinding_registry_cocoa.mm

Issue 10880064: Make extension commands grant the activeTab permission. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update GTK with the TabContents changes Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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" 9 #include "chrome/browser/extensions/browser_event_router.h"
Finnur 2012/09/21 10:07:00 Can this be removed now?
not at google - send to devlin 2012/09/23 23:53:18 Done.
10 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
11 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/common/extensions/extension.h" 12 #include "chrome/common/extensions/extension.h"
13 #include "chrome/common/chrome_notification_types.h" 13 #include "chrome/common/chrome_notification_types.h"
14 #include "chrome/common/extensions/extension_manifest_constants.h" 14 #include "chrome/common/extensions/extension_manifest_constants.h"
15 #include "content/public/browser/native_web_keyboard_event.h" 15 #include "content/public/browser/native_web_keyboard_event.h"
16 #include "content/public/browser/notification_service.h" 16 #include "content/public/browser/notification_service.h"
17 17
18 namespace values = extension_manifest_values; 18 namespace values = extension_manifest_values;
19 19
20 // static 20 // static
21 void extensions::ExtensionKeybindingRegistry::SetShortcutHandlingSuspended( 21 void extensions::ExtensionKeybindingRegistry::SetShortcutHandlingSuspended(
22 bool suspended) { 22 bool suspended) {
23 ExtensionKeybindingRegistryCocoa::set_shortcut_handling_suspended(suspended); 23 ExtensionKeybindingRegistryCocoa::set_shortcut_handling_suspended(suspended);
24 } 24 }
25 25
26 bool ExtensionKeybindingRegistryCocoa::shortcut_handling_suspended_ = false; 26 bool ExtensionKeybindingRegistryCocoa::shortcut_handling_suspended_ = false;
27 27
28 ExtensionKeybindingRegistryCocoa::ExtensionKeybindingRegistryCocoa( 28 ExtensionKeybindingRegistryCocoa::ExtensionKeybindingRegistryCocoa(
29 Profile* profile, 29 Profile* profile,
30 gfx::NativeWindow window, 30 gfx::NativeWindow window,
31 ExtensionFilter extension_filter) 31 ExtensionFilter extension_filter,
32 : ExtensionKeybindingRegistry(profile, extension_filter), 32 Delegate* delegate)
33 : ExtensionKeybindingRegistry(profile, extension_filter, delegate),
33 profile_(profile), 34 profile_(profile),
34 window_(window) { 35 window_(window) {
35 Init(); 36 Init();
36 } 37 }
37 38
38 ExtensionKeybindingRegistryCocoa::~ExtensionKeybindingRegistryCocoa() { 39 ExtensionKeybindingRegistryCocoa::~ExtensionKeybindingRegistryCocoa() {
39 } 40 }
40 41
41 bool ExtensionKeybindingRegistryCocoa::ProcessKeyEvent( 42 bool ExtensionKeybindingRegistryCocoa::ProcessKeyEvent(
42 const content::NativeWebKeyboardEvent& event) { 43 const content::NativeWebKeyboardEvent& event) {
(...skipping 12 matching lines...) Expand all
55 int type = 0; 56 int type = 0;
56 if (command_name == values::kPageActionCommandEvent) { 57 if (command_name == values::kPageActionCommandEvent) {
57 type = chrome::NOTIFICATION_EXTENSION_COMMAND_PAGE_ACTION_MAC; 58 type = chrome::NOTIFICATION_EXTENSION_COMMAND_PAGE_ACTION_MAC;
58 } else if (command_name == values::kBrowserActionCommandEvent) { 59 } else if (command_name == values::kBrowserActionCommandEvent) {
59 type = chrome::NOTIFICATION_EXTENSION_COMMAND_BROWSER_ACTION_MAC; 60 type = chrome::NOTIFICATION_EXTENSION_COMMAND_BROWSER_ACTION_MAC;
60 } else if (command_name == values::kScriptBadgeCommandEvent) { 61 } else if (command_name == values::kScriptBadgeCommandEvent) {
61 type = chrome::NOTIFICATION_EXTENSION_COMMAND_SCRIPT_BADGE_MAC; 62 type = chrome::NOTIFICATION_EXTENSION_COMMAND_SCRIPT_BADGE_MAC;
62 } else { 63 } else {
63 // Not handled by using notifications. Route it through the Browser Event 64 // Not handled by using notifications. Route it through the Browser Event
64 // Router. 65 // Router.
65 ExtensionService* service = profile_->GetExtensionService(); 66 CommandExecuted(extension_id, command_name);
66 service->browser_event_router()->CommandExecuted(
67 profile_, extension_id, command_name);
68 return true; 67 return true;
69 } 68 }
70 69
71 std::pair<const std::string, gfx::NativeWindow> details = 70 std::pair<const std::string, gfx::NativeWindow> details =
72 std::make_pair(extension_id, window_); 71 std::make_pair(extension_id, window_);
73 content::NotificationService::current()->Notify( 72 content::NotificationService::current()->Notify(
74 type, 73 type,
75 content::Source<Profile>(profile_), 74 content::Source<Profile>(profile_),
76 content::Details< 75 content::Details<
77 std::pair<const std::string, gfx::NativeWindow> >(&details)); 76 std::pair<const std::string, gfx::NativeWindow> >(&details));
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 const extensions::Extension* extension, 141 const extensions::Extension* extension,
143 const std::string& command_name) { 142 const std::string& command_name) {
144 EventTargets::iterator iter = event_targets_.begin(); 143 EventTargets::iterator iter = event_targets_.begin();
145 while (iter != event_targets_.end()) { 144 while (iter != event_targets_.end()) {
146 EventTargets::iterator old = iter++; 145 EventTargets::iterator old = iter++;
147 if (old->second.first == extension->id() && 146 if (old->second.first == extension->id() &&
148 (command_name.empty() || (old->second.second == command_name))) 147 (command_name.empty() || (old->second.second == command_name)))
149 event_targets_.erase(old); 148 event_targets_.erase(old);
150 } 149 }
151 } 150 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698