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

Side by Side Diff: ui/views/controls/webview/web_dialog_view.cc

Issue 12091075: Fix the issue introduced by hooking window.onbeforeunload in WebDialogView which breaks WebDialogUI… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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 | « ui/views/controls/webview/web_dialog_view.h ('k') | ui/web_dialogs/web_dialog_delegate.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 "ui/views/controls/webview/web_dialog_view.h" 5 #include "ui/views/controls/webview/web_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 "content/public/browser/browser_context.h" 10 #include "content/public/browser/browser_context.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 WebDialogView::WebDialogView( 42 WebDialogView::WebDialogView(
43 content::BrowserContext* context, 43 content::BrowserContext* context,
44 WebDialogDelegate* delegate, 44 WebDialogDelegate* delegate,
45 WebContentsHandler* handler) 45 WebContentsHandler* handler)
46 : ClientView(NULL, NULL), 46 : ClientView(NULL, NULL),
47 WebDialogWebContentsDelegate(context, handler), 47 WebDialogWebContentsDelegate(context, handler),
48 initialized_(false), 48 initialized_(false),
49 delegate_(delegate), 49 delegate_(delegate),
50 web_view_(new views::WebView(context)), 50 web_view_(new views::WebView(context)),
51 is_attempting_close_dialog_(false), 51 is_attempting_close_dialog_(false),
52 before_unload_fired_(false) { 52 before_unload_fired_(false),
53 closed_via_webui_(false) {
53 web_view_->set_allow_accelerators(true); 54 web_view_->set_allow_accelerators(true);
54 AddChildView(web_view_); 55 AddChildView(web_view_);
55 set_contents_view(web_view_); 56 set_contents_view(web_view_);
56 SetLayoutManager(new views::FillLayout); 57 SetLayoutManager(new views::FillLayout);
57 // Pressing the ESC key will close the dialog. 58 // Pressing the ESC key will close the dialog.
58 AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE)); 59 AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE));
59 } 60 }
60 61
61 WebDialogView::~WebDialogView() { 62 WebDialogView::~WebDialogView() {
62 } 63 }
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 219
219 if (GetWidget()) 220 if (GetWidget())
220 GetWidget()->Close(); 221 GetWidget()->Close();
221 222
222 if (delegate_) { 223 if (delegate_) {
223 delegate_->OnDialogClosed(json_retval); 224 delegate_->OnDialogClosed(json_retval);
224 delegate_ = NULL; // We will not communicate further with the delegate. 225 delegate_ = NULL; // We will not communicate further with the delegate.
225 } 226 }
226 } 227 }
227 228
229 void WebDialogView::OnDialogCloseFromWebUI(const std::string& json_retval) {
230 closed_via_webui_ = true;
231 dialog_close_retval_ = json_retval;
232 if (GetWidget())
233 GetWidget()->Close();
234 }
235
228 void WebDialogView::OnCloseContents(WebContents* source, 236 void WebDialogView::OnCloseContents(WebContents* source,
229 bool* out_close_dialog) { 237 bool* out_close_dialog) {
230 if (delegate_) 238 if (delegate_)
231 delegate_->OnCloseContents(source, out_close_dialog); 239 delegate_->OnCloseContents(source, out_close_dialog);
232 } 240 }
233 241
234 bool WebDialogView::ShouldShowDialogTitle() const { 242 bool WebDialogView::ShouldShowDialogTitle() const {
235 if (delegate_) 243 if (delegate_)
236 return delegate_->ShouldShowDialogTitle(); 244 return delegate_->ShouldShowDialogTitle();
237 return true; 245 return true;
(...skipping 30 matching lines...) Expand all
268 // This allows stuff like F10, etc to work correctly. 276 // This allows stuff like F10, etc to work correctly.
269 DefWindowProc(event.os_event.hwnd, event.os_event.message, 277 DefWindowProc(event.os_event.hwnd, event.os_event.message,
270 event.os_event.wParam, event.os_event.lParam); 278 event.os_event.wParam, event.os_event.lParam);
271 #endif 279 #endif
272 } 280 }
273 281
274 void WebDialogView::CloseContents(WebContents* source) { 282 void WebDialogView::CloseContents(WebContents* source) {
275 bool close_dialog = false; 283 bool close_dialog = false;
276 OnCloseContents(source, &close_dialog); 284 OnCloseContents(source, &close_dialog);
277 if (close_dialog) 285 if (close_dialog)
278 OnDialogClosed(std::string()); 286 OnDialogClosed(closed_via_webui_ ? dialog_close_retval_ : std::string());
279 } 287 }
280 288
281 content::WebContents* WebDialogView::OpenURLFromTab( 289 content::WebContents* WebDialogView::OpenURLFromTab(
282 content::WebContents* source, 290 content::WebContents* source,
283 const content::OpenURLParams& params) { 291 const content::OpenURLParams& params) {
284 content::WebContents* new_contents = NULL; 292 content::WebContents* new_contents = NULL;
285 if (delegate_ && 293 if (delegate_ &&
286 delegate_->HandleOpenURLFromTab(source, params, &new_contents)) { 294 delegate_->HandleOpenURLFromTab(source, params, &new_contents)) {
287 return new_contents; 295 return new_contents;
288 } 296 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 web_contents->SetDelegate(this); 335 web_contents->SetDelegate(this);
328 336
329 // Set the delegate. This must be done before loading the page. See 337 // Set the delegate. This must be done before loading the page. See
330 // the comment above WebDialogUI in its header file for why. 338 // the comment above WebDialogUI in its header file for why.
331 WebDialogUI::SetDelegate(web_contents, this); 339 WebDialogUI::SetDelegate(web_contents, this);
332 340
333 web_view_->LoadInitialURL(GetDialogContentURL()); 341 web_view_->LoadInitialURL(GetDialogContentURL());
334 } 342 }
335 343
336 } // namespace views 344 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/webview/web_dialog_view.h ('k') | ui/web_dialogs/web_dialog_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698