Upstream version 11.40.277.0
[platform/framework/web/crosswalk.git] / src / content / child / request_extra_data.h
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
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_CHILD_REQUEST_EXTRA_DATA_H_
6 #define CONTENT_CHILD_REQUEST_EXTRA_DATA_H_
7
8 #include "base/compiler_specific.h"
9 #include "content/child/web_url_loader_impl.h"
10 #include "content/common/content_export.h"
11 #include "third_party/WebKit/public/platform/WebString.h"
12 #include "third_party/WebKit/public/platform/WebURLRequest.h"
13 #include "third_party/WebKit/public/web/WebPageVisibilityState.h"
14 #include "ui/base/page_transition_types.h"
15
16 namespace content {
17
18 // Can be used by callers to store extra data on every ResourceRequest
19 // which will be incorporated into the ResourceHostMsg_Request message
20 // sent by ResourceDispatcher.
21 class CONTENT_EXPORT RequestExtraData
22     : public NON_EXPORTED_BASE(blink::WebURLRequest::ExtraData) {
23  public:
24   RequestExtraData();
25   virtual ~RequestExtraData();
26
27   blink::WebPageVisibilityState visibility_state() const {
28     return visibility_state_;
29   }
30   void set_visibility_state(blink::WebPageVisibilityState visibility_state) {
31     visibility_state_ = visibility_state;
32   }
33   int render_frame_id() const { return render_frame_id_; }
34   void set_render_frame_id(int render_frame_id) {
35     render_frame_id_ = render_frame_id;
36   }
37   bool is_main_frame() const { return is_main_frame_; }
38   void set_is_main_frame(bool is_main_frame) {
39     is_main_frame_ = is_main_frame;
40   }
41   GURL frame_origin() const { return frame_origin_; }
42   void set_frame_origin(const GURL& frame_origin) {
43     frame_origin_ = frame_origin;
44   }
45   bool parent_is_main_frame() const { return parent_is_main_frame_; }
46   void set_parent_is_main_frame(bool parent_is_main_frame) {
47     parent_is_main_frame_ = parent_is_main_frame;
48   }
49   int parent_render_frame_id() const { return parent_render_frame_id_; }
50   void set_parent_render_frame_id(int parent_render_frame_id) {
51     parent_render_frame_id_ = parent_render_frame_id;
52   }
53   bool allow_download() const { return allow_download_; }
54   void set_allow_download(bool allow_download) {
55     allow_download_ = allow_download;
56   }
57   ui::PageTransition transition_type() const { return transition_type_; }
58   void set_transition_type(ui::PageTransition transition_type) {
59     transition_type_ = transition_type;
60   }
61   bool should_replace_current_entry() const {
62     return should_replace_current_entry_;
63   }
64   void set_should_replace_current_entry(
65       bool should_replace_current_entry) {
66     should_replace_current_entry_ = should_replace_current_entry;
67   }
68   int transferred_request_child_id() const {
69     return transferred_request_child_id_;
70   }
71   void set_transferred_request_child_id(
72       int transferred_request_child_id) {
73     transferred_request_child_id_ = transferred_request_child_id;
74   }
75   int transferred_request_request_id() const {
76     return transferred_request_request_id_;
77   }
78   void set_transferred_request_request_id(
79       int transferred_request_request_id) {
80     transferred_request_request_id_ = transferred_request_request_id;
81   }
82   int service_worker_provider_id() const {
83     return service_worker_provider_id_;
84   }
85   void set_service_worker_provider_id(
86       int service_worker_provider_id) {
87     service_worker_provider_id_ = service_worker_provider_id;
88   }
89   // |custom_user_agent| is used to communicate an overriding custom user agent
90   // to |RenderViewImpl::willSendRequest()|; set to a null string to indicate no
91   // override and an empty string to indicate that there should be no user
92   // agent.
93   const blink::WebString& custom_user_agent() const {
94     return custom_user_agent_;
95   }
96   void set_custom_user_agent(const blink::WebString& custom_user_agent) {
97     custom_user_agent_ = custom_user_agent;
98   }
99   const blink::WebString& requested_with() const {
100     return requested_with_;
101   }
102   void set_requested_with(const blink::WebString& requested_with) {
103     requested_with_ = requested_with;
104   }
105
106   // PlzNavigate: |stream_override| is used to override certain parameters of
107   // navigation requests.
108   scoped_ptr<StreamOverrideParameters> TakeStreamOverrideOwnership() {
109     return stream_override_.Pass();
110   }
111
112   void set_stream_override(
113       scoped_ptr<StreamOverrideParameters> stream_override) {
114     stream_override_ = stream_override.Pass();
115   }
116
117  private:
118   blink::WebPageVisibilityState visibility_state_;
119   int render_frame_id_;
120   bool is_main_frame_;
121   GURL frame_origin_;
122   bool parent_is_main_frame_;
123   int parent_render_frame_id_;
124   bool allow_download_;
125   ui::PageTransition transition_type_;
126   bool should_replace_current_entry_;
127   int transferred_request_child_id_;
128   int transferred_request_request_id_;
129   int service_worker_provider_id_;
130   blink::WebString custom_user_agent_;
131   blink::WebString requested_with_;
132   scoped_ptr<StreamOverrideParameters> stream_override_;
133
134   DISALLOW_COPY_AND_ASSIGN(RequestExtraData);
135 };
136
137 }  // namespace content
138
139 #endif  // CONTENT_CHILD_REQUEST_EXTRA_DATA_H_