| 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/renderer_host/render_view_host_impl.h" | 5 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 bool guest_compositing_enabled = !command_line.HasSwitch( | 575 bool guest_compositing_enabled = !command_line.HasSwitch( |
| 576 switches::kDisableBrowserPluginCompositing); | 576 switches::kDisableBrowserPluginCompositing); |
| 577 if (GetProcess()->IsGuest() && !guest_compositing_enabled) { | 577 if (GetProcess()->IsGuest() && !guest_compositing_enabled) { |
| 578 prefs.force_compositing_mode = false; | 578 prefs.force_compositing_mode = false; |
| 579 prefs.accelerated_compositing_enabled = false; | 579 prefs.accelerated_compositing_enabled = false; |
| 580 } | 580 } |
| 581 | 581 |
| 582 return prefs; | 582 return prefs; |
| 583 } | 583 } |
| 584 | 584 |
| 585 void RenderViewHostImpl::Navigate(const ViewMsg_Navigate_Params& params) { | 585 void RenderViewHostImpl::Navigate(const FrameMsg_Navigate_Params& params) { |
| 586 TRACE_EVENT0("renderer_host", "RenderViewHostImpl::Navigate"); | 586 TRACE_EVENT0("renderer_host", "RenderViewHostImpl::Navigate"); |
| 587 // Browser plugin guests are not allowed to navigate outside web-safe schemes, | 587 delegate_->GetFrameTree()->GetMainFrame()->Navigate(params); |
| 588 // so do not grant them the ability to request additional URLs. | |
| 589 if (!GetProcess()->IsGuest()) { | |
| 590 ChildProcessSecurityPolicyImpl::GetInstance()->GrantRequestURL( | |
| 591 GetProcess()->GetID(), params.url); | |
| 592 if (params.url.SchemeIs(kDataScheme) && | |
| 593 params.base_url_for_data_url.SchemeIs(kFileScheme)) { | |
| 594 // If 'data:' is used, and we have a 'file:' base url, grant access to | |
| 595 // local files. | |
| 596 ChildProcessSecurityPolicyImpl::GetInstance()->GrantRequestURL( | |
| 597 GetProcess()->GetID(), params.base_url_for_data_url); | |
| 598 } | |
| 599 } | |
| 600 | |
| 601 // Only send the message if we aren't suspended at the start of a cross-site | |
| 602 // request. | |
| 603 if (navigations_suspended_) { | |
| 604 // Shouldn't be possible to have a second navigation while suspended, since | |
| 605 // navigations will only be suspended during a cross-site request. If a | |
| 606 // second navigation occurs, WebContentsImpl will cancel this pending RVH | |
| 607 // create a new pending RVH. | |
| 608 DCHECK(!suspended_nav_params_.get()); | |
| 609 suspended_nav_params_.reset(new ViewMsg_Navigate_Params(params)); | |
| 610 } else { | |
| 611 // Get back to a clean state, in case we start a new navigation without | |
| 612 // completing a RVH swap or unload handler. | |
| 613 SetState(STATE_DEFAULT); | |
| 614 | |
| 615 Send(new ViewMsg_Navigate(GetRoutingID(), params)); | |
| 616 } | |
| 617 | |
| 618 // Force the throbber to start. We do this because WebKit's "started | |
| 619 // loading" message will be received asynchronously from the UI of the | |
| 620 // browser. But we want to keep the throbber in sync with what's happening | |
| 621 // in the UI. For example, we want to start throbbing immediately when the | |
| 622 // user naivgates even if the renderer is delayed. There is also an issue | |
| 623 // with the throbber starting because the WebUI (which controls whether the | |
| 624 // favicon is displayed) happens synchronously. If the start loading | |
| 625 // messages was asynchronous, then the default favicon would flash in. | |
| 626 // | |
| 627 // WebKit doesn't send throb notifications for JavaScript URLs, so we | |
| 628 // don't want to either. | |
| 629 if (!params.url.SchemeIs(kJavaScriptScheme)) { | |
| 630 RenderFrameHostImpl* rfh = | |
| 631 static_cast<RenderFrameHostImpl*>(GetMainFrame()); | |
| 632 rfh->OnDidStartLoading(); | |
| 633 } | |
| 634 } | 588 } |
| 635 | 589 |
| 636 void RenderViewHostImpl::NavigateToURL(const GURL& url) { | 590 void RenderViewHostImpl::NavigateToURL(const GURL& url) { |
| 637 ViewMsg_Navigate_Params params; | 591 delegate_->GetFrameTree()->GetMainFrame()->NavigateToURL(url); |
| 638 params.page_id = -1; | |
| 639 params.pending_history_list_offset = -1; | |
| 640 params.current_history_list_offset = -1; | |
| 641 params.current_history_list_length = 0; | |
| 642 params.url = url; | |
| 643 params.transition = PAGE_TRANSITION_LINK; | |
| 644 params.navigation_type = ViewMsg_Navigate_Type::NORMAL; | |
| 645 Navigate(params); | |
| 646 } | 592 } |
| 647 | 593 |
| 648 void RenderViewHostImpl::SetNavigationsSuspended( | 594 void RenderViewHostImpl::SetNavigationsSuspended( |
| 649 bool suspend, | 595 bool suspend, |
| 650 const base::TimeTicks& proceed_time) { | 596 const base::TimeTicks& proceed_time) { |
| 651 // This should only be called to toggle the state. | 597 // This should only be called to toggle the state. |
| 652 DCHECK(navigations_suspended_ != suspend); | 598 DCHECK(navigations_suspended_ != suspend); |
| 653 | 599 |
| 654 navigations_suspended_ = suspend; | 600 navigations_suspended_ = suspend; |
| 655 if (!suspend && suspended_nav_params_) { | 601 if (!suspend && suspended_nav_params_) { |
| 656 // There's navigation message params waiting to be sent. Now that we're not | 602 // There's navigation message params waiting to be sent. Now that we're not |
| 657 // suspended anymore, resume navigation by sending them. If we were swapped | 603 // suspended anymore, resume navigation by sending them. If we were swapped |
| 658 // out, we should also stop filtering out the IPC messages now. | 604 // out, we should also stop filtering out the IPC messages now. |
| 659 SetState(STATE_DEFAULT); | 605 SetState(STATE_DEFAULT); |
| 660 | 606 |
| 661 DCHECK(!proceed_time.is_null()); | 607 DCHECK(!proceed_time.is_null()); |
| 662 suspended_nav_params_->browser_navigation_start = proceed_time; | 608 suspended_nav_params_->browser_navigation_start = proceed_time; |
| 663 Send(new ViewMsg_Navigate(GetRoutingID(), *suspended_nav_params_.get())); | 609 Send(new FrameMsg_Navigate(GetRoutingID(), *suspended_nav_params_.get())); |
| 664 suspended_nav_params_.reset(); | 610 suspended_nav_params_.reset(); |
| 665 } | 611 } |
| 666 } | 612 } |
| 667 | 613 |
| 668 void RenderViewHostImpl::CancelSuspendedNavigations() { | 614 void RenderViewHostImpl::CancelSuspendedNavigations() { |
| 669 // Clear any state if a pending navigation is canceled or pre-empted. | 615 // Clear any state if a pending navigation is canceled or pre-empted. |
| 670 if (suspended_nav_params_) | 616 if (suspended_nav_params_) |
| 671 suspended_nav_params_.reset(); | 617 suspended_nav_params_.reset(); |
| 672 navigations_suspended_ = false; | 618 navigations_suspended_ = false; |
| 673 } | 619 } |
| (...skipping 1488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2162 void RenderViewHostImpl::AttachToFrameTree() { | 2108 void RenderViewHostImpl::AttachToFrameTree() { |
| 2163 FrameTree* frame_tree = delegate_->GetFrameTree(); | 2109 FrameTree* frame_tree = delegate_->GetFrameTree(); |
| 2164 | 2110 |
| 2165 frame_tree->ResetForMainFrameSwap(); | 2111 frame_tree->ResetForMainFrameSwap(); |
| 2166 if (main_frame_id() != FrameTreeNode::kInvalidFrameId) { | 2112 if (main_frame_id() != FrameTreeNode::kInvalidFrameId) { |
| 2167 frame_tree->OnFirstNavigationAfterSwap(main_frame_id()); | 2113 frame_tree->OnFirstNavigationAfterSwap(main_frame_id()); |
| 2168 } | 2114 } |
| 2169 } | 2115 } |
| 2170 | 2116 |
| 2171 } // namespace content | 2117 } // namespace content |
| OLD | NEW |