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

Side by Side Diff: chrome/browser/views/extensions/extension_view.cc

Issue 164092: Correctly handle extensions width in the GTK extension shelf. (Closed)
Patch Set: Created 11 years, 4 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/views/extensions/extension_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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)
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 } 96 }
97 97
98 void ExtensionView::ShowIfCompletelyLoaded() { 98 void ExtensionView::ShowIfCompletelyLoaded() {
99 // We wait to show the ExtensionView until it has loaded, our parent has 99 // We wait to show the ExtensionView until it has loaded, our parent has
100 // given us a background and css has been inserted into page. These can happen 100 // given us a background and css has been inserted into page. These can happen
101 // in different orders. 101 // in different orders.
102 if (!IsVisible() && host_->did_stop_loading() && render_view_host()->view() && 102 if (!IsVisible() && host_->did_stop_loading() && render_view_host()->view() &&
103 !is_clipped_ && did_insert_css_ && 103 !is_clipped_ && did_insert_css_ &&
104 !render_view_host()->view()->background().empty()) { 104 !render_view_host()->view()->background().empty()) {
105 SetVisible(true); 105 SetVisible(true);
106 DidContentsPreferredWidthChange(pending_preferred_width_); 106 UpdatePreferredWidth(pending_preferred_width_);
107 } 107 }
108 } 108 }
109 109
110 void ExtensionView::CleanUp() { 110 void ExtensionView::CleanUp() {
111 if (!initialized_) 111 if (!initialized_)
112 return; 112 return;
113 if (native_view()) 113 if (native_view())
114 Detach(); 114 Detach();
115 initialized_ = false; 115 initialized_ = false;
116 } 116 }
117 117
118 void ExtensionView::SetBackground(const SkBitmap& background) { 118 void ExtensionView::SetBackground(const SkBitmap& background) {
119 if (initialized_ && render_view_host()->view()) { 119 if (initialized_ && render_view_host()->view()) {
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::UpdatePreferredWidth(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 gfx::Size preferred_size = GetPreferredSize();
131 if (!IsVisible()) { 131 if (!IsVisible()) {
132 pending_preferred_width_ = pref_width; 132 pending_preferred_width_ = pref_width;
133 } else if (pref_width > 0 && pref_width != preferred_size.width()) { 133 } else if (pref_width > 0 && pref_width != preferred_size.width()) {
134 if (preferred_size.height() == 0) 134 if (preferred_size.height() == 0)
135 preferred_size.set_height(height()); 135 preferred_size.set_height(height());
136 SetPreferredSize(gfx::Size(pref_width, preferred_size.height())); 136 SetPreferredSize(gfx::Size(pref_width, preferred_size.height()));
137 } 137 }
(...skipping 14 matching lines...) Expand all
152 152
153 void ExtensionView::HandleMouseEvent() { 153 void ExtensionView::HandleMouseEvent() {
154 if (container_) 154 if (container_)
155 container_->OnExtensionMouseEvent(this); 155 container_->OnExtensionMouseEvent(this);
156 } 156 }
157 157
158 void ExtensionView::HandleMouseLeave() { 158 void ExtensionView::HandleMouseLeave() {
159 if (container_) 159 if (container_)
160 container_->OnExtensionMouseLeave(this); 160 container_->OnExtensionMouseLeave(this);
161 } 161 }
OLDNEW
« no previous file with comments | « chrome/browser/views/extensions/extension_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698