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

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

Issue 2783723002: Keep track in the browser of which frames have onunload and onbeforeunload handlers. (Closed)
Patch Set: fix content_browsertests with plznavigate and also remove now unnecessary unloadcontroller change Created 3 years, 8 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
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/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "content/public/browser/browser_context.h" 10 #include "content/public/browser/browser_context.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 // If CloseContents() is called before CanClose(), which is called by 103 // If CloseContents() is called before CanClose(), which is called by
104 // RenderViewHostImpl::ClosePageIgnoringUnloadEvents, it indicates 104 // RenderViewHostImpl::ClosePageIgnoringUnloadEvents, it indicates
105 // beforeunload event should not be fired during closing. 105 // beforeunload event should not be fired during closing.
106 if ((is_attempting_close_dialog_ && before_unload_fired_) || 106 if ((is_attempting_close_dialog_ && before_unload_fired_) ||
107 close_contents_called_) { 107 close_contents_called_) {
108 is_attempting_close_dialog_ = false; 108 is_attempting_close_dialog_ = false;
109 before_unload_fired_ = false; 109 before_unload_fired_ = false;
110 return true; 110 return true;
111 } 111 }
112 112
113 if (!is_attempting_close_dialog_) { 113 if (!is_attempting_close_dialog_ &&
114 web_view_->web_contents()->NeedToFireBeforeUnload()) {
114 // Fire beforeunload event when user attempts to close the dialog. 115 // Fire beforeunload event when user attempts to close the dialog.
115 is_attempting_close_dialog_ = true; 116 is_attempting_close_dialog_ = true;
116 web_view_->web_contents()->DispatchBeforeUnload(); 117 web_view_->web_contents()->DispatchBeforeUnload();
117 } 118 }
118 return false; 119 return false;
119 } 120 }
120 121
121 //////////////////////////////////////////////////////////////////////////////// 122 ////////////////////////////////////////////////////////////////////////////////
122 // WebDialogView, views::WidgetDelegate implementation: 123 // WebDialogView, views::WidgetDelegate implementation:
123 124
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 web_contents->SetDelegate(this); 361 web_contents->SetDelegate(this);
361 362
362 // Set the delegate. This must be done before loading the page. See 363 // Set the delegate. This must be done before loading the page. See
363 // the comment above WebDialogUI in its header file for why. 364 // the comment above WebDialogUI in its header file for why.
364 WebDialogUI::SetDelegate(web_contents, this); 365 WebDialogUI::SetDelegate(web_contents, this);
365 366
366 web_view_->LoadInitialURL(GetDialogContentURL()); 367 web_view_->LoadInitialURL(GetDialogContentURL());
367 } 368 }
368 369
369 } // namespace views 370 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698