Index: chrome/browser/ui/cocoa/extensions/extension_view_mac.mm |
diff --git a/chrome/browser/ui/cocoa/extensions/extension_view_mac.mm b/chrome/browser/ui/cocoa/extensions/extension_view_mac.mm |
index f0a61c27a6290c4a41ec058c4e130a61020036ce..f888d4e66ea2ac65c37a0c823cd6bf9df45be524 100644 |
--- a/chrome/browser/ui/cocoa/extensions/extension_view_mac.mm |
+++ b/chrome/browser/ui/cocoa/extensions/extension_view_mac.mm |
@@ -2,10 +2,12 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#import <Cocoa/Cocoa.h> |
- |
#include "chrome/browser/ui/cocoa/extensions/extension_view_mac.h" |
+#import <Cocoa/Cocoa.h> |
+ |
+#include "chrome/browser/extensions/extension_view_host.h" |
+#import "chrome/browser/ui/cocoa/chrome_event_processing_window.h" |
#include "content/public/browser/render_view_host.h" |
#include "content/public/browser/render_widget_host_view.h" |
#include "content/public/browser/web_contents.h" |
@@ -24,26 +26,45 @@ ExtensionViewMac::ExtensionViewMac(extensions::ExtensionHost* extension_host, |
extension_host_(extension_host), |
container_(NULL) { |
DCHECK(extension_host_); |
- [native_view() setHidden:YES]; |
+ [GetNativeView() setHidden:YES]; |
} |
ExtensionViewMac::~ExtensionViewMac() { |
} |
-void ExtensionViewMac::Init() { |
- CreateWidgetHostView(); |
+content::RenderViewHost* ExtensionViewMac::render_view_host() const { |
Robert Sesek
2014/07/08 12:50:37
nit: implementation order should match header orde
tapted
2014/07/08 23:54:58
Done.
|
+ return extension_host_->render_view_host(); |
} |
-gfx::NativeView ExtensionViewMac::native_view() { |
- return extension_host_->host_contents()->GetNativeView(); |
+void ExtensionViewMac::WindowFrameChanged() { |
+ if (render_view_host()->GetView()) |
+ render_view_host()->GetView()->WindowFrameChanged(); |
} |
-content::RenderViewHost* ExtensionViewMac::render_view_host() const { |
- return extension_host_->render_view_host(); |
+void ExtensionViewMac::CreateWidgetHostView() { |
+ extension_host_->CreateRenderViewSoon(); |
} |
-void ExtensionViewMac::DidStopLoading() { |
- ShowIfCompletelyLoaded(); |
+void ExtensionViewMac::ShowIfCompletelyLoaded() { |
+ // We wait to show the ExtensionView until it has loaded, and the view has |
+ // actually been created. These can happen in different orders. |
+ if (extension_host_->did_stop_loading()) { |
+ [GetNativeView() setHidden:NO]; |
+ if (container_) |
+ container_->OnExtensionViewDidShow(this); |
+ } |
+} |
+ |
+void ExtensionViewMac::Init() { |
+ CreateWidgetHostView(); |
+} |
+ |
+Browser* ExtensionViewMac::GetBrowser() { |
+ return browser_; |
+} |
+ |
+gfx::NativeView ExtensionViewMac::GetNativeView() { |
+ return extension_host_->host_contents()->GetNativeView(); |
} |
void ExtensionViewMac::ResizeDueToAutoResize(const gfx::Size& new_size) { |
@@ -62,21 +83,33 @@ void ExtensionViewMac::RenderViewCreated() { |
} |
} |
-void ExtensionViewMac::WindowFrameChanged() { |
- if (render_view_host()->GetView()) |
- render_view_host()->GetView()->WindowFrameChanged(); |
+void ExtensionViewMac::HandleKeyboardEvent( |
+ content::WebContents* source, |
+ const content::NativeWebKeyboardEvent& event) { |
+ if (event.skip_in_browser || |
+ event.type == content::NativeWebKeyboardEvent::Char || |
+ extension_host_->extension_host_type() != |
+ extensions::VIEW_TYPE_EXTENSION_POPUP) |
+ return; |
+ |
+ ChromeEventProcessingWindow* event_window = |
+ static_cast<ChromeEventProcessingWindow*>([GetNativeView() window]); |
Robert Sesek
2014/07/08 12:50:37
Can use ObjCCastStrict here.
tapted
2014/07/08 23:54:58
Done.
|
+ DCHECK([event_window isKindOfClass:[ChromeEventProcessingWindow class]]); |
+ [event_window redispatchKeyEvent:event.os_event]; |
} |
-void ExtensionViewMac::CreateWidgetHostView() { |
- extension_host_->CreateRenderViewSoon(); |
+void ExtensionViewMac::DidStopLoading() { |
+ ShowIfCompletelyLoaded(); |
} |
-void ExtensionViewMac::ShowIfCompletelyLoaded() { |
- // We wait to show the ExtensionView until it has loaded, and the view has |
- // actually been created. These can happen in different orders. |
- if (extension_host_->did_stop_loading()) { |
- [native_view() setHidden:NO]; |
- if (container_) |
- container_->OnExtensionViewDidShow(this); |
- } |
+namespace extensions { |
+ |
+// static |
+scoped_ptr<ExtensionView> ExtensionViewHost::CreateExtensionView( |
+ ExtensionViewHost* host, |
+ Browser* browser) { |
+ scoped_ptr<ExtensionViewMac> view(new ExtensionViewMac(host, browser)); |
+ return view.PassAs<ExtensionView>(); |
} |
+ |
+} // namespace extensions |