blob: 63af6871b20e202b7d796960e9d298c9d86e2a35 [file] [log] [blame]
[email protected]86cd9472012-02-03 19:51:051// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]36fc0392011-12-25 03:59:512// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CONTENT_PUBLIC_BROWSER_NAVIGATION_ENTRY_H_
6#define CONTENT_PUBLIC_BROWSER_NAVIGATION_ENTRY_H_
[email protected]36fc0392011-12-25 03:59:517
8#include <string>
9
[email protected]132e281a2012-07-31 18:32:4410#include "base/memory/ref_counted_memory.h"
[email protected]36fc0392011-12-25 03:59:5111#include "base/string16.h"
[email protected]688aa65c62012-09-28 04:32:2212#include "base/time.h"
[email protected]5050b9522011-12-28 07:11:0313#include "content/common/content_export.h"
[email protected]36fc0392011-12-25 03:59:5114#include "content/public/common/page_transition_types.h"
[email protected]ad23a092011-12-28 07:02:0415#include "content/public/common/page_type.h"
[email protected]36fc0392011-12-25 03:59:5116#include "content/public/common/referrer.h"
17
18class GURL;
19
20namespace content {
21
[email protected]d583e3f22011-12-27 21:38:1722struct FaviconStatus;
23struct SSLStatus;
24
[email protected]36fc0392011-12-25 03:59:5125// A NavigationEntry is a data structure that captures all the information
26// required to recreate a browsing state. This includes some opaque binary
[email protected]770005b2012-04-16 15:58:1327// state as provided by the WebContentsImpl as well as some clear text title and
[email protected]36fc0392011-12-25 03:59:5128// URL which is used for our user interface.
29class NavigationEntry {
30 public:
31 virtual ~NavigationEntry() {}
32
[email protected]5050b9522011-12-28 07:11:0333 CONTENT_EXPORT static NavigationEntry* Create();
34 CONTENT_EXPORT static NavigationEntry* Create(const NavigationEntry& copy);
[email protected]ad23a092011-12-28 07:02:0435
[email protected]36fc0392011-12-25 03:59:5136 // Page-related stuff --------------------------------------------------------
37
38 // A unique ID is preserved across commits and redirects, which means that
39 // sometimes a NavigationEntry's unique ID needs to be set (e.g. when
40 // creating a committed entry to correspond to a to-be-deleted pending entry,
41 // the pending entry's ID must be copied).
42 virtual int GetUniqueID() const = 0;
43
[email protected]ad23a092011-12-28 07:02:0444 // The page type tells us if this entry is for an interstitial or error page.
45 virtual content::PageType GetPageType() const = 0;
46
[email protected]36fc0392011-12-25 03:59:5147 // The actual URL of the page. For some about pages, this may be a scary
48 // data: URL or something like that. Use GetVirtualURL() below for showing to
49 // the user.
[email protected]ad23a092011-12-28 07:02:0450 virtual void SetURL(const GURL& url) = 0;
[email protected]36fc0392011-12-25 03:59:5151 virtual const GURL& GetURL() const = 0;
52
[email protected]d1ef81d2012-07-24 11:39:3653 // Used for specifying a base URL for pages loaded via data URLs.
54 virtual void SetBaseURLForDataURL(const GURL& url) = 0;
55 virtual const GURL& GetBaseURLForDataURL() const = 0;
56
[email protected]36fc0392011-12-25 03:59:5157 // The referring URL. Can be empty.
[email protected]022af742011-12-28 18:37:2558 virtual void SetReferrer(const content::Referrer& referrer) = 0;
[email protected]36fc0392011-12-25 03:59:5159 virtual const content::Referrer& GetReferrer() const = 0;
60
61 // The virtual URL, when nonempty, will override the actual URL of the page
62 // when we display it to the user. This allows us to have nice and friendly
63 // URLs that the user sees for things like about: URLs, but actually feed
64 // the renderer a data URL that results in the content loading.
65 //
66 // GetVirtualURL() will return the URL to display to the user in all cases, so
67 // if there is no overridden display URL, it will return the actual one.
68 virtual void SetVirtualURL(const GURL& url) = 0;
69 virtual const GURL& GetVirtualURL() const = 0;
70
71 // The title as set by the page. This will be empty if there is no title set.
72 // The caller is responsible for detecting when there is no title and
73 // displaying the appropriate "Untitled" label if this is being displayed to
74 // the user.
75 virtual void SetTitle(const string16& title) = 0;
76 virtual const string16& GetTitle() const = 0;
77
78 // Content state is an opaque blob created by WebKit that represents the
79 // state of the page. This includes form entries and scroll position for each
80 // frame. We store it so that we can supply it back to WebKit to restore form
81 // state properly when the user goes back and forward.
82 //
83 // WARNING: This state is saved to the file and used to restore previous
84 // states. If the format is modified in the future, we should still be able to
85 // deal with older versions.
86 virtual void SetContentState(const std::string& state) = 0;
87 virtual const std::string& GetContentState() const = 0;
88
[email protected]e018d3b2012-04-17 13:24:1589 // Describes the current page that the tab represents. This is the ID that the
90 // renderer generated for the page and is how we can tell new versus
91 // renavigations.
[email protected]36fc0392011-12-25 03:59:5192 virtual void SetPageID(int page_id) = 0;
93 virtual int32 GetPageID() const = 0;
94
95 // Page-related helpers ------------------------------------------------------
96
97 // Returns the title to be displayed on the tab. This could be the title of
98 // the page if it is available or the URL. |languages| is the list of
99 // accpeted languages (e.g., prefs::kAcceptLanguages) or empty if proper
100 // URL formatting isn't needed (e.g., unit tests).
101 virtual const string16& GetTitleForDisplay(
102 const std::string& languages) const = 0;
103
104 // Returns true if the current tab is in view source mode. This will be false
105 // if there is no navigation.
106 virtual bool IsViewSourceMode() const = 0;
107
108 // Tracking stuff ------------------------------------------------------------
109
110 // The transition type indicates what the user did to move to this page from
111 // the previous page.
[email protected]022af742011-12-28 18:37:25112 virtual void SetTransitionType(content::PageTransition transition_type) = 0;
[email protected]36fc0392011-12-25 03:59:51113 virtual content::PageTransition GetTransitionType() const = 0;
114
[email protected]ad23a092011-12-28 07:02:04115 // The user typed URL was the URL that the user initiated the navigation
116 // with, regardless of any redirects. This is used to generate keywords, for
117 // example, based on "what the user thinks the site is called" rather than
118 // what it's actually called. For example, if the user types "foo.com", that
119 // may redirect somewhere arbitrary like "bar.com/foo", and we want to use
120 // the name that the user things of the site as having.
121 //
122 // This URL will be is_empty() if the URL was navigated to some other way.
123 // Callers should fall back on using the regular or display URL in this case.
124 virtual const GURL& GetUserTypedURL() const = 0;
125
[email protected]36fc0392011-12-25 03:59:51126 // Post data is form data that was posted to get to this page. The data will
127 // have to be reposted to reload the page properly. This flag indicates
128 // whether the page had post data.
129 //
[email protected]132e281a2012-07-31 18:32:44130 // The actual post data is stored either in
131 // 1) browser_initiated_post_data when a new post data request is started.
132 // 2) content_state when a post request has started and is extracted by
133 // WebKit to actually make the request.
[email protected]36fc0392011-12-25 03:59:51134 virtual void SetHasPostData(bool has_post_data) = 0;
135 virtual bool GetHasPostData() const = 0;
[email protected]d583e3f22011-12-27 21:38:17136
[email protected]86cd9472012-02-03 19:51:05137 // The Post identifier associated with the page.
138 virtual void SetPostID(int64 post_id) = 0;
139 virtual int64 GetPostID() const = 0;
140
[email protected]132e281a2012-07-31 18:32:44141 // Holds the raw post data of a browser initiated post request.
142 // For efficiency, this should be cleared when content_state is populated
143 // since the data is duplicated.
144 // Note, this field:
145 // 1) is not persisted in session restore.
146 // 2) is shallow copied with the static copy Create method above.
147 // 3) may be NULL so check before use.
148 virtual void SetBrowserInitiatedPostData(
149 const base::RefCountedMemory* data) = 0;
150 virtual const base::RefCountedMemory* GetBrowserInitiatedPostData() const = 0;
151
[email protected]d583e3f22011-12-27 21:38:17152 // The favicon data and tracking information. See content::FaviconStatus.
153 virtual const FaviconStatus& GetFavicon() const = 0;
154 virtual FaviconStatus& GetFavicon() = 0;
155
156 // All the SSL flags and state. See content::SSLStatus.
157 virtual const SSLStatus& GetSSL() const = 0;
158 virtual SSLStatus& GetSSL() = 0;
[email protected]074269f2012-04-17 21:12:42159
160 // Store the URL that caused this NavigationEntry to be created.
161 virtual void SetOriginalRequestURL(const GURL& original_url) = 0;
162 virtual const GURL& GetOriginalRequestURL() const = 0;
[email protected]86ef6a392012-05-11 22:03:11163
164 // Store whether or not we're overriding the user agent.
165 virtual void SetIsOverridingUserAgent(bool override) = 0;
166 virtual bool GetIsOverridingUserAgent() const = 0;
[email protected]688aa65c62012-09-28 04:32:22167
168 // The time at which the last known local navigation has
169 // completed. (A navigation can be completed more than once if the
170 // page is reloaded.)
171 //
172 // If GetTimestamp() returns a null time, that means that either:
173 //
174 // - this navigation hasn't completed yet;
175 // - this navigation was restored and for some reason the
176 // timestamp wasn't available;
177 // - or this navigation was copied from a foreign session.
178 virtual void SetTimestamp(base::Time timestamp) = 0;
179 virtual base::Time GetTimestamp() const = 0;
[email protected]951a64832012-10-11 16:26:37180
181 // Used to specify if this entry should be able to access local file://
182 // resources.
183 virtual void SetCanLoadLocalResources(bool allow) = 0;
184 virtual bool GetCanLoadLocalResources() const = 0;
[email protected]36fc0392011-12-25 03:59:51185};
186
187} // namespace content
188
189#endif // CONTENT_PUBLIC_BROWSER_NAVIGATION_ENTRY_H_