Chromium Code Reviews| 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_host_mac.h" | 5 #include "chrome/browser/extensions/extension_host_mac.h" |
| 6 | 6 |
| 7 #import "chrome/browser/ui/cocoa/chrome_event_processing_window.h" | 7 #import "chrome/browser/ui/cocoa/chrome_event_processing_window.h" |
| 8 #import "chrome/browser/ui/cocoa/extensions/extension_popup_controller.h" | 8 #import "chrome/browser/ui/cocoa/extensions/extension_popup_controller.h" |
| 9 #import "chrome/browser/ui/cocoa/info_bubble_window.h" | 9 #import "chrome/browser/ui/cocoa/info_bubble_window.h" |
| 10 #include "chrome/common/view_type.h" | |
| 11 #include "content/public/browser/native_web_keyboard_event.h" | 10 #include "content/public/browser/native_web_keyboard_event.h" |
| 12 | 11 |
| 13 using content::NativeWebKeyboardEvent; | 12 using content::NativeWebKeyboardEvent; |
| 14 | 13 |
| 15 namespace extensions { | 14 namespace extensions { |
| 16 | 15 |
| 17 ExtensionHostMac::~ExtensionHostMac() { | 16 ExtensionHostMac::~ExtensionHostMac() { |
| 18 // If there is a popup open for this host's extension, close it. | 17 // If there is a popup open for this host's extension, close it. |
| 19 ExtensionPopupController* popup = [ExtensionPopupController popup]; | 18 ExtensionPopupController* popup = [ExtensionPopupController popup]; |
| 20 if ([[popup window] isVisible] && | 19 if ([[popup window] isVisible] && |
| 21 [popup extensionHost]->extension() == this->extension()) { | 20 [popup extensionHost]->extension() == this->extension()) { |
| 22 InfoBubbleWindow* window = (InfoBubbleWindow*)[popup window]; | 21 InfoBubbleWindow* window = (InfoBubbleWindow*)[popup window]; |
| 23 [window setAllowedAnimations:info_bubble::kAnimateNone]; | 22 [window setAllowedAnimations:info_bubble::kAnimateNone]; |
| 24 [popup close]; | 23 [popup close]; |
| 25 } | 24 } |
| 26 } | 25 } |
| 27 | 26 |
| 28 void ExtensionHostMac::UnhandledKeyboardEvent( | 27 void ExtensionHostMac::UnhandledKeyboardEvent( |
| 29 content::WebContents* source, | 28 content::WebContents* source, |
| 30 const NativeWebKeyboardEvent& event) { | 29 const NativeWebKeyboardEvent& event) { |
| 31 if (event.skip_in_browser || event.type == NativeWebKeyboardEvent::Char || | 30 if (event.skip_in_browser || event.type == NativeWebKeyboardEvent::Char || |
| 32 extension_host_type() != chrome::VIEW_TYPE_EXTENSION_POPUP) { | 31 extension_host_type() != extensions::VIEW_TYPE_EXTENSION_POPUP) { |
|
Yoyo Zhou
2013/04/01 17:36:51
''
| |
| 33 return; | 32 return; |
| 34 } | 33 } |
| 35 | 34 |
| 36 ChromeEventProcessingWindow* event_window = | 35 ChromeEventProcessingWindow* event_window = |
| 37 static_cast<ChromeEventProcessingWindow*>([view()->native_view() window]); | 36 static_cast<ChromeEventProcessingWindow*>([view()->native_view() window]); |
| 38 DCHECK([event_window isKindOfClass:[ChromeEventProcessingWindow class]]); | 37 DCHECK([event_window isKindOfClass:[ChromeEventProcessingWindow class]]); |
| 39 [event_window redispatchKeyEvent:event.os_event]; | 38 [event_window redispatchKeyEvent:event.os_event]; |
| 40 } | 39 } |
| 41 | 40 |
| 42 } // namespace extensions | 41 } // namespace extensions |
| OLD | NEW |