OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |