| 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 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 // to be shutdown and be deleted as well. | 490 // to be shutdown and be deleted as well. |
| 491 node->render_manager()->ClearRFHsPendingShutdown(); | 491 node->render_manager()->ClearRFHsPendingShutdown(); |
| 492 node->render_manager()->ClearWebUIInstances(); | 492 node->render_manager()->ClearWebUIInstances(); |
| 493 } | 493 } |
| 494 | 494 |
| 495 for (RenderWidgetHostImpl* widget : created_widgets_) | 495 for (RenderWidgetHostImpl* widget : created_widgets_) |
| 496 widget->DetachDelegate(); | 496 widget->DetachDelegate(); |
| 497 created_widgets_.clear(); | 497 created_widgets_.clear(); |
| 498 | 498 |
| 499 // Clear out any JavaScript state. | 499 // Clear out any JavaScript state. |
| 500 if (dialog_manager_) | 500 if (dialog_manager_) { |
| 501 dialog_manager_->ResetDialogState(this); | 501 // This object is being destructed, so make sure that no callbacks happen. |
| 502 dialog_manager_->CancelDialogs(this, |
| 503 true, // suppress_callbacks, |
| 504 true); // reset_state |
| 505 } |
| 502 | 506 |
| 503 if (color_chooser_info_.get()) | 507 if (color_chooser_info_.get()) |
| 504 color_chooser_info_->chooser->End(); | 508 color_chooser_info_->chooser->End(); |
| 505 | 509 |
| 506 NotifyDisconnected(); | 510 NotifyDisconnected(); |
| 507 | 511 |
| 508 // Notify any observer that have a reference on this WebContents. | 512 // Notify any observer that have a reference on this WebContents. |
| 509 NotificationService::current()->Notify( | 513 NotificationService::current()->Notify( |
| 510 NOTIFICATION_WEB_CONTENTS_DESTROYED, | 514 NOTIFICATION_WEB_CONTENTS_DESTROYED, |
| 511 Source<WebContents>(this), | 515 Source<WebContents>(this), |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 894 } | 898 } |
| 895 | 899 |
| 896 int WebContentsImpl::GetRoutingID() const { | 900 int WebContentsImpl::GetRoutingID() const { |
| 897 if (!GetRenderViewHost()) | 901 if (!GetRenderViewHost()) |
| 898 return MSG_ROUTING_NONE; | 902 return MSG_ROUTING_NONE; |
| 899 | 903 |
| 900 return GetRenderViewHost()->GetRoutingID(); | 904 return GetRenderViewHost()->GetRoutingID(); |
| 901 } | 905 } |
| 902 | 906 |
| 903 void WebContentsImpl::CancelActiveAndPendingDialogs() { | 907 void WebContentsImpl::CancelActiveAndPendingDialogs() { |
| 904 if (dialog_manager_) | 908 if (dialog_manager_) { |
| 905 dialog_manager_->CancelActiveAndPendingDialogs(this); | 909 dialog_manager_->CancelDialogs(this, |
| 910 false, // suppress_callbacks, |
| 911 false); // reset_state |
| 912 } |
| 906 if (browser_plugin_embedder_) | 913 if (browser_plugin_embedder_) |
| 907 browser_plugin_embedder_->CancelGuestDialogs(); | 914 browser_plugin_embedder_->CancelGuestDialogs(); |
| 908 } | 915 } |
| 909 | 916 |
| 910 void WebContentsImpl::ClosePage() { | 917 void WebContentsImpl::ClosePage() { |
| 911 GetRenderViewHost()->ClosePage(); | 918 GetRenderViewHost()->ClosePage(); |
| 912 } | 919 } |
| 913 | 920 |
| 914 RenderWidgetHostView* WebContentsImpl::GetRenderWidgetHostView() const { | 921 RenderWidgetHostView* WebContentsImpl::GetRenderWidgetHostView() const { |
| 915 return GetRenderManager()->GetRenderWidgetHostView(); | 922 return GetRenderManager()->GetRenderWidgetHostView(); |
| (...skipping 2538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3454 // Now that something has committed, we don't need to track whether the | 3461 // Now that something has committed, we don't need to track whether the |
| 3455 // initial page has been accessed. | 3462 // initial page has been accessed. |
| 3456 has_accessed_initial_document_ = false; | 3463 has_accessed_initial_document_ = false; |
| 3457 | 3464 |
| 3458 // If we navigate off the page, close all JavaScript dialogs. | 3465 // If we navigate off the page, close all JavaScript dialogs. |
| 3459 if (!details.is_in_page) | 3466 if (!details.is_in_page) |
| 3460 CancelActiveAndPendingDialogs(); | 3467 CancelActiveAndPendingDialogs(); |
| 3461 | 3468 |
| 3462 // If this is a user-initiated navigation, start allowing JavaScript dialogs | 3469 // If this is a user-initiated navigation, start allowing JavaScript dialogs |
| 3463 // again. | 3470 // again. |
| 3464 if (params.gesture == NavigationGestureUser && dialog_manager_) | 3471 if (params.gesture == NavigationGestureUser && dialog_manager_) { |
| 3465 dialog_manager_->ResetDialogState(this); | 3472 dialog_manager_->CancelDialogs(this, |
| 3473 false, // suppress_callbacks, |
| 3474 true); // reset_state |
| 3475 } |
| 3466 | 3476 |
| 3467 // Notify observers about navigation. | 3477 // Notify observers about navigation. |
| 3468 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 3478 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 3469 DidNavigateAnyFrame(render_frame_host, details, params)); | 3479 DidNavigateAnyFrame(render_frame_host, details, params)); |
| 3470 } | 3480 } |
| 3471 | 3481 |
| 3472 void WebContentsImpl::SetMainFrameMimeType(const std::string& mime_type) { | 3482 void WebContentsImpl::SetMainFrameMimeType(const std::string& mime_type) { |
| 3473 contents_mime_type_ = mime_type; | 3483 contents_mime_type_ = mime_type; |
| 3474 } | 3484 } |
| 3475 | 3485 |
| (...skipping 1384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4860 | 4870 |
| 4861 void WebContentsImpl::CancelModalDialogsForRenderManager() { | 4871 void WebContentsImpl::CancelModalDialogsForRenderManager() { |
| 4862 // We need to cancel modal dialogs when doing a process swap, since the load | 4872 // We need to cancel modal dialogs when doing a process swap, since the load |
| 4863 // deferrer would prevent us from swapping out. We also clear the state | 4873 // deferrer would prevent us from swapping out. We also clear the state |
| 4864 // because this is a cross-process navigation, which means that it's a new | 4874 // because this is a cross-process navigation, which means that it's a new |
| 4865 // site that should not have to pay for the sins of its predecessor. | 4875 // site that should not have to pay for the sins of its predecessor. |
| 4866 // | 4876 // |
| 4867 // Note that we don't bother telling browser_plugin_embedder_ because the | 4877 // Note that we don't bother telling browser_plugin_embedder_ because the |
| 4868 // cross-process navigation will either destroy the browser plugins or not | 4878 // cross-process navigation will either destroy the browser plugins or not |
| 4869 // require their dialogs to close. | 4879 // require their dialogs to close. |
| 4870 if (dialog_manager_) | 4880 if (dialog_manager_) { |
| 4871 dialog_manager_->ResetDialogState(this); | 4881 dialog_manager_->CancelDialogs(this, |
| 4882 false, // suppress_callbacks, |
| 4883 true); // reset_state |
| 4884 } |
| 4872 } | 4885 } |
| 4873 | 4886 |
| 4874 void WebContentsImpl::NotifySwappedFromRenderManager(RenderFrameHost* old_host, | 4887 void WebContentsImpl::NotifySwappedFromRenderManager(RenderFrameHost* old_host, |
| 4875 RenderFrameHost* new_host, | 4888 RenderFrameHost* new_host, |
| 4876 bool is_main_frame) { | 4889 bool is_main_frame) { |
| 4877 if (is_main_frame) { | 4890 if (is_main_frame) { |
| 4878 NotifyViewSwapped(old_host ? old_host->GetRenderViewHost() : nullptr, | 4891 NotifyViewSwapped(old_host ? old_host->GetRenderViewHost() : nullptr, |
| 4879 new_host->GetRenderViewHost()); | 4892 new_host->GetRenderViewHost()); |
| 4880 | 4893 |
| 4881 // Make sure the visible RVH reflects the new delegate's preferences. | 4894 // Make sure the visible RVH reflects the new delegate's preferences. |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5278 dialog_manager_ = dialog_manager; | 5291 dialog_manager_ = dialog_manager; |
| 5279 } | 5292 } |
| 5280 | 5293 |
| 5281 void WebContentsImpl::RemoveBindingSet(const std::string& interface_name) { | 5294 void WebContentsImpl::RemoveBindingSet(const std::string& interface_name) { |
| 5282 auto it = binding_sets_.find(interface_name); | 5295 auto it = binding_sets_.find(interface_name); |
| 5283 if (it != binding_sets_.end()) | 5296 if (it != binding_sets_.end()) |
| 5284 binding_sets_.erase(it); | 5297 binding_sets_.erase(it); |
| 5285 } | 5298 } |
| 5286 | 5299 |
| 5287 } // namespace content | 5300 } // namespace content |
| OLD | NEW |