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

Unified Diff: chrome/browser/ui/views/extensions/extension_view_views.cc

Issue 10961066: Revert 158199 - extensions: Add ExtensionView interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 months 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/views/extensions/extension_view_views.cc
===================================================================
--- chrome/browser/ui/views/extensions/extension_view_views.cc (revision 158218)
+++ chrome/browser/ui/views/extensions/extension_view_views.cc (working copy)
@@ -20,12 +20,10 @@
: host_(host),
browser_(browser),
initialized_(false),
- container_(NULL) {
- // We are owned by ExtensionHost, so views hierarchy shouldn't delete us!
- set_owned_by_client();
+ container_(NULL),
+ is_clipped_(false) {
+ host_->set_view(this);
- host_->SetExtensionView(this);
-
// This view needs to be focusable so it can act as the focused view for the
// focus manager. This is required to have SkipDefaultKeyEventProcessing
// called so the tab key events are forwarded to the renderer.
@@ -38,16 +36,30 @@
CleanUp();
}
-void ExtensionViewViews::SetBackground(const SkBitmap& background) {
- if (GetRenderViewHost()->IsRenderViewLive() &&
- GetRenderViewHost()->GetView()) {
- GetRenderViewHost()->GetView()->SetBackground(background);
- } else {
- pending_background_ = background;
- }
+const extensions::Extension* ExtensionViewViews::extension() const {
+ return host_->extension();
+}
+
+content::RenderViewHost* ExtensionViewViews::render_view_host() const {
+ return host_->render_view_host();
+}
+
+void ExtensionViewViews::DidStopLoading() {
ShowIfCompletelyLoaded();
}
+void ExtensionViewViews::SetIsClipped(bool is_clipped) {
+ if (is_clipped_ != is_clipped) {
+ is_clipped_ = is_clipped;
+ if (visible())
+ ShowIfCompletelyLoaded();
+ }
+}
+
+gfx::NativeCursor ExtensionViewViews::GetCursor(const ui::MouseEvent& event) {
+ return gfx::kNullCursor;
+}
+
void ExtensionViewViews::SetVisible(bool is_visible) {
if (is_visible != visible()) {
NativeViewHost::SetVisible(is_visible);
@@ -55,84 +67,15 @@
// Also tell RenderWidgetHostView the new visibility. Despite its name, it
// is not part of the View hierarchy and does not know about the change
// unless we tell it.
- if (GetRenderViewHost()->GetView()) {
+ if (render_view_host()->GetView()) {
if (is_visible)
- GetRenderViewHost()->GetView()->Show();
+ render_view_host()->GetView()->Show();
else
- GetRenderViewHost()->GetView()->Hide();
+ render_view_host()->GetView()->Hide();
}
}
}
-gfx::NativeCursor ExtensionViewViews::GetCursor(const ui::MouseEvent& event) {
- return gfx::kNullCursor;
-}
-
-void ExtensionViewViews::ViewHierarchyChanged(bool is_add,
- views::View* parent,
- views::View* child) {
- NativeViewHost::ViewHierarchyChanged(is_add, parent, child);
- if (is_add && GetWidget() && !initialized_)
- CreateWidgetHostView();
-}
-
-Browser* ExtensionViewViews::GetBrowser() {
- return browser_;
-}
-
-const Browser* ExtensionViewViews::GetBrowser() const {
- return browser_;
-}
-
-gfx::NativeView ExtensionViewViews::GetNativeView() {
- return host_->host_contents()->GetView()->GetNativeView();
-}
-
-content::RenderViewHost* ExtensionViewViews::GetRenderViewHost() const {
- return host_->render_view_host();
-}
-
-void ExtensionViewViews::SetContainer(ExtensionViewContainer* container) {
- container_ = container;
-}
-
-void ExtensionViewViews::ResizeDueToAutoResize(const gfx::Size& new_size) {
- // Don't actually do anything with this information until we have been shown.
- // Size changes will not be honored by lower layers while we are hidden.
- if (!visible()) {
- pending_preferred_size_ = new_size;
- return;
- }
-
- gfx::Size preferred_size = GetPreferredSize();
- if (new_size != preferred_size)
- SetPreferredSize(new_size);
-}
-
-void ExtensionViewViews::RenderViewCreated() {
- if (!pending_background_.empty() && GetRenderViewHost()->GetView()) {
- GetRenderViewHost()->GetView()->SetBackground(pending_background_);
- pending_background_.reset();
- }
-
- chrome::ViewType host_type = host_->extension_host_type();
- if (host_type == chrome::VIEW_TYPE_EXTENSION_POPUP) {
- gfx::Size min_size(ExtensionPopup::kMinWidth,
- ExtensionPopup::kMinHeight);
- gfx::Size max_size(ExtensionPopup::kMaxWidth,
- ExtensionPopup::kMaxHeight);
- GetRenderViewHost()->EnableAutoResize(min_size, max_size);
- }
-}
-
-void ExtensionViewViews::DidStopLoading() {
- ShowIfCompletelyLoaded();
-}
-
-void ExtensionViewViews::WindowFrameChanged() {
- NOTIMPLEMENTED();
-}
-
void ExtensionViewViews::CreateWidgetHostView() {
DCHECK(!initialized_);
initialized_ = true;
@@ -142,7 +85,7 @@
}
void ExtensionViewViews::ShowIfCompletelyLoaded() {
- if (visible())
+ if (visible() || is_clipped_)
return;
// We wait to show the ExtensionViewViews until it has loaded, and the view
@@ -161,10 +104,40 @@
initialized_ = false;
}
+void ExtensionViewViews::SetBackground(const SkBitmap& background) {
+ if (render_view_host()->IsRenderViewLive() && render_view_host()->GetView()) {
+ render_view_host()->GetView()->SetBackground(background);
+ } else {
+ pending_background_ = background;
+ }
+ ShowIfCompletelyLoaded();
+}
+
+void ExtensionViewViews::ResizeDueToAutoResize(const gfx::Size& new_size) {
+ // Don't actually do anything with this information until we have been shown.
+ // Size changes will not be honored by lower layers while we are hidden.
+ if (!visible()) {
+ pending_preferred_size_ = new_size;
+ return;
+ }
+
+ gfx::Size preferred_size = GetPreferredSize();
+ if (new_size != preferred_size)
+ SetPreferredSize(new_size);
+}
+
+void ExtensionViewViews::ViewHierarchyChanged(bool is_add,
+ views::View* parent,
+ views::View* child) {
+ NativeViewHost::ViewHierarchyChanged(is_add, parent, child);
+ if (is_add && GetWidget() && !initialized_)
+ CreateWidgetHostView();
+}
+
void ExtensionViewViews::PreferredSizeChanged() {
View::PreferredSizeChanged();
if (container_)
- container_->OnExtensionSizeChanged(this, gfx::Size());
+ container_->OnExtensionSizeChanged(this);
}
bool ExtensionViewViews::SkipDefaultKeyEventProcessing(const ui::KeyEvent& e) {
@@ -179,18 +152,35 @@
void ExtensionViewViews::OnBoundsChanged(const gfx::Rect& previous_bounds) {
// Propagate the new size to RenderWidgetHostView.
// We can't send size zero because RenderWidget DCHECKs that.
- if (GetRenderViewHost()->GetView() && !bounds().IsEmpty())
- GetRenderViewHost()->GetView()->SetSize(size());
+ if (render_view_host()->GetView() && !bounds().IsEmpty()) {
+ render_view_host()->GetView()->SetSize(size());
+
+ if (container_)
+ container_->OnViewWasResized();
+ }
}
+void ExtensionViewViews::RenderViewCreated() {
+ if (!pending_background_.empty() && render_view_host()->GetView()) {
+ render_view_host()->GetView()->SetBackground(pending_background_);
+ pending_background_.reset();
+ }
+
+ chrome::ViewType host_type = host_->extension_host_type();
+ if (host_type == chrome::VIEW_TYPE_EXTENSION_POPUP) {
+ gfx::Size min_size(ExtensionPopup::kMinWidth,
+ ExtensionPopup::kMinHeight);
+ gfx::Size max_size(ExtensionPopup::kMaxWidth,
+ ExtensionPopup::kMaxHeight);
+ render_view_host()->EnableAutoResize(min_size, max_size);
+ }
+
+ if (container_)
+ container_->OnViewWasResized();
+}
+
void ExtensionViewViews::HandleKeyboardEvent(
const content::NativeWebKeyboardEvent& event) {
unhandled_keyboard_event_handler_.HandleKeyboardEvent(event,
GetFocusManager());
}
-
-// static
-ExtensionView* ExtensionView::Create(extensions::ExtensionHost* host,
- Browser* browser) {
- return new ExtensionViewViews(host, browser);
-}
« no previous file with comments | « chrome/browser/ui/views/extensions/extension_view_views.h ('k') | chrome/browser/ui/views/infobars/extension_infobar.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698