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

Side by Side Diff: chrome/browser/extensions/extension_host_mac.mm

Issue 8587001: Have ExtensionHost use TabContents instead of RenderViewHost. Try #3. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/chrome_view_types.h" 10 #include "chrome/common/chrome_view_types.h"
11 #include "content/browser/renderer_host/render_widget_host_view_mac.h" 11 #include "content/browser/renderer_host/render_widget_host_view_mac.h"
12 #include "content/public/browser/native_web_keyboard_event.h" 12 #include "content/public/browser/native_web_keyboard_event.h"
13 13
14 ExtensionHostMac::~ExtensionHostMac() { 14 ExtensionHostMac::~ExtensionHostMac() {
15 // If there is a popup open for this host's extension, close it. 15 // If there is a popup open for this host's extension, close it.
16 ExtensionPopupController* popup = [ExtensionPopupController popup]; 16 ExtensionPopupController* popup = [ExtensionPopupController popup];
17 if ([[popup window] isVisible] && 17 if ([[popup window] isVisible] &&
18 [popup extensionHost]->extension() == this->extension()) { 18 [popup extensionHost]->extension() == this->extension()) {
19 InfoBubbleWindow* window = (InfoBubbleWindow*)[popup window]; 19 InfoBubbleWindow* window = (InfoBubbleWindow*)[popup window];
20 [window setDelayOnClose:NO]; 20 [window setDelayOnClose:NO];
21 [popup close]; 21 [popup close];
22 } 22 }
23 } 23 }
24 24
25 RenderWidgetHostView* ExtensionHostMac::CreateNewWidgetInternal(
26 int route_id,
27 WebKit::WebPopupType popup_type) {
28 // A RenderWidgetHostViewMac has lifetime scoped to the view. We'll retain it
29 // to allow it to survive the trip without being hosed.
30 RenderWidgetHostView* widget_view =
31 ExtensionHost::CreateNewWidgetInternal(route_id, popup_type);
32 RenderWidgetHostViewMac* widget_view_mac =
33 static_cast<RenderWidgetHostViewMac*>(widget_view);
34 [widget_view_mac->native_view() retain];
35
36 return widget_view;
37 }
38
39 void ExtensionHostMac::ShowCreatedWidgetInternal(
40 RenderWidgetHostView* widget_host_view,
41 const gfx::Rect& initial_pos) {
42 ExtensionHost::ShowCreatedWidgetInternal(widget_host_view, initial_pos);
43
44 // A RenderWidgetHostViewMac has lifetime scoped to the view. Now that it's
45 // properly embedded (or purposefully ignored) we can release the reference we
46 // took in CreateNewWidgetInternal().
47 RenderWidgetHostViewMac* widget_view_mac =
48 static_cast<RenderWidgetHostViewMac*>(widget_host_view);
49 [widget_view_mac->native_view() release];
50 }
51
52 void ExtensionHostMac::UnhandledKeyboardEvent( 25 void ExtensionHostMac::UnhandledKeyboardEvent(
53 const NativeWebKeyboardEvent& event) { 26 const NativeWebKeyboardEvent& event) {
54 if (event.skip_in_browser || event.type == NativeWebKeyboardEvent::Char || 27 if (event.skip_in_browser || event.type == NativeWebKeyboardEvent::Char ||
55 extension_host_type() != chrome::VIEW_TYPE_EXTENSION_POPUP) { 28 extension_host_type() != chrome::VIEW_TYPE_EXTENSION_POPUP) {
56 return; 29 return;
57 } 30 }
58 31
59 ChromeEventProcessingWindow* event_window = 32 ChromeEventProcessingWindow* event_window =
60 static_cast<ChromeEventProcessingWindow*>([view()->native_view() window]); 33 static_cast<ChromeEventProcessingWindow*>([view()->native_view() window]);
61 DCHECK([event_window isKindOfClass:[ChromeEventProcessingWindow class]]); 34 DCHECK([event_window isKindOfClass:[ChromeEventProcessingWindow class]]);
62 [event_window redispatchKeyEvent:event.os_event]; 35 [event_window redispatchKeyEvent:event.os_event];
63 } 36 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698