OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/renderer/render_frame_impl.h" | 5 #include "content/renderer/render_frame_impl.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 2581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2592 blink::WebNavigationPolicy policy, | 2592 blink::WebNavigationPolicy policy, |
2593 const blink::WebString& suggested_name, | 2593 const blink::WebString& suggested_name, |
2594 bool should_replace_current_entry) { | 2594 bool should_replace_current_entry) { |
2595 Referrer referrer(RenderViewImpl::GetReferrerFromRequest(frame_, request)); | 2595 Referrer referrer(RenderViewImpl::GetReferrerFromRequest(frame_, request)); |
2596 if (policy == blink::WebNavigationPolicyDownload) { | 2596 if (policy == blink::WebNavigationPolicyDownload) { |
2597 render_view_->Send(new ViewHostMsg_DownloadUrl(render_view_->GetRoutingID(), | 2597 render_view_->Send(new ViewHostMsg_DownloadUrl(render_view_->GetRoutingID(), |
2598 GetRoutingID(), | 2598 GetRoutingID(), |
2599 request.url(), referrer, | 2599 request.url(), referrer, |
2600 suggested_name)); | 2600 suggested_name)); |
2601 } else { | 2601 } else { |
2602 OpenURL(request.url(), referrer, policy, should_replace_current_entry); | 2602 OpenURL(request.url(), referrer, policy, should_replace_current_entry, |
| 2603 false); |
2603 } | 2604 } |
2604 } | 2605 } |
2605 | 2606 |
2606 blink::WebHistoryItem RenderFrameImpl::historyItemForNewChildFrame( | 2607 blink::WebHistoryItem RenderFrameImpl::historyItemForNewChildFrame() { |
2607 blink::WebFrame* frame) { | 2608 // OOPIF enabled modes will punt this navigation to the browser in |
2608 DCHECK(!frame_ || frame_ == frame); | 2609 // decidePolicyForNavigation. |
2609 | |
2610 // TODO(creis): In OOPIF enabled modes, send an IPC to the browser process | |
2611 // telling it to navigate the new frame. See https://crbug.com/502317. | |
2612 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) | 2610 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) |
2613 return WebHistoryItem(); | 2611 return WebHistoryItem(); |
2614 | 2612 |
2615 return render_view_->history_controller()->GetItemForNewChildFrame(this); | 2613 return render_view_->history_controller()->GetItemForNewChildFrame(this); |
2616 } | 2614 } |
2617 | 2615 |
2618 void RenderFrameImpl::willSendSubmitEvent(blink::WebLocalFrame* frame, | 2616 void RenderFrameImpl::willSendSubmitEvent(blink::WebLocalFrame* frame, |
2619 const blink::WebFormElement& form) { | 2617 const blink::WebFormElement& form) { |
2620 DCHECK(!frame_ || frame_ == frame); | 2618 DCHECK(!frame_ || frame_ == frame); |
2621 | 2619 |
(...skipping 1880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4502 if (info.urlRequest.url() != GURL(kSwappedOutURL)) { | 4500 if (info.urlRequest.url() != GURL(kSwappedOutURL)) { |
4503 // Targeted links may try to navigate a swapped out frame. Allow the | 4501 // Targeted links may try to navigate a swapped out frame. Allow the |
4504 // browser process to navigate the tab instead. Note that it is also | 4502 // browser process to navigate the tab instead. Note that it is also |
4505 // possible for non-targeted navigations (from this view) to arrive | 4503 // possible for non-targeted navigations (from this view) to arrive |
4506 // here just after we are swapped out. It's ok to send them to the | 4504 // here just after we are swapped out. It's ok to send them to the |
4507 // browser, as long as they're for the top level frame. | 4505 // browser, as long as they're for the top level frame. |
4508 // TODO(creis): Ensure this supports targeted form submissions when | 4506 // TODO(creis): Ensure this supports targeted form submissions when |
4509 // fixing http://crbug.com/101395. | 4507 // fixing http://crbug.com/101395. |
4510 if (frame_->parent() == NULL) { | 4508 if (frame_->parent() == NULL) { |
4511 OpenURL(info.urlRequest.url(), referrer, info.defaultPolicy, | 4509 OpenURL(info.urlRequest.url(), referrer, info.defaultPolicy, |
4512 info.replacesCurrentHistoryItem); | 4510 info.replacesCurrentHistoryItem, false); |
4513 return blink::WebNavigationPolicyIgnore; // Suppress the load here. | 4511 return blink::WebNavigationPolicyIgnore; // Suppress the load here. |
4514 } | 4512 } |
4515 | 4513 |
4516 // We should otherwise ignore in-process iframe navigations, if they | 4514 // We should otherwise ignore in-process iframe navigations, if they |
4517 // arrive just after we are swapped out. | 4515 // arrive just after we are swapped out. |
4518 return blink::WebNavigationPolicyIgnore; | 4516 return blink::WebNavigationPolicyIgnore; |
4519 } | 4517 } |
4520 | 4518 |
4521 // Allow kSwappedOutURL to complete. | 4519 // Allow kSwappedOutURL to complete. |
4522 return info.defaultPolicy; | 4520 return info.defaultPolicy; |
4523 } | 4521 } |
4524 } | 4522 } |
4525 | 4523 |
4526 // Webkit is asking whether to navigate to a new URL. | 4524 // Webkit is asking whether to navigate to a new URL. |
4527 // This is fine normally, except if we're showing UI from one security | 4525 // This is fine normally, except if we're showing UI from one security |
4528 // context and they're trying to navigate to a different context. | 4526 // context and they're trying to navigate to a different context. |
4529 const GURL& url = info.urlRequest.url(); | 4527 const GURL& url = info.urlRequest.url(); |
4530 | 4528 |
4531 // If the browser is interested, then give it a chance to look at the request. | 4529 // If the browser is interested, then give it a chance to look at the request. |
4532 if (is_content_initiated && IsTopLevelNavigation(frame_) && | 4530 if (is_content_initiated && IsTopLevelNavigation(frame_) && |
4533 render_view_->renderer_preferences_ | 4531 render_view_->renderer_preferences_ |
4534 .browser_handles_all_top_level_requests) { | 4532 .browser_handles_all_top_level_requests) { |
4535 OpenURL(url, referrer, info.defaultPolicy, info.replacesCurrentHistoryItem); | 4533 OpenURL(url, referrer, info.defaultPolicy, info.replacesCurrentHistoryItem, |
| 4534 false); |
4536 return blink::WebNavigationPolicyIgnore; // Suppress the load here. | 4535 return blink::WebNavigationPolicyIgnore; // Suppress the load here. |
4537 } | 4536 } |
4538 | 4537 |
| 4538 // In OOPIF-enabled modes, back/forward navigations in newly created subframes |
| 4539 // should be sent to the browser in case there is a matching |
| 4540 // FrameNavigationEntry. If none is found, fall back to the default url. |
| 4541 if (SiteIsolationPolicy::UseSubframeNavigationEntries() && |
| 4542 info.isHistoryNavigationInNewChildFrame && is_content_initiated) { |
| 4543 OpenURL(url, referrer, info.defaultPolicy, info.replacesCurrentHistoryItem, |
| 4544 true); |
| 4545 // Suppress the load in Blink but mark the frame as loading. |
| 4546 return blink::WebNavigationPolicyHandledByClient; |
| 4547 } |
| 4548 |
4539 // Use the frame's original request's URL rather than the document's URL for | 4549 // Use the frame's original request's URL rather than the document's URL for |
4540 // subsequent checks. For a popup, the document's URL may become the opener | 4550 // subsequent checks. For a popup, the document's URL may become the opener |
4541 // window's URL if the opener has called document.write(). | 4551 // window's URL if the opener has called document.write(). |
4542 // See http://crbug.com/93517. | 4552 // See http://crbug.com/93517. |
4543 GURL old_url(frame_->dataSource()->request().url()); | 4553 GURL old_url(frame_->dataSource()->request().url()); |
4544 | 4554 |
4545 // Detect when we're crossing a permission-based boundary (e.g. into or out of | 4555 // Detect when we're crossing a permission-based boundary (e.g. into or out of |
4546 // an extension or app origin, leaving a WebUI page, etc). We only care about | 4556 // an extension or app origin, leaving a WebUI page, etc). We only care about |
4547 // top-level navigations (not iframes). But we sometimes navigate to | 4557 // top-level navigations (not iframes). But we sometimes navigate to |
4548 // about:blank to clear a tab, and we want to still allow that. | 4558 // about:blank to clear a tab, and we want to still allow that. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4588 | 4598 |
4589 if (!should_fork) { | 4599 if (!should_fork) { |
4590 // Give the embedder a chance. | 4600 // Give the embedder a chance. |
4591 should_fork = GetContentClient()->renderer()->ShouldFork( | 4601 should_fork = GetContentClient()->renderer()->ShouldFork( |
4592 frame_, url, info.urlRequest.httpMethod().utf8(), | 4602 frame_, url, info.urlRequest.httpMethod().utf8(), |
4593 is_initial_navigation, is_redirect, &send_referrer); | 4603 is_initial_navigation, is_redirect, &send_referrer); |
4594 } | 4604 } |
4595 | 4605 |
4596 if (should_fork) { | 4606 if (should_fork) { |
4597 OpenURL(url, send_referrer ? referrer : Referrer(), info.defaultPolicy, | 4607 OpenURL(url, send_referrer ? referrer : Referrer(), info.defaultPolicy, |
4598 info.replacesCurrentHistoryItem); | 4608 info.replacesCurrentHistoryItem, false); |
4599 return blink::WebNavigationPolicyIgnore; // Suppress the load here. | 4609 return blink::WebNavigationPolicyIgnore; // Suppress the load here. |
4600 } | 4610 } |
4601 } | 4611 } |
4602 | 4612 |
4603 // Detect when a page is "forking" a new tab that can be safely rendered in | 4613 // Detect when a page is "forking" a new tab that can be safely rendered in |
4604 // its own process. This is done by sites like Gmail that try to open links | 4614 // its own process. This is done by sites like Gmail that try to open links |
4605 // in new windows without script connections back to the original page. We | 4615 // in new windows without script connections back to the original page. We |
4606 // treat such cases as browser navigations (in which we will create a new | 4616 // treat such cases as browser navigations (in which we will create a new |
4607 // renderer for a cross-site navigation), rather than WebKit navigations. | 4617 // renderer for a cross-site navigation), rather than WebKit navigations. |
4608 // | 4618 // |
(...skipping 19 matching lines...) Expand all Loading... |
4628 // Must not have issued the request from this page. | 4638 // Must not have issued the request from this page. |
4629 is_content_initiated && | 4639 is_content_initiated && |
4630 // Must be targeted at the current tab. | 4640 // Must be targeted at the current tab. |
4631 info.defaultPolicy == blink::WebNavigationPolicyCurrentTab && | 4641 info.defaultPolicy == blink::WebNavigationPolicyCurrentTab && |
4632 // Must be a JavaScript navigation, which appears as "other". | 4642 // Must be a JavaScript navigation, which appears as "other". |
4633 info.navigationType == blink::WebNavigationTypeOther; | 4643 info.navigationType == blink::WebNavigationTypeOther; |
4634 | 4644 |
4635 if (is_fork) { | 4645 if (is_fork) { |
4636 // Open the URL via the browser, not via WebKit. | 4646 // Open the URL via the browser, not via WebKit. |
4637 OpenURL(url, Referrer(), info.defaultPolicy, | 4647 OpenURL(url, Referrer(), info.defaultPolicy, |
4638 info.replacesCurrentHistoryItem); | 4648 info.replacesCurrentHistoryItem, false); |
4639 return blink::WebNavigationPolicyIgnore; | 4649 return blink::WebNavigationPolicyIgnore; |
4640 } | 4650 } |
4641 | 4651 |
4642 // PlzNavigate: if the navigation is not synchronous, send it to the browser. | 4652 // PlzNavigate: if the navigation is not synchronous, send it to the browser. |
4643 // This includes navigations with no request being sent to the network stack. | 4653 // This includes navigations with no request being sent to the network stack. |
4644 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 4654 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
4645 switches::kEnableBrowserSideNavigation) && | 4655 switches::kEnableBrowserSideNavigation) && |
4646 info.urlRequest.checkForBrowserSideNavigation() && | 4656 info.urlRequest.checkForBrowserSideNavigation() && |
4647 ShouldMakeNetworkRequestForURL(url)) { | 4657 ShouldMakeNetworkRequestForURL(url)) { |
4648 BeginNavigation(&info.urlRequest); | 4658 BeginNavigation(&info.urlRequest); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4688 // Serialize the frame (without recursing into subframes). | 4698 // Serialize the frame (without recursing into subframes). |
4689 WebPageSerializer::serialize(GetWebFrame(), | 4699 WebPageSerializer::serialize(GetWebFrame(), |
4690 this, // WebPageSerializerClient. | 4700 this, // WebPageSerializerClient. |
4691 weburl_links, webstring_paths, | 4701 weburl_links, webstring_paths, |
4692 local_directory_path.AsUTF16Unsafe()); | 4702 local_directory_path.AsUTF16Unsafe()); |
4693 } | 4703 } |
4694 | 4704 |
4695 void RenderFrameImpl::OpenURL(const GURL& url, | 4705 void RenderFrameImpl::OpenURL(const GURL& url, |
4696 const Referrer& referrer, | 4706 const Referrer& referrer, |
4697 WebNavigationPolicy policy, | 4707 WebNavigationPolicy policy, |
4698 bool should_replace_current_entry) { | 4708 bool should_replace_current_entry, |
| 4709 bool is_history_navigation_in_new_child) { |
4699 FrameHostMsg_OpenURL_Params params; | 4710 FrameHostMsg_OpenURL_Params params; |
4700 params.url = url; | 4711 params.url = url; |
4701 params.referrer = referrer; | 4712 params.referrer = referrer; |
4702 params.disposition = RenderViewImpl::NavigationPolicyToDisposition(policy); | 4713 params.disposition = RenderViewImpl::NavigationPolicyToDisposition(policy); |
4703 | 4714 |
4704 if (IsBrowserInitiated(pending_navigation_params_.get())) { | 4715 if (IsBrowserInitiated(pending_navigation_params_.get())) { |
4705 // This is necessary to preserve the should_replace_current_entry value on | 4716 // This is necessary to preserve the should_replace_current_entry value on |
4706 // cross-process redirects, in the event it was set by a previous process. | 4717 // cross-process redirects, in the event it was set by a previous process. |
4707 // | 4718 // |
4708 // TODO(davidben): Avoid this awkward duplication of state. See comment on | 4719 // TODO(davidben): Avoid this awkward duplication of state. See comment on |
4709 // NavigationState::should_replace_current_entry(). | 4720 // NavigationState::should_replace_current_entry(). |
4710 params.should_replace_current_entry = | 4721 params.should_replace_current_entry = |
4711 pending_navigation_params_->common_params.should_replace_current_entry; | 4722 pending_navigation_params_->common_params.should_replace_current_entry; |
4712 } else { | 4723 } else { |
4713 params.should_replace_current_entry = | 4724 params.should_replace_current_entry = |
4714 should_replace_current_entry && render_view_->history_list_length_; | 4725 should_replace_current_entry && render_view_->history_list_length_; |
4715 } | 4726 } |
4716 params.user_gesture = WebUserGestureIndicator::isProcessingUserGesture(); | 4727 params.user_gesture = WebUserGestureIndicator::isProcessingUserGesture(); |
4717 if (GetContentClient()->renderer()->AllowPopup()) | 4728 if (GetContentClient()->renderer()->AllowPopup()) |
4718 params.user_gesture = true; | 4729 params.user_gesture = true; |
4719 | 4730 |
4720 if (policy == blink::WebNavigationPolicyNewBackgroundTab || | 4731 if (policy == blink::WebNavigationPolicyNewBackgroundTab || |
4721 policy == blink::WebNavigationPolicyNewForegroundTab || | 4732 policy == blink::WebNavigationPolicyNewForegroundTab || |
4722 policy == blink::WebNavigationPolicyNewWindow || | 4733 policy == blink::WebNavigationPolicyNewWindow || |
4723 policy == blink::WebNavigationPolicyNewPopup) { | 4734 policy == blink::WebNavigationPolicyNewPopup) { |
4724 WebUserGestureIndicator::consumeUserGesture(); | 4735 WebUserGestureIndicator::consumeUserGesture(); |
4725 } | 4736 } |
4726 | 4737 |
| 4738 if (is_history_navigation_in_new_child) { |
| 4739 DCHECK(SiteIsolationPolicy::UseSubframeNavigationEntries()); |
| 4740 params.is_history_navigation_in_new_child = true; |
| 4741 params.frame_unique_name = frame_->uniqueName().utf8(); |
| 4742 } |
| 4743 |
4727 Send(new FrameHostMsg_OpenURL(routing_id_, params)); | 4744 Send(new FrameHostMsg_OpenURL(routing_id_, params)); |
4728 } | 4745 } |
4729 | 4746 |
4730 void RenderFrameImpl::NavigateInternal( | 4747 void RenderFrameImpl::NavigateInternal( |
4731 const CommonNavigationParams& common_params, | 4748 const CommonNavigationParams& common_params, |
4732 const StartNavigationParams& start_params, | 4749 const StartNavigationParams& start_params, |
4733 const RequestNavigationParams& request_params, | 4750 const RequestNavigationParams& request_params, |
4734 scoped_ptr<StreamOverrideParameters> stream_params) { | 4751 scoped_ptr<StreamOverrideParameters> stream_params) { |
4735 bool browser_side_navigation = | 4752 bool browser_side_navigation = |
4736 base::CommandLine::ForCurrentProcess()->HasSwitch( | 4753 base::CommandLine::ForCurrentProcess()->HasSwitch( |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4849 // store the relevant frame's WebHistoryItem in the root of the | 4866 // store the relevant frame's WebHistoryItem in the root of the |
4850 // PageState. | 4867 // PageState. |
4851 SetPendingNavigationParams(navigation_params.Pass()); | 4868 SetPendingNavigationParams(navigation_params.Pass()); |
4852 blink::WebHistoryItem history_item = entry->root(); | 4869 blink::WebHistoryItem history_item = entry->root(); |
4853 blink::WebHistoryLoadType load_type = | 4870 blink::WebHistoryLoadType load_type = |
4854 request_params.is_same_document_history_load | 4871 request_params.is_same_document_history_load |
4855 ? blink::WebHistorySameDocumentLoad | 4872 ? blink::WebHistorySameDocumentLoad |
4856 : blink::WebHistoryDifferentDocumentLoad; | 4873 : blink::WebHistoryDifferentDocumentLoad; |
4857 | 4874 |
4858 // Navigate the frame directly. | 4875 // Navigate the frame directly. |
| 4876 // TODO(creis): Use InitialHistoryLoad rather than BackForward for a |
| 4877 // history navigation in a newly created subframe. |
4859 WebURLRequest request = | 4878 WebURLRequest request = |
4860 frame_->requestFromHistoryItem(history_item, cache_policy); | 4879 frame_->requestFromHistoryItem(history_item, cache_policy); |
4861 frame_->load(request, blink::WebFrameLoadType::BackForward, | 4880 frame_->load(request, blink::WebFrameLoadType::BackForward, |
4862 history_item, load_type); | 4881 history_item, load_type); |
4863 } | 4882 } |
4864 } else { | 4883 } else { |
4865 // TODO(clamy): this should be set to the HistoryItem sent by the | 4884 // TODO(clamy): this should be set to the HistoryItem sent by the |
4866 // browser once the HistoryController has moved to the browser. | 4885 // browser once the HistoryController has moved to the browser. |
4867 // TODO(clamy): distinguish between different document and same document | 4886 // TODO(clamy): distinguish between different document and same document |
4868 // loads. | 4887 // loads. |
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5473 media::ConvertToSwitchOutputDeviceCB(web_callbacks); | 5492 media::ConvertToSwitchOutputDeviceCB(web_callbacks); |
5474 scoped_refptr<media::AudioOutputDevice> device = | 5493 scoped_refptr<media::AudioOutputDevice> device = |
5475 AudioDeviceFactory::NewOutputDevice(routing_id_, 0, sink_id.utf8(), | 5494 AudioDeviceFactory::NewOutputDevice(routing_id_, 0, sink_id.utf8(), |
5476 security_origin); | 5495 security_origin); |
5477 media::OutputDeviceStatus status = device->GetDeviceStatus(); | 5496 media::OutputDeviceStatus status = device->GetDeviceStatus(); |
5478 device->Stop(); | 5497 device->Stop(); |
5479 callback.Run(status); | 5498 callback.Run(status); |
5480 } | 5499 } |
5481 | 5500 |
5482 } // namespace content | 5501 } // namespace content |
OLD | NEW |