Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(298)

Side by Side Diff: content/browser/tab_contents/navigation_entry_impl.h

Issue 9960071: TabContents -> WebContentsImpl, part 3. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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.
4
5 #ifndef CONTENT_BROWSER_TAB_CONTENTS_NAVIGATION_ENTRY_IMPL_H_
6 #define CONTENT_BROWSER_TAB_CONTENTS_NAVIGATION_ENTRY_IMPL_H_
7 #pragma once
8
9 #include "base/basictypes.h"
10 #include "base/memory/ref_counted.h"
11 #include "content/browser/site_instance_impl.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/common/ssl_status.h"
16
17 namespace content {
18
19 class CONTENT_EXPORT NavigationEntryImpl
20 : public NON_EXPORTED_BASE(NavigationEntry) {
21 public:
22 static NavigationEntryImpl* FromNavigationEntry(NavigationEntry* entry);
23
24 NavigationEntryImpl();
25 NavigationEntryImpl(SiteInstanceImpl* instance,
26 int page_id,
27 const GURL& url,
28 const Referrer& referrer,
29 const string16& title,
30 PageTransition transition_type,
31 bool is_renderer_initiated);
32 virtual ~NavigationEntryImpl();
33
34 // NavigationEntry implementation:
35 virtual int GetUniqueID() const OVERRIDE;
36 virtual PageType GetPageType() const OVERRIDE;
37 virtual void SetURL(const GURL& url) OVERRIDE;
38 virtual const GURL& GetURL() const OVERRIDE;
39 virtual void SetReferrer(const Referrer& referrer) OVERRIDE;
40 virtual const Referrer& GetReferrer() const OVERRIDE;
41 virtual void SetVirtualURL(const GURL& url) OVERRIDE;
42 virtual const GURL& GetVirtualURL() const OVERRIDE;
43 virtual void SetTitle(const string16& title) OVERRIDE;
44 virtual const string16& GetTitle() const OVERRIDE;
45 virtual void SetContentState(const std::string& state) OVERRIDE;
46 virtual const std::string& GetContentState() const OVERRIDE;
47 virtual void SetPageID(int page_id) OVERRIDE;
48 virtual int32 GetPageID() const OVERRIDE;
49 virtual const string16& GetTitleForDisplay(
50 const std::string& languages) const OVERRIDE;
51 virtual bool IsViewSourceMode() const OVERRIDE;
52 virtual void SetTransitionType(PageTransition transition_type) OVERRIDE;
53 virtual PageTransition GetTransitionType() const OVERRIDE;
54 virtual const GURL& GetUserTypedURL() const OVERRIDE;
55 virtual void SetHasPostData(bool has_post_data) OVERRIDE;
56 virtual bool GetHasPostData() const OVERRIDE;
57 virtual void SetPostID(int64 post_id) OVERRIDE;
58 virtual int64 GetPostID() const OVERRIDE;
59 virtual const FaviconStatus& GetFavicon() const OVERRIDE;
60 virtual FaviconStatus& GetFavicon() OVERRIDE;
61 virtual const SSLStatus& GetSSL() const OVERRIDE;
62 virtual 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(SiteInstanceImpl* site_instance);
76 SiteInstanceImpl* site_instance() const {
77 return site_instance_.get();
78 }
79
80 void set_page_type(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 GlobalRequestID& transferred_global_request_id) {
140 transferred_global_request_id_ = transferred_global_request_id;
141 }
142
143 GlobalRequestID transferred_global_request_id() const {
144 return transferred_global_request_id_;
145 }
146
147 // Whether this (pending) navigation is reload across site instances.
148 // Resets to false after commit.
149 void set_is_cross_site_reload(bool is_cross_site_reload) {
150 is_cross_site_reload_ = is_cross_site_reload;
151 }
152 bool is_cross_site_reload() const {
153 return is_cross_site_reload_;
154 }
155
156 private:
157 // WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
158 // Session/Tab restore save portions of this class so that it can be recreated
159 // later. If you add a new field that needs to be persisted you'll have to
160 // update SessionService/TabRestoreService appropriately.
161 // WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
162
163 // See the accessors above for descriptions.
164 int unique_id_;
165 scoped_refptr<SiteInstanceImpl> site_instance_;
166 PageType page_type_;
167 GURL url_;
168 Referrer referrer_;
169 GURL virtual_url_;
170 bool update_virtual_url_with_url_;
171 string16 title_;
172 FaviconStatus favicon_;
173 std::string content_state_;
174 int32 page_id_;
175 SSLStatus ssl_;
176 PageTransition transition_type_;
177 GURL user_typed_url_;
178 bool has_post_data_;
179 int64 post_id_;
180 RestoreType restore_type_;
181
182 // This member is not persisted with sesssion restore.
183 std::string extra_headers_;
184
185 // Whether the entry, while loading, was created for a renderer-initiated
186 // navigation. This dictates whether the URL should be displayed before the
187 // navigation commits. It is cleared on commit and not persisted.
188 bool is_renderer_initiated_;
189
190 // This is a cached version of the result of GetTitleForDisplay. It prevents
191 // us from having to do URL formatting on the URL every time the title is
192 // displayed. When the URL, virtual URL, or title is set, this should be
193 // cleared to force a refresh.
194 mutable string16 cached_display_title_;
195
196 // In case a navigation is transferred to a new RVH but the request has
197 // been generated in the renderer already, this identifies the old request so
198 // that it can be resumed. The old request is stored until the
199 // ResourceDispatcher receives the navigation from the renderer which
200 // carries this |transferred_global_request_id_| annotation. Once the request
201 // is transferred to the new process, this is cleared and the request
202 // continues as normal.
203 GlobalRequestID transferred_global_request_id_;
204
205 // This is set to true when this entry is being reloaded and due to changes in
206 // the state of the URL, it has to be reloaded in a different site instance.
207 // In such case, we must treat it as an existing navigation in the new site
208 // instance, instead of a new navigation. This value should not be persisted
209 // and is not needed after the entry commits.
210 bool is_cross_site_reload_;
211
212 // Copy and assignment is explicitly allowed for this class.
213 };
214
215 } // namespace content
216
217 #endif // CONTENT_BROWSER_TAB_CONTENTS_NAVIGATION_ENTRY_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698