| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/extensions/extension_view.h" | 5 #include "chrome/browser/extensions/extension_view.h" |
| 6 | 6 |
| 7 #include "chrome/browser/extensions/extension_host.h" | 7 #include "chrome/browser/extensions/extension_host.h" |
| 8 #include "chrome/browser/renderer_host/render_view_host.h" | 8 #include "chrome/browser/renderer_host/render_view_host.h" |
| 9 #include "chrome/browser/renderer_host/render_widget_host_view.h" | 9 #include "chrome/browser/renderer_host/render_widget_host_view.h" |
| 10 #if defined(OS_WIN) | 10 #if defined(OS_WIN) |
| 11 #include "chrome/browser/renderer_host/render_widget_host_view_win.h" | 11 #include "chrome/browser/renderer_host/render_widget_host_view_win.h" |
| 12 #endif | 12 #endif |
| 13 #include "views/widget/widget.h" | 13 #include "views/widget/widget.h" |
| 14 | 14 |
| 15 ExtensionView::ExtensionView(ExtensionHost* host, Browser* browser, | 15 ExtensionView::ExtensionView(ExtensionHost* host, Browser* browser, |
| 16 const GURL& content_url) | 16 const GURL& content_url) |
| 17 : host_(host), browser_(browser), content_url_(content_url), | 17 : host_(host), browser_(browser), content_url_(content_url), |
| 18 initialized_(false), container_(NULL) { | 18 initialized_(false), container_(NULL) { |
| 19 host_->set_view(this); | 19 host_->set_view(this); |
| 20 } | 20 } |
| 21 | 21 |
| 22 ExtensionView::~ExtensionView() { | 22 ExtensionView::~ExtensionView() { |
| 23 if (GetHWND()) | 23 if (native_view()) |
| 24 Detach(); | 24 Detach(); |
| 25 } | 25 } |
| 26 | 26 |
| 27 void ExtensionView::SetVisible(bool is_visible) { | 27 void ExtensionView::SetVisible(bool is_visible) { |
| 28 if (is_visible != IsVisible()) { | 28 if (is_visible != IsVisible()) { |
| 29 HWNDView::SetVisible(is_visible); | 29 NativeViewHost::SetVisible(is_visible); |
| 30 | 30 |
| 31 // Also tell RenderWidgetHostView the new visibility. Despite its name, it | 31 // Also tell RenderWidgetHostView the new visibility. Despite its name, it |
| 32 // is not part of the View heirarchy and does not know about the change | 32 // is not part of the View heirarchy and does not know about the change |
| 33 // unless we tell it. | 33 // unless we tell it. |
| 34 if (render_view_host()->view()) { | 34 if (render_view_host()->view()) { |
| 35 if (is_visible) | 35 if (is_visible) |
| 36 render_view_host()->view()->Show(); | 36 render_view_host()->view()->Show(); |
| 37 else | 37 else |
| 38 render_view_host()->view()->Hide(); | 38 render_view_host()->view()->Hide(); |
| 39 } | 39 } |
| 40 } | 40 } |
| 41 } | 41 } |
| 42 | 42 |
| 43 void ExtensionView::DidChangeBounds(const gfx::Rect& previous, | 43 void ExtensionView::DidChangeBounds(const gfx::Rect& previous, |
| 44 const gfx::Rect& current) { | 44 const gfx::Rect& current) { |
| 45 // Propagate the new size to RenderWidgetHostView. | 45 // Propagate the new size to RenderWidgetHostView. |
| 46 // We can't send size zero because RenderWidget DCHECKs that. | 46 // We can't send size zero because RenderWidget DCHECKs that. |
| 47 if (render_view_host()->view() && !current.IsEmpty()) | 47 if (render_view_host()->view() && !current.IsEmpty()) |
| 48 render_view_host()->view()->SetSize(gfx::Size(width(), height())); | 48 render_view_host()->view()->SetSize(gfx::Size(width(), height())); |
| 49 // Layout is where the HWND is properly positioned. | 49 // Layout is where the HWND is properly positioned. |
| 50 // TODO(erikkay) - perhaps this should be in HWNDView | 50 // TODO(erikkay) - perhaps this should be in NativeViewHost |
| 51 Layout(); | 51 Layout(); |
| 52 } | 52 } |
| 53 | 53 |
| 54 void ExtensionView::ShowIfCompletelyLoaded() { | 54 void ExtensionView::ShowIfCompletelyLoaded() { |
| 55 // We wait to show the ExtensionView until it has loaded and our parent has | 55 // We wait to show the ExtensionView until it has loaded and our parent has |
| 56 // given us a background. These can happen in different orders. | 56 // given us a background. These can happen in different orders. |
| 57 if (!IsVisible() && host_->did_stop_loading() && render_view_host()->view() && | 57 if (!IsVisible() && host_->did_stop_loading() && render_view_host()->view() && |
| 58 !render_view_host()->view()->background().empty()) { | 58 !render_view_host()->view()->background().empty()) { |
| 59 SetVisible(true); | 59 SetVisible(true); |
| 60 DidContentsPreferredWidthChange(pending_preferred_width_); | 60 DidContentsPreferredWidthChange(pending_preferred_width_); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 | 117 |
| 118 void ExtensionView::HandleMouseEvent() { | 118 void ExtensionView::HandleMouseEvent() { |
| 119 if (container_) | 119 if (container_) |
| 120 container_->OnExtensionMouseEvent(this); | 120 container_->OnExtensionMouseEvent(this); |
| 121 } | 121 } |
| 122 | 122 |
| 123 void ExtensionView::HandleMouseLeave() { | 123 void ExtensionView::HandleMouseLeave() { |
| 124 if (container_) | 124 if (container_) |
| 125 container_->OnExtensionMouseLeave(this); | 125 container_->OnExtensionMouseLeave(this); |
| 126 } | 126 } |
| OLD | NEW |