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