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

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: Another one bites the dust. 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"
17 #include "content/public/browser/browser_thread.h" 18 #include "content/public/browser/browser_thread.h"
18 #include "content/public/browser/content_browser_client.h" 19 #include "content/public/browser/content_browser_client.h"
19 #include "content/public/browser/render_process_host.h" 20 #include "content/public/browser/render_process_host.h"
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 354
354 bool RenderFrameHostImpl::CanCommitURL(const GURL& url) { 355 bool RenderFrameHostImpl::CanCommitURL(const GURL& url) {
355 // TODO(creis): We should also check for WebUI pages here. Also, when the 356 // 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 357 // out-of-process iframes implementation is ready, we should check for
357 // cross-site URLs that are not allowed to commit in this process. 358 // cross-site URLs that are not allowed to commit in this process.
358 359
359 // Give the client a chance to disallow URLs from committing. 360 // Give the client a chance to disallow URLs from committing.
360 return GetContentClient()->browser()->CanCommitURL(GetProcess(), url); 361 return GetContentClient()->browser()->CanCommitURL(GetProcess(), url);
361 } 362 }
362 363
364 void RenderFrameHostImpl::Navigate(const FrameMsg_Navigate_Params& params) {
365 TRACE_EVENT0("frame_host", "RenderFrameHostImpl::Navigate");
366 // Browser plugin guests are not allowed to navigate outside web-safe schemes,
367 // so do not grant them the ability to request additional URLs.
368 if (!GetProcess()->IsGuest()) {
369 ChildProcessSecurityPolicyImpl::GetInstance()->GrantRequestURL(
370 GetProcess()->GetID(), params.url);
371 if (params.url.SchemeIs(kDataScheme) &&
372 params.base_url_for_data_url.SchemeIs(kFileScheme)) {
373 // If 'data:' is used, and we have a 'file:' base url, grant access to
374 // local files.
375 ChildProcessSecurityPolicyImpl::GetInstance()->GrantRequestURL(
376 GetProcess()->GetID(), params.base_url_for_data_url);
377 }
378 }
379
380 // Only send the message if we aren't suspended at the start of a cross-site
381 // request.
382 if (render_view_host_->navigations_suspended_) {
383 // Shouldn't be possible to have a second navigation while suspended, since
384 // navigations will only be suspended during a cross-site request. If a
385 // second navigation occurs, RenderFrameHostManager will cancel this pending
386 // RFH and create a new pending RFH.
387 DCHECK(!render_view_host_->suspended_nav_params_.get());
388 render_view_host_->suspended_nav_params_.reset(
389 new FrameMsg_Navigate_Params(params));
390 } else {
391 // Get back to a clean state, in case we start a new navigation without
392 // completing a RVH swap or unload handler.
393 render_view_host_->SetState(RenderViewHostImpl::STATE_DEFAULT);
394
395 Send(new FrameMsg_Navigate(GetRoutingID(), params));
396 }
397
398 // Force the throbber to start. We do this because Blink's "started
399 // loading" message will be received asynchronously from the UI of the
400 // browser. But we want to keep the throbber in sync with what's happening
401 // in the UI. For example, we want to start throbbing immediately when the
402 // user naivgates even if the renderer is delayed. There is also an issue
403 // with the throbber starting because the WebUI (which controls whether the
404 // favicon is displayed) happens synchronously. If the start loading
405 // messages was asynchronous, then the default favicon would flash in.
406 //
407 // Blink doesn't send throb notifications for JavaScript URLs, so we
408 // don't want to either.
409 if (!params.url.SchemeIs(kJavaScriptScheme))
410 delegate_->DidStartLoading(this);
411 }
412
413 void RenderFrameHostImpl::NavigateToURL(const GURL& url) {
414 FrameMsg_Navigate_Params params;
415 params.page_id = -1;
416 params.pending_history_list_offset = -1;
417 params.current_history_list_offset = -1;
418 params.current_history_list_length = 0;
419 params.url = url;
420 params.transition = PAGE_TRANSITION_LINK;
421 params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
422 Navigate(params);
423 }
424
363 } // namespace content 425 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/render_frame_host_impl.h ('k') | content/browser/frame_host/render_frame_host_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698