| 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/views/extensions/extension_view.h" | 5 #include "chrome/browser/views/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 : host_(host), browser_(browser), | 16 : host_(host), browser_(browser), |
| 17 initialized_(false), pending_preferred_width_(0), container_(NULL), | 17 initialized_(false), pending_preferred_width_(0), container_(NULL), |
| 18 did_insert_css_(false), is_clipped_(false) { | 18 did_insert_css_(false), is_clipped_(false), is_toolstrip_(true) { |
| 19 host_->set_view(this); | 19 host_->set_view(this); |
| 20 } | 20 } |
| 21 | 21 |
| 22 ExtensionView::~ExtensionView() { | 22 ExtensionView::~ExtensionView() { |
| 23 View* parent = GetParent(); | 23 View* parent = GetParent(); |
| 24 if (parent) | 24 if (parent) |
| 25 parent->RemoveChildView(this); | 25 parent->RemoveChildView(this); |
| 26 CleanUp(); | 26 CleanUp(); |
| 27 } | 27 } |
| 28 | 28 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 render_view_host()->view()->SetBackground(background); | 120 render_view_host()->view()->SetBackground(background); |
| 121 } else { | 121 } else { |
| 122 pending_background_ = background; | 122 pending_background_ = background; |
| 123 } | 123 } |
| 124 ShowIfCompletelyLoaded(); | 124 ShowIfCompletelyLoaded(); |
| 125 } | 125 } |
| 126 | 126 |
| 127 void ExtensionView::DidContentsPreferredWidthChange(const int pref_width) { | 127 void ExtensionView::DidContentsPreferredWidthChange(const int pref_width) { |
| 128 // Don't actually do anything with this information until we have been shown. | 128 // Don't actually do anything with this information until we have been shown. |
| 129 // Size changes will not be honored by lower layers while we are hidden. | 129 // Size changes will not be honored by lower layers while we are hidden. |
| 130 gfx::Size preferred_size = GetPreferredSize(); |
| 130 if (!IsVisible()) { | 131 if (!IsVisible()) { |
| 131 pending_preferred_width_ = pref_width; | 132 pending_preferred_width_ = pref_width; |
| 132 } else if (pref_width > 0 && pref_width != GetPreferredSize().width()) { | 133 } else if (pref_width > 0 && pref_width != preferred_size.width()) { |
| 133 SetPreferredSize(gfx::Size(pref_width, height())); | 134 if (preferred_size.height() == 0) |
| 135 preferred_size.set_height(height()); |
| 136 SetPreferredSize(gfx::Size(pref_width, preferred_size.height())); |
| 134 } | 137 } |
| 135 } | 138 } |
| 136 | 139 |
| 137 void ExtensionView::ViewHierarchyChanged(bool is_add, | 140 void ExtensionView::ViewHierarchyChanged(bool is_add, |
| 138 views::View *parent, | 141 views::View *parent, |
| 139 views::View *child) { | 142 views::View *child) { |
| 140 NativeViewHost::ViewHierarchyChanged(is_add, parent, child); | 143 NativeViewHost::ViewHierarchyChanged(is_add, parent, child); |
| 141 if (is_add && GetWidget() && !initialized_) | 144 if (is_add && GetWidget() && !initialized_) |
| 142 CreateWidgetHostView(); | 145 CreateWidgetHostView(); |
| 143 } | 146 } |
| 144 | 147 |
| 145 void ExtensionView::RecoverCrashedExtension() { | 148 void ExtensionView::RecoverCrashedExtension() { |
| 146 CleanUp(); | 149 CleanUp(); |
| 147 CreateWidgetHostView(); | 150 CreateWidgetHostView(); |
| 148 } | 151 } |
| 149 | 152 |
| 150 void ExtensionView::HandleMouseEvent() { | 153 void ExtensionView::HandleMouseEvent() { |
| 151 if (container_) | 154 if (container_) |
| 152 container_->OnExtensionMouseEvent(this); | 155 container_->OnExtensionMouseEvent(this); |
| 153 } | 156 } |
| 154 | 157 |
| 155 void ExtensionView::HandleMouseLeave() { | 158 void ExtensionView::HandleMouseLeave() { |
| 156 if (container_) | 159 if (container_) |
| 157 container_->OnExtensionMouseLeave(this); | 160 container_->OnExtensionMouseLeave(this); |
| 158 } | 161 } |
| OLD | NEW |