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 ViewMsg_Navigate_Params& params) { | 568 void RenderViewHostImpl::Navigate(const FrameMsg_Navigate_Params& params) { |
569 TRACE_EVENT0("renderer_host", "RenderViewHostImpl::Navigate"); | 569 TRACE_EVENT0("renderer_host", "RenderViewHostImpl::Navigate"); |
570 // Browser plugin guests are not allowed to navigate outside web-safe schemes, | 570 delegate_->GetFrameTree()->GetMainFrame()->Navigate(params); |
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 } | |
617 } | 571 } |
618 | 572 |
619 void RenderViewHostImpl::NavigateToURL(const GURL& url) { | 573 void RenderViewHostImpl::NavigateToURL(const GURL& url) { |
620 ViewMsg_Navigate_Params params; | 574 delegate_->GetFrameTree()->GetMainFrame()->NavigateToURL(url); |
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); | |
629 } | 575 } |
630 | 576 |
631 void RenderViewHostImpl::SetNavigationsSuspended( | 577 void RenderViewHostImpl::SetNavigationsSuspended( |
632 bool suspend, | 578 bool suspend, |
633 const base::TimeTicks& proceed_time) { | 579 const base::TimeTicks& proceed_time) { |
634 // This should only be called to toggle the state. | 580 // This should only be called to toggle the state. |
635 DCHECK(navigations_suspended_ != suspend); | 581 DCHECK(navigations_suspended_ != suspend); |
636 | 582 |
637 navigations_suspended_ = suspend; | 583 navigations_suspended_ = suspend; |
638 if (!suspend && suspended_nav_params_) { | 584 if (!suspend && suspended_nav_params_) { |
639 // There's navigation message params waiting to be sent. Now that we're not | 585 // There's navigation message params waiting to be sent. Now that we're not |
640 // suspended anymore, resume navigation by sending them. If we were swapped | 586 // suspended anymore, resume navigation by sending them. If we were swapped |
641 // out, we should also stop filtering out the IPC messages now. | 587 // out, we should also stop filtering out the IPC messages now. |
642 SetState(STATE_DEFAULT); | 588 SetState(STATE_DEFAULT); |
643 | 589 |
644 DCHECK(!proceed_time.is_null()); | 590 DCHECK(!proceed_time.is_null()); |
645 suspended_nav_params_->browser_navigation_start = proceed_time; | 591 suspended_nav_params_->browser_navigation_start = proceed_time; |
646 Send(new ViewMsg_Navigate(GetRoutingID(), *suspended_nav_params_.get())); | 592 Send(new FrameMsg_Navigate( |
| 593 main_frame_routing_id_, *suspended_nav_params_.get())); |
647 suspended_nav_params_.reset(); | 594 suspended_nav_params_.reset(); |
648 } | 595 } |
649 } | 596 } |
650 | 597 |
651 void RenderViewHostImpl::CancelSuspendedNavigations() { | 598 void RenderViewHostImpl::CancelSuspendedNavigations() { |
652 // Clear any state if a pending navigation is canceled or pre-empted. | 599 // Clear any state if a pending navigation is canceled or pre-empted. |
653 if (suspended_nav_params_) | 600 if (suspended_nav_params_) |
654 suspended_nav_params_.reset(); | 601 suspended_nav_params_.reset(); |
655 navigations_suspended_ = false; | 602 navigations_suspended_ = false; |
656 } | 603 } |
(...skipping 1432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2089 return true; | 2036 return true; |
2090 } | 2037 } |
2091 | 2038 |
2092 void RenderViewHostImpl::AttachToFrameTree() { | 2039 void RenderViewHostImpl::AttachToFrameTree() { |
2093 FrameTree* frame_tree = delegate_->GetFrameTree(); | 2040 FrameTree* frame_tree = delegate_->GetFrameTree(); |
2094 | 2041 |
2095 frame_tree->ResetForMainFrameSwap(); | 2042 frame_tree->ResetForMainFrameSwap(); |
2096 } | 2043 } |
2097 | 2044 |
2098 } // namespace content | 2045 } // namespace content |
OLD | NEW |