Chromium Code Reviews| 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 "content/browser/web_contents/web_contents_impl.h" | 5 #include "content/browser/web_contents/web_contents_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <cmath> | 9 #include <cmath> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 4195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4206 static_cast<RenderFrameHostImpl*>(render_frame_host); | 4206 static_cast<RenderFrameHostImpl*>(render_frame_host); |
| 4207 if (delegate_) | 4207 if (delegate_) |
| 4208 delegate_->WillRunBeforeUnloadConfirm(); | 4208 delegate_->WillRunBeforeUnloadConfirm(); |
| 4209 | 4209 |
| 4210 bool suppress_this_message = | 4210 bool suppress_this_message = |
| 4211 !rfhi->is_active() || | 4211 !rfhi->is_active() || |
| 4212 ShowingInterstitialPage() || !delegate_ || | 4212 ShowingInterstitialPage() || !delegate_ || |
| 4213 delegate_->ShouldSuppressDialogs(this) || | 4213 delegate_->ShouldSuppressDialogs(this) || |
| 4214 !delegate_->GetJavaScriptDialogManager(this); | 4214 !delegate_->GetJavaScriptDialogManager(this); |
| 4215 if (suppress_this_message) { | 4215 if (suppress_this_message) { |
| 4216 rfhi->JavaScriptDialogClosed(reply_msg, true, base::string16(), true); | 4216 rfhi->JavaScriptDialogClosed(true, reply_msg, true, base::string16(), true); |
| 4217 return; | 4217 return; |
| 4218 } | 4218 } |
| 4219 | 4219 |
| 4220 is_showing_before_unload_dialog_ = true; | 4220 is_showing_before_unload_dialog_ = true; |
| 4221 dialog_manager_ = delegate_->GetJavaScriptDialogManager(this); | 4221 dialog_manager_ = delegate_->GetJavaScriptDialogManager(this); |
| 4222 dialog_manager_->RunBeforeUnloadDialog( | 4222 dialog_manager_->RunBeforeUnloadDialog( |
| 4223 this, is_reload, | 4223 this, is_reload, |
| 4224 base::Bind(&WebContentsImpl::OnDialogClosed, base::Unretained(this), | 4224 base::Bind(&WebContentsImpl::OnDialogClosed, base::Unretained(this), |
| 4225 render_frame_host->GetProcess()->GetID(), | 4225 render_frame_host->GetProcess()->GetID(), |
| 4226 render_frame_host->GetRoutingID(), reply_msg, | 4226 render_frame_host->GetRoutingID(), reply_msg, |
| (...skipping 909 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5136 // meantime. Do not reset the navigation state in that case. | 5136 // meantime. Do not reset the navigation state in that case. |
| 5137 if (rfh && rfh == rfh->frame_tree_node()->current_frame_host()) { | 5137 if (rfh && rfh == rfh->frame_tree_node()->current_frame_host()) { |
| 5138 rfh->frame_tree_node()->BeforeUnloadCanceled(); | 5138 rfh->frame_tree_node()->BeforeUnloadCanceled(); |
| 5139 controller_.DiscardNonCommittedEntries(); | 5139 controller_.DiscardNonCommittedEntries(); |
| 5140 } | 5140 } |
| 5141 | 5141 |
| 5142 for (auto& observer : observers_) | 5142 for (auto& observer : observers_) |
| 5143 observer.BeforeUnloadDialogCancelled(); | 5143 observer.BeforeUnloadDialogCancelled(); |
| 5144 } | 5144 } |
| 5145 | 5145 |
| 5146 if (rfh) { | |
| 5147 rfh->JavaScriptDialogClosed(is_showing_before_unload_dialog_, reply_msg, | |
|
Charlie Reis
2017/02/27 18:41:41
I suppose we could have avoided passing this in as
Avi (use Gerrit)
2017/02/27 19:28:49
Acknowledged.
| |
| 5148 success, user_input, dialog_was_suppressed); | |
| 5149 } else { | |
| 5150 // Don't leak the sync IPC reply if the RFH or process is gone. | |
| 5151 delete reply_msg; | |
| 5152 } | |
| 5153 | |
| 5146 is_showing_javascript_dialog_ = false; | 5154 is_showing_javascript_dialog_ = false; |
| 5147 is_showing_before_unload_dialog_ = false; | 5155 is_showing_before_unload_dialog_ = false; |
| 5148 if (rfh) { | |
| 5149 rfh->JavaScriptDialogClosed(reply_msg, success, user_input, | |
| 5150 dialog_was_suppressed); | |
| 5151 } else { | |
| 5152 // Don't leak the sync IPC reply if the RFH or process is gone. | |
| 5153 delete reply_msg; | |
| 5154 } | |
| 5155 } | 5156 } |
| 5156 | 5157 |
| 5157 void WebContentsImpl::SetEncoding(const std::string& encoding) { | 5158 void WebContentsImpl::SetEncoding(const std::string& encoding) { |
| 5158 if (encoding == last_reported_encoding_) | 5159 if (encoding == last_reported_encoding_) |
| 5159 return; | 5160 return; |
| 5160 last_reported_encoding_ = encoding; | 5161 last_reported_encoding_ = encoding; |
| 5161 | 5162 |
| 5162 canonical_encoding_ = base::GetCanonicalEncodingNameByAliasName(encoding); | 5163 canonical_encoding_ = base::GetCanonicalEncodingNameByAliasName(encoding); |
| 5163 } | 5164 } |
| 5164 | 5165 |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5432 RenderViewHost* render_view_host = RenderViewHost::From(render_widget_host); | 5433 RenderViewHost* render_view_host = RenderViewHost::From(render_widget_host); |
| 5433 if (!render_view_host) | 5434 if (!render_view_host) |
| 5434 continue; | 5435 continue; |
| 5435 render_view_host_set.insert(render_view_host); | 5436 render_view_host_set.insert(render_view_host); |
| 5436 } | 5437 } |
| 5437 for (RenderViewHost* render_view_host : render_view_host_set) | 5438 for (RenderViewHost* render_view_host : render_view_host_set) |
| 5438 render_view_host->OnWebkitPreferencesChanged(); | 5439 render_view_host->OnWebkitPreferencesChanged(); |
| 5439 } | 5440 } |
| 5440 | 5441 |
| 5441 } // namespace content | 5442 } // namespace content |
| OLD | NEW |