| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_PUBLIC_RENDERER_DOCUMENT_STATE_H_ | 5 #ifndef CONTENT_PUBLIC_RENDERER_DOCUMENT_STATE_H_ |
| 6 #define CONTENT_PUBLIC_RENDERER_DOCUMENT_STATE_H_ | 6 #define CONTENT_PUBLIC_RENDERER_DOCUMENT_STATE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/supports_user_data.h" | 12 #include "base/supports_user_data.h" |
| 13 #include "base/time.h" | 13 #include "base/time.h" |
| 14 #include "third_party/WebKit/Source/Platform/chromium/public/WebReferrerPolicy.h
" | |
| 15 #include "third_party/WebKit/Source/Platform/chromium/public/WebURLRequest.h" | |
| 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" | 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" |
| 17 | 15 |
| 18 namespace webkit_glue { | |
| 19 class AltErrorPageResourceFetcher; | |
| 20 } | |
| 21 | |
| 22 namespace content { | 16 namespace content { |
| 23 | 17 |
| 24 class NavigationState; | 18 class NavigationState; |
| 25 struct PasswordForm; | 19 struct PasswordForm; |
| 26 | 20 |
| 27 // The RenderView stores an instance of this class in the "extra data" of each | 21 // The RenderView stores an instance of this class in the "extra data" of each |
| 28 // WebDataSource (see RenderView::DidCreateDataSource). | 22 // WebDataSource (see RenderView::DidCreateDataSource). |
| 29 class DocumentState : public WebKit::WebDataSource::ExtraData, | 23 class DocumentState : public WebKit::WebDataSource::ExtraData, |
| 30 public base::SupportsUserData { | 24 public base::SupportsUserData { |
| 31 public: | 25 public: |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 load_histograms_recorded_ = value; | 118 load_histograms_recorded_ = value; |
| 125 } | 119 } |
| 126 | 120 |
| 127 bool web_timing_histograms_recorded() const { | 121 bool web_timing_histograms_recorded() const { |
| 128 return web_timing_histograms_recorded_; | 122 return web_timing_histograms_recorded_; |
| 129 } | 123 } |
| 130 void set_web_timing_histograms_recorded(bool value) { | 124 void set_web_timing_histograms_recorded(bool value) { |
| 131 web_timing_histograms_recorded_ = value; | 125 web_timing_histograms_recorded_ = value; |
| 132 } | 126 } |
| 133 | 127 |
| 134 int http_status_code() const { return http_status_code_; } | |
| 135 void set_http_status_code(int http_status_code) { | |
| 136 http_status_code_ = http_status_code; | |
| 137 } | |
| 138 | |
| 139 // Indicator if SPDY was used as part of this page load. | 128 // Indicator if SPDY was used as part of this page load. |
| 140 bool was_fetched_via_spdy() const { return was_fetched_via_spdy_; } | 129 bool was_fetched_via_spdy() const { return was_fetched_via_spdy_; } |
| 141 void set_was_fetched_via_spdy(bool value) { was_fetched_via_spdy_ = value; } | 130 void set_was_fetched_via_spdy(bool value) { was_fetched_via_spdy_ = value; } |
| 142 | 131 |
| 143 bool was_npn_negotiated() const { return was_npn_negotiated_; } | 132 bool was_npn_negotiated() const { return was_npn_negotiated_; } |
| 144 void set_was_npn_negotiated(bool value) { was_npn_negotiated_ = value; } | 133 void set_was_npn_negotiated(bool value) { was_npn_negotiated_ = value; } |
| 145 | 134 |
| 146 const std::string& npn_negotiated_protocol() const { | 135 const std::string& npn_negotiated_protocol() const { |
| 147 return npn_negotiated_protocol_; | 136 return npn_negotiated_protocol_; |
| 148 } | 137 } |
| 149 void set_npn_negotiated_protocol(const std::string& value) { | 138 void set_npn_negotiated_protocol(const std::string& value) { |
| 150 npn_negotiated_protocol_ = value; | 139 npn_negotiated_protocol_ = value; |
| 151 } | 140 } |
| 152 | 141 |
| 153 bool was_alternate_protocol_available() const { | 142 bool was_alternate_protocol_available() const { |
| 154 return was_alternate_protocol_available_; | 143 return was_alternate_protocol_available_; |
| 155 } | 144 } |
| 156 void set_was_alternate_protocol_available(bool value) { | 145 void set_was_alternate_protocol_available(bool value) { |
| 157 was_alternate_protocol_available_ = value; | 146 was_alternate_protocol_available_ = value; |
| 158 } | 147 } |
| 159 | 148 |
| 160 bool was_fetched_via_proxy() const { return was_fetched_via_proxy_; } | 149 bool was_fetched_via_proxy() const { return was_fetched_via_proxy_; } |
| 161 void set_was_fetched_via_proxy(bool value) { | 150 void set_was_fetched_via_proxy(bool value) { |
| 162 was_fetched_via_proxy_ = value; | 151 was_fetched_via_proxy_ = value; |
| 163 } | 152 } |
| 164 | 153 |
| 165 const GURL& searchable_form_url() const { return searchable_form_url_; } | |
| 166 void set_searchable_form_url(const GURL& url) { searchable_form_url_ = url; } | |
| 167 const std::string& searchable_form_encoding() const { | |
| 168 return searchable_form_encoding_; | |
| 169 } | |
| 170 void set_searchable_form_encoding(const std::string& encoding) { | |
| 171 searchable_form_encoding_ = encoding; | |
| 172 } | |
| 173 | |
| 174 // If set, contains the PasswordForm that we believe triggered the current | 154 // If set, contains the PasswordForm that we believe triggered the current |
| 175 // navigation (there is some ambiguity in the case of javascript initiated | 155 // navigation (there is some ambiguity in the case of javascript initiated |
| 176 // navigations). This information is used by the PasswordManager to determine | 156 // navigations). This information is used by the PasswordManager to determine |
| 177 // if the user should be prompted to save their password. | 157 // if the user should be prompted to save their password. |
| 178 // | 158 // |
| 179 // Note that setting this field doesn't affect where the data is sent or what | 159 // Note that setting this field doesn't affect where the data is sent or what |
| 180 // origin we associate it with, only whether we prompt the user to save it. | 160 // origin we associate it with, only whether we prompt the user to save it. |
| 181 // That is, a false positive is a usability issue (e.g. may try to save a | 161 // That is, a false positive is a usability issue (e.g. may try to save a |
| 182 // mis-typed password) not a security issue. | 162 // mis-typed password) not a security issue. |
| 183 PasswordForm* password_form_data() const { | 163 PasswordForm* password_form_data() const { |
| 184 return password_form_data_.get(); | 164 return password_form_data_.get(); |
| 185 } | 165 } |
| 186 void set_password_form_data(scoped_ptr<PasswordForm> data); | 166 void set_password_form_data(scoped_ptr<PasswordForm> data); |
| 187 | 167 |
| 188 const std::string& security_info() const { return security_info_; } | |
| 189 void set_security_info(const std::string& security_info) { | |
| 190 security_info_ = security_info; | |
| 191 } | |
| 192 | |
| 193 // True if an error page should be used, if the http status code also | |
| 194 // indicates an error. | |
| 195 bool use_error_page() const { return use_error_page_; } | |
| 196 void set_use_error_page(bool use_error_page) { | |
| 197 use_error_page_ = use_error_page; | |
| 198 } | |
| 199 | |
| 200 // True if the user agent was overridden for this page. | |
| 201 bool is_overriding_user_agent() const { return is_overriding_user_agent_; } | |
| 202 void set_is_overriding_user_agent(bool state) { | |
| 203 is_overriding_user_agent_ = state; | |
| 204 } | |
| 205 | |
| 206 // True if we have to reset the scroll and scale state of the page | |
| 207 // after the provisional load has been committed. | |
| 208 bool must_reset_scroll_and_scale_state() const { | |
| 209 return must_reset_scroll_and_scale_state_; | |
| 210 } | |
| 211 void set_must_reset_scroll_and_scale_state(bool state) { | |
| 212 must_reset_scroll_and_scale_state_ = state; | |
| 213 } | |
| 214 | |
| 215 void set_was_prefetcher(bool value) { was_prefetcher_ = value; } | 168 void set_was_prefetcher(bool value) { was_prefetcher_ = value; } |
| 216 bool was_prefetcher() const { return was_prefetcher_; } | 169 bool was_prefetcher() const { return was_prefetcher_; } |
| 217 | 170 |
| 218 void set_was_referred_by_prefetcher(bool value) { | 171 void set_was_referred_by_prefetcher(bool value) { |
| 219 was_referred_by_prefetcher_ = value; | 172 was_referred_by_prefetcher_ = value; |
| 220 } | 173 } |
| 221 bool was_referred_by_prefetcher() const { | 174 bool was_referred_by_prefetcher() const { |
| 222 return was_referred_by_prefetcher_; | 175 return was_referred_by_prefetcher_; |
| 223 } | 176 } |
| 224 | 177 |
| 225 // Record the nature of this load, for use when histogramming page load times. | 178 // Record the nature of this load, for use when histogramming page load times. |
| 226 LoadType load_type() const { return load_type_; } | 179 LoadType load_type() const { return load_type_; } |
| 227 void set_load_type(LoadType load_type) { load_type_ = load_type; } | 180 void set_load_type(LoadType load_type) { load_type_ = load_type; } |
| 228 | 181 |
| 229 // Sets the cache policy. The cache policy is only used if explicitly set and | |
| 230 // by default is not set. You can mark a NavigationState as not having a cache | |
| 231 // state by way of clear_cache_policy_override. | |
| 232 void set_cache_policy_override( | |
| 233 WebKit::WebURLRequest::CachePolicy cache_policy) { | |
| 234 cache_policy_override_ = cache_policy; | |
| 235 cache_policy_override_set_ = true; | |
| 236 } | |
| 237 WebKit::WebURLRequest::CachePolicy cache_policy_override() const { | |
| 238 return cache_policy_override_; | |
| 239 } | |
| 240 void clear_cache_policy_override() { | |
| 241 cache_policy_override_set_ = false; | |
| 242 cache_policy_override_ = WebKit::WebURLRequest::UseProtocolCachePolicy; | |
| 243 } | |
| 244 bool is_cache_policy_override_set() const { | |
| 245 return cache_policy_override_set_; | |
| 246 } | |
| 247 | |
| 248 // Sets the referrer policy to use. This is only used for browser initiated | |
| 249 // navigations, otherwise, the referrer policy is defined by the frame's | |
| 250 // document. | |
| 251 WebKit::WebReferrerPolicy referrer_policy() const { | |
| 252 return referrer_policy_; | |
| 253 } | |
| 254 void set_referrer_policy(WebKit::WebReferrerPolicy referrer_policy) { | |
| 255 referrer_policy_ = referrer_policy; | |
| 256 referrer_policy_set_ = true; | |
| 257 } | |
| 258 void clear_referrer_policy() { | |
| 259 referrer_policy_ = WebKit::WebReferrerPolicyDefault; | |
| 260 referrer_policy_set_ = false; | |
| 261 } | |
| 262 bool is_referrer_policy_set() const { return referrer_policy_set_; } | |
| 263 | |
| 264 webkit_glue::AltErrorPageResourceFetcher* alt_error_page_fetcher() const { | |
| 265 return alt_error_page_fetcher_.get(); | |
| 266 } | |
| 267 void set_alt_error_page_fetcher(webkit_glue::AltErrorPageResourceFetcher* f); | |
| 268 | |
| 269 NavigationState* navigation_state() { return navigation_state_.get(); } | 182 NavigationState* navigation_state() { return navigation_state_.get(); } |
| 270 void set_navigation_state(NavigationState* navigation_state); | 183 void set_navigation_state(NavigationState* navigation_state); |
| 271 | 184 |
| 272 bool can_load_local_resources() const { return can_load_local_resources_; } | 185 bool can_load_local_resources() const { return can_load_local_resources_; } |
| 273 void set_can_load_local_resources(bool can_load) { | 186 void set_can_load_local_resources(bool can_load) { |
| 274 can_load_local_resources_ = can_load; | 187 can_load_local_resources_ = can_load; |
| 275 } | 188 } |
| 276 | 189 |
| 277 private: | 190 private: |
| 278 base::Time request_time_; | 191 base::Time request_time_; |
| 279 base::Time start_load_time_; | 192 base::Time start_load_time_; |
| 280 base::Time commit_load_time_; | 193 base::Time commit_load_time_; |
| 281 base::Time finish_document_load_time_; | 194 base::Time finish_document_load_time_; |
| 282 base::Time finish_load_time_; | 195 base::Time finish_load_time_; |
| 283 base::Time first_paint_time_; | 196 base::Time first_paint_time_; |
| 284 base::Time first_paint_after_load_time_; | 197 base::Time first_paint_after_load_time_; |
| 285 bool load_histograms_recorded_; | 198 bool load_histograms_recorded_; |
| 286 bool web_timing_histograms_recorded_; | 199 bool web_timing_histograms_recorded_; |
| 287 int http_status_code_; | |
| 288 bool was_fetched_via_spdy_; | 200 bool was_fetched_via_spdy_; |
| 289 bool was_npn_negotiated_; | 201 bool was_npn_negotiated_; |
| 290 std::string npn_negotiated_protocol_; | 202 std::string npn_negotiated_protocol_; |
| 291 bool was_alternate_protocol_available_; | 203 bool was_alternate_protocol_available_; |
| 292 bool was_fetched_via_proxy_; | 204 bool was_fetched_via_proxy_; |
| 293 | 205 |
| 294 GURL searchable_form_url_; | |
| 295 std::string searchable_form_encoding_; | |
| 296 scoped_ptr<PasswordForm> password_form_data_; | 206 scoped_ptr<PasswordForm> password_form_data_; |
| 297 std::string security_info_; | |
| 298 | |
| 299 bool use_error_page_; | |
| 300 | |
| 301 bool is_overriding_user_agent_; | |
| 302 bool must_reset_scroll_and_scale_state_; | |
| 303 | 207 |
| 304 // A prefetcher is a page that contains link rel=prefetch elements. | 208 // A prefetcher is a page that contains link rel=prefetch elements. |
| 305 bool was_prefetcher_; | 209 bool was_prefetcher_; |
| 306 bool was_referred_by_prefetcher_; | 210 bool was_referred_by_prefetcher_; |
| 307 | 211 |
| 308 LoadType load_type_; | 212 LoadType load_type_; |
| 309 | 213 |
| 310 bool cache_policy_override_set_; | |
| 311 WebKit::WebURLRequest::CachePolicy cache_policy_override_; | |
| 312 | |
| 313 bool referrer_policy_set_; | |
| 314 WebKit::WebReferrerPolicy referrer_policy_; | |
| 315 | |
| 316 scoped_ptr<webkit_glue::AltErrorPageResourceFetcher> alt_error_page_fetcher_; | |
| 317 | |
| 318 scoped_ptr<NavigationState> navigation_state_; | 214 scoped_ptr<NavigationState> navigation_state_; |
| 319 | 215 |
| 320 bool can_load_local_resources_; | 216 bool can_load_local_resources_; |
| 321 }; | 217 }; |
| 322 | 218 |
| 323 #endif // CONTENT_PUBLIC_RENDERER_DOCUMENT_STATE_H_ | 219 #endif // CONTENT_PUBLIC_RENDERER_DOCUMENT_STATE_H_ |
| 324 | 220 |
| 325 } // namespace content | 221 } // namespace content |
| OLD | NEW |