| Index: chrome/browser/ui/cocoa/extensions/extension_view_mac.mm
|
| ===================================================================
|
| --- chrome/browser/ui/cocoa/extensions/extension_view_mac.mm (revision 110269)
|
| +++ chrome/browser/ui/cocoa/extensions/extension_view_mac.mm (working copy)
|
| @@ -5,12 +5,8 @@
|
| #include "chrome/browser/ui/cocoa/extensions/extension_view_mac.h"
|
|
|
| #include "chrome/browser/extensions/extension_host.h"
|
| -#include "chrome/browser/tab_contents/tab_contents_view_mac.h"
|
| #include "content/browser/renderer_host/render_view_host.h"
|
| -#include "content/browser/renderer_host/render_widget_host_view.h"
|
| #include "content/browser/renderer_host/render_widget_host_view_mac.h"
|
| -#include "content/browser/tab_contents/tab_contents.h"
|
| -#include "content/browser/tab_contents/tab_contents_view.h"
|
|
|
| // The minimum/maximum dimensions of the popup.
|
| const CGFloat ExtensionViewMac::kMinWidth = 25.0;
|
| @@ -21,12 +17,14 @@
|
| ExtensionViewMac::ExtensionViewMac(ExtensionHost* extension_host,
|
| Browser* browser)
|
| : browser_(browser),
|
| - extension_host_(extension_host) {
|
| + extension_host_(extension_host),
|
| + render_widget_host_view_(NULL) {
|
| DCHECK(extension_host_);
|
| - [native_view() setHidden:YES];
|
| }
|
|
|
| ExtensionViewMac::~ExtensionViewMac() {
|
| + if (render_widget_host_view_)
|
| + [render_widget_host_view_->native_view() release];
|
| }
|
|
|
| void ExtensionViewMac::Init() {
|
| @@ -34,33 +32,26 @@
|
| }
|
|
|
| gfx::NativeView ExtensionViewMac::native_view() {
|
| - return extension_host_->host_contents()->view()->GetNativeView();
|
| + DCHECK(render_widget_host_view_);
|
| + return render_widget_host_view_->native_view();
|
| }
|
|
|
| RenderViewHost* ExtensionViewMac::render_view_host() const {
|
| return extension_host_->render_view_host();
|
| }
|
|
|
| -void ExtensionViewMac::DidStopLoading() {
|
| - ShowIfCompletelyLoaded();
|
| -}
|
| -
|
| void ExtensionViewMac::SetBackground(const SkBitmap& background) {
|
| - if (!pending_background_.empty() && render_view_host()->view()) {
|
| - render_view_host()->view()->SetBackground(background);
|
| + DCHECK(render_widget_host_view_);
|
| + if (render_view_host()->IsRenderViewLive()) {
|
| + render_widget_host_view_->SetBackground(background);
|
| } else {
|
| pending_background_ = background;
|
| }
|
| - ShowIfCompletelyLoaded();
|
| }
|
|
|
| void ExtensionViewMac::UpdatePreferredSize(const gfx::Size& new_size) {
|
| - // When we update the size, our container becomes visible. Stay hidden until
|
| - // the host is loaded.
|
| - if (!extension_host_->did_stop_loading()) {
|
| - pending_preferred_size_ = new_size;
|
| - return;
|
| - }
|
| + // TODO(thakis, erikkay): Windows does some tricks to resize the extension
|
| + // view not before it's visible. Do something similar here.
|
|
|
| // No need to use CA here, our caller calls us repeatedly to animate the
|
| // resizing.
|
| @@ -80,10 +71,10 @@
|
| if (NSIsEmptyRect(frame))
|
| return;
|
|
|
| - DCHECK([view isKindOfClass:[TabContentsViewCocoa class]]);
|
| - TabContentsViewCocoa* hostView = (TabContentsViewCocoa*)view;
|
| + DCHECK([view isKindOfClass:[RenderWidgetHostViewCocoa class]]);
|
| + RenderWidgetHostViewCocoa* hostView = (RenderWidgetHostViewCocoa*)view;
|
|
|
| - // TabContentsViewCocoa overrides setFrame but not setFrameSize.
|
| + // RenderWidgetHostViewCocoa overrides setFrame but not setFrameSize.
|
| // We need to defer the update back to the RenderWidgetHost so we don't
|
| // get the flickering effect on 10.5 of http://crbug.com/31970
|
| [hostView setFrameWithDeferredUpdate:frame];
|
| @@ -100,25 +91,24 @@
|
| extension_host_->DisableScrollbarsForSmallWindows(largest_popup_size);
|
|
|
| if (!pending_background_.empty() && render_view_host()->view()) {
|
| - render_view_host()->view()->SetBackground(pending_background_);
|
| + render_widget_host_view_->SetBackground(pending_background_);
|
| pending_background_.reset();
|
| }
|
| }
|
|
|
| void ExtensionViewMac::WindowFrameChanged() {
|
| - if (render_view_host()->view())
|
| - render_view_host()->view()->WindowFrameChanged();
|
| + if (render_widget_host_view_)
|
| + render_widget_host_view_->WindowFrameChanged();
|
| }
|
|
|
| void ExtensionViewMac::CreateWidgetHostView() {
|
| - extension_host_->CreateRenderViewSoon();
|
| -}
|
| + DCHECK(!render_widget_host_view_);
|
| + render_widget_host_view_ = new RenderWidgetHostViewMac(render_view_host());
|
|
|
| -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];
|
| - UpdatePreferredSize(pending_preferred_size_);
|
| - }
|
| + // The RenderWidgetHostViewMac is owned by its native view, which is created
|
| + // in an autoreleased state. retain it, so that it doesn't immediately
|
| + // disappear.
|
| + [render_widget_host_view_->native_view() retain];
|
| +
|
| + extension_host_->CreateRenderViewSoon(render_widget_host_view_);
|
| }
|
|
|
| Property changes on: chrome/browser/ui/cocoa/extensions/extension_view_mac.mm
|
| ___________________________________________________________________
|
| Added: svn:mergeinfo
|
|
|
|
|