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

Unified Diff: chrome/browser/ui/cocoa/extensions/extension_view_mac.mm

Issue 8520036: Revert 110262 - Have ExtensionHost use TabContents instead of RenderViewHost. Try #2. (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 side-by-side diff with in-line comments
Download patch
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
« no previous file with comments | « chrome/browser/ui/cocoa/extensions/extension_view_mac.h ('k') | chrome/browser/ui/gtk/extensions/extension_view_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698