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 // Set to true once RenderViewImpl::didFirstVisuallyNonEmptyLayout() is
33 bool did_first_visually_non_empty_layout() const {
34 return did_first_visually_non_empty_layout_
;
36 void set_did_first_visually_non_empty_layout(bool value
) {
37 did_first_visually_non_empty_layout_
= value
;
40 int http_status_code() const { return http_status_code_
; }
41 void set_http_status_code(int http_status_code
) {
42 http_status_code_
= http_status_code
;
45 const GURL
& searchable_form_url() const { return searchable_form_url_
; }
46 void set_searchable_form_url(const GURL
& url
) { searchable_form_url_
= url
; }
47 const std::string
& searchable_form_encoding() const {
48 return searchable_form_encoding_
;
50 void set_searchable_form_encoding(const std::string
& encoding
) {
51 searchable_form_encoding_
= encoding
;
54 // True if an error page should be used, if the http status code also
55 // indicates an error.
56 bool use_error_page() const { return use_error_page_
; }
57 void set_use_error_page(bool use_error_page
) {
58 use_error_page_
= use_error_page
;
61 // True if the user agent was overridden for this page.
62 bool is_overriding_user_agent() const { return is_overriding_user_agent_
; }
63 void set_is_overriding_user_agent(bool state
) {
64 is_overriding_user_agent_
= state
;
67 // True if we have to reset the scroll and scale state of the page
68 // after the provisional load has been committed.
69 bool must_reset_scroll_and_scale_state() const {
70 return must_reset_scroll_and_scale_state_
;
72 void set_must_reset_scroll_and_scale_state(bool state
) {
73 must_reset_scroll_and_scale_state_
= state
;
76 // Sets the cache policy. The cache policy is only used if explicitly set and
77 // by default is not set. You can mark a NavigationState as not having a cache
78 // state by way of clear_cache_policy_override.
79 void set_cache_policy_override(
80 blink::WebURLRequest::CachePolicy cache_policy
) {
81 cache_policy_override_
= cache_policy
;
82 cache_policy_override_set_
= true;
84 blink::WebURLRequest::CachePolicy
cache_policy_override() const {
85 return cache_policy_override_
;
87 void clear_cache_policy_override() {
88 cache_policy_override_set_
= false;
89 cache_policy_override_
= blink::WebURLRequest::UseProtocolCachePolicy
;
91 bool is_cache_policy_override_set() const {
92 return cache_policy_override_set_
;
96 ~InternalDocumentStateData() override
;
99 bool did_first_visually_non_empty_layout_
;
100 bool did_first_visually_non_empty_paint_
;
101 int http_status_code_
;
102 GURL searchable_form_url_
;
103 std::string searchable_form_encoding_
;
104 bool use_error_page_
;
105 bool is_overriding_user_agent_
;
106 bool must_reset_scroll_and_scale_state_
;
107 bool cache_policy_override_set_
;
108 blink::WebURLRequest::CachePolicy cache_policy_override_
;
110 DISALLOW_COPY_AND_ASSIGN(InternalDocumentStateData
);
113 } // namespace content
115 #endif // CONTENT_RENDERER_INTERNAL_DOCUMENT_STATE_DATA_H_