Upstreaming browser/ui/uikit_ui_util from iOS.
[chromium-blink-merge.git] / content / renderer / internal_document_state_data.h
blob93f9dd5b51f21f88b1376a3a2ab47af97eaaadef
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_
8 #include <string>
10 #include "base/memory/scoped_ptr.h"
11 #include "base/supports_user_data.h"
12 #include "third_party/WebKit/public/platform/WebURLRequest.h"
13 #include "url/gurl.h"
15 namespace blink {
16 class WebDataSource;
19 namespace content {
21 class DocumentState;
23 // Stores internal state per WebDataSource.
24 class InternalDocumentStateData : public base::SupportsUserData::Data {
25 public:
26 InternalDocumentStateData();
28 static InternalDocumentStateData* FromDataSource(blink::WebDataSource* ds);
29 static InternalDocumentStateData* FromDocumentState(DocumentState* ds);
31 // Set to true once RenderViewImpl::didFirstVisuallyNonEmptyLayout() is
32 // invoked.
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 the user agent was overridden for this page.
55 bool is_overriding_user_agent() const { return is_overriding_user_agent_; }
56 void set_is_overriding_user_agent(bool state) {
57 is_overriding_user_agent_ = state;
60 // True if we have to reset the scroll and scale state of the page
61 // after the provisional load has been committed.
62 bool must_reset_scroll_and_scale_state() const {
63 return must_reset_scroll_and_scale_state_;
65 void set_must_reset_scroll_and_scale_state(bool state) {
66 must_reset_scroll_and_scale_state_ = state;
69 // Sets the cache policy. The cache policy is only used if explicitly set and
70 // by default is not set. You can mark a NavigationState as not having a cache
71 // state by way of clear_cache_policy_override.
72 void set_cache_policy_override(
73 blink::WebURLRequest::CachePolicy cache_policy) {
74 cache_policy_override_ = cache_policy;
75 cache_policy_override_set_ = true;
77 blink::WebURLRequest::CachePolicy cache_policy_override() const {
78 return cache_policy_override_;
80 void clear_cache_policy_override() {
81 cache_policy_override_set_ = false;
82 cache_policy_override_ = blink::WebURLRequest::UseProtocolCachePolicy;
84 bool is_cache_policy_override_set() const {
85 return cache_policy_override_set_;
88 protected:
89 ~InternalDocumentStateData() override;
91 private:
92 bool did_first_visually_non_empty_layout_;
93 bool did_first_visually_non_empty_paint_;
94 int http_status_code_;
95 GURL searchable_form_url_;
96 std::string searchable_form_encoding_;
97 bool is_overriding_user_agent_;
98 bool must_reset_scroll_and_scale_state_;
99 bool cache_policy_override_set_;
100 blink::WebURLRequest::CachePolicy cache_policy_override_;
102 DISALLOW_COPY_AND_ASSIGN(InternalDocumentStateData);
105 } // namespace content
107 #endif // CONTENT_RENDERER_INTERNAL_DOCUMENT_STATE_DATA_H_