| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/cocoa/chrome_event_processing_window.h" | 7 #import "chrome/browser/cocoa/chrome_event_processing_window.h" |
| 8 #import "chrome/browser/cocoa/extensions/extension_popup_controller.h" | 8 #import "chrome/browser/cocoa/extensions/extension_popup_controller.h" |
| 9 #import "chrome/browser/cocoa/info_bubble_window.h" | 9 #import "chrome/browser/cocoa/info_bubble_window.h" |
| 10 #include "chrome/browser/renderer_host/render_widget_host_view_mac.h" | 10 #include "chrome/browser/renderer_host/render_widget_host_view_mac.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 int route_id, | 24 int route_id, |
| 25 WebKit::WebPopupType popup_type) { | 25 WebKit::WebPopupType popup_type) { |
| 26 // A RenderWidgetHostViewMac has lifetime scoped to the view. We'll retain it | 26 // A RenderWidgetHostViewMac has lifetime scoped to the view. We'll retain it |
| 27 // to allow it to survive the trip without being hosed. | 27 // to allow it to survive the trip without being hosed. |
| 28 RenderWidgetHostView* widget_view = | 28 RenderWidgetHostView* widget_view = |
| 29 ExtensionHost::CreateNewWidgetInternal(route_id, popup_type); | 29 ExtensionHost::CreateNewWidgetInternal(route_id, popup_type); |
| 30 RenderWidgetHostViewMac* widget_view_mac = | 30 RenderWidgetHostViewMac* widget_view_mac = |
| 31 static_cast<RenderWidgetHostViewMac*>(widget_view); | 31 static_cast<RenderWidgetHostViewMac*>(widget_view); |
| 32 [widget_view_mac->native_view() retain]; | 32 [widget_view_mac->native_view() retain]; |
| 33 | 33 |
| 34 // |widget_view_mac| needs to know how to position itself in our view. | |
| 35 widget_view_mac->set_parent_view(view()->native_view()); | |
| 36 | |
| 37 return widget_view; | 34 return widget_view; |
| 38 } | 35 } |
| 39 | 36 |
| 40 void ExtensionHostMac::ShowCreatedWidgetInternal( | 37 void ExtensionHostMac::ShowCreatedWidgetInternal( |
| 41 RenderWidgetHostView* widget_host_view, | 38 RenderWidgetHostView* widget_host_view, |
| 42 const gfx::Rect& initial_pos) { | 39 const gfx::Rect& initial_pos) { |
| 43 ExtensionHost::ShowCreatedWidgetInternal(widget_host_view, initial_pos); | 40 ExtensionHost::ShowCreatedWidgetInternal(widget_host_view, initial_pos); |
| 44 | 41 |
| 45 // A RenderWidgetHostViewMac has lifetime scoped to the view. Now that it's | 42 // A RenderWidgetHostViewMac has lifetime scoped to the view. Now that it's |
| 46 // properly embedded (or purposefully ignored) we can release the reference we | 43 // properly embedded (or purposefully ignored) we can release the reference we |
| 47 // took in CreateNewWidgetInternal(). | 44 // took in CreateNewWidgetInternal(). |
| 48 RenderWidgetHostViewMac* widget_view_mac = | 45 RenderWidgetHostViewMac* widget_view_mac = |
| 49 static_cast<RenderWidgetHostViewMac*>(widget_host_view); | 46 static_cast<RenderWidgetHostViewMac*>(widget_host_view); |
| 50 [widget_view_mac->native_view() release]; | 47 [widget_view_mac->native_view() release]; |
| 51 } | 48 } |
| 52 | 49 |
| 53 void ExtensionHostMac::UnhandledKeyboardEvent( | 50 void ExtensionHostMac::UnhandledKeyboardEvent( |
| 54 const NativeWebKeyboardEvent& event) { | 51 const NativeWebKeyboardEvent& event) { |
| 55 if (event.skip_in_browser || event.type == NativeWebKeyboardEvent::Char || | 52 if (event.skip_in_browser || event.type == NativeWebKeyboardEvent::Char || |
| 56 extension_host_type() != ViewType::EXTENSION_POPUP) { | 53 extension_host_type() != ViewType::EXTENSION_POPUP) { |
| 57 return; | 54 return; |
| 58 } | 55 } |
| 59 | 56 |
| 60 ChromeEventProcessingWindow* event_window = | 57 ChromeEventProcessingWindow* event_window = |
| 61 static_cast<ChromeEventProcessingWindow*>([view()->native_view() window]); | 58 static_cast<ChromeEventProcessingWindow*>([view()->native_view() window]); |
| 62 DCHECK([event_window isKindOfClass:[ChromeEventProcessingWindow class]]); | 59 DCHECK([event_window isKindOfClass:[ChromeEventProcessingWindow class]]); |
| 63 [event_window redispatchKeyEvent:event.os_event]; | 60 [event_window redispatchKeyEvent:event.os_event]; |
| 64 } | 61 } |
| OLD | NEW |