| 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 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 is_showing_before_unload_dialog_(false), | 341 is_showing_before_unload_dialog_(false), |
| 342 last_active_time_(base::TimeTicks::Now()), | 342 last_active_time_(base::TimeTicks::Now()), |
| 343 closed_by_user_gesture_(false), | 343 closed_by_user_gesture_(false), |
| 344 minimum_zoom_percent_(static_cast<int>(kMinimumZoomFactor * 100)), | 344 minimum_zoom_percent_(static_cast<int>(kMinimumZoomFactor * 100)), |
| 345 maximum_zoom_percent_(static_cast<int>(kMaximumZoomFactor * 100)), | 345 maximum_zoom_percent_(static_cast<int>(kMaximumZoomFactor * 100)), |
| 346 totalPinchGestureAmount_(0), | 346 totalPinchGestureAmount_(0), |
| 347 currentPinchZoomStepDelta_(0), | 347 currentPinchZoomStepDelta_(0), |
| 348 render_view_message_source_(NULL), | 348 render_view_message_source_(NULL), |
| 349 fullscreen_widget_routing_id_(MSG_ROUTING_NONE), | 349 fullscreen_widget_routing_id_(MSG_ROUTING_NONE), |
| 350 is_subframe_(false), | 350 is_subframe_(false), |
| 351 overscroll_content_disabled_(false), |
| 351 last_dialog_suppressed_(false) { | 352 last_dialog_suppressed_(false) { |
| 352 for (size_t i = 0; i < g_created_callbacks.Get().size(); i++) | 353 for (size_t i = 0; i < g_created_callbacks.Get().size(); i++) |
| 353 g_created_callbacks.Get().at(i).Run(this); | 354 g_created_callbacks.Get().at(i).Run(this); |
| 354 frame_tree_.SetFrameRemoveListener( | 355 frame_tree_.SetFrameRemoveListener( |
| 355 base::Bind(&WebContentsImpl::OnFrameRemoved, | 356 base::Bind(&WebContentsImpl::OnFrameRemoved, |
| 356 base::Unretained(this))); | 357 base::Unretained(this))); |
| 357 } | 358 } |
| 358 | 359 |
| 359 WebContentsImpl::~WebContentsImpl() { | 360 WebContentsImpl::~WebContentsImpl() { |
| 360 is_being_destroyed_ = true; | 361 is_being_destroyed_ = true; |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 // TODO(cbentzel): remove this debugging code? | 608 // TODO(cbentzel): remove this debugging code? |
| 608 if (delegate == delegate_) | 609 if (delegate == delegate_) |
| 609 return; | 610 return; |
| 610 if (delegate_) | 611 if (delegate_) |
| 611 delegate_->Detach(this); | 612 delegate_->Detach(this); |
| 612 delegate_ = delegate; | 613 delegate_ = delegate; |
| 613 if (delegate_) { | 614 if (delegate_) { |
| 614 delegate_->Attach(this); | 615 delegate_->Attach(this); |
| 615 // Ensure the visible RVH reflects the new delegate's preferences. | 616 // Ensure the visible RVH reflects the new delegate's preferences. |
| 616 if (view_) | 617 if (view_) |
| 617 view_->SetOverscrollControllerEnabled(delegate->CanOverscrollContent()); | 618 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); |
| 618 } | 619 } |
| 619 } | 620 } |
| 620 | 621 |
| 621 RenderProcessHost* WebContentsImpl::GetRenderProcessHost() const { | 622 RenderProcessHost* WebContentsImpl::GetRenderProcessHost() const { |
| 622 RenderViewHostImpl* host = GetRenderManager()->current_host(); | 623 RenderViewHostImpl* host = GetRenderManager()->current_host(); |
| 623 return host ? host->GetProcess() : NULL; | 624 return host ? host->GetProcess() : NULL; |
| 624 } | 625 } |
| 625 | 626 |
| 626 RenderFrameHost* WebContentsImpl::GetMainFrame() { | 627 RenderFrameHost* WebContentsImpl::GetMainFrame() { |
| 627 return frame_tree_.root()->current_frame_host(); | 628 return frame_tree_.root()->current_frame_host(); |
| (...skipping 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1688 const gfx::Rect& anchor_in_root_view) { | 1689 const gfx::Rect& anchor_in_root_view) { |
| 1689 if (delegate_) | 1690 if (delegate_) |
| 1690 delegate_->MoveValidationMessage(this, anchor_in_root_view); | 1691 delegate_->MoveValidationMessage(this, anchor_in_root_view); |
| 1691 } | 1692 } |
| 1692 | 1693 |
| 1693 void WebContentsImpl::DidSendScreenRects(RenderWidgetHostImpl* rwh) { | 1694 void WebContentsImpl::DidSendScreenRects(RenderWidgetHostImpl* rwh) { |
| 1694 if (browser_plugin_embedder_) | 1695 if (browser_plugin_embedder_) |
| 1695 browser_plugin_embedder_->DidSendScreenRects(); | 1696 browser_plugin_embedder_->DidSendScreenRects(); |
| 1696 } | 1697 } |
| 1697 | 1698 |
| 1699 void WebContentsImpl::SetOverscrollContentDisabled(bool disabled) { |
| 1700 overscroll_content_disabled_ = disabled; |
| 1701 // Make sure the visible RVH reflects new preference. |
| 1702 if (view_) |
| 1703 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); |
| 1704 } |
| 1705 |
| 1698 void WebContentsImpl::UpdatePreferredSize(const gfx::Size& pref_size) { | 1706 void WebContentsImpl::UpdatePreferredSize(const gfx::Size& pref_size) { |
| 1699 const gfx::Size old_size = GetPreferredSize(); | 1707 const gfx::Size old_size = GetPreferredSize(); |
| 1700 preferred_size_ = pref_size; | 1708 preferred_size_ = pref_size; |
| 1701 OnPreferredSizeChanged(old_size); | 1709 OnPreferredSizeChanged(old_size); |
| 1702 } | 1710 } |
| 1703 | 1711 |
| 1704 void WebContentsImpl::ResizeDueToAutoResize(const gfx::Size& new_size) { | 1712 void WebContentsImpl::ResizeDueToAutoResize(const gfx::Size& new_size) { |
| 1705 if (delegate_) | 1713 if (delegate_) |
| 1706 delegate_->ResizeDueToAutoResize(this, new_size); | 1714 delegate_->ResizeDueToAutoResize(this, new_size); |
| 1707 } | 1715 } |
| (...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2446 // displayed insecure content. | 2454 // displayed insecure content. |
| 2447 displayed_insecure_content_ = false; | 2455 displayed_insecure_content_ = false; |
| 2448 SSLManager::NotifySSLInternalStateChanged( | 2456 SSLManager::NotifySSLInternalStateChanged( |
| 2449 GetController().GetBrowserContext()); | 2457 GetController().GetBrowserContext()); |
| 2450 } | 2458 } |
| 2451 | 2459 |
| 2452 // Notify observers about navigation. | 2460 // Notify observers about navigation. |
| 2453 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 2461 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 2454 DidNavigateMainFrame(details, params)); | 2462 DidNavigateMainFrame(details, params)); |
| 2455 | 2463 |
| 2456 if (delegate_) { | 2464 if (delegate_) |
| 2457 delegate_->DidNavigateMainFramePostCommit(this); | 2465 delegate_->DidNavigateMainFramePostCommit(this); |
| 2458 view_->SetOverscrollControllerEnabled(delegate_->CanOverscrollContent()); | 2466 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); |
| 2459 } | |
| 2460 } | 2467 } |
| 2461 | 2468 |
| 2462 void WebContentsImpl::DidNavigateAnyFramePostCommit( | 2469 void WebContentsImpl::DidNavigateAnyFramePostCommit( |
| 2463 RenderFrameHostImpl* render_frame_host, | 2470 RenderFrameHostImpl* render_frame_host, |
| 2464 const LoadCommittedDetails& details, | 2471 const LoadCommittedDetails& details, |
| 2465 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { | 2472 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { |
| 2466 // Now that something has committed, we don't need to track whether the | 2473 // Now that something has committed, we don't need to track whether the |
| 2467 // initial page has been accessed. | 2474 // initial page has been accessed. |
| 2468 has_accessed_initial_document_ = false; | 2475 has_accessed_initial_document_ = false; |
| 2469 | 2476 |
| 2470 // If we navigate off the page, close all JavaScript dialogs. | 2477 // If we navigate off the page, close all JavaScript dialogs. |
| 2471 if (dialog_manager_ && !details.is_in_page) | 2478 if (dialog_manager_ && !details.is_in_page) |
| 2472 dialog_manager_->CancelActiveAndPendingDialogs(this); | 2479 dialog_manager_->CancelActiveAndPendingDialogs(this); |
| 2473 | 2480 |
| 2474 // Notify observers about navigation. | 2481 // Notify observers about navigation. |
| 2475 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 2482 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 2476 DidNavigateAnyFrame(details, params)); | 2483 DidNavigateAnyFrame(details, params)); |
| 2477 } | 2484 } |
| 2478 | 2485 |
| 2479 void WebContentsImpl::SetMainFrameMimeType(const std::string& mime_type) { | 2486 void WebContentsImpl::SetMainFrameMimeType(const std::string& mime_type) { |
| 2480 contents_mime_type_ = mime_type; | 2487 contents_mime_type_ = mime_type; |
| 2481 } | 2488 } |
| 2482 | 2489 |
| 2483 bool WebContentsImpl::CanOverscrollContent() const { | 2490 bool WebContentsImpl::CanOverscrollContent() const { |
| 2491 if (overscroll_content_disabled_) |
| 2492 return false; |
| 2493 |
| 2484 if (delegate_) | 2494 if (delegate_) |
| 2485 return delegate_->CanOverscrollContent(); | 2495 return delegate_->CanOverscrollContent(); |
| 2486 | 2496 |
| 2487 return false; | 2497 return false; |
| 2488 } | 2498 } |
| 2489 | 2499 |
| 2490 void WebContentsImpl::OnDidLoadResourceFromMemoryCache( | 2500 void WebContentsImpl::OnDidLoadResourceFromMemoryCache( |
| 2491 const GURL& url, | 2501 const GURL& url, |
| 2492 const std::string& security_info, | 2502 const std::string& security_info, |
| 2493 const std::string& http_method, | 2503 const std::string& http_method, |
| (...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3285 } | 3295 } |
| 3286 | 3296 |
| 3287 void WebContentsImpl::RenderViewCreated(RenderViewHost* render_view_host) { | 3297 void WebContentsImpl::RenderViewCreated(RenderViewHost* render_view_host) { |
| 3288 // Don't send notifications if we are just creating a swapped-out RVH for | 3298 // Don't send notifications if we are just creating a swapped-out RVH for |
| 3289 // the opener chain. These won't be used for view-source or WebUI, so it's | 3299 // the opener chain. These won't be used for view-source or WebUI, so it's |
| 3290 // ok to return early. | 3300 // ok to return early. |
| 3291 if (static_cast<RenderViewHostImpl*>(render_view_host)->IsSwappedOut()) | 3301 if (static_cast<RenderViewHostImpl*>(render_view_host)->IsSwappedOut()) |
| 3292 return; | 3302 return; |
| 3293 | 3303 |
| 3294 if (delegate_) | 3304 if (delegate_) |
| 3295 view_->SetOverscrollControllerEnabled(delegate_->CanOverscrollContent()); | 3305 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); |
| 3296 | 3306 |
| 3297 NotificationService::current()->Notify( | 3307 NotificationService::current()->Notify( |
| 3298 NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED, | 3308 NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED, |
| 3299 Source<WebContents>(this), | 3309 Source<WebContents>(this), |
| 3300 Details<RenderViewHost>(render_view_host)); | 3310 Details<RenderViewHost>(render_view_host)); |
| 3301 | 3311 |
| 3302 // When we're creating views, we're still doing initial setup, so we always | 3312 // When we're creating views, we're still doing initial setup, so we always |
| 3303 // use the pending Web UI rather than any possibly existing committed one. | 3313 // use the pending Web UI rather than any possibly existing committed one. |
| 3304 if (GetRenderManager()->pending_web_ui()) | 3314 if (GetRenderManager()->pending_web_ui()) |
| 3305 GetRenderManager()->pending_web_ui()->RenderViewCreated(render_view_host); | 3315 GetRenderManager()->pending_web_ui()->RenderViewCreated(render_view_host); |
| (...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3787 if (dialog_manager_) | 3797 if (dialog_manager_) |
| 3788 dialog_manager_->CancelActiveAndPendingDialogs(this); | 3798 dialog_manager_->CancelActiveAndPendingDialogs(this); |
| 3789 } | 3799 } |
| 3790 | 3800 |
| 3791 void WebContentsImpl::NotifySwappedFromRenderManager(RenderViewHost* old_host, | 3801 void WebContentsImpl::NotifySwappedFromRenderManager(RenderViewHost* old_host, |
| 3792 RenderViewHost* new_host) { | 3802 RenderViewHost* new_host) { |
| 3793 NotifySwapped(old_host, new_host); | 3803 NotifySwapped(old_host, new_host); |
| 3794 | 3804 |
| 3795 // Make sure the visible RVH reflects the new delegate's preferences. | 3805 // Make sure the visible RVH reflects the new delegate's preferences. |
| 3796 if (delegate_) | 3806 if (delegate_) |
| 3797 view_->SetOverscrollControllerEnabled(delegate_->CanOverscrollContent()); | 3807 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); |
| 3798 | 3808 |
| 3799 view_->RenderViewSwappedIn(new_host); | 3809 view_->RenderViewSwappedIn(new_host); |
| 3800 } | 3810 } |
| 3801 | 3811 |
| 3802 int WebContentsImpl::CreateOpenerRenderViewsForRenderManager( | 3812 int WebContentsImpl::CreateOpenerRenderViewsForRenderManager( |
| 3803 SiteInstance* instance) { | 3813 SiteInstance* instance) { |
| 3804 if (!opener_) | 3814 if (!opener_) |
| 3805 return MSG_ROUTING_NONE; | 3815 return MSG_ROUTING_NONE; |
| 3806 | 3816 |
| 3807 // Recursively create RenderViews for anything else in the opener chain. | 3817 // Recursively create RenderViews for anything else in the opener chain. |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4047 | 4057 |
| 4048 void WebContentsImpl::OnPreferredSizeChanged(const gfx::Size& old_size) { | 4058 void WebContentsImpl::OnPreferredSizeChanged(const gfx::Size& old_size) { |
| 4049 if (!delegate_) | 4059 if (!delegate_) |
| 4050 return; | 4060 return; |
| 4051 const gfx::Size new_size = GetPreferredSize(); | 4061 const gfx::Size new_size = GetPreferredSize(); |
| 4052 if (new_size != old_size) | 4062 if (new_size != old_size) |
| 4053 delegate_->UpdatePreferredSize(this, new_size); | 4063 delegate_->UpdatePreferredSize(this, new_size); |
| 4054 } | 4064 } |
| 4055 | 4065 |
| 4056 } // namespace content | 4066 } // namespace content |
| OLD | NEW |