summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-06 23:02:56 +0000
committermpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-06 23:02:56 +0000
commit55e2fb2271a1d02ce157909b870c2e18b5ffa390 (patch)
tree9f4ae1e4c1e93104c949206a6d95e6f4f5aa99be
parent83c5a17bb1eb1222dad0f01a1864e3776e0998dc (diff)
downloadchromium_src-55e2fb2271a1d02ce157909b870c2e18b5ffa390.zip
chromium_src-55e2fb2271a1d02ce157909b870c2e18b5ffa390.tar.gz
chromium_src-55e2fb2271a1d02ce157909b870c2e18b5ffa390.tar.bz2
Fix a regression with setting the toolstrip background.
BUG=23458 TEST=Load an extension with a toolstrip. The toolstrip's background should match the shelf's background for your theme. Review URL: http://codereview.chromium.org/243114 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28177 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/cocoa/extension_view_mac.h9
-rw-r--r--chrome/browser/cocoa/extension_view_mac.mm13
-rw-r--r--chrome/browser/extensions/extension_host.cc3
-rw-r--r--chrome/browser/gtk/extension_view_gtk.cc13
-rw-r--r--chrome/browser/gtk/extension_view_gtk.h9
-rw-r--r--chrome/browser/views/extensions/extension_view.cc16
-rw-r--r--chrome/browser/views/extensions/extension_view.h4
7 files changed, 58 insertions, 9 deletions
diff --git a/chrome/browser/cocoa/extension_view_mac.h b/chrome/browser/cocoa/extension_view_mac.h
index e358d1b..f162fd7 100644
--- a/chrome/browser/cocoa/extension_view_mac.h
+++ b/chrome/browser/cocoa/extension_view_mac.h
@@ -7,6 +7,7 @@
#include "base/basictypes.h"
#include "base/gfx/native_widget_types.h"
+#include "third_party/skia/include/core/SkBitmap.h"
class Browser;
class ExtensionHost;
@@ -43,6 +44,10 @@ class ExtensionViewMac {
// extension contents.
void UpdatePreferredWidth(int pref_width);
+ // Method for the ExtensionHost to notify us when the RenderViewHost has a
+ // connection.
+ void RenderViewCreated();
+
private:
RenderViewHost* render_view_host() const;
@@ -59,6 +64,10 @@ class ExtensionViewMac {
// rwhv's native view in our destructor, effectively freeing this.
RenderWidgetHostViewMac* render_widget_host_view_;
+ // The background the view should have once it is initialized. This is set
+ // when the view has a custom background, but hasn't been initialized yet.
+ SkBitmap pending_background_;
+
DISALLOW_COPY_AND_ASSIGN(ExtensionViewMac);
};
diff --git a/chrome/browser/cocoa/extension_view_mac.mm b/chrome/browser/cocoa/extension_view_mac.mm
index b8e11f7..53db3f2 100644
--- a/chrome/browser/cocoa/extension_view_mac.mm
+++ b/chrome/browser/cocoa/extension_view_mac.mm
@@ -37,7 +37,11 @@ RenderViewHost* ExtensionViewMac::render_view_host() const {
void ExtensionViewMac::SetBackground(const SkBitmap& background) {
DCHECK(render_widget_host_view_);
- render_widget_host_view_->SetBackground(background);
+ if (render_view_host()->IsRenderViewLive()) {
+ render_widget_host_view_->SetBackground(background);
+ } else {
+ pending_background_ = background;
+ }
}
void ExtensionViewMac::UpdatePreferredWidth(int pref_width) {
@@ -55,6 +59,13 @@ void ExtensionViewMac::UpdatePreferredWidth(int pref_width) {
[view setNeedsDisplay:YES];
}
+void ExtensionViewMac::RenderViewCreated() {
+ if (!pending_background_.empty()) {
+ render_widget_host_view_->SetBackground(pending_background_);
+ pending_background_.reset();
+ }
+}
+
void ExtensionViewMac::CreateWidgetHostView() {
DCHECK(!render_widget_host_view_);
render_widget_host_view_ = new RenderWidgetHostViewMac(render_view_host());
diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc
index 8bad4ce..f69068f 100644
--- a/chrome/browser/extensions/extension_host.cc
+++ b/chrome/browser/extensions/extension_host.cc
@@ -490,6 +490,9 @@ ViewType::Type ExtensionHost::GetRenderViewType() const {
}
void ExtensionHost::RenderViewCreated(RenderViewHost* render_view_host) {
+ if (view_.get())
+ view_->RenderViewCreated();
+
// TODO(mpcomplete): This is duplicated in DidNavigate, which means that
// we'll create 2 EFDs for the first navigation. We should try to find a
// better way to unify them.
diff --git a/chrome/browser/gtk/extension_view_gtk.cc b/chrome/browser/gtk/extension_view_gtk.cc
index b6bb3a4..2f3d48d 100644
--- a/chrome/browser/gtk/extension_view_gtk.cc
+++ b/chrome/browser/gtk/extension_view_gtk.cc
@@ -29,7 +29,11 @@ RenderViewHost* ExtensionViewGtk::render_view_host() const {
}
void ExtensionViewGtk::SetBackground(const SkBitmap& background) {
- render_widget_host_view_->SetBackground(background);
+ if (render_view_host()->IsRenderViewLive()) {
+ render_widget_host_view_->SetBackground(background);
+ } else {
+ pending_background_ = background;
+ }
}
void ExtensionViewGtk::UpdatePreferredWidth(int pref_width) {
@@ -43,3 +47,10 @@ void ExtensionViewGtk::CreateWidgetHostView() {
extension_host_->CreateRenderViewSoon(render_widget_host_view_);
}
+
+void ExtensionViewGtk::RenderViewCreated() {
+ if (!pending_background_.empty()) {
+ render_widget_host_view_->SetBackground(pending_background_);
+ pending_background_.reset();
+ }
+}
diff --git a/chrome/browser/gtk/extension_view_gtk.h b/chrome/browser/gtk/extension_view_gtk.h
index 7612c94..2ae49c2 100644
--- a/chrome/browser/gtk/extension_view_gtk.h
+++ b/chrome/browser/gtk/extension_view_gtk.h
@@ -7,6 +7,7 @@
#include "base/basictypes.h"
#include "base/gfx/native_widget_types.h"
+#include "third_party/skia/include/core/SkBitmap.h"
class Browser;
class ExtensionHost;
@@ -32,6 +33,10 @@ class ExtensionViewGtk {
// extension contents.
void UpdatePreferredWidth(int pref_width);
+ // Method for the ExtensionHost to notify us when the RenderViewHost has a
+ // connection.
+ void RenderViewCreated();
+
private:
RenderViewHost* render_view_host() const;
@@ -46,6 +51,10 @@ class ExtensionViewGtk {
RenderWidgetHostViewGtk* render_widget_host_view_;
+ // The background the view should have once it is initialized. This is set
+ // when the view has a custom background, but hasn't been initialized yet.
+ SkBitmap pending_background_;
+
DISALLOW_COPY_AND_ASSIGN(ExtensionViewGtk);
};
diff --git a/chrome/browser/views/extensions/extension_view.cc b/chrome/browser/views/extensions/extension_view.cc
index 20fc7b1..2915235 100644
--- a/chrome/browser/views/extensions/extension_view.cc
+++ b/chrome/browser/views/extensions/extension_view.cc
@@ -95,11 +95,6 @@ void ExtensionView::CreateWidgetHostView() {
host_->CreateRenderViewSoon(view);
SetVisible(false);
-
- if (!pending_background_.empty()) {
- render_view_host()->view()->SetBackground(pending_background_);
- pending_background_.reset();
- }
}
void ExtensionView::ShowIfCompletelyLoaded() {
@@ -108,7 +103,7 @@ void ExtensionView::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 (host_->did_stop_loading() && initialized_) {
+ if (host_->did_stop_loading()) {
// For toolstrips, also wait until our parent has given us a background.
if (host_->GetRenderViewType() == ViewType::EXTENSION_TOOLSTRIP &&
render_view_host()->view()->background().empty()) {
@@ -128,7 +123,7 @@ void ExtensionView::CleanUp() {
}
void ExtensionView::SetBackground(const SkBitmap& background) {
- if (initialized_ && render_view_host()->view()) {
+ if (render_view_host()->IsRenderViewLive() && render_view_host()->view()) {
render_view_host()->view()->SetBackground(background);
} else {
pending_background_ = background;
@@ -166,3 +161,10 @@ void ExtensionView::HandleMouseLeave() {
if (container_)
container_->OnExtensionMouseLeave(this);
}
+
+void ExtensionView::RenderViewCreated() {
+ if (!pending_background_.empty()) {
+ render_view_host()->view()->SetBackground(pending_background_);
+ pending_background_.reset();
+ }
+}
diff --git a/chrome/browser/views/extensions/extension_view.h b/chrome/browser/views/extensions/extension_view.h
index 3eceee0..39b5851 100644
--- a/chrome/browser/views/extensions/extension_view.h
+++ b/chrome/browser/views/extensions/extension_view.h
@@ -44,6 +44,10 @@ class ExtensionView : public views::NativeViewHost {
void HandleMouseEvent();
void HandleMouseLeave();
+ // Method for the ExtensionHost to notify us when the RenderViewHost has a
+ // connection.
+ void RenderViewCreated();
+
// Set a custom background for the view. The background will be tiled.
void SetBackground(const SkBitmap& background);