| 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/browser/frame_host/render_frame_host_impl.h" | 5 #include "content/browser/frame_host/render_frame_host_impl.h" |
| 6 | 6 |
| 7 #include "base/containers/hash_tables.h" | 7 #include "base/containers/hash_tables.h" |
| 8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
| 9 #include "base/metrics/user_metrics_action.h" | 9 #include "base/metrics/user_metrics_action.h" |
| 10 #include "content/browser/child_process_security_policy_impl.h" | |
| 11 #include "content/browser/frame_host/cross_process_frame_connector.h" | 10 #include "content/browser/frame_host/cross_process_frame_connector.h" |
| 12 #include "content/browser/frame_host/frame_tree.h" | 11 #include "content/browser/frame_host/frame_tree.h" |
| 13 #include "content/browser/frame_host/frame_tree_node.h" | 12 #include "content/browser/frame_host/frame_tree_node.h" |
| 14 #include "content/browser/frame_host/navigator.h" | 13 #include "content/browser/frame_host/navigator.h" |
| 15 #include "content/browser/frame_host/render_frame_host_delegate.h" | 14 #include "content/browser/frame_host/render_frame_host_delegate.h" |
| 16 #include "content/browser/renderer_host/render_view_host_impl.h" | 15 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 17 #include "content/common/frame_messages.h" | 16 #include "content/common/frame_messages.h" |
| 18 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
| 19 #include "content/public/browser/content_browser_client.h" | 18 #include "content/public/browser/content_browser_client.h" |
| 20 #include "content/public/browser/render_process_host.h" | 19 #include "content/public/browser/render_process_host.h" |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 | 337 |
| 339 bool RenderFrameHostImpl::CanCommitURL(const GURL& url) { | 338 bool RenderFrameHostImpl::CanCommitURL(const GURL& url) { |
| 340 // TODO(creis): We should also check for WebUI pages here. Also, when the | 339 // TODO(creis): We should also check for WebUI pages here. Also, when the |
| 341 // out-of-process iframes implementation is ready, we should check for | 340 // out-of-process iframes implementation is ready, we should check for |
| 342 // cross-site URLs that are not allowed to commit in this process. | 341 // cross-site URLs that are not allowed to commit in this process. |
| 343 | 342 |
| 344 // Give the client a chance to disallow URLs from committing. | 343 // Give the client a chance to disallow URLs from committing. |
| 345 return GetContentClient()->browser()->CanCommitURL(GetProcess(), url); | 344 return GetContentClient()->browser()->CanCommitURL(GetProcess(), url); |
| 346 } | 345 } |
| 347 | 346 |
| 348 void RenderFrameHostImpl::Navigate(const FrameMsg_Navigate_Params& params) { | |
| 349 TRACE_EVENT0("frame_host", "RenderFrameHostImpl::Navigate"); | |
| 350 // Browser plugin guests are not allowed to navigate outside web-safe schemes, | |
| 351 // so do not grant them the ability to request additional URLs. | |
| 352 if (!GetProcess()->IsGuest()) { | |
| 353 ChildProcessSecurityPolicyImpl::GetInstance()->GrantRequestURL( | |
| 354 GetProcess()->GetID(), params.url); | |
| 355 if (params.url.SchemeIs(kDataScheme) && | |
| 356 params.base_url_for_data_url.SchemeIs(kFileScheme)) { | |
| 357 // If 'data:' is used, and we have a 'file:' base url, grant access to | |
| 358 // local files. | |
| 359 ChildProcessSecurityPolicyImpl::GetInstance()->GrantRequestURL( | |
| 360 GetProcess()->GetID(), params.base_url_for_data_url); | |
| 361 } | |
| 362 } | |
| 363 | |
| 364 // Only send the message if we aren't suspended at the start of a cross-site | |
| 365 // request. | |
| 366 if (render_view_host_->navigations_suspended_) { | |
| 367 // Shouldn't be possible to have a second navigation while suspended, since | |
| 368 // navigations will only be suspended during a cross-site request. If a | |
| 369 // second navigation occurs, RenderFrameHostManager will cancel this pending | |
| 370 // RFH and create a new pending RFH. | |
| 371 DCHECK(!render_view_host_->suspended_nav_params_.get()); | |
| 372 render_view_host_->suspended_nav_params_.reset( | |
| 373 new FrameMsg_Navigate_Params(params)); | |
| 374 } else { | |
| 375 // Get back to a clean state, in case we start a new navigation without | |
| 376 // completing a RVH swap or unload handler. | |
| 377 render_view_host_->SetState(RenderViewHostImpl::STATE_DEFAULT); | |
| 378 | |
| 379 Send(new FrameMsg_Navigate(GetRoutingID(), params)); | |
| 380 } | |
| 381 | |
| 382 // Force the throbber to start. We do this because Blink's "started | |
| 383 // loading" message will be received asynchronously from the UI of the | |
| 384 // browser. But we want to keep the throbber in sync with what's happening | |
| 385 // in the UI. For example, we want to start throbbing immediately when the | |
| 386 // user naivgates even if the renderer is delayed. There is also an issue | |
| 387 // with the throbber starting because the WebUI (which controls whether the | |
| 388 // favicon is displayed) happens synchronously. If the start loading | |
| 389 // messages was asynchronous, then the default favicon would flash in. | |
| 390 // | |
| 391 // Blink doesn't send throb notifications for JavaScript URLs, so we | |
| 392 // don't want to either. | |
| 393 if (!params.url.SchemeIs(kJavaScriptScheme)) | |
| 394 delegate_->DidStartLoading(this); | |
| 395 } | |
| 396 | |
| 397 void RenderFrameHostImpl::NavigateToURL(const GURL& url) { | |
| 398 FrameMsg_Navigate_Params params; | |
| 399 params.page_id = -1; | |
| 400 params.pending_history_list_offset = -1; | |
| 401 params.current_history_list_offset = -1; | |
| 402 params.current_history_list_length = 0; | |
| 403 params.url = url; | |
| 404 params.transition = PAGE_TRANSITION_LINK; | |
| 405 params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | |
| 406 Navigate(params); | |
| 407 } | |
| 408 | |
| 409 } // namespace content | 347 } // namespace content |
| OLD | NEW |