blob: 3239ebd8244633ffc629eb0a7d60468c3ddc6ad7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/extensions/extension_host_mac.h"
#import "chrome/browser/cocoa/chrome_event_processing_window.h"
#import "chrome/browser/cocoa/extensions/extension_popup_controller.h"
#import "chrome/browser/cocoa/info_bubble_window.h"
#include "chrome/browser/renderer_host/render_widget_host_view_mac.h"
#include "chrome/common/native_web_keyboard_event.h"
ExtensionHostMac::~ExtensionHostMac() {
// If there is a popup open for this host's extension, close it.
ExtensionPopupController* popup = [ExtensionPopupController popup];
if (popup && [popup extensionHost]->extension() == this->extension()) {
InfoBubbleWindow* window = (InfoBubbleWindow*)[popup window];
[window setDelayOnClose:NO];
[popup close];
}
}
RenderWidgetHostView* ExtensionHostMac::CreateNewWidgetInternal(
int route_id,
WebKit::WebPopupType popup_type) {
// A RenderWidgetHostViewMac has lifetime scoped to the view. We'll retain it
// to allow it to survive the trip without being hosed.
RenderWidgetHostView* widget_view =
ExtensionHost::CreateNewWidgetInternal(route_id, popup_type);
RenderWidgetHostViewMac* widget_view_mac =
static_cast<RenderWidgetHostViewMac*>(widget_view);
[widget_view_mac->native_view() retain];
// |widget_view_mac| needs to know how to position itself in our view.
widget_view_mac->set_parent_view(view()->native_view());
return widget_view;
}
void ExtensionHostMac::ShowCreatedWidgetInternal(
RenderWidgetHostView* widget_host_view,
const gfx::Rect& initial_pos) {
ExtensionHost::ShowCreatedWidgetInternal(widget_host_view, initial_pos);
// A RenderWidgetHostViewMac has lifetime scoped to the view. Now that it's
// properly embedded (or purposefully ignored) we can release the reference we
// took in CreateNewWidgetInternal().
RenderWidgetHostViewMac* widget_view_mac =
static_cast<RenderWidgetHostViewMac*>(widget_host_view);
[widget_view_mac->native_view() release];
}
void ExtensionHostMac::UnhandledKeyboardEvent(
const NativeWebKeyboardEvent& event) {
if (event.skip_in_browser || event.type == NativeWebKeyboardEvent::Char ||
extension_host_type() != ViewType::EXTENSION_POPUP) {
return;
}
ChromeEventProcessingWindow* event_window =
static_cast<ChromeEventProcessingWindow*>([view()->native_view() window]);
DCHECK([event_window isKindOfClass:[ChromeEventProcessingWindow class]]);
[event_window redispatchKeyEvent:event.os_event];
}
|