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