OLD | NEW |
| (Empty) |
1 // 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_BROWSER_TAB_CONTENTS_NAVIGATION_ENTRY_H_ | |
6 #define CONTENT_BROWSER_TAB_CONTENTS_NAVIGATION_ENTRY_H_ | |
7 #pragma once | |
8 | |
9 #include "base/basictypes.h" | |
10 #include "base/compiler_specific.h" | |
11 #include "base/memory/ref_counted.h" | |
12 #include "content/public/browser/favicon_status.h" | |
13 #include "content/public/browser/global_request_id.h" | |
14 #include "content/public/browser/navigation_entry.h" | |
15 #include "content/public/browser/ssl_status.h" | |
16 | |
17 class SiteInstance; | |
18 | |
19 class CONTENT_EXPORT NavigationEntry | |
20 : public NON_EXPORTED_BASE(content::NavigationEntry) { | |
21 public: | |
22 | |
23 static NavigationEntry* FromNavigationEntry(content::NavigationEntry* entry); | |
24 | |
25 NavigationEntry(); | |
26 NavigationEntry(SiteInstance* instance, | |
27 int page_id, | |
28 const GURL& url, | |
29 const content::Referrer& referrer, | |
30 const string16& title, | |
31 content::PageTransition transition_type, | |
32 bool is_renderer_initiated); | |
33 virtual ~NavigationEntry(); | |
34 | |
35 // content::NavigationEntry implementation: | |
36 virtual int GetUniqueID() const OVERRIDE; | |
37 virtual content::PageType GetPageType() const OVERRIDE; | |
38 virtual void SetURL(const GURL& url) OVERRIDE; | |
39 virtual const GURL& GetURL() const OVERRIDE; | |
40 virtual void SetReferrer(const content::Referrer& referrer) OVERRIDE; | |
41 virtual const content::Referrer& GetReferrer() const OVERRIDE; | |
42 virtual void SetVirtualURL(const GURL& url) OVERRIDE; | |
43 virtual const GURL& GetVirtualURL() const OVERRIDE; | |
44 virtual void SetTitle(const string16& title) OVERRIDE; | |
45 virtual const string16& GetTitle() const OVERRIDE; | |
46 virtual void SetContentState(const std::string& state) OVERRIDE; | |
47 virtual const std::string& GetContentState() const OVERRIDE; | |
48 virtual void SetPageID(int page_id) OVERRIDE; | |
49 virtual int32 GetPageID() const OVERRIDE; | |
50 virtual const string16& GetTitleForDisplay( | |
51 const std::string& languages) const OVERRIDE; | |
52 virtual bool IsViewSourceMode() const OVERRIDE; | |
53 virtual void SetTransitionType( | |
54 content::PageTransition transition_type) OVERRIDE; | |
55 virtual content::PageTransition GetTransitionType() const OVERRIDE; | |
56 virtual const GURL& GetUserTypedURL() const OVERRIDE; | |
57 virtual void SetHasPostData(bool has_post_data) OVERRIDE; | |
58 virtual bool GetHasPostData() const OVERRIDE; | |
59 virtual const content::FaviconStatus& GetFavicon() const OVERRIDE; | |
60 virtual content::FaviconStatus& GetFavicon() OVERRIDE; | |
61 virtual const content::SSLStatus& GetSSL() const OVERRIDE; | |
62 virtual content::SSLStatus& GetSSL() OVERRIDE; | |
63 | |
64 void set_unique_id(int unique_id) { | |
65 unique_id_ = unique_id; | |
66 } | |
67 | |
68 // The SiteInstance tells us how to share sub-processes when the tab type is | |
69 // TAB_CONTENTS_WEB. This will be NULL otherwise. This is a reference counted | |
70 // pointer to a shared site instance. | |
71 // | |
72 // Note that the SiteInstance should usually not be changed after it is set, | |
73 // but this may happen if the NavigationEntry was cloned and needs to use a | |
74 // different SiteInstance. | |
75 void set_site_instance(SiteInstance* site_instance); | |
76 SiteInstance* site_instance() const { | |
77 return site_instance_; | |
78 } | |
79 | |
80 void set_page_type(content::PageType page_type) { | |
81 page_type_ = page_type; | |
82 } | |
83 | |
84 bool has_virtual_url() const { | |
85 return !virtual_url_.is_empty(); | |
86 } | |
87 | |
88 bool update_virtual_url_with_url() const { | |
89 return update_virtual_url_with_url_; | |
90 } | |
91 void set_update_virtual_url_with_url(bool update) { | |
92 update_virtual_url_with_url_ = update; | |
93 } | |
94 | |
95 // Extra headers (separated by \n) to send during the request. | |
96 void set_extra_headers(const std::string& extra_headers) { | |
97 extra_headers_ = extra_headers; | |
98 } | |
99 const std::string& extra_headers() const { | |
100 return extra_headers_; | |
101 } | |
102 | |
103 // Whether this (pending) navigation is renderer-initiated. Resets to false | |
104 // for all types of navigations after commit. | |
105 void set_is_renderer_initiated(bool is_renderer_initiated) { | |
106 is_renderer_initiated_ = is_renderer_initiated; | |
107 } | |
108 bool is_renderer_initiated() const { | |
109 return is_renderer_initiated_; | |
110 } | |
111 | |
112 void set_user_typed_url(const GURL& user_typed_url) { | |
113 user_typed_url_ = user_typed_url; | |
114 } | |
115 | |
116 // Enumerations of the possible restore types. | |
117 enum RestoreType { | |
118 // The entry has been restored is from the last session. | |
119 RESTORE_LAST_SESSION, | |
120 | |
121 // The entry has been restored from the current session. This is used when | |
122 // the user issues 'reopen closed tab'. | |
123 RESTORE_CURRENT_SESSION, | |
124 | |
125 // The entry was not restored. | |
126 RESTORE_NONE | |
127 }; | |
128 | |
129 // The RestoreType for this entry. This is set if the entry was retored. This | |
130 // is set to RESTORE_NONE once the entry is loaded. | |
131 void set_restore_type(RestoreType type) { | |
132 restore_type_ = type; | |
133 } | |
134 RestoreType restore_type() const { | |
135 return restore_type_; | |
136 } | |
137 | |
138 void set_transferred_global_request_id( | |
139 const content::GlobalRequestID& transferred_global_request_id) { | |
140 transferred_global_request_id_ = transferred_global_request_id; | |
141 } | |
142 | |
143 content::GlobalRequestID transferred_global_request_id() const { | |
144 return transferred_global_request_id_; | |
145 } | |
146 | |
147 private: | |
148 // WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING | |
149 // Session/Tab restore save portions of this class so that it can be recreated | |
150 // later. If you add a new field that needs to be persisted you'll have to | |
151 // update SessionService/TabRestoreService appropriately. | |
152 // WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING | |
153 | |
154 // See the accessors above for descriptions. | |
155 int unique_id_; | |
156 scoped_refptr<SiteInstance> site_instance_; | |
157 content::PageType page_type_; | |
158 GURL url_; | |
159 content::Referrer referrer_; | |
160 GURL virtual_url_; | |
161 bool update_virtual_url_with_url_; | |
162 string16 title_; | |
163 content::FaviconStatus favicon_; | |
164 std::string content_state_; | |
165 int32 page_id_; | |
166 content::SSLStatus ssl_; | |
167 content::PageTransition transition_type_; | |
168 GURL user_typed_url_; | |
169 bool has_post_data_; | |
170 RestoreType restore_type_; | |
171 | |
172 // This member is not persisted with sesssion restore. | |
173 std::string extra_headers_; | |
174 | |
175 // Whether the entry, while loading, was created for a renderer-initiated | |
176 // navigation. This dictates whether the URL should be displayed before the | |
177 // navigation commits. It is cleared on commit and not persisted. | |
178 bool is_renderer_initiated_; | |
179 | |
180 // This is a cached version of the result of GetTitleForDisplay. It prevents | |
181 // us from having to do URL formatting on the URL every time the title is | |
182 // displayed. When the URL, virtual URL, or title is set, this should be | |
183 // cleared to force a refresh. | |
184 mutable string16 cached_display_title_; | |
185 | |
186 // In case a navigation is transferred to a new RVH but the request has | |
187 // been generated in the renderer already, this identifies the old request so | |
188 // that it can be resumed. The old request is stored until the | |
189 // ResourceDispatcher receives the navigation from the renderer which | |
190 // carries this |transferred_global_request_id_| annotation. Once the request | |
191 // is transferred to the new process, this is cleared and the request | |
192 // continues as normal. | |
193 content::GlobalRequestID transferred_global_request_id_; | |
194 | |
195 // Copy and assignment is explicitly allowed for this class. | |
196 }; | |
197 | |
198 #endif // CONTENT_BROWSER_TAB_CONTENTS_NAVIGATION_ENTRY_H_ | |
OLD | NEW |