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 // Set to true once RenderViewImpl::DidFlushPaint() is inovked after
41 // RenderViewImpl::didFirstVisuallyNonEmptyLayout(). In other words after the
42 // page has painted something.
43 bool did_first_visually_non_empty_paint() const {
44 return did_first_visually_non_empty_paint_
;
46 void set_did_first_visually_non_empty_paint(bool value
) {
47 did_first_visually_non_empty_paint_
= value
;
50 int http_status_code() const { return http_status_code_
; }
51 void set_http_status_code(int http_status_code
) {
52 http_status_code_
= http_status_code
;
55 const GURL
& searchable_form_url() const { return searchable_form_url_
; }
56 void set_searchable_form_url(const GURL
& url
) { searchable_form_url_
= url
; }
57 const std::string
& searchable_form_encoding() const {
58 return searchable_form_encoding_
;
60 void set_searchable_form_encoding(const std::string
& encoding
) {
61 searchable_form_encoding_
= encoding
;
64 // True if an error page should be used, if the http status code also
65 // indicates an error.
66 bool use_error_page() const { return use_error_page_
; }
67 void set_use_error_page(bool use_error_page
) {
68 use_error_page_
= use_error_page
;
71 // True if the user agent was overridden for this page.
72 bool is_overriding_user_agent() const { return is_overriding_user_agent_
; }
73 void set_is_overriding_user_agent(bool state
) {
74 is_overriding_user_agent_
= state
;
77 // True if we have to reset the scroll and scale state of the page
78 // after the provisional load has been committed.
79 bool must_reset_scroll_and_scale_state() const {
80 return must_reset_scroll_and_scale_state_
;
82 void set_must_reset_scroll_and_scale_state(bool state
) {
83 must_reset_scroll_and_scale_state_
= state
;
86 // Sets the cache policy. The cache policy is only used if explicitly set and
87 // by default is not set. You can mark a NavigationState as not having a cache
88 // state by way of clear_cache_policy_override.
89 void set_cache_policy_override(
90 blink::WebURLRequest::CachePolicy cache_policy
) {
91 cache_policy_override_
= cache_policy
;
92 cache_policy_override_set_
= true;
94 blink::WebURLRequest::CachePolicy
cache_policy_override() const {
95 return cache_policy_override_
;
97 void clear_cache_policy_override() {
98 cache_policy_override_set_
= false;
99 cache_policy_override_
= blink::WebURLRequest::UseProtocolCachePolicy
;
101 bool is_cache_policy_override_set() const {
102 return cache_policy_override_set_
;
106 virtual ~InternalDocumentStateData();
109 bool did_first_visually_non_empty_layout_
;
110 bool did_first_visually_non_empty_paint_
;
111 int http_status_code_
;
112 GURL searchable_form_url_
;
113 std::string searchable_form_encoding_
;
114 bool use_error_page_
;
115 bool is_overriding_user_agent_
;
116 bool must_reset_scroll_and_scale_state_
;
117 bool cache_policy_override_set_
;
118 blink::WebURLRequest::CachePolicy cache_policy_override_
;
120 DISALLOW_COPY_AND_ASSIGN(InternalDocumentStateData
);
123 } // namespace content
125 #endif // CONTENT_RENDERER_INTERNAL_DOCUMENT_STATE_DATA_H_