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 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 for (size_t i = 0; i < g_created_callbacks.Get().size(); i++) | 320 for (size_t i = 0; i < g_created_callbacks.Get().size(); i++) |
321 g_created_callbacks.Get().at(i).Run(this); | 321 g_created_callbacks.Get().at(i).Run(this); |
322 frame_tree_.SetFrameRemoveListener( | 322 frame_tree_.SetFrameRemoveListener( |
323 base::Bind(&WebContentsImpl::OnFrameRemoved, | 323 base::Bind(&WebContentsImpl::OnFrameRemoved, |
324 base::Unretained(this))); | 324 base::Unretained(this))); |
325 } | 325 } |
326 | 326 |
327 WebContentsImpl::~WebContentsImpl() { | 327 WebContentsImpl::~WebContentsImpl() { |
328 is_being_destroyed_ = true; | 328 is_being_destroyed_ = true; |
329 | 329 |
| 330 // Delete all RFH pending shutdown, which will lead the corresponding RVH to |
| 331 // shutdown and be deleted as well. |
| 332 frame_tree_.ForEach( |
| 333 base::Bind(&RenderFrameHostManager::ClearRFHsPendingShutdown)); |
| 334 |
330 ClearAllPowerSaveBlockers(); | 335 ClearAllPowerSaveBlockers(); |
331 | 336 |
332 for (std::set<RenderWidgetHostImpl*>::iterator iter = | 337 for (std::set<RenderWidgetHostImpl*>::iterator iter = |
333 created_widgets_.begin(); iter != created_widgets_.end(); ++iter) { | 338 created_widgets_.begin(); iter != created_widgets_.end(); ++iter) { |
334 (*iter)->DetachDelegate(); | 339 (*iter)->DetachDelegate(); |
335 } | 340 } |
336 created_widgets_.clear(); | 341 created_widgets_.clear(); |
337 | 342 |
338 // Clear out any JavaScript state. | 343 // Clear out any JavaScript state. |
339 if (dialog_manager_) | 344 if (dialog_manager_) |
(...skipping 2432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2772 | 2777 |
2773 void WebContentsImpl::RemoveBrowserPluginEmbedder() { | 2778 void WebContentsImpl::RemoveBrowserPluginEmbedder() { |
2774 if (browser_plugin_embedder_) | 2779 if (browser_plugin_embedder_) |
2775 browser_plugin_embedder_.reset(); | 2780 browser_plugin_embedder_.reset(); |
2776 } | 2781 } |
2777 | 2782 |
2778 void WebContentsImpl::RenderViewCreated(RenderViewHost* render_view_host) { | 2783 void WebContentsImpl::RenderViewCreated(RenderViewHost* render_view_host) { |
2779 // Don't send notifications if we are just creating a swapped-out RVH for | 2784 // Don't send notifications if we are just creating a swapped-out RVH for |
2780 // the opener chain. These won't be used for view-source or WebUI, so it's | 2785 // the opener chain. These won't be used for view-source or WebUI, so it's |
2781 // ok to return early. | 2786 // ok to return early. |
2782 if (static_cast<RenderViewHostImpl*>(render_view_host)->is_swapped_out()) | 2787 if (static_cast<RenderViewHostImpl*>(render_view_host)->IsSwappedOut()) |
2783 return; | 2788 return; |
2784 | 2789 |
2785 if (delegate_) | 2790 if (delegate_) |
2786 view_->SetOverscrollControllerEnabled(delegate_->CanOverscrollContent()); | 2791 view_->SetOverscrollControllerEnabled(delegate_->CanOverscrollContent()); |
2787 | 2792 |
2788 NotificationService::current()->Notify( | 2793 NotificationService::current()->Notify( |
2789 NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED, | 2794 NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED, |
2790 Source<WebContents>(this), | 2795 Source<WebContents>(this), |
2791 Details<RenderViewHost>(render_view_host)); | 2796 Details<RenderViewHost>(render_view_host)); |
2792 | 2797 |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3054 | 3059 |
3055 void WebContentsImpl::RequestOpenURL(RenderViewHost* rvh, | 3060 void WebContentsImpl::RequestOpenURL(RenderViewHost* rvh, |
3056 const GURL& url, | 3061 const GURL& url, |
3057 const Referrer& referrer, | 3062 const Referrer& referrer, |
3058 WindowOpenDisposition disposition, | 3063 WindowOpenDisposition disposition, |
3059 int64 source_frame_id, | 3064 int64 source_frame_id, |
3060 bool should_replace_current_entry, | 3065 bool should_replace_current_entry, |
3061 bool user_gesture) { | 3066 bool user_gesture) { |
3062 // If this came from a swapped out RenderViewHost, we only allow the request | 3067 // If this came from a swapped out RenderViewHost, we only allow the request |
3063 // if we are still in the same BrowsingInstance. | 3068 // if we are still in the same BrowsingInstance. |
3064 if (static_cast<RenderViewHostImpl*>(rvh)->is_swapped_out() && | 3069 if (static_cast<RenderViewHostImpl*>(rvh)->IsSwappedOut() && |
3065 !rvh->GetSiteInstance()->IsRelatedSiteInstance(GetSiteInstance())) { | 3070 !rvh->GetSiteInstance()->IsRelatedSiteInstance(GetSiteInstance())) { |
3066 return; | 3071 return; |
3067 } | 3072 } |
3068 | 3073 |
3069 // Delegate to RequestTransferURL because this is just the generic | 3074 // Delegate to RequestTransferURL because this is just the generic |
3070 // case where |old_request_id| is empty. | 3075 // case where |old_request_id| is empty. |
3071 // TODO(creis): Pass the redirect_chain into this method to support client | 3076 // TODO(creis): Pass the redirect_chain into this method to support client |
3072 // redirects. http://crbug.com/311721. | 3077 // redirects. http://crbug.com/311721. |
3073 std::vector<GURL> redirect_chain; | 3078 std::vector<GURL> redirect_chain; |
3074 RequestTransferURL(url, redirect_chain, referrer, PAGE_TRANSITION_LINK, | 3079 RequestTransferURL(url, redirect_chain, referrer, PAGE_TRANSITION_LINK, |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3225 const base::string16& message, | 3230 const base::string16& message, |
3226 const base::string16& default_prompt, | 3231 const base::string16& default_prompt, |
3227 const GURL& frame_url, | 3232 const GURL& frame_url, |
3228 JavaScriptMessageType javascript_message_type, | 3233 JavaScriptMessageType javascript_message_type, |
3229 IPC::Message* reply_msg, | 3234 IPC::Message* reply_msg, |
3230 bool* did_suppress_message) { | 3235 bool* did_suppress_message) { |
3231 // Suppress JavaScript dialogs when requested. Also suppress messages when | 3236 // Suppress JavaScript dialogs when requested. Also suppress messages when |
3232 // showing an interstitial as it's shown over the previous page and we don't | 3237 // showing an interstitial as it's shown over the previous page and we don't |
3233 // want the hidden page's dialogs to interfere with the interstitial. | 3238 // want the hidden page's dialogs to interfere with the interstitial. |
3234 bool suppress_this_message = | 3239 bool suppress_this_message = |
3235 static_cast<RenderViewHostImpl*>(rvh)->is_swapped_out() || | 3240 static_cast<RenderViewHostImpl*>(rvh)->IsSwappedOut() || |
3236 ShowingInterstitialPage() || | 3241 ShowingInterstitialPage() || |
3237 !delegate_ || | 3242 !delegate_ || |
3238 delegate_->ShouldSuppressDialogs() || | 3243 delegate_->ShouldSuppressDialogs() || |
3239 !delegate_->GetJavaScriptDialogManager(); | 3244 !delegate_->GetJavaScriptDialogManager(); |
3240 | 3245 |
3241 if (!suppress_this_message) { | 3246 if (!suppress_this_message) { |
3242 std::string accept_lang = GetContentClient()->browser()-> | 3247 std::string accept_lang = GetContentClient()->browser()-> |
3243 GetAcceptLangs(GetBrowserContext()); | 3248 GetAcceptLangs(GetBrowserContext()); |
3244 dialog_manager_ = delegate_->GetJavaScriptDialogManager(); | 3249 dialog_manager_ = delegate_->GetJavaScriptDialogManager(); |
3245 dialog_manager_->RunJavaScriptDialog( | 3250 dialog_manager_->RunJavaScriptDialog( |
(...skipping 24 matching lines...) Expand all Loading... |
3270 | 3275 |
3271 void WebContentsImpl::RunBeforeUnloadConfirm(RenderViewHost* rvh, | 3276 void WebContentsImpl::RunBeforeUnloadConfirm(RenderViewHost* rvh, |
3272 const base::string16& message, | 3277 const base::string16& message, |
3273 bool is_reload, | 3278 bool is_reload, |
3274 IPC::Message* reply_msg) { | 3279 IPC::Message* reply_msg) { |
3275 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>(rvh); | 3280 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>(rvh); |
3276 if (delegate_) | 3281 if (delegate_) |
3277 delegate_->WillRunBeforeUnloadConfirm(); | 3282 delegate_->WillRunBeforeUnloadConfirm(); |
3278 | 3283 |
3279 bool suppress_this_message = | 3284 bool suppress_this_message = |
3280 rvhi->is_swapped_out() || | 3285 rvhi->rvh_state() != RenderViewHostImpl::STATE_DEFAULT || |
3281 !delegate_ || | 3286 !delegate_ || |
3282 delegate_->ShouldSuppressDialogs() || | 3287 delegate_->ShouldSuppressDialogs() || |
3283 !delegate_->GetJavaScriptDialogManager(); | 3288 !delegate_->GetJavaScriptDialogManager(); |
3284 if (suppress_this_message) { | 3289 if (suppress_this_message) { |
3285 // The reply must be sent to the RVH that sent the request. | 3290 // The reply must be sent to the RVH that sent the request. |
3286 rvhi->JavaScriptDialogClosed(reply_msg, true, base::string16()); | 3291 rvhi->JavaScriptDialogClosed(reply_msg, true, base::string16()); |
3287 return; | 3292 return; |
3288 } | 3293 } |
3289 | 3294 |
3290 is_showing_before_unload_dialog_ = true; | 3295 is_showing_before_unload_dialog_ = true; |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3662 | 3667 |
3663 void WebContentsImpl::OnPreferredSizeChanged(const gfx::Size& old_size) { | 3668 void WebContentsImpl::OnPreferredSizeChanged(const gfx::Size& old_size) { |
3664 if (!delegate_) | 3669 if (!delegate_) |
3665 return; | 3670 return; |
3666 const gfx::Size new_size = GetPreferredSize(); | 3671 const gfx::Size new_size = GetPreferredSize(); |
3667 if (new_size != old_size) | 3672 if (new_size != old_size) |
3668 delegate_->UpdatePreferredSize(this, new_size); | 3673 delegate_->UpdatePreferredSize(this, new_size); |
3669 } | 3674 } |
3670 | 3675 |
3671 } // namespace content | 3676 } // namespace content |
OLD | NEW |