blob: d3b8268b3376a1825f3a57dcb9e6b5b7449380e5 [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.
[email protected]022af742011-12-28 18:37:2553 virtual void SetReferrer(const content::Referrer& referrer) = 0;
[email protected]36fc0392011-12-25 03:59:5154 virtual const content::Referrer& GetReferrer() const = 0;
55
56 // The virtual URL, when nonempty, will override the actual URL of the page
57 // when we display it to the user. This allows us to have nice and friendly
58 // URLs that the user sees for things like about: URLs, but actually feed
59 // the renderer a data URL that results in the content loading.
60 //
61 // GetVirtualURL() will return the URL to display to the user in all cases, so
62 // if there is no overridden display URL, it will return the actual one.
63 virtual void SetVirtualURL(const GURL& url) = 0;
64 virtual const GURL& GetVirtualURL() const = 0;
65
66 // The title as set by the page. This will be empty if there is no title set.
67 // The caller is responsible for detecting when there is no title and
68 // displaying the appropriate "Untitled" label if this is being displayed to
69 // the user.
70 virtual void SetTitle(const string16& title) = 0;
71 virtual const string16& GetTitle() const = 0;
72
73 // Content state is an opaque blob created by WebKit that represents the
74 // state of the page. This includes form entries and scroll position for each
75 // frame. We store it so that we can supply it back to WebKit to restore form
76 // state properly when the user goes back and forward.
77 //
78 // WARNING: This state is saved to the file and used to restore previous
79 // states. If the format is modified in the future, we should still be able to
80 // deal with older versions.
81 virtual void SetContentState(const std::string& state) = 0;
82 virtual const std::string& GetContentState() const = 0;
83
84 // Describes the current page that the tab represents. For web pages
85 // (TAB_CONTENTS_WEB) this is the ID that the renderer generated for the page
86 // and is how we can tell new versus renavigations.
87 virtual void SetPageID(int page_id) = 0;
88 virtual int32 GetPageID() const = 0;
89
90 // Page-related helpers ------------------------------------------------------
91
92 // Returns the title to be displayed on the tab. This could be the title of
93 // the page if it is available or the URL. |languages| is the list of
94 // accpeted languages (e.g., prefs::kAcceptLanguages) or empty if proper
95 // URL formatting isn't needed (e.g., unit tests).
96 virtual const string16& GetTitleForDisplay(
97 const std::string& languages) const = 0;
98
99 // Returns true if the current tab is in view source mode. This will be false
100 // if there is no navigation.
101 virtual bool IsViewSourceMode() const = 0;
102
103 // Tracking stuff ------------------------------------------------------------
104
105 // The transition type indicates what the user did to move to this page from
106 // the previous page.
[email protected]022af742011-12-28 18:37:25107 virtual void SetTransitionType(content::PageTransition transition_type) = 0;
[email protected]36fc0392011-12-25 03:59:51108 virtual content::PageTransition GetTransitionType() const = 0;
109
[email protected]ad23a092011-12-28 07:02:04110 // The user typed URL was the URL that the user initiated the navigation
111 // with, regardless of any redirects. This is used to generate keywords, for
112 // example, based on "what the user thinks the site is called" rather than
113 // what it's actually called. For example, if the user types "foo.com", that
114 // may redirect somewhere arbitrary like "bar.com/foo", and we want to use
115 // the name that the user things of the site as having.
116 //
117 // This URL will be is_empty() if the URL was navigated to some other way.
118 // Callers should fall back on using the regular or display URL in this case.
119 virtual const GURL& GetUserTypedURL() const = 0;
120
[email protected]36fc0392011-12-25 03:59:51121 // Post data is form data that was posted to get to this page. The data will
122 // have to be reposted to reload the page properly. This flag indicates
123 // whether the page had post data.
124 //
125 // The actual post data is stored in the content_state and is extracted by
126 // WebKit to actually make the request.
127 virtual void SetHasPostData(bool has_post_data) = 0;
128 virtual bool GetHasPostData() const = 0;
[email protected]d583e3f22011-12-27 21:38:17129
130 // The favicon data and tracking information. See content::FaviconStatus.
131 virtual const FaviconStatus& GetFavicon() const = 0;
132 virtual FaviconStatus& GetFavicon() = 0;
133
134 // All the SSL flags and state. See content::SSLStatus.
135 virtual const SSLStatus& GetSSL() const = 0;
136 virtual SSLStatus& GetSSL() = 0;
[email protected]36fc0392011-12-25 03:59:51137};
138
139} // namespace content
140
141#endif // CONTENT_PUBLIC_BROWSER_NAVIGATION_ENTRY_H_