1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // PageNavigator defines an interface that can be used to express the user's
6 // intention to navigate to a particular URL. The implementing class should
7 // perform the navigation.
9 #ifndef CONTENT_PUBLIC_BROWSER_PAGE_NAVIGATOR_H_
10 #define CONTENT_PUBLIC_BROWSER_PAGE_NAVIGATOR_H_
14 #include "base/memory/ref_counted.h"
15 #include "base/memory/ref_counted_memory.h"
16 #include "content/common/content_export.h"
17 #include "content/public/browser/global_request_id.h"
18 #include "content/public/browser/site_instance.h"
19 #include "content/public/common/referrer.h"
20 #include "ui/base/page_transition_types.h"
21 #include "ui/base/window_open_disposition.h"
28 struct CONTENT_EXPORT OpenURLParams
{
29 OpenURLParams(const GURL
& url
,
30 const Referrer
& referrer
,
31 WindowOpenDisposition disposition
,
32 ui::PageTransition transition
,
33 bool is_renderer_initiated
);
34 OpenURLParams(const GURL
& url
,
35 const Referrer
& referrer
,
36 int64 frame_tree_node_id
,
37 WindowOpenDisposition disposition
,
38 ui::PageTransition transition
,
39 bool is_renderer_initiated
);
42 // The URL/referrer to be opened.
46 // SiteInstance of the frame that initiated the navigation or null if we
48 scoped_refptr
<content::SiteInstance
> source_site_instance
;
50 // Any redirect URLs that occurred for this navigation before |url|.
51 std::vector
<GURL
> redirect_chain
;
53 // Indicates whether this navigation will be sent using POST.
54 // The POST method is limited support for basic POST data by leveraging
55 // NavigationController::LOAD_TYPE_BROWSER_INITIATED_HTTP_POST.
56 // It is not for things like file uploads.
59 // The post data when the navigation uses POST.
60 scoped_refptr
<base::RefCountedMemory
> browser_initiated_post_data
;
62 // Extra headers to add to the request for this page. Headers are
63 // represented as "<name>: <value>" and separated by \r\n. The entire string
64 // is terminated by \r\n. May be empty if no extra headers are needed.
65 std::string extra_headers
;
67 // The browser-global FrameTreeNode ID or -1 to indicate the main frame.
68 int64 frame_tree_node_id
;
70 // The disposition requested by the navigation source.
71 WindowOpenDisposition disposition
;
73 // The transition type of navigation.
74 ui::PageTransition transition
;
76 // Whether this navigation is initiated by the renderer process.
77 bool is_renderer_initiated
;
79 // Reference to the old request id in case this is a navigation that is being
80 // transferred to a new renderer.
81 GlobalRequestID transferred_global_request_id
;
83 // Indicates whether this navigation should replace the current
85 bool should_replace_current_entry
;
87 // Indicates whether this navigation was triggered while processing a user
88 // gesture if the navigation was initiated by the renderer.
97 virtual ~PageNavigator() {}
99 // Opens a URL with the given disposition. The transition specifies how this
100 // navigation should be recorded in the history system (for example, typed).
101 // Returns the WebContents the URL is opened in, or nullptr if the URL wasn't
102 // opened immediately.
103 virtual WebContents
* OpenURL(const OpenURLParams
& params
) = 0;
106 } // namespace content
108 #endif // CONTENT_PUBLIC_BROWSER_PAGE_NAVIGATOR_H_