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 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 bool guest_compositing_enabled = !command_line.HasSwitch( | 558 bool guest_compositing_enabled = !command_line.HasSwitch( |
559 switches::kDisableBrowserPluginCompositing); | 559 switches::kDisableBrowserPluginCompositing); |
560 if (GetProcess()->IsGuest() && !guest_compositing_enabled) { | 560 if (GetProcess()->IsGuest() && !guest_compositing_enabled) { |
561 prefs.force_compositing_mode = false; | 561 prefs.force_compositing_mode = false; |
562 prefs.accelerated_compositing_enabled = false; | 562 prefs.accelerated_compositing_enabled = false; |
563 } | 563 } |
564 | 564 |
565 return prefs; | 565 return prefs; |
566 } | 566 } |
567 | 567 |
568 void RenderViewHostImpl::Navigate(const FrameMsg_Navigate_Params& params) { | 568 void RenderViewHostImpl::Navigate(const ViewMsg_Navigate_Params& params) { |
569 TRACE_EVENT0("renderer_host", "RenderViewHostImpl::Navigate"); | 569 TRACE_EVENT0("renderer_host", "RenderViewHostImpl::Navigate"); |
570 delegate_->GetFrameTree()->GetMainFrame()->Navigate(params); | 570 // Browser plugin guests are not allowed to navigate outside web-safe schemes, |
| 571 // so do not grant them the ability to request additional URLs. |
| 572 if (!GetProcess()->IsGuest()) { |
| 573 ChildProcessSecurityPolicyImpl::GetInstance()->GrantRequestURL( |
| 574 GetProcess()->GetID(), params.url); |
| 575 if (params.url.SchemeIs(kDataScheme) && |
| 576 params.base_url_for_data_url.SchemeIs(kFileScheme)) { |
| 577 // If 'data:' is used, and we have a 'file:' base url, grant access to |
| 578 // local files. |
| 579 ChildProcessSecurityPolicyImpl::GetInstance()->GrantRequestURL( |
| 580 GetProcess()->GetID(), params.base_url_for_data_url); |
| 581 } |
| 582 } |
| 583 |
| 584 // Only send the message if we aren't suspended at the start of a cross-site |
| 585 // request. |
| 586 if (navigations_suspended_) { |
| 587 // Shouldn't be possible to have a second navigation while suspended, since |
| 588 // navigations will only be suspended during a cross-site request. If a |
| 589 // second navigation occurs, WebContentsImpl will cancel this pending RVH |
| 590 // create a new pending RVH. |
| 591 DCHECK(!suspended_nav_params_.get()); |
| 592 suspended_nav_params_.reset(new ViewMsg_Navigate_Params(params)); |
| 593 } else { |
| 594 // Get back to a clean state, in case we start a new navigation without |
| 595 // completing a RVH swap or unload handler. |
| 596 SetState(STATE_DEFAULT); |
| 597 |
| 598 Send(new ViewMsg_Navigate(GetRoutingID(), params)); |
| 599 } |
| 600 |
| 601 // Force the throbber to start. We do this because WebKit's "started |
| 602 // loading" message will be received asynchronously from the UI of the |
| 603 // browser. But we want to keep the throbber in sync with what's happening |
| 604 // in the UI. For example, we want to start throbbing immediately when the |
| 605 // user naivgates even if the renderer is delayed. There is also an issue |
| 606 // with the throbber starting because the WebUI (which controls whether the |
| 607 // favicon is displayed) happens synchronously. If the start loading |
| 608 // messages was asynchronous, then the default favicon would flash in. |
| 609 // |
| 610 // WebKit doesn't send throb notifications for JavaScript URLs, so we |
| 611 // don't want to either. |
| 612 if (!params.url.SchemeIs(kJavaScriptScheme)) { |
| 613 RenderFrameHostImpl* rfh = |
| 614 static_cast<RenderFrameHostImpl*>(GetMainFrame()); |
| 615 rfh->OnDidStartLoading(); |
| 616 } |
571 } | 617 } |
572 | 618 |
573 void RenderViewHostImpl::NavigateToURL(const GURL& url) { | 619 void RenderViewHostImpl::NavigateToURL(const GURL& url) { |
574 delegate_->GetFrameTree()->GetMainFrame()->NavigateToURL(url); | 620 ViewMsg_Navigate_Params params; |
| 621 params.page_id = -1; |
| 622 params.pending_history_list_offset = -1; |
| 623 params.current_history_list_offset = -1; |
| 624 params.current_history_list_length = 0; |
| 625 params.url = url; |
| 626 params.transition = PAGE_TRANSITION_LINK; |
| 627 params.navigation_type = ViewMsg_Navigate_Type::NORMAL; |
| 628 Navigate(params); |
575 } | 629 } |
576 | 630 |
577 void RenderViewHostImpl::SetNavigationsSuspended( | 631 void RenderViewHostImpl::SetNavigationsSuspended( |
578 bool suspend, | 632 bool suspend, |
579 const base::TimeTicks& proceed_time) { | 633 const base::TimeTicks& proceed_time) { |
580 // This should only be called to toggle the state. | 634 // This should only be called to toggle the state. |
581 DCHECK(navigations_suspended_ != suspend); | 635 DCHECK(navigations_suspended_ != suspend); |
582 | 636 |
583 navigations_suspended_ = suspend; | 637 navigations_suspended_ = suspend; |
584 if (!suspend && suspended_nav_params_) { | 638 if (!suspend && suspended_nav_params_) { |
585 // There's navigation message params waiting to be sent. Now that we're not | 639 // There's navigation message params waiting to be sent. Now that we're not |
586 // suspended anymore, resume navigation by sending them. If we were swapped | 640 // suspended anymore, resume navigation by sending them. If we were swapped |
587 // out, we should also stop filtering out the IPC messages now. | 641 // out, we should also stop filtering out the IPC messages now. |
588 SetState(STATE_DEFAULT); | 642 SetState(STATE_DEFAULT); |
589 | 643 |
590 DCHECK(!proceed_time.is_null()); | 644 DCHECK(!proceed_time.is_null()); |
591 suspended_nav_params_->browser_navigation_start = proceed_time; | 645 suspended_nav_params_->browser_navigation_start = proceed_time; |
592 Send(new FrameMsg_Navigate( | 646 Send(new ViewMsg_Navigate(GetRoutingID(), *suspended_nav_params_.get())); |
593 main_frame_routing_id_, *suspended_nav_params_.get())); | |
594 suspended_nav_params_.reset(); | 647 suspended_nav_params_.reset(); |
595 } | 648 } |
596 } | 649 } |
597 | 650 |
598 void RenderViewHostImpl::CancelSuspendedNavigations() { | 651 void RenderViewHostImpl::CancelSuspendedNavigations() { |
599 // Clear any state if a pending navigation is canceled or pre-empted. | 652 // Clear any state if a pending navigation is canceled or pre-empted. |
600 if (suspended_nav_params_) | 653 if (suspended_nav_params_) |
601 suspended_nav_params_.reset(); | 654 suspended_nav_params_.reset(); |
602 navigations_suspended_ = false; | 655 navigations_suspended_ = false; |
603 } | 656 } |
(...skipping 1433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2037 return true; | 2090 return true; |
2038 } | 2091 } |
2039 | 2092 |
2040 void RenderViewHostImpl::AttachToFrameTree() { | 2093 void RenderViewHostImpl::AttachToFrameTree() { |
2041 FrameTree* frame_tree = delegate_->GetFrameTree(); | 2094 FrameTree* frame_tree = delegate_->GetFrameTree(); |
2042 | 2095 |
2043 frame_tree->ResetForMainFrameSwap(); | 2096 frame_tree->ResetForMainFrameSwap(); |
2044 } | 2097 } |
2045 | 2098 |
2046 } // namespace content | 2099 } // namespace content |
OLD | NEW |