page_navigator.h revision 5821806d5e7f356e8fa4b058a389a808ea183019
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. 4 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. 8 9#ifndef CONTENT_PUBLIC_BROWSER_PAGE_NAVIGATOR_H_ 10#define CONTENT_PUBLIC_BROWSER_PAGE_NAVIGATOR_H_ 11 12#include <string> 13 14#include "content/common/content_export.h" 15#include "content/public/browser/global_request_id.h" 16#include "content/public/common/page_transition_types.h" 17#include "content/public/common/referrer.h" 18#include "googleurl/src/gurl.h" 19#include "webkit/glue/window_open_disposition.h" 20 21namespace content { 22 23class WebContents; 24 25struct CONTENT_EXPORT OpenURLParams { 26 OpenURLParams(const GURL& url, 27 const Referrer& referrer, 28 WindowOpenDisposition disposition, 29 PageTransition transition, 30 bool is_renderer_initiated); 31 OpenURLParams(const GURL& url, 32 const Referrer& referrer, 33 int64 source_frame_id, 34 WindowOpenDisposition disposition, 35 PageTransition transition, 36 bool is_renderer_initiated); 37 ~OpenURLParams(); 38 39 // The URL/referrer to be opened. 40 GURL url; 41 Referrer referrer; 42 43 // Extra headers to add to the request for this page. Headers are 44 // represented as "<name>: <value>" and separated by \r\n. The entire string 45 // is terminated by \r\n. May be empty if no extra headers are needed. 46 std::string extra_headers; 47 48 // The source frame id or -1 to indicate the main frame. 49 int64 source_frame_id; 50 51 // The disposition requested by the navigation source. 52 WindowOpenDisposition disposition; 53 54 // The transition type of navigation. 55 PageTransition transition; 56 57 // Whether this navigation is initiated by the renderer process. 58 bool is_renderer_initiated; 59 60 // The override encoding of the URL contents to be opened. 61 std::string override_encoding; 62 63 // Reference to the old request id in case this is a navigation that is being 64 // transferred to a new renderer. 65 GlobalRequestID transferred_global_request_id; 66 67 private: 68 OpenURLParams(); 69}; 70 71class PageNavigator { 72 public: 73 virtual ~PageNavigator() {} 74 75 // Opens a URL with the given disposition. The transition specifies how this 76 // navigation should be recorded in the history system (for example, typed). 77 // Returns the WebContents the URL is opened in, or NULL if the URL wasn't 78 // opened immediately. 79 virtual WebContents* OpenURL(const OpenURLParams& params) = 0; 80}; 81 82} 83 84#endif // CONTENT_PUBLIC_BROWSER_PAGE_NAVIGATOR_H_ 85