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

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

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

Powered by Google App Engine
This is Rietveld 408576698