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

Side by Side Diff: chrome/browser/ui/views/html_dialog_view.cc

Issue 9569001: WebUI TaskManager: Add method to set minimum window size on HTMLDialog. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review fix Created 8 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/ui/views/html_dialog_view.h" 5 #include "chrome/browser/ui/views/html_dialog_view.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 71
72 HtmlDialogView::~HtmlDialogView() { 72 HtmlDialogView::~HtmlDialogView() {
73 } 73 }
74 74
75 //////////////////////////////////////////////////////////////////////////////// 75 ////////////////////////////////////////////////////////////////////////////////
76 // HtmlDialogView, views::View implementation: 76 // HtmlDialogView, views::View implementation:
77 77
78 gfx::Size HtmlDialogView::GetPreferredSize() { 78 gfx::Size HtmlDialogView::GetPreferredSize() {
79 gfx::Size out; 79 gfx::Size out;
80 if (delegate_) 80 if (delegate_)
81 delegate_->GetDialogSize(&out); 81 delegate_->GetMinimumDialogSize(&out);
82 return out; 82 return out;
83 } 83 }
84 84
85 bool HtmlDialogView::AcceleratorPressed(const ui::Accelerator& accelerator) { 85 bool HtmlDialogView::AcceleratorPressed(const ui::Accelerator& accelerator) {
86 // Pressing ESC closes the dialog. 86 // Pressing ESC closes the dialog.
87 DCHECK_EQ(ui::VKEY_ESCAPE, accelerator.key_code()); 87 DCHECK_EQ(ui::VKEY_ESCAPE, accelerator.key_code());
88 OnDialogClosed(std::string()); 88 OnDialogClosed(std::string());
89 return true; 89 return true;
90 } 90 }
91 91
(...skipping 21 matching lines...) Expand all
113 ui::ModalType HtmlDialogView::GetModalType() const { 113 ui::ModalType HtmlDialogView::GetModalType() const {
114 return GetDialogModalType(); 114 return GetDialogModalType();
115 } 115 }
116 116
117 string16 HtmlDialogView::GetWindowTitle() const { 117 string16 HtmlDialogView::GetWindowTitle() const {
118 if (delegate_) 118 if (delegate_)
119 return delegate_->GetDialogTitle(); 119 return delegate_->GetDialogTitle();
120 return string16(); 120 return string16();
121 } 121 }
122 122
123 std::string HtmlDialogView::GetWindowName() const {
124 if (delegate_)
125 return delegate_->GetDialogName();
126 return std::string();
127 }
128
123 void HtmlDialogView::WindowClosing() { 129 void HtmlDialogView::WindowClosing() {
124 // If we still have a delegate that means we haven't notified it of the 130 // If we still have a delegate that means we haven't notified it of the
125 // dialog closing. This happens if the user clicks the Close button on the 131 // dialog closing. This happens if the user clicks the Close button on the
126 // dialog. 132 // dialog.
127 if (delegate_) 133 if (delegate_)
128 OnDialogClosed(""); 134 OnDialogClosed("");
129 } 135 }
130 136
131 views::View* HtmlDialogView::GetContentsView() { 137 views::View* HtmlDialogView::GetContentsView() {
132 return this; 138 return this;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 std::vector<WebUIMessageHandler*>* handlers) const { 177 std::vector<WebUIMessageHandler*>* handlers) const {
172 if (delegate_) 178 if (delegate_)
173 delegate_->GetWebUIMessageHandlers(handlers); 179 delegate_->GetWebUIMessageHandlers(handlers);
174 } 180 }
175 181
176 void HtmlDialogView::GetDialogSize(gfx::Size* size) const { 182 void HtmlDialogView::GetDialogSize(gfx::Size* size) const {
177 if (delegate_) 183 if (delegate_)
178 delegate_->GetDialogSize(size); 184 delegate_->GetDialogSize(size);
179 } 185 }
180 186
187 void HtmlDialogView::GetMinimumDialogSize(gfx::Size* size) const {
188 if (delegate_)
189 delegate_->GetMinimumDialogSize(size);
190 }
191
181 std::string HtmlDialogView::GetDialogArgs() const { 192 std::string HtmlDialogView::GetDialogArgs() const {
182 if (delegate_) 193 if (delegate_)
183 return delegate_->GetDialogArgs(); 194 return delegate_->GetDialogArgs();
184 return std::string(); 195 return std::string();
185 } 196 }
186 197
187 void HtmlDialogView::OnDialogClosed(const std::string& json_retval) { 198 void HtmlDialogView::OnDialogClosed(const std::string& json_retval) {
188 HtmlDialogTabContentsDelegate::Detach(); 199 HtmlDialogTabContentsDelegate::Detach();
189 if (delegate_) { 200 if (delegate_) {
190 HtmlDialogUIDelegate* dialog_delegate = delegate_; 201 HtmlDialogUIDelegate* dialog_delegate = delegate_;
191 delegate_ = NULL; // We will not communicate further with the delegate.
192 202
193 // Store the dialog content area size. 203 // Store the dialog content area size.
194 dialog_delegate->StoreDialogSize(GetContentsBounds().size()); 204 dialog_delegate->StoreDialogSize(GetContentsBounds().size());
195 205
196 dialog_delegate->OnDialogClosed(json_retval); 206 dialog_delegate->OnDialogClosed(json_retval);
197 } 207 }
198 GetWidget()->Close(); 208 GetWidget()->Close();
209
210 if (delegate_)
211 delegate_ = NULL; // We will not communicate further with the delegate.
199 } 212 }
200 213
201 void HtmlDialogView::OnCloseContents(WebContents* source, 214 void HtmlDialogView::OnCloseContents(WebContents* source,
202 bool* out_close_dialog) { 215 bool* out_close_dialog) {
203 if (delegate_) 216 if (delegate_)
204 delegate_->OnCloseContents(source, out_close_dialog); 217 delegate_->OnCloseContents(source, out_close_dialog);
205 } 218 }
206 219
207 bool HtmlDialogView::ShouldShowDialogTitle() const { 220 bool HtmlDialogView::ShouldShowDialogTitle() const {
208 if (delegate_) 221 if (delegate_)
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 308
296 WebContents* web_contents = dom_contents_->web_contents(); 309 WebContents* web_contents = dom_contents_->web_contents();
297 web_contents->SetDelegate(this); 310 web_contents->SetDelegate(this);
298 311
299 // Set the delegate. This must be done before loading the page. See 312 // Set the delegate. This must be done before loading the page. See
300 // the comment above HtmlDialogUI in its header file for why. 313 // the comment above HtmlDialogUI in its header file for why.
301 HtmlDialogUI::GetPropertyAccessor().SetProperty( 314 HtmlDialogUI::GetPropertyAccessor().SetProperty(
302 web_contents->GetPropertyBag(), this); 315 web_contents->GetPropertyBag(), this);
303 tab_watcher_.reset(new TabFirstRenderWatcher(web_contents, this)); 316 tab_watcher_.reset(new TabFirstRenderWatcher(web_contents, this));
304 317
318 if (delegate_) {
319 gfx::Size out;
320 delegate_->GetDialogSize(&out);
321 if (!out.IsEmpty())
322 GetWidget()->CenterWindow(out);
323 }
324
305 DOMView::LoadURL(GetDialogContentURL()); 325 DOMView::LoadURL(GetDialogContentURL());
306 } 326 }
307 327
308 void HtmlDialogView::RegisterDialogAccelerators() { 328 void HtmlDialogView::RegisterDialogAccelerators() {
309 // Pressing the ESC key will close the dialog. 329 // Pressing the ESC key will close the dialog.
310 AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, false, false, false)); 330 AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, false, false, false));
311 } 331 }
312 332
313 void HtmlDialogView::OnRenderHostCreated(RenderViewHost* host) { 333 void HtmlDialogView::OnRenderHostCreated(RenderViewHost* host) {
314 } 334 }
315 335
316 void HtmlDialogView::OnTabMainFrameLoaded() { 336 void HtmlDialogView::OnTabMainFrameLoaded() {
317 } 337 }
318 338
319 void HtmlDialogView::OnTabMainFrameFirstRender() { 339 void HtmlDialogView::OnTabMainFrameFirstRender() {
320 #if defined(OS_CHROMEOS) && defined(TOOLKIT_USES_GTK) 340 #if defined(OS_CHROMEOS) && defined(TOOLKIT_USES_GTK)
321 if (initialized_) { 341 if (initialized_) {
322 views::NativeWidgetGtk::UpdateFreezeUpdatesProperty( 342 views::NativeWidgetGtk::UpdateFreezeUpdatesProperty(
323 GTK_WINDOW(GetWidget()->GetNativeView()), false); 343 GTK_WINDOW(GetWidget()->GetNativeView()), false);
324 } 344 }
325 #endif 345 #endif
326 } 346 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698