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