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

Side by Side Diff: chrome/browser/extensions/api/web_request/form_data_parser.h

Issue 10694055: Add read-only access to POST data for webRequest's onBeforeRequest (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: No change in code, but with a patch generated without copy detection Created 8 years, 3 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
« no previous file with comments | « no previous file | chrome/browser/extensions/api/web_request/form_data_parser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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 CHROME_BROWSER_EXTENSIONS_API_WEB_REQUEST_FORM_DATA_PARSER_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_WEB_REQUEST_FORM_DATA_PARSER_H_
7
8 #include <string>
9
10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h"
12 // Cannot forward declare StringPiece because it is a typedef.
13 #include "base/string_piece.h"
14
15 namespace net {
16 class URLRequest;
17 }
18
19 namespace extensions {
20
21 // Interface for the form data parsers.
22 class FormDataParser {
23 public:
24 class Result {
25 public:
26 Result();
27 ~Result();
28 const std::string& name() const {
29 return name_;
30 }
31 const std::string& value() const {
32 return value_;
33 }
34 void set_name(const base::StringPiece& str) {
35 str.CopyToString(&name_);
36 }
37 void set_value(const base::StringPiece& str) {
38 str.CopyToString(&value_);
39 }
40 void set_name(const std::string& str) {
41 name_ = str;
42 }
43 void set_value(const std::string& str) {
44 value_ = str;
45 }
46 void Reset();
47
48 private:
49 std::string name_;
50 std::string value_;
51
52 DISALLOW_COPY_AND_ASSIGN(Result);
53 };
54
55 virtual ~FormDataParser();
56
57 // Creates a correct parser instance based on the |request|. Returns NULL
58 // on failure.
59 static scoped_ptr<FormDataParser> Create(const net::URLRequest* request);
60
61 // Creates a correct parser instance based on |content_type_header|, the
62 // "Content-Type" request header value. If |content_type_header| is NULL, it
63 // defaults to "application/x-www-form-urlencoded". Returns NULL on failure.
64 static scoped_ptr<FormDataParser> Create(
65 const std::string* content_type_header);
66
67 // Returns true if there was some data, it was well formed and all was read.
68 virtual bool AllDataReadOK() = 0;
69
70 // Returns the next name-value pair as |result|. After SetSource has
71 // succeeded, this allows to iterate over all pairs in the source.
72 // Returns true as long as a new pair was successfully found.
73 virtual bool GetNextNameValue(Result* result) = 0;
74
75 // Sets the |source| of the data to be parsed. The ownership is left with the
76 // caller and the source should live until |this| dies or |this->SetSource()|
77 // is called again, whichever comes sooner. Returns true on success.
78 virtual bool SetSource(const base::StringPiece& source) = 0;
79
80 protected:
81 FormDataParser();
82
83 private:
84 DISALLOW_COPY_AND_ASSIGN(FormDataParser);
85 };
86
87 } // namespace extensions
88
89 #endif // CHROME_BROWSER_EXTENSIONS_API_WEB_REQUEST_FORM_DATA_PARSER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/api/web_request/form_data_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698