Switch global error menu icon to vectorized MD asset
[chromium-blink-merge.git] / content / public / browser / navigation_entry.h
blob773028116e51afb538ecc9e21e0767de0cda758a
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 #ifndef CONTENT_PUBLIC_BROWSER_NAVIGATION_ENTRY_H_
6 #define CONTENT_PUBLIC_BROWSER_NAVIGATION_ENTRY_H_
8 #include <string>
10 #include "base/memory/ref_counted_memory.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/strings/string16.h"
13 #include "base/time/time.h"
14 #include "content/common/content_export.h"
15 #include "content/public/common/page_type.h"
16 #include "content/public/common/referrer.h"
17 #include "ui/base/page_transition_types.h"
19 class GURL;
21 namespace content {
23 class PageState;
24 struct FaviconStatus;
25 struct SSLStatus;
27 // A NavigationEntry is a data structure that captures all the information
28 // required to recreate a browsing state. This includes some opaque binary
29 // state as provided by the WebContents as well as some clear text title and
30 // URL which is used for our user interface.
31 class NavigationEntry {
32 public:
33 virtual ~NavigationEntry() {}
35 CONTENT_EXPORT static scoped_ptr<NavigationEntry> Create();
37 // Page-related stuff --------------------------------------------------------
39 // A unique ID is preserved across commits and redirects, which means that
40 // sometimes a NavigationEntry's unique ID needs to be set (e.g. when
41 // creating a committed entry to correspond to a to-be-deleted pending entry,
42 // the pending entry's ID must be copied).
43 virtual int GetUniqueID() const = 0;
45 // The page type tells us if this entry is for an interstitial or error page.
46 virtual content::PageType GetPageType() const = 0;
48 // The actual URL of the page. For some about pages, this may be a scary
49 // data: URL or something like that. Use GetVirtualURL() below for showing to
50 // the user.
51 virtual void SetURL(const GURL& url) = 0;
52 virtual const GURL& GetURL() const = 0;
54 // Used for specifying a base URL for pages loaded via data URLs.
55 virtual void SetBaseURLForDataURL(const GURL& url) = 0;
56 virtual const GURL& GetBaseURLForDataURL() const = 0;
58 // The referring URL. Can be empty.
59 virtual void SetReferrer(const content::Referrer& referrer) = 0;
60 virtual const content::Referrer& GetReferrer() const = 0;
62 // The virtual URL, when nonempty, will override the actual URL of the page
63 // when we display it to the user. This allows us to have nice and friendly
64 // URLs that the user sees for things like about: URLs, but actually feed
65 // the renderer a data URL that results in the content loading.
67 // GetVirtualURL() will return the URL to display to the user in all cases, so
68 // if there is no overridden display URL, it will return the actual one.
69 virtual void SetVirtualURL(const GURL& url) = 0;
70 virtual const GURL& GetVirtualURL() const = 0;
72 // The title as set by the page. This will be empty if there is no title set.
73 // The caller is responsible for detecting when there is no title and
74 // displaying the appropriate "Untitled" label if this is being displayed to
75 // the user.
76 virtual void SetTitle(const base::string16& title) = 0;
77 virtual const base::string16& GetTitle() const = 0;
79 // Page state is an opaque blob created by Blink that represents the state of
80 // the page. This includes form entries and scroll position for each frame.
81 // We store it so that we can supply it back to Blink to restore form state
82 // properly when the user goes back and forward.
84 // NOTE: This state is saved to disk and used to restore previous states. If
85 // the format is modified in the future, we should still be able to deal with
86 // older versions.
87 virtual void SetPageState(const PageState& state) = 0;
88 virtual const PageState& GetPageState() const = 0;
90 // Describes the current page that the tab represents. This is the ID that the
91 // renderer generated for the page and is how we can tell new versus
92 // renavigations.
93 virtual void SetPageID(int page_id) = 0;
94 virtual int32 GetPageID() const = 0;
96 // Page-related helpers ------------------------------------------------------
98 // Returns the title to be displayed on the tab. This could be the title of
99 // the page if it is available or the URL. |languages| is the list of
100 // accepted languages (e.g., prefs::kAcceptLanguages) or empty if proper
101 // URL formatting isn't needed (e.g., unit tests).
102 virtual const base::string16& GetTitleForDisplay(
103 const std::string& languages) const = 0;
105 // Returns true if the current tab is in view source mode. This will be false
106 // if there is no navigation.
107 virtual bool IsViewSourceMode() const = 0;
109 // Tracking stuff ------------------------------------------------------------
111 // The transition type indicates what the user did to move to this page from
112 // the previous page.
113 virtual void SetTransitionType(ui::PageTransition transition_type) = 0;
114 virtual ui::PageTransition GetTransitionType() const = 0;
116 // The user typed URL was the URL that the user initiated the navigation
117 // with, regardless of any redirects. This is used to generate keywords, for
118 // example, based on "what the user thinks the site is called" rather than
119 // what it's actually called. For example, if the user types "foo.com", that
120 // may redirect somewhere arbitrary like "bar.com/foo", and we want to use
121 // the name that the user things of the site as having.
123 // This URL will be is_empty() if the URL was navigated to some other way.
124 // Callers should fall back on using the regular or display URL in this case.
125 virtual const GURL& GetUserTypedURL() const = 0;
127 // Post data is form data that was posted to get to this page. The data will
128 // have to be reposted to reload the page properly. This flag indicates
129 // whether the page had post data.
131 // The actual post data is stored either in
132 // 1) browser_initiated_post_data when a new post data request is started.
133 // 2) content_state when a post request has started and is extracted by
134 // WebKit to actually make the request.
135 virtual void SetHasPostData(bool has_post_data) = 0;
136 virtual bool GetHasPostData() const = 0;
138 // The Post identifier associated with the page.
139 virtual void SetPostID(int64 post_id) = 0;
140 virtual int64 GetPostID() const = 0;
142 // Holds the raw post data of a browser initiated post request.
143 // For efficiency, this should be cleared when content_state is populated
144 // since the data is duplicated.
145 // Note, this field:
146 // 1) is not persisted in session restore.
147 // 2) is shallow copied with the static copy Create method above.
148 // 3) may be nullptr so check before use.
149 virtual void SetBrowserInitiatedPostData(
150 const base::RefCountedMemory* data) = 0;
151 virtual const base::RefCountedMemory* GetBrowserInitiatedPostData() const = 0;
153 // The favicon data and tracking information. See content::FaviconStatus.
154 virtual const FaviconStatus& GetFavicon() const = 0;
155 virtual FaviconStatus& GetFavicon() = 0;
157 // All the SSL flags and state. See content::SSLStatus.
158 virtual const SSLStatus& GetSSL() const = 0;
159 virtual SSLStatus& GetSSL() = 0;
161 // Store the URL that caused this NavigationEntry to be created.
162 virtual void SetOriginalRequestURL(const GURL& original_url) = 0;
163 virtual const GURL& GetOriginalRequestURL() const = 0;
165 // Store whether or not we're overriding the user agent.
166 virtual void SetIsOverridingUserAgent(bool override) = 0;
167 virtual bool GetIsOverridingUserAgent() const = 0;
169 // The time at which the last known local navigation has
170 // completed. (A navigation can be completed more than once if the
171 // page is reloaded.)
173 // If GetTimestamp() returns a null time, that means that either:
175 // - this navigation hasn't completed yet;
176 // - this navigation was restored and for some reason the
177 // timestamp wasn't available;
178 // - or this navigation was copied from a foreign session.
179 virtual void SetTimestamp(base::Time timestamp) = 0;
180 virtual base::Time GetTimestamp() const = 0;
182 // Used to specify if this entry should be able to access local file://
183 // resources.
184 virtual void SetCanLoadLocalResources(bool allow) = 0;
185 virtual bool GetCanLoadLocalResources() const = 0;
187 // Set extra data on this NavigationEntry according to the specified |key|.
188 // This data is not persisted by default.
189 virtual void SetExtraData(const std::string& key,
190 const base::string16& data) = 0;
191 // If present, fills the |data| present at the specified |key|.
192 virtual bool GetExtraData(const std::string& key,
193 base::string16* data) const = 0;
194 // Removes the data at the specified |key|.
195 virtual void ClearExtraData(const std::string& key) = 0;
197 // The status code of the last known successful navigation. If
198 // GetHttpStatusCode() returns 0 that means that either:
200 // - this navigation hasn't completed yet;
201 // - a response wasn't received;
202 // - or this navigation was restored and for some reason the
203 // status code wasn't available.
204 virtual void SetHttpStatusCode(int http_status_code) = 0;
205 virtual int GetHttpStatusCode() const = 0;
207 // The redirect chain traversed during this navigation, from the initial
208 // redirecting URL to the final non-redirecting current URL.
209 virtual void SetRedirectChain(const std::vector<GURL>& redirects) = 0;
210 virtual const std::vector<GURL>& GetRedirectChain() const = 0;
212 // True if this entry is restored and hasn't been loaded.
213 virtual bool IsRestored() const = 0;
216 } // namespace content
218 #endif // CONTENT_PUBLIC_BROWSER_NAVIGATION_ENTRY_H_