Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / extensions / extension_view_host_mac.mm
blobee78305836099e4eb8dedee9ceac40ba3bbb3ebb
1 // Copyright 2013 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.
5 #include "chrome/browser/extensions/extension_view_host_mac.h"
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"
12 using content::NativeWebKeyboardEvent;
14 namespace extensions {
16 ExtensionViewHostMac::~ExtensionViewHostMac() {
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 extensionViewHost]->extension() == this->extension()) {
21     InfoBubbleWindow* window = (InfoBubbleWindow*)[popup window];
22     [window setAllowedAnimations:info_bubble::kAnimateNone];
23     [popup close];
24   }
27 void ExtensionViewHostMac::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   }
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];
41 }  // namespace extensions