Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(526)

Side by Side Diff: content/browser/frame_host/render_frame_host_impl.cc

Issue 148083013: Move browser initiated navigation from RenderViewHost to RenderFrameHost. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix ASAN builds. Try 2. Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
10 #include "content/browser/frame_host/cross_process_frame_connector.h" 11 #include "content/browser/frame_host/cross_process_frame_connector.h"
11 #include "content/browser/frame_host/frame_tree.h" 12 #include "content/browser/frame_host/frame_tree.h"
12 #include "content/browser/frame_host/frame_tree_node.h" 13 #include "content/browser/frame_host/frame_tree_node.h"
13 #include "content/browser/frame_host/navigator.h" 14 #include "content/browser/frame_host/navigator.h"
14 #include "content/browser/frame_host/render_frame_host_delegate.h" 15 #include "content/browser/frame_host/render_frame_host_delegate.h"
15 #include "content/browser/renderer_host/render_view_host_impl.h" 16 #include "content/browser/renderer_host/render_view_host_impl.h"
16 #include "content/common/frame_messages.h" 17 #include "content/common/frame_messages.h"
18 #include "content/common/view_messages.h"
Charlie Reis 2014/02/13 01:23:53 Why do we need this?
nasko 2014/02/13 17:05:27 Done.
17 #include "content/public/browser/browser_thread.h" 19 #include "content/public/browser/browser_thread.h"
18 #include "content/public/browser/content_browser_client.h" 20 #include "content/public/browser/content_browser_client.h"
19 #include "content/public/browser/render_process_host.h" 21 #include "content/public/browser/render_process_host.h"
20 #include "content/public/browser/render_widget_host_view.h" 22 #include "content/public/browser/render_widget_host_view.h"
21 #include "content/public/browser/user_metrics.h" 23 #include "content/public/browser/user_metrics.h"
22 #include "content/public/common/url_constants.h" 24 #include "content/public/common/url_constants.h"
23 #include "url/gurl.h" 25 #include "url/gurl.h"
24 26
25 namespace content { 27 namespace content {
26 28
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 355
354 bool RenderFrameHostImpl::CanCommitURL(const GURL& url) { 356 bool RenderFrameHostImpl::CanCommitURL(const GURL& url) {
355 // TODO(creis): We should also check for WebUI pages here. Also, when the 357 // TODO(creis): We should also check for WebUI pages here. Also, when the
356 // out-of-process iframes implementation is ready, we should check for 358 // out-of-process iframes implementation is ready, we should check for
357 // cross-site URLs that are not allowed to commit in this process. 359 // cross-site URLs that are not allowed to commit in this process.
358 360
359 // Give the client a chance to disallow URLs from committing. 361 // Give the client a chance to disallow URLs from committing.
360 return GetContentClient()->browser()->CanCommitURL(GetProcess(), url); 362 return GetContentClient()->browser()->CanCommitURL(GetProcess(), url);
361 } 363 }
362 364
365 void RenderFrameHostImpl::Navigate(const FrameMsg_Navigate_Params& params) {
366 TRACE_EVENT0("renderer_host", "RenderFrameHostImpl::Navigate");
Charlie Reis 2014/02/13 01:23:53 Does this require any other bookkeeping to registe
nasko 2014/02/13 17:05:27 Nothing else is required, this is used for about:t
367 // Browser plugin guests are not allowed to navigate outside web-safe schemes,
368 // so do not grant them the ability to request additional URLs.
369 if (!GetProcess()->IsGuest()) {
370 ChildProcessSecurityPolicyImpl::GetInstance()->GrantRequestURL(
371 GetProcess()->GetID(), params.url);
372 if (params.url.SchemeIs(kDataScheme) &&
373 params.base_url_for_data_url.SchemeIs(kFileScheme)) {
374 // If 'data:' is used, and we have a 'file:' base url, grant access to
375 // local files.
376 ChildProcessSecurityPolicyImpl::GetInstance()->GrantRequestURL(
377 GetProcess()->GetID(), params.base_url_for_data_url);
378 }
379 }
380
381 // Only send the message if we aren't suspended at the start of a cross-site
382 // request.
383 if (render_view_host_->navigations_suspended_) {
384 // Shouldn't be possible to have a second navigation while suspended, since
385 // navigations will only be suspended during a cross-site request. If a
386 // second navigation occurs, RenderFrameHostManager will cancel this pending
387 // RFH and create a new pending RFH.
388 DCHECK(!render_view_host_->suspended_nav_params_.get());
389 render_view_host_->suspended_nav_params_.reset(
390 new FrameMsg_Navigate_Params(params));
391 } else {
392 // Get back to a clean state, in case we start a new navigation without
393 // completing a RVH swap or unload handler.
394 render_view_host_->SetState(RenderViewHostImpl::STATE_DEFAULT);
395
396 Send(new FrameMsg_Navigate(GetRoutingID(), params));
397 }
398
399 // Force the throbber to start. We do this because Blink's "started
400 // loading" message will be received asynchronously from the UI of the
401 // browser. But we want to keep the throbber in sync with what's happening
402 // in the UI. For example, we want to start throbbing immediately when the
403 // user naivgates even if the renderer is delayed. There is also an issue
404 // with the throbber starting because the WebUI (which controls whether the
405 // favicon is displayed) happens synchronously. If the start loading
406 // messages was asynchronous, then the default favicon would flash in.
407 //
408 // Blink doesn't send throb notifications for JavaScript URLs, so we
409 // don't want to either.
410 if (!params.url.SchemeIs(kJavaScriptScheme))
411 delegate_->DidStartLoading(this);
412 }
413
414 void RenderFrameHostImpl::NavigateToURL(const GURL& url) {
415 FrameMsg_Navigate_Params params;
416 params.page_id = -1;
417 params.pending_history_list_offset = -1;
418 params.current_history_list_offset = -1;
419 params.current_history_list_length = 0;
420 params.url = url;
421 params.transition = PAGE_TRANSITION_LINK;
422 params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
423 Navigate(params);
424 }
425
363 } // namespace content 426 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698