Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Side by Side Diff: chrome/browser/extensions/api/declarative_webrequest/webrequest_action.h

Issue 10386172: Implemented declarative redirects to transparent image and empty document. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed nits Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_ACTION_H _ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_ACTION_H _
6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_ACTION_H _ 6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_ACTION_H _
7 #pragma once 7 #pragma once
8 8
9 #include <list> 9 #include <list>
10 #include <string> 10 #include <string>
(...skipping 25 matching lines...) Expand all
36 LinkedPtrEventResponseDelta; 36 LinkedPtrEventResponseDelta;
37 37
38 // Base class for all WebRequestActions of the declarative Web Request API. 38 // Base class for all WebRequestActions of the declarative Web Request API.
39 // 39 //
40 // TODO(battre): Add method that corresponds to executing the action. 40 // TODO(battre): Add method that corresponds to executing the action.
41 class WebRequestAction { 41 class WebRequestAction {
42 public: 42 public:
43 // Type identifiers for concrete WebRequestActions. 43 // Type identifiers for concrete WebRequestActions.
44 enum Type { 44 enum Type {
45 ACTION_CANCEL_REQUEST, 45 ACTION_CANCEL_REQUEST,
46 ACTION_REDIRECT_REQUEST 46 ACTION_REDIRECT_REQUEST,
47 ACTION_REDIRECT_TO_TRANSPARENT_IMAGE,
48 ACTION_REDIRECT_TO_EMPTY_DOCUMENT,
47 }; 49 };
48 50
49 WebRequestAction(); 51 WebRequestAction();
50 virtual ~WebRequestAction(); 52 virtual ~WebRequestAction();
51 53
52 // Returns a bit vector representing extensions::RequestStages. The bit vector 54 // Returns a bit vector representing extensions::RequestStages. The bit vector
53 // contains a 1 for each request stage during which the condition can be 55 // contains a 1 for each request stage during which the condition can be
54 // tested. 56 // tested.
55 virtual int GetStages() const = 0; 57 virtual int GetStages() const = 0;
56 58
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 RequestStages request_stage, 146 RequestStages request_stage,
145 const std::string& extension_id, 147 const std::string& extension_id,
146 const base::Time& extension_install_time) const OVERRIDE; 148 const base::Time& extension_install_time) const OVERRIDE;
147 149
148 private: 150 private:
149 GURL redirect_url_; // Target to which the request shall be redirected. 151 GURL redirect_url_; // Target to which the request shall be redirected.
150 152
151 DISALLOW_COPY_AND_ASSIGN(WebRequestRedirectAction); 153 DISALLOW_COPY_AND_ASSIGN(WebRequestRedirectAction);
152 }; 154 };
153 155
156 // Action that instructs to redirect a network request to a transparent image.
157 class WebRequestRedirectToTransparentImageAction : public WebRequestAction {
158 public:
159 explicit WebRequestRedirectToTransparentImageAction();
160 virtual ~WebRequestRedirectToTransparentImageAction();
161
162 // Implementation of WebRequestAction:
163 virtual int GetStages() const OVERRIDE;
164 virtual Type GetType() const OVERRIDE;
165 virtual LinkedPtrEventResponseDelta CreateDelta(
166 net::URLRequest* request,
167 RequestStages request_stage,
168 const std::string& extension_id,
169 const base::Time& extension_install_time) const OVERRIDE;
170
171 private:
172 DISALLOW_COPY_AND_ASSIGN(WebRequestRedirectToTransparentImageAction);
173 };
174
175
176 // Action that instructs to redirect a network request to an empty document.
177 class WebRequestRedirectToEmptyDocumentAction : public WebRequestAction {
178 public:
179 explicit WebRequestRedirectToEmptyDocumentAction();
180 virtual ~WebRequestRedirectToEmptyDocumentAction();
181
182 // Implementation of WebRequestAction:
183 virtual int GetStages() const OVERRIDE;
184 virtual Type GetType() const OVERRIDE;
185 virtual LinkedPtrEventResponseDelta CreateDelta(
186 net::URLRequest* request,
187 RequestStages request_stage,
188 const std::string& extension_id,
189 const base::Time& extension_install_time) const OVERRIDE;
190
191 private:
192 DISALLOW_COPY_AND_ASSIGN(WebRequestRedirectToEmptyDocumentAction);
193 };
194
154 // TODO(battre) Implement further actions: 195 // TODO(battre) Implement further actions:
155 // Redirect to constant url, Redirect by RegEx, Set header, Remove header, ... 196 // Redirect to constant url, Redirect by RegEx, Set header, Remove header, ...
156 197
157 } // namespace extensions 198 } // namespace extensions
158 199
159 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_ACTIO N_H_ 200 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_ACTIO N_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698