1 // Copyright (c) 2013 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.
5 #ifndef CONTENT_RENDERER_INTERNAL_DOCUMENT_STATE_DATA_H_
6 #define CONTENT_RENDERER_INTERNAL_DOCUMENT_STATE_DATA_H_
10 #include "base/memory/scoped_ptr.h"
11 #include "base/supports_user_data.h"
12 #include "third_party/WebKit/public/platform/WebURLRequest.h"
23 // Stores internal state per WebDataSource.
24 class InternalDocumentStateData
: public base::SupportsUserData::Data
{
26 InternalDocumentStateData();
28 static InternalDocumentStateData
* FromDataSource(blink::WebDataSource
* ds
);
29 static InternalDocumentStateData
* FromDocumentState(DocumentState
* ds
);
31 int http_status_code() const { return http_status_code_
; }
32 void set_http_status_code(int http_status_code
) {
33 http_status_code_
= http_status_code
;
36 const GURL
& searchable_form_url() const { return searchable_form_url_
; }
37 void set_searchable_form_url(const GURL
& url
) { searchable_form_url_
= url
; }
38 const std::string
& searchable_form_encoding() const {
39 return searchable_form_encoding_
;
41 void set_searchable_form_encoding(const std::string
& encoding
) {
42 searchable_form_encoding_
= encoding
;
45 // True if the user agent was overridden for this page.
46 bool is_overriding_user_agent() const { return is_overriding_user_agent_
; }
47 void set_is_overriding_user_agent(bool state
) {
48 is_overriding_user_agent_
= state
;
51 // True if we have to reset the scroll and scale state of the page
52 // after the provisional load has been committed.
53 bool must_reset_scroll_and_scale_state() const {
54 return must_reset_scroll_and_scale_state_
;
56 void set_must_reset_scroll_and_scale_state(bool state
) {
57 must_reset_scroll_and_scale_state_
= state
;
60 // Sets the cache policy. The cache policy is only used if explicitly set and
61 // by default is not set. You can mark a NavigationState as not having a cache
62 // state by way of clear_cache_policy_override.
63 void set_cache_policy_override(
64 blink::WebURLRequest::CachePolicy cache_policy
) {
65 cache_policy_override_
= cache_policy
;
66 cache_policy_override_set_
= true;
68 blink::WebURLRequest::CachePolicy
cache_policy_override() const {
69 return cache_policy_override_
;
71 void clear_cache_policy_override() {
72 cache_policy_override_set_
= false;
73 cache_policy_override_
= blink::WebURLRequest::UseProtocolCachePolicy
;
75 bool is_cache_policy_override_set() const {
76 return cache_policy_override_set_
;
80 ~InternalDocumentStateData() override
;
83 int http_status_code_
;
84 GURL searchable_form_url_
;
85 std::string searchable_form_encoding_
;
86 bool is_overriding_user_agent_
;
87 bool must_reset_scroll_and_scale_state_
;
88 bool cache_policy_override_set_
;
89 blink::WebURLRequest::CachePolicy cache_policy_override_
;
91 DISALLOW_COPY_AND_ASSIGN(InternalDocumentStateData
);
94 } // namespace content
96 #endif // CONTENT_RENDERER_INTERNAL_DOCUMENT_STATE_DATA_H_