blob: 912cab83ea62ee7f7503458bf1399bf0b4830029 [file] [log] [blame]
// Copyright (c) 2012 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.
// PageNavigator defines an interface that can be used to express the user's
// intention to navigate to a particular URL. The implementing class should
// perform the navigation.
#include <string>
#include "base/memory/ref_counted.h"
#include "base/memory/ref_counted_memory.h"
#include "content/common/content_export.h"
#include "content/public/browser/global_request_id.h"
#include "content/public/browser/site_instance.h"
#include "content/public/common/referrer.h"
#include "ui/base/page_transition_types.h"
#include "ui/base/window_open_disposition.h"
#include "url/gurl.h"
namespace content {
class WebContents;
struct CONTENT_EXPORT OpenURLParams {
OpenURLParams(const GURL& url,
const Referrer& referrer,
WindowOpenDisposition disposition,
ui::PageTransition transition,
bool is_renderer_initiated);
OpenURLParams(const GURL& url,
const Referrer& referrer,
int frame_tree_node_id,
WindowOpenDisposition disposition,
ui::PageTransition transition,
bool is_renderer_initiated);
// The URL/referrer to be opened.
GURL url;
Referrer referrer;
// SiteInstance of the frame that initiated the navigation or null if we
// don't know it.
scoped_refptr<content::SiteInstance> source_site_instance;
// Any redirect URLs that occurred for this navigation before |url|.
std::vector<GURL> redirect_chain;
// Indicates whether this navigation will be sent using POST.
// The POST method is limited support for basic POST data by leveraging
// It is not for things like file uploads.
bool uses_post;
// The post data when the navigation uses POST.
scoped_refptr<base::RefCountedMemory> browser_initiated_post_data;
// Extra headers to add to the request for this page. Headers are
// represented as "<name>: <value>" and separated by \r\n. The entire string
// is terminated by \r\n. May be empty if no extra headers are needed.
std::string extra_headers;
// The browser-global FrameTreeNode ID or -1 to indicate the main frame.
int frame_tree_node_id;
// The disposition requested by the navigation source.
WindowOpenDisposition disposition;
// The transition type of navigation.
ui::PageTransition transition;
// Whether this navigation is initiated by the renderer process.
bool is_renderer_initiated;
// Reference to the old request id in case this is a navigation that is being
// transferred to a new renderer.
GlobalRequestID transferred_global_request_id;
// Indicates whether this navigation should replace the current
// navigation entry.
bool should_replace_current_entry;
// Indicates whether this navigation was triggered while processing a user
// gesture if the navigation was initiated by the renderer.
bool user_gesture;
class PageNavigator {
virtual ~PageNavigator() {}
// Opens a URL with the given disposition. The transition specifies how this
// navigation should be recorded in the history system (for example, typed).
// Returns the WebContents the URL is opened in, or nullptr if the URL wasn't
// opened immediately.
virtual WebContents* OpenURL(const OpenURLParams& params) = 0;
} // namespace content