summaryrefslogtreecommitdiffstats
path: root/content/public/browser/navigation_handle.cc
blob: 857e17d74f9c6589ce3e313ac4150bb200569e4f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "content/public/browser/navigation_handle.h"

#include <utility>

#include "content/browser/frame_host/navigation_handle_impl.h"
#include "content/browser/frame_host/navigator.h"
#include "content/browser/frame_host/render_frame_host_impl.h"
#include "content/browser/web_contents/web_contents_impl.h"

namespace content {

WebContents* NavigationHandle::GetWebContents() {
  // The NavigationHandleImpl cannot access the WebContentsImpl as it would be
  // a layering violation, hence the cast here.
  return static_cast<WebContentsImpl*>(
      static_cast<NavigationHandleImpl*>(this)->GetDelegate());
}

// static
scoped_ptr<NavigationHandle> NavigationHandle::CreateNavigationHandleForTesting(
    const GURL& url,
    RenderFrameHost* render_frame_host) {
  scoped_ptr<NavigationHandleImpl> handle_impl = NavigationHandleImpl::Create(
      url,
      static_cast<RenderFrameHostImpl*>(render_frame_host)->frame_tree_node(),
      false,  // is_synchronous
      false,  // is_srcdoc
      base::TimeTicks::Now());
  return scoped_ptr<NavigationHandle>(std::move(handle_impl));
}

}  // namespace content