| 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 return true; | 93 return true; |
| 94 } | 94 } |
| 95 | 95 |
| 96 void WebDialogView::ViewHierarchyChanged( | 96 void WebDialogView::ViewHierarchyChanged( |
| 97 const ViewHierarchyChangedDetails& details) { | 97 const ViewHierarchyChangedDetails& details) { |
| 98 if (details.is_add && GetWidget()) | 98 if (details.is_add && GetWidget()) |
| 99 InitDialog(); | 99 InitDialog(); |
| 100 } | 100 } |
| 101 | 101 |
| 102 bool WebDialogView::CanClose() { | 102 bool WebDialogView::CanClose() { |
| 103 // Don't close UI if |delegate_| does not allow users to close it by |
| 104 // clicking on "x" button or pressing Esc shortcut key on hosting dialog. |
| 105 if (!delegate_->CanCloseDialog() && !close_contents_called_) |
| 106 return false; |
| 107 |
| 103 // If CloseContents() is called before CanClose(), which is called by | 108 // If CloseContents() is called before CanClose(), which is called by |
| 104 // RenderViewHostImpl::ClosePageIgnoringUnloadEvents, it indicates | 109 // RenderViewHostImpl::ClosePageIgnoringUnloadEvents, it indicates |
| 105 // beforeunload event should not be fired during closing. | 110 // beforeunload event should not be fired during closing. |
| 106 if ((is_attempting_close_dialog_ && before_unload_fired_) || | 111 if ((is_attempting_close_dialog_ && before_unload_fired_) || |
| 107 close_contents_called_) { | 112 close_contents_called_) { |
| 108 is_attempting_close_dialog_ = false; | 113 is_attempting_close_dialog_ = false; |
| 109 before_unload_fired_ = false; | 114 before_unload_fired_ = false; |
| 110 return true; | 115 return true; |
| 111 } | 116 } |
| 112 | 117 |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 web_contents->SetDelegate(this); | 358 web_contents->SetDelegate(this); |
| 354 | 359 |
| 355 // Set the delegate. This must be done before loading the page. See | 360 // Set the delegate. This must be done before loading the page. See |
| 356 // the comment above WebDialogUI in its header file for why. | 361 // the comment above WebDialogUI in its header file for why. |
| 357 WebDialogUI::SetDelegate(web_contents, this); | 362 WebDialogUI::SetDelegate(web_contents, this); |
| 358 | 363 |
| 359 web_view_->LoadInitialURL(GetDialogContentURL()); | 364 web_view_->LoadInitialURL(GetDialogContentURL()); |
| 360 } | 365 } |
| 361 | 366 |
| 362 } // namespace views | 367 } // namespace views |
| OLD | NEW |