| 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 2687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2698 | 2698 |
| 2699 void WebContentsImpl::RemoveBrowserPluginEmbedder() { | 2699 void WebContentsImpl::RemoveBrowserPluginEmbedder() { |
| 2700 if (browser_plugin_embedder_) | 2700 if (browser_plugin_embedder_) |
| 2701 browser_plugin_embedder_.reset(); | 2701 browser_plugin_embedder_.reset(); |
| 2702 } | 2702 } |
| 2703 | 2703 |
| 2704 void WebContentsImpl::RenderViewCreated(RenderViewHost* render_view_host) { | 2704 void WebContentsImpl::RenderViewCreated(RenderViewHost* render_view_host) { |
| 2705 // Don't send notifications if we are just creating a swapped-out RVH for | 2705 // Don't send notifications if we are just creating a swapped-out RVH for |
| 2706 // the opener chain. These won't be used for view-source or WebUI, so it's | 2706 // the opener chain. These won't be used for view-source or WebUI, so it's |
| 2707 // ok to return early. | 2707 // ok to return early. |
| 2708 if (static_cast<RenderViewHostImpl*>(render_view_host)->is_swapped_out()) | 2708 if (static_cast<RenderViewHostImpl*>(render_view_host)->rvh_state() == |
| 2709 RenderViewHostImpl::RVH_STATE_SWAPPED_OUT) |
| 2709 return; | 2710 return; |
| 2710 | 2711 |
| 2711 if (delegate_) | 2712 if (delegate_) |
| 2712 view_->SetOverscrollControllerEnabled(delegate_->CanOverscrollContent()); | 2713 view_->SetOverscrollControllerEnabled(delegate_->CanOverscrollContent()); |
| 2713 | 2714 |
| 2714 NotificationService::current()->Notify( | 2715 NotificationService::current()->Notify( |
| 2715 NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED, | 2716 NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED, |
| 2716 Source<WebContents>(this), | 2717 Source<WebContents>(this), |
| 2717 Details<RenderViewHost>(render_view_host)); | 2718 Details<RenderViewHost>(render_view_host)); |
| 2718 | 2719 |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3119 | 3120 |
| 3120 void WebContentsImpl::RequestOpenURL(RenderViewHost* rvh, | 3121 void WebContentsImpl::RequestOpenURL(RenderViewHost* rvh, |
| 3121 const GURL& url, | 3122 const GURL& url, |
| 3122 const Referrer& referrer, | 3123 const Referrer& referrer, |
| 3123 WindowOpenDisposition disposition, | 3124 WindowOpenDisposition disposition, |
| 3124 int64 source_frame_id, | 3125 int64 source_frame_id, |
| 3125 bool should_replace_current_entry, | 3126 bool should_replace_current_entry, |
| 3126 bool user_gesture) { | 3127 bool user_gesture) { |
| 3127 // If this came from a swapped out RenderViewHost, we only allow the request | 3128 // If this came from a swapped out RenderViewHost, we only allow the request |
| 3128 // if we are still in the same BrowsingInstance. | 3129 // if we are still in the same BrowsingInstance. |
| 3129 if (static_cast<RenderViewHostImpl*>(rvh)->is_swapped_out() && | 3130 if (static_cast<RenderViewHostImpl*>(rvh)->rvh_state() == |
| 3131 RenderViewHostImpl::RVH_STATE_SWAPPED_OUT && |
| 3130 !rvh->GetSiteInstance()->IsRelatedSiteInstance(GetSiteInstance())) { | 3132 !rvh->GetSiteInstance()->IsRelatedSiteInstance(GetSiteInstance())) { |
| 3131 return; | 3133 return; |
| 3132 } | 3134 } |
| 3133 | 3135 |
| 3134 // Delegate to RequestTransferURL because this is just the generic | 3136 // Delegate to RequestTransferURL because this is just the generic |
| 3135 // case where |old_request_id| is empty. | 3137 // case where |old_request_id| is empty. |
| 3136 // TODO(creis): Pass the redirect_chain into this method to support client | 3138 // TODO(creis): Pass the redirect_chain into this method to support client |
| 3137 // redirects. http://crbug.com/311721. | 3139 // redirects. http://crbug.com/311721. |
| 3138 std::vector<GURL> redirect_chain; | 3140 std::vector<GURL> redirect_chain; |
| 3139 RequestTransferURL(url, redirect_chain, referrer, PAGE_TRANSITION_LINK, | 3141 RequestTransferURL(url, redirect_chain, referrer, PAGE_TRANSITION_LINK, |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3289 const base::string16& message, | 3291 const base::string16& message, |
| 3290 const base::string16& default_prompt, | 3292 const base::string16& default_prompt, |
| 3291 const GURL& frame_url, | 3293 const GURL& frame_url, |
| 3292 JavaScriptMessageType javascript_message_type, | 3294 JavaScriptMessageType javascript_message_type, |
| 3293 IPC::Message* reply_msg, | 3295 IPC::Message* reply_msg, |
| 3294 bool* did_suppress_message) { | 3296 bool* did_suppress_message) { |
| 3295 // Suppress JavaScript dialogs when requested. Also suppress messages when | 3297 // Suppress JavaScript dialogs when requested. Also suppress messages when |
| 3296 // showing an interstitial as it's shown over the previous page and we don't | 3298 // showing an interstitial as it's shown over the previous page and we don't |
| 3297 // want the hidden page's dialogs to interfere with the interstitial. | 3299 // want the hidden page's dialogs to interfere with the interstitial. |
| 3298 bool suppress_this_message = | 3300 bool suppress_this_message = |
| 3299 static_cast<RenderViewHostImpl*>(rvh)->is_swapped_out() || | 3301 static_cast<RenderViewHostImpl*>(rvh)->rvh_state() == |
| 3302 RenderViewHostImpl::RVH_STATE_SWAPPED_OUT || |
| 3300 ShowingInterstitialPage() || | 3303 ShowingInterstitialPage() || |
| 3301 !delegate_ || | 3304 !delegate_ || |
| 3302 delegate_->ShouldSuppressDialogs() || | 3305 delegate_->ShouldSuppressDialogs() || |
| 3303 !delegate_->GetJavaScriptDialogManager(); | 3306 !delegate_->GetJavaScriptDialogManager(); |
| 3304 | 3307 |
| 3305 if (!suppress_this_message) { | 3308 if (!suppress_this_message) { |
| 3306 std::string accept_lang = GetContentClient()->browser()-> | 3309 std::string accept_lang = GetContentClient()->browser()-> |
| 3307 GetAcceptLangs(GetBrowserContext()); | 3310 GetAcceptLangs(GetBrowserContext()); |
| 3308 dialog_manager_ = delegate_->GetJavaScriptDialogManager(); | 3311 dialog_manager_ = delegate_->GetJavaScriptDialogManager(); |
| 3309 dialog_manager_->RunJavaScriptDialog( | 3312 dialog_manager_->RunJavaScriptDialog( |
| (...skipping 24 matching lines...) Expand all Loading... |
| 3334 | 3337 |
| 3335 void WebContentsImpl::RunBeforeUnloadConfirm(RenderViewHost* rvh, | 3338 void WebContentsImpl::RunBeforeUnloadConfirm(RenderViewHost* rvh, |
| 3336 const base::string16& message, | 3339 const base::string16& message, |
| 3337 bool is_reload, | 3340 bool is_reload, |
| 3338 IPC::Message* reply_msg) { | 3341 IPC::Message* reply_msg) { |
| 3339 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>(rvh); | 3342 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>(rvh); |
| 3340 if (delegate_) | 3343 if (delegate_) |
| 3341 delegate_->WillRunBeforeUnloadConfirm(); | 3344 delegate_->WillRunBeforeUnloadConfirm(); |
| 3342 | 3345 |
| 3343 bool suppress_this_message = | 3346 bool suppress_this_message = |
| 3344 rvhi->is_swapped_out() || | 3347 rvhi->rvh_state() != RenderViewHostImpl::RVH_STATE_LIVE || |
| 3345 !delegate_ || | 3348 !delegate_ || |
| 3346 delegate_->ShouldSuppressDialogs() || | 3349 delegate_->ShouldSuppressDialogs() || |
| 3347 !delegate_->GetJavaScriptDialogManager(); | 3350 !delegate_->GetJavaScriptDialogManager(); |
| 3348 if (suppress_this_message) { | 3351 if (suppress_this_message) { |
| 3349 // The reply must be sent to the RVH that sent the request. | 3352 // The reply must be sent to the RVH that sent the request. |
| 3350 rvhi->JavaScriptDialogClosed(reply_msg, true, base::string16()); | 3353 rvhi->JavaScriptDialogClosed(reply_msg, true, base::string16()); |
| 3351 return; | 3354 return; |
| 3352 } | 3355 } |
| 3353 | 3356 |
| 3354 is_showing_before_unload_dialog_ = true; | 3357 is_showing_before_unload_dialog_ = true; |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3703 } | 3706 } |
| 3704 | 3707 |
| 3705 void WebContentsImpl::OnFrameRemoved( | 3708 void WebContentsImpl::OnFrameRemoved( |
| 3706 RenderViewHostImpl* render_view_host, | 3709 RenderViewHostImpl* render_view_host, |
| 3707 int64 frame_id) { | 3710 int64 frame_id) { |
| 3708 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 3711 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 3709 FrameDetached(render_view_host, frame_id)); | 3712 FrameDetached(render_view_host, frame_id)); |
| 3710 } | 3713 } |
| 3711 | 3714 |
| 3712 } // namespace content | 3715 } // namespace content |
| OLD | NEW |