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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 2694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2705 | 2705 |
2706 void WebContentsImpl::RemoveBrowserPluginEmbedder() { | 2706 void WebContentsImpl::RemoveBrowserPluginEmbedder() { |
2707 if (browser_plugin_embedder_) | 2707 if (browser_plugin_embedder_) |
2708 browser_plugin_embedder_.reset(); | 2708 browser_plugin_embedder_.reset(); |
2709 } | 2709 } |
2710 | 2710 |
2711 void WebContentsImpl::RenderViewCreated(RenderViewHost* render_view_host) { | 2711 void WebContentsImpl::RenderViewCreated(RenderViewHost* render_view_host) { |
2712 // Don't send notifications if we are just creating a swapped-out RVH for | 2712 // Don't send notifications if we are just creating a swapped-out RVH for |
2713 // the opener chain. These won't be used for view-source or WebUI, so it's | 2713 // the opener chain. These won't be used for view-source or WebUI, so it's |
2714 // ok to return early. | 2714 // ok to return early. |
2715 if (static_cast<RenderViewHostImpl*>(render_view_host)->is_swapped_out()) | 2715 if (static_cast<RenderViewHostImpl*>(render_view_host)->rvh_state() == |
| 2716 RenderViewHostImpl::STATE_SWAPPED_OUT) |
2716 return; | 2717 return; |
2717 | 2718 |
2718 if (delegate_) | 2719 if (delegate_) |
2719 view_->SetOverscrollControllerEnabled(delegate_->CanOverscrollContent()); | 2720 view_->SetOverscrollControllerEnabled(delegate_->CanOverscrollContent()); |
2720 | 2721 |
2721 NotificationService::current()->Notify( | 2722 NotificationService::current()->Notify( |
2722 NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED, | 2723 NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED, |
2723 Source<WebContents>(this), | 2724 Source<WebContents>(this), |
2724 Details<RenderViewHost>(render_view_host)); | 2725 Details<RenderViewHost>(render_view_host)); |
2725 | 2726 |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3126 | 3127 |
3127 void WebContentsImpl::RequestOpenURL(RenderViewHost* rvh, | 3128 void WebContentsImpl::RequestOpenURL(RenderViewHost* rvh, |
3128 const GURL& url, | 3129 const GURL& url, |
3129 const Referrer& referrer, | 3130 const Referrer& referrer, |
3130 WindowOpenDisposition disposition, | 3131 WindowOpenDisposition disposition, |
3131 int64 source_frame_id, | 3132 int64 source_frame_id, |
3132 bool should_replace_current_entry, | 3133 bool should_replace_current_entry, |
3133 bool user_gesture) { | 3134 bool user_gesture) { |
3134 // If this came from a swapped out RenderViewHost, we only allow the request | 3135 // If this came from a swapped out RenderViewHost, we only allow the request |
3135 // if we are still in the same BrowsingInstance. | 3136 // if we are still in the same BrowsingInstance. |
3136 if (static_cast<RenderViewHostImpl*>(rvh)->is_swapped_out() && | 3137 if (static_cast<RenderViewHostImpl*>(rvh)->rvh_state() == |
| 3138 RenderViewHostImpl::STATE_SWAPPED_OUT && |
3137 !rvh->GetSiteInstance()->IsRelatedSiteInstance(GetSiteInstance())) { | 3139 !rvh->GetSiteInstance()->IsRelatedSiteInstance(GetSiteInstance())) { |
3138 return; | 3140 return; |
3139 } | 3141 } |
3140 | 3142 |
3141 // Delegate to RequestTransferURL because this is just the generic | 3143 // Delegate to RequestTransferURL because this is just the generic |
3142 // case where |old_request_id| is empty. | 3144 // case where |old_request_id| is empty. |
3143 // TODO(creis): Pass the redirect_chain into this method to support client | 3145 // TODO(creis): Pass the redirect_chain into this method to support client |
3144 // redirects. http://crbug.com/311721. | 3146 // redirects. http://crbug.com/311721. |
3145 std::vector<GURL> redirect_chain; | 3147 std::vector<GURL> redirect_chain; |
3146 RequestTransferURL(url, redirect_chain, referrer, PAGE_TRANSITION_LINK, | 3148 RequestTransferURL(url, redirect_chain, referrer, PAGE_TRANSITION_LINK, |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3296 const base::string16& message, | 3298 const base::string16& message, |
3297 const base::string16& default_prompt, | 3299 const base::string16& default_prompt, |
3298 const GURL& frame_url, | 3300 const GURL& frame_url, |
3299 JavaScriptMessageType javascript_message_type, | 3301 JavaScriptMessageType javascript_message_type, |
3300 IPC::Message* reply_msg, | 3302 IPC::Message* reply_msg, |
3301 bool* did_suppress_message) { | 3303 bool* did_suppress_message) { |
3302 // Suppress JavaScript dialogs when requested. Also suppress messages when | 3304 // Suppress JavaScript dialogs when requested. Also suppress messages when |
3303 // showing an interstitial as it's shown over the previous page and we don't | 3305 // showing an interstitial as it's shown over the previous page and we don't |
3304 // want the hidden page's dialogs to interfere with the interstitial. | 3306 // want the hidden page's dialogs to interfere with the interstitial. |
3305 bool suppress_this_message = | 3307 bool suppress_this_message = |
3306 static_cast<RenderViewHostImpl*>(rvh)->is_swapped_out() || | 3308 static_cast<RenderViewHostImpl*>(rvh)->rvh_state() == |
| 3309 RenderViewHostImpl::STATE_SWAPPED_OUT || |
3307 ShowingInterstitialPage() || | 3310 ShowingInterstitialPage() || |
3308 !delegate_ || | 3311 !delegate_ || |
3309 delegate_->ShouldSuppressDialogs() || | 3312 delegate_->ShouldSuppressDialogs() || |
3310 !delegate_->GetJavaScriptDialogManager(); | 3313 !delegate_->GetJavaScriptDialogManager(); |
3311 | 3314 |
3312 if (!suppress_this_message) { | 3315 if (!suppress_this_message) { |
3313 std::string accept_lang = GetContentClient()->browser()-> | 3316 std::string accept_lang = GetContentClient()->browser()-> |
3314 GetAcceptLangs(GetBrowserContext()); | 3317 GetAcceptLangs(GetBrowserContext()); |
3315 dialog_manager_ = delegate_->GetJavaScriptDialogManager(); | 3318 dialog_manager_ = delegate_->GetJavaScriptDialogManager(); |
3316 dialog_manager_->RunJavaScriptDialog( | 3319 dialog_manager_->RunJavaScriptDialog( |
(...skipping 24 matching lines...) Expand all Loading... |
3341 | 3344 |
3342 void WebContentsImpl::RunBeforeUnloadConfirm(RenderViewHost* rvh, | 3345 void WebContentsImpl::RunBeforeUnloadConfirm(RenderViewHost* rvh, |
3343 const base::string16& message, | 3346 const base::string16& message, |
3344 bool is_reload, | 3347 bool is_reload, |
3345 IPC::Message* reply_msg) { | 3348 IPC::Message* reply_msg) { |
3346 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>(rvh); | 3349 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>(rvh); |
3347 if (delegate_) | 3350 if (delegate_) |
3348 delegate_->WillRunBeforeUnloadConfirm(); | 3351 delegate_->WillRunBeforeUnloadConfirm(); |
3349 | 3352 |
3350 bool suppress_this_message = | 3353 bool suppress_this_message = |
3351 rvhi->is_swapped_out() || | 3354 rvhi->rvh_state() != RenderViewHostImpl::STATE_LIVE || |
3352 !delegate_ || | 3355 !delegate_ || |
3353 delegate_->ShouldSuppressDialogs() || | 3356 delegate_->ShouldSuppressDialogs() || |
3354 !delegate_->GetJavaScriptDialogManager(); | 3357 !delegate_->GetJavaScriptDialogManager(); |
3355 if (suppress_this_message) { | 3358 if (suppress_this_message) { |
3356 // The reply must be sent to the RVH that sent the request. | 3359 // The reply must be sent to the RVH that sent the request. |
3357 rvhi->JavaScriptDialogClosed(reply_msg, true, base::string16()); | 3360 rvhi->JavaScriptDialogClosed(reply_msg, true, base::string16()); |
3358 return; | 3361 return; |
3359 } | 3362 } |
3360 | 3363 |
3361 is_showing_before_unload_dialog_ = true; | 3364 is_showing_before_unload_dialog_ = true; |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3725 } | 3728 } |
3726 | 3729 |
3727 void WebContentsImpl::OnFrameRemoved( | 3730 void WebContentsImpl::OnFrameRemoved( |
3728 RenderViewHostImpl* render_view_host, | 3731 RenderViewHostImpl* render_view_host, |
3729 int64 frame_id) { | 3732 int64 frame_id) { |
3730 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 3733 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
3731 FrameDetached(render_view_host, frame_id)); | 3734 FrameDetached(render_view_host, frame_id)); |
3732 } | 3735 } |
3733 | 3736 |
3734 } // namespace content | 3737 } // namespace content |
OLD | NEW |