blob: bec474ba7e40407419298a1b48837d0cf2e15ca8 [file] [log] [blame]
[email protected]36fc0392011-12-25 03:59:511// Copyright (c) 2011 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#ifndef CONTENT_PUBLIC_BROWSER_NAVIGATION_ENTRY_H_
6#define CONTENT_PUBLIC_BROWSER_NAVIGATION_ENTRY_H_
7#pragma once
8
9#include <string>
10
11#include "base/string16.h"
[email protected]5050b9522011-12-28 07:11:0312#include "content/common/content_export.h"
[email protected]36fc0392011-12-25 03:59:5113#include "content/public/common/page_transition_types.h"
[email protected]ad23a092011-12-28 07:02:0414#include "content/public/common/page_type.h"
[email protected]36fc0392011-12-25 03:59:5115#include "content/public/common/referrer.h"
16
17class GURL;
18
19namespace content {
20
[email protected]d583e3f22011-12-27 21:38:1721struct FaviconStatus;
22struct SSLStatus;
23
[email protected]36fc0392011-12-25 03:59:5124// A NavigationEntry is a data structure that captures all the information
25// required to recreate a browsing state. This includes some opaque binary
26// state as provided by the TabContents as well as some clear text title and
27// URL which is used for our user interface.
28class NavigationEntry {
29 public:
30 virtual ~NavigationEntry() {}
31
[email protected]5050b9522011-12-28 07:11:0332 CONTENT_EXPORT static NavigationEntry* Create();
33 CONTENT_EXPORT static NavigationEntry* Create(const NavigationEntry& copy);
[email protected]ad23a092011-12-28 07:02:0434
[email protected]36fc0392011-12-25 03:59:5135 // Page-related stuff --------------------------------------------------------
36
37 // A unique ID is preserved across commits and redirects, which means that
38 // sometimes a NavigationEntry's unique ID needs to be set (e.g. when
39 // creating a committed entry to correspond to a to-be-deleted pending entry,
40 // the pending entry's ID must be copied).
41 virtual int GetUniqueID() const = 0;
42
[email protected]ad23a092011-12-28 07:02:0443 // The page type tells us if this entry is for an interstitial or error page.
44 virtual content::PageType GetPageType() const = 0;
45
[email protected]36fc0392011-12-25 03:59:5146 // The actual URL of the page. For some about pages, this may be a scary
47 // data: URL or something like that. Use GetVirtualURL() below for showing to
48 // the user.
[email protected]ad23a092011-12-28 07:02:0449 virtual void SetURL(const GURL& url) = 0;
[email protected]36fc0392011-12-25 03:59:5150 virtual const GURL& GetURL() const = 0;
51
52 // The referring URL. Can be empty.
53 virtual const content::Referrer& GetReferrer() const = 0;
54
55 // The virtual URL, when nonempty, will override the actual URL of the page
56 // when we display it to the user. This allows us to have nice and friendly
57 // URLs that the user sees for things like about: URLs, but actually feed
58 // the renderer a data URL that results in the content loading.
59 //
60 // GetVirtualURL() will return the URL to display to the user in all cases, so
61 // if there is no overridden display URL, it will return the actual one.
62 virtual void SetVirtualURL(const GURL& url) = 0;
63 virtual const GURL& GetVirtualURL() const = 0;
64
65 // The title as set by the page. This will be empty if there is no title set.
66 // The caller is responsible for detecting when there is no title and
67 // displaying the appropriate "Untitled" label if this is being displayed to
68 // the user.
69 virtual void SetTitle(const string16& title) = 0;
70 virtual const string16& GetTitle() const = 0;
71
72 // Content state is an opaque blob created by WebKit that represents the
73 // state of the page. This includes form entries and scroll position for each
74 // frame. We store it so that we can supply it back to WebKit to restore form
75 // state properly when the user goes back and forward.
76 //
77 // WARNING: This state is saved to the file and used to restore previous
78 // states. If the format is modified in the future, we should still be able to
79 // deal with older versions.
80 virtual void SetContentState(const std::string& state) = 0;
81 virtual const std::string& GetContentState() const = 0;
82
83 // Describes the current page that the tab represents. For web pages
84 // (TAB_CONTENTS_WEB) this is the ID that the renderer generated for the page
85 // and is how we can tell new versus renavigations.
86 virtual void SetPageID(int page_id) = 0;
87 virtual int32 GetPageID() const = 0;
88
89 // Page-related helpers ------------------------------------------------------
90
91 // Returns the title to be displayed on the tab. This could be the title of
92 // the page if it is available or the URL. |languages| is the list of
93 // accpeted languages (e.g., prefs::kAcceptLanguages) or empty if proper
94 // URL formatting isn't needed (e.g., unit tests).
95 virtual const string16& GetTitleForDisplay(
96 const std::string& languages) const = 0;
97
98 // Returns true if the current tab is in view source mode. This will be false
99 // if there is no navigation.
100 virtual bool IsViewSourceMode() const = 0;
101
102 // Tracking stuff ------------------------------------------------------------
103
104 // The transition type indicates what the user did to move to this page from
105 // the previous page.
106 virtual content::PageTransition GetTransitionType() const = 0;
107
[email protected]ad23a092011-12-28 07:02:04108 // The user typed URL was the URL that the user initiated the navigation
109 // with, regardless of any redirects. This is used to generate keywords, for
110 // example, based on "what the user thinks the site is called" rather than
111 // what it's actually called. For example, if the user types "foo.com", that
112 // may redirect somewhere arbitrary like "bar.com/foo", and we want to use
113 // the name that the user things of the site as having.
114 //
115 // This URL will be is_empty() if the URL was navigated to some other way.
116 // Callers should fall back on using the regular or display URL in this case.
117 virtual const GURL& GetUserTypedURL() const = 0;
118
[email protected]36fc0392011-12-25 03:59:51119 // Post data is form data that was posted to get to this page. The data will
120 // have to be reposted to reload the page properly. This flag indicates
121 // whether the page had post data.
122 //
123 // The actual post data is stored in the content_state and is extracted by
124 // WebKit to actually make the request.
125 virtual void SetHasPostData(bool has_post_data) = 0;
126 virtual bool GetHasPostData() const = 0;
[email protected]d583e3f22011-12-27 21:38:17127
128 // The favicon data and tracking information. See content::FaviconStatus.
129 virtual const FaviconStatus& GetFavicon() const = 0;
130 virtual FaviconStatus& GetFavicon() = 0;
131
132 // All the SSL flags and state. See content::SSLStatus.
133 virtual const SSLStatus& GetSSL() const = 0;
134 virtual SSLStatus& GetSSL() = 0;
[email protected]36fc0392011-12-25 03:59:51135};
136
137} // namespace content
138
139#endif // CONTENT_PUBLIC_BROWSER_NAVIGATION_ENTRY_H_