OLD | NEW |
---|---|
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 #include "chrome/browser/extensions/api/web_request/web_request_api.h" | 5 #include "chrome/browser/extensions/api/web_request/web_request_api.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 26 matching lines...) Expand all Loading... | |
37 #include "chrome/common/extensions/url_pattern.h" | 37 #include "chrome/common/extensions/url_pattern.h" |
38 #include "chrome/common/url_constants.h" | 38 #include "chrome/common/url_constants.h" |
39 #include "content/public/browser/browser_message_filter.h" | 39 #include "content/public/browser/browser_message_filter.h" |
40 #include "content/public/browser/browser_thread.h" | 40 #include "content/public/browser/browser_thread.h" |
41 #include "content/public/browser/render_process_host.h" | 41 #include "content/public/browser/render_process_host.h" |
42 #include "content/public/browser/resource_request_info.h" | 42 #include "content/public/browser/resource_request_info.h" |
43 #include "googleurl/src/gurl.h" | 43 #include "googleurl/src/gurl.h" |
44 #include "grit/generated_resources.h" | 44 #include "grit/generated_resources.h" |
45 #include "net/base/auth.h" | 45 #include "net/base/auth.h" |
46 #include "net/base/net_errors.h" | 46 #include "net/base/net_errors.h" |
47 #include "net/base/upload_data.h" | |
47 #include "net/http/http_response_headers.h" | 48 #include "net/http/http_response_headers.h" |
48 #include "net/url_request/url_request.h" | 49 #include "net/url_request/url_request.h" |
49 #include "ui/base/l10n/l10n_util.h" | 50 #include "ui/base/l10n/l10n_util.h" |
50 | 51 |
51 using content::BrowserMessageFilter; | 52 using content::BrowserMessageFilter; |
52 using content::BrowserThread; | 53 using content::BrowserThread; |
53 using content::ResourceRequestInfo; | 54 using content::ResourceRequestInfo; |
54 using extensions::Extension; | 55 using extensions::Extension; |
55 | 56 |
56 namespace helpers = extension_web_request_api_helpers; | 57 namespace helpers = extension_web_request_api_helpers; |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
162 base::Uint64ToString(request->identifier())); | 163 base::Uint64ToString(request->identifier())); |
163 out->SetString(keys::kUrlKey, request->url().spec()); | 164 out->SetString(keys::kUrlKey, request->url().spec()); |
164 out->SetString(keys::kMethodKey, request->method()); | 165 out->SetString(keys::kMethodKey, request->method()); |
165 out->SetInteger(keys::kFrameIdKey, frame_id_for_extension); | 166 out->SetInteger(keys::kFrameIdKey, frame_id_for_extension); |
166 out->SetInteger(keys::kParentFrameIdKey, parent_frame_id_for_extension); | 167 out->SetInteger(keys::kParentFrameIdKey, parent_frame_id_for_extension); |
167 out->SetInteger(keys::kTabIdKey, tab_id); | 168 out->SetInteger(keys::kTabIdKey, tab_id); |
168 out->SetString(keys::kTypeKey, helpers::ResourceTypeToString(resource_type)); | 169 out->SetString(keys::kTypeKey, helpers::ResourceTypeToString(resource_type)); |
169 out->SetDouble(keys::kTimeStampKey, base::Time::Now().ToDoubleT() * 1000); | 170 out->SetDouble(keys::kTimeStampKey, base::Time::Now().ToDoubleT() * 1000); |
170 } | 171 } |
171 | 172 |
173 // Interface for parsers for the POST data. | |
174 class PostDataParser { | |
175 public: | |
176 struct Result { | |
177 const char* key; | |
178 size_t key_length; | |
battre
2012/07/06 07:36:24
This looks like a usecase of StringPiece
vabr (Chromium)
2012/07/06 14:09:01
Done.
| |
179 const char* val; | |
180 size_t val_length; | |
181 }; | |
182 // Attempts to set the |length| bytes at |source| as the data to be parsed. | |
battre
2012/07/06 07:36:24
s/Attempts to set/Sets/
vabr (Chromium)
2012/07/06 14:09:01
Done.
| |
183 // Returns true on success. | |
184 virtual bool SetSource(const char* source, size_t length) = 0; | |
185 // Returns the next key-value pair as |result|. After SetSource has succeeded, | |
186 // this allows to iterate over all pairs in the source. | |
187 // Returns true as long as a new pair was successfully found. | |
188 virtual bool GetNextPair(Result* result) = 0; | |
189 // Returns true if there was some data, it was well formed and all was read. | |
190 virtual bool AllDataReadOK() = 0; | |
battre
2012/07/06 07:36:24
new line before protected: and private:
vabr (Chromium)
2012/07/06 14:09:01
Done.
| |
191 protected: | |
192 PostDataParser() {} | |
193 private: | |
194 DISALLOW_COPY_AND_ASSIGN(PostDataParser); | |
195 }; | |
196 | |
197 class PostDataParserUrlEncoded : public PostDataParser { | |
198 public: | |
199 PostDataParserUrlEncoded() : source_(NULL) {} | |
battre
2012/07/06 07:36:24
length_ and offset_ should be initialized
vabr (Chromium)
2012/07/06 14:09:01
I did not initialize them on purpose. Their value
| |
200 ~PostDataParserUrlEncoded() {} | |
201 virtual bool SetSource(const char* source, size_t length) OVERRIDE; | |
battre
2012/07/06 07:36:24
Please add a new line
// Implementation of PostDa
vabr (Chromium)
2012/07/06 14:09:01
Done.
| |
202 virtual bool GetNextPair(Result* result) OVERRIDE; | |
203 virtual bool AllDataReadOK() OVERRIDE; | |
battre
2012/07/06 07:36:24
new line before private:
vabr (Chromium)
2012/07/06 14:09:01
Done.
| |
204 private: | |
205 // We parse the first |length_| bytes from |source_|. | |
206 const char* source_; | |
207 size_t length_; | |
208 size_t offset_; | |
209 DISALLOW_COPY_AND_ASSIGN(PostDataParserUrlEncoded); | |
210 }; | |
211 | |
212 bool PostDataParserUrlEncoded::AllDataReadOK() { | |
213 return source_ != NULL && offset_ >= length_; | |
214 } | |
215 | |
216 bool PostDataParserUrlEncoded::SetSource(const char* source, size_t length) { | |
217 if (source_ != NULL) return false; | |
218 source_ = source; | |
219 length_ = length; | |
220 offset_ = 0; | |
221 return true; | |
222 } | |
223 | |
224 bool PostDataParserUrlEncoded::GetNextPair(Result* result) { | |
225 if (source_ == NULL) return false; | |
226 if (offset_ >= length_) return false; | |
227 size_t seek = offset_; | |
228 // (*) Now we have |seek| >= |offset_| until the end of this function: | |
229 while (seek < length_ && *(source_ + seek) != '=') ++seek; | |
battre
2012/07/06 07:36:24
I think this is legal but unconventional style. Ty
vabr (Chromium)
2012/07/06 14:09:01
Done, also at the similar while-cycle below.
| |
230 if (seek >= length_) { | |
231 // This means the data is malformed. | |
232 offset_ = seek; | |
233 return false; | |
234 } | |
235 result->key = source_ + offset_; | |
236 result->key_length = seek - offset_; // Safe, see (*). | |
237 offset_ = ++seek; | |
238 while (seek < length_ && *(source_ + seek) != '&') ++seek; | |
239 result->val = source_ + offset_; | |
240 result->val_length = seek - offset_; // Safe, see (*). | |
241 offset_ = ++seek; | |
242 return true; | |
243 } | |
244 | |
245 class PostDataParserMultipart : public PostDataParser { | |
246 public: | |
247 explicit PostDataParserMultipart(const std::string& boundary) | |
248 : source_(NULL), | |
249 boundary_(boundary), | |
250 state_(kInit) {} | |
battre
2012/07/06 07:36:24
initialize all atomic variables
vabr (Chromium)
2012/07/06 14:09:01
Similarly to PostDataParserUrlEncoded, the variabl
| |
251 ~PostDataParserMultipart() {} | |
252 virtual bool SetSource(const char* source, size_t length) OVERRIDE; | |
253 virtual bool GetNextPair(Result* result) OVERRIDE; | |
254 virtual bool AllDataReadOK() OVERRIDE; | |
255 private: | |
battre
2012/07/06 07:36:24
newline before private:
vabr (Chromium)
2012/07/06 14:09:01
Done.
| |
256 // Note on implementation: | |
257 // This parser reads the source line by line. There are four types of lines: | |
258 // (BOUND) "Boundary" line, separating entries. | |
259 // (FBOUND) Final "boundary" line, ends the data. | |
260 // (DISP) "Content-Disposition" line, containing the "key" for |result|. | |
261 // (EMPTY) empty lines | |
262 // (OTHER) other non-empty lines | |
263 enum Lines {kBound, kFBound, kDisp, kEmpty, kOther}; | |
264 // The parser uses the following 7-state automaton to check for structure: | |
265 // kInit --BOUND--> kFirst, kInit --not(BOUND)--> kError | |
266 // kFirst --DISP--> kSkip, kFirst --not(DISP)--> kHead | |
267 // kHead --DISP--> kSkip, kHead --not(DISP)-->kHead | |
268 // kSkip --EMPTY-->kBody, kSkip --not(EMPTY)--> kSkip | |
269 // kBody --BOUND--> kFirst, kBody --FBOUND--> kFinal, | |
270 // kBody --not(BOUND)--> kBody | |
271 enum States {kInit, kFirst, kHead, kSkip, kBody, kFinal, kError}; | |
272 // Read one more line from |source_|, update line pointers. | |
273 bool GetNextLine(); | |
274 // Determine the |line_type_| of the current line_. | |
275 void GetLineType(); | |
276 // One-step of the automaton, based on |state_| and |line_type_|. | |
277 // This calls GetNextLine() and returns it return value. | |
278 bool DoStep(); | |
279 // Extracts "key" and possibly "val" from a DISP line. Returns success. | |
280 bool ParseHead(Result* result); | |
281 // We parse the first |length_| bytes from |source_|. | |
282 const char* source_; | |
283 size_t length_; | |
284 // Offset of the current and next line from |source_|: | |
285 // [line_]...line... [line_end_]EOL [next_line_]...line... | |
286 size_t line_; | |
287 size_t line_end_; | |
288 size_t next_line_; | |
289 const std::string boundary_; | |
290 States state_; | |
291 Lines line_type_; | |
292 DISALLOW_COPY_AND_ASSIGN(PostDataParserMultipart); | |
293 }; | |
294 | |
295 bool PostDataParserMultipart::AllDataReadOK() { | |
296 return source_ != NULL && next_line_ >= length_ && state_ == kFinal; | |
297 } | |
298 | |
299 bool PostDataParserMultipart::SetSource(const char* source, size_t length) { | |
300 if (state_ == kError) return false; | |
301 if (source_ != NULL && next_line_ < length_) return false; | |
302 source_ = source; | |
303 length_ = length; | |
304 next_line_ = 0; | |
305 return true; | |
306 } | |
307 | |
308 bool PostDataParserMultipart::GetNextPair(Result* result) { | |
309 if (state_ == kError) return false; | |
310 while (state_ != kSkip) if (!DoStep()) return false; | |
battre
2012/07/06 07:36:24
This should go into multiple lines
vabr (Chromium)
2012/07/06 14:09:01
Done.
| |
311 bool name_parsed = ParseHead(result); | |
312 while (state_ != kBody) if (!DoStep()) return false; | |
313 size_t val_start; | |
314 size_t val_end; | |
315 // There may not be more to read from |source_| if the current result comes | |
316 // from a "file" input element. But then |result->val| != NULL already. | |
317 if (!DoStep()) return result->val != NULL; | |
318 val_start = line_; | |
319 while (state_ != kFirst && state_ != kFinal) { | |
320 val_end = line_end_; | |
321 if (!DoStep()) break; | |
322 } | |
323 if (name_parsed && result->val == NULL) { | |
324 // This pair is from non-file form item, |val| is on subsequent lines. | |
325 result->val = source_ + val_start; | |
326 result->val_length = val_end - val_start; | |
327 } | |
328 return name_parsed; | |
329 } | |
330 | |
331 // Contract: only to be called from GetNextLine(). | |
332 void PostDataParserMultipart::GetLineType() { | |
333 const char* line = source_ + line_; | |
334 const size_t line_length = line_end_ - line_; | |
335 const bool boundary_test = line[0] == '-' && line[1] == '-' && | |
336 strncmp(boundary_.c_str(), line+2, boundary_.size()) == 0; | |
337 if (boundary_test && line_length == boundary_.size() + 2) | |
338 line_type_ = kBound; | |
339 else if (boundary_test && line_length == boundary_.size() + 4 && | |
340 line[line_length-2] == '-' && line[line_length-1] == '-') | |
341 line_type_ = kFBound; | |
342 else if (strncmp(line, "Content-Disposition:", 20) == 0) | |
battre
2012/07/06 07:36:24
static const char kContentDisposition[] = "Content
vabr (Chromium)
2012/07/06 14:09:01
Done via strlen(), as it appears to be evaluated a
| |
343 line_type_ = kDisp; | |
344 else if (line_ == line_end_) | |
345 line_type_ = kEmpty; | |
346 else | |
347 line_type_ = kOther; | |
348 } | |
349 | |
350 // Contract: only to be called from DoStep(). | |
351 bool PostDataParserMultipart::GetNextLine() { | |
352 if (source_ == NULL || state_ == kError) return false; | |
353 if (next_line_ >= length_) return false; | |
354 size_t seek = line_ = next_line_; | |
355 while (seek < length_ && *(source_ + seek) != '\r') ++seek; | |
356 line_end_ = seek; | |
357 GetLineType(); | |
358 if (seek < length_ && *(source_ + seek + 1) != '\n') return false; | |
359 next_line_ = seek + 2; | |
360 return true; | |
361 } | |
362 | |
363 bool PostDataParserMultipart::DoStep() { | |
364 if (!GetNextLine()) return false; | |
365 switch (state_) { | |
366 case kInit: | |
367 if (line_type_ == kBound) state_ = kFirst; | |
battre
2012/07/06 07:36:24
\n after )
vabr (Chromium)
2012/07/06 14:09:01
Done.
| |
368 else | |
369 state_ = kError; | |
370 break; | |
371 case kFirst: | |
372 if (line_type_ == kDisp) state_ = kSkip; | |
373 else | |
374 state_ = kHead; | |
375 break; | |
376 case kHead: | |
377 if (line_type_ == kDisp) state_ = kSkip; | |
378 break; | |
379 case kSkip: | |
380 if (line_type_ == kEmpty) state_ = kBody; | |
381 break; | |
382 case kBody: | |
383 if (line_type_ == kBound) state_ = kFirst; | |
384 else if (line_type_ == kFBound) state_ = kFinal; | |
385 break; | |
386 case kFinal: | |
387 if (line_type_ != kEmpty) state_ = kError; | |
388 case kError: | |
389 break; | |
390 } | |
391 return true; | |
392 } | |
393 | |
394 // Contract: line_type_ == kDisp. | |
395 bool PostDataParserMultipart::ParseHead(Result* result) { | |
396 std::string line(source_ + line_, line_end_-line_); | |
397 size_t key_offset = line.find(" name=\"") + 7; | |
398 if (key_offset == std::string::npos) return false; | |
399 result->key = source_ + line_ + key_offset; | |
400 result->key_length = line.find('"', key_offset) - key_offset; | |
401 size_t val_offset = line.find(" filename=\""); | |
402 if (val_offset == std::string::npos) { | |
403 result->val = NULL; | |
404 } else { | |
405 val_offset += 11; | |
406 result->val = source_ + line_ + val_offset; | |
407 result->val_length = line.find('"', val_offset) - val_offset; | |
408 } | |
409 return true; | |
410 } | |
411 | |
412 // Helps to choose the right POST data parser and takes care of its lifetime. | |
413 class PostDataParserProxy : public PostDataParser { | |
414 public: | |
415 PostDataParserProxy() : parser_(NULL) {} | |
416 ~PostDataParserProxy() { | |
417 if (parser_ != NULL) delete parser_; | |
418 } | |
419 // Chooses the parser based on content-type of the request. True == success. | |
420 bool Init(net::URLRequest* request); | |
421 virtual bool SetSource(const char* source, size_t length) OVERRIDE; | |
422 virtual bool GetNextPair(Result* result) OVERRIDE; | |
423 virtual bool AllDataReadOK() OVERRIDE; | |
424 private: | |
425 PostDataParser* parser_; | |
426 DISALLOW_COPY_AND_ASSIGN(PostDataParserProxy); | |
427 }; | |
428 | |
429 bool PostDataParserProxy::AllDataReadOK() { | |
430 return parser_ != NULL ? parser_->AllDataReadOK() : false; | |
431 } | |
432 | |
433 bool PostDataParserProxy::Init(net::URLRequest* request) { | |
434 std::string value; | |
435 const bool found = request->extra_request_headers().GetHeader( | |
436 "Content-Type", &value); | |
437 std::string content_type = value.substr(0, value.find(';')); | |
438 if (!found || content_type == "application/x-www-form-urlencoded") { | |
439 parser_ = new PostDataParserUrlEncoded(); | |
440 } else if (content_type == "text/plain") { | |
441 // Unable to parse, may be ambiguous. | |
442 } else if (content_type == "multipart/form-data") { | |
443 size_t offset = value.find("boundary="); | |
444 offset += 9; // 9 == length of "boundary=" | |
445 std::string boundary = value.substr(offset, value.find(';', offset)); | |
446 parser_ = new PostDataParserMultipart(boundary); | |
447 } else { | |
448 return false; | |
449 } | |
450 return parser_ != NULL; | |
451 } | |
452 | |
453 bool PostDataParserProxy::SetSource(const char* source, size_t length) { | |
454 return parser_ != NULL ? parser_->SetSource(source, length) : false; | |
455 } | |
456 | |
457 bool PostDataParserProxy::GetNextPair(Result* result) { | |
458 if (parser_ != NULL) return parser_->GetNextPair(result); | |
battre
2012/07/06 07:36:24
newline before return. http://google-styleguide.go
vabr (Chromium)
2012/07/06 14:09:01
Done.
| |
459 else | |
460 return false; | |
461 } | |
462 | |
463 // Takes |dictionary| of <string, list of strings> pairs, and appends | |
464 // |value| to the list for |key|, creating it if necessary. | |
465 // Contract: |dictionary| only contains ListValue objects. | |
466 void UpdateDictionaryWithString(DictionaryValue* dictionary, | |
467 const std::string& key, | |
468 const std::string& value) { | |
469 ListValue* list = NULL; | |
470 Value* receive = NULL; | |
471 if (!dictionary->Get(key, &receive)) { | |
472 list = new ListValue(); | |
473 dictionary->Set(key, list); | |
474 } else { | |
475 list = reinterpret_cast<ListValue*>(receive); // Safe due to contract. | |
battre
2012/07/06 07:36:24
you can get rid of the else clause if you use
if (
vabr (Chromium)
2012/07/06 14:09:01
Done.
| |
476 } | |
477 StringValue* string_value = new StringValue(value); | |
478 list->Append(string_value); | |
battre
2012/07/06 07:36:24
I would inline string_value.
vabr (Chromium)
2012/07/06 14:09:01
Done.
| |
479 } | |
480 | |
481 // Extracts the POST data from |request| and writes the data into |out|. | |
482 // This can be expensive, so it's separated from ExtractRequestInfo(). | |
483 // Contract: request->method() == "POST" | |
484 void ExtractRequestInfoPost(net::URLRequest* request, DictionaryValue* out) { | |
485 const std::vector<net::UploadData::Element>* elements = | |
486 request->get_upload()->elements(); | |
487 PostDataParserProxy parser; | |
488 parser.Init(request); | |
489 DictionaryValue* post_data = new DictionaryValue(); | |
battre
2012/07/06 07:36:24
please use a scoped_ptr<DictionaryValue>, this way
vabr (Chromium)
2012/07/06 14:09:01
Done, including using get()/release() where approp
| |
490 std::vector<net::UploadData::Element>::const_iterator element; | |
491 for (element = elements->begin(); element != elements->end(); ++element) { | |
492 if (element->type() != net::UploadData::TYPE_BYTES) continue; | |
493 const char* bytes = &(element->bytes()[0]); | |
494 const size_t size = element->bytes().size(); | |
495 if (!parser.SetSource(bytes, size)) continue; | |
battre
2012/07/06 07:36:24
Any reason why you don't pass a const std::vector<
vabr (Chromium)
2012/07/06 14:09:01
No, good point. Done.
| |
496 PostDataParser::Result result; | |
497 while (parser.GetNextPair(&result)) { | |
498 std::string key(result.key, result.key_length); | |
499 std::string val(result.val, result.val_length); | |
500 UpdateDictionaryWithString(post_data, key, val); | |
battre
2012/07/06 07:36:24
How about
GetOrCreateList(post_data, key)->Append(
vabr (Chromium)
2012/07/06 14:09:01
Done.
| |
501 } | |
502 } | |
503 if (parser.AllDataReadOK()) out->Set(keys::kPostDataKey, post_data); | |
battre
2012/07/06 07:36:24
newline before out->Set http://google-styleguide.g
vabr (Chromium)
2012/07/06 14:09:01
Done.
| |
504 else | |
505 delete post_data; | |
506 } | |
507 | |
172 // Converts a HttpHeaders dictionary to a |name|, |value| pair. Returns | 508 // Converts a HttpHeaders dictionary to a |name|, |value| pair. Returns |
173 // true if successful. | 509 // true if successful. |
174 bool FromHeaderDictionary(const DictionaryValue* header_value, | 510 bool FromHeaderDictionary(const DictionaryValue* header_value, |
175 std::string* name, | 511 std::string* name, |
176 std::string* value) { | 512 std::string* value) { |
177 if (!header_value->GetString(keys::kHeaderNameKey, name)) | 513 if (!header_value->GetString(keys::kHeaderNameKey, name)) |
178 return false; | 514 return false; |
179 | 515 |
180 // We require either a "value" or a "binaryValue" entry. | 516 // We require either a "value" or a "binaryValue" entry. |
181 if (!(header_value->HasKey(keys::kHeaderValueKey) ^ | 517 if (!(header_value->HasKey(keys::kHeaderValueKey) ^ |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
409 return false; | 745 return false; |
410 | 746 |
411 if (str == "requestHeaders") | 747 if (str == "requestHeaders") |
412 *extra_info_spec |= REQUEST_HEADERS; | 748 *extra_info_spec |= REQUEST_HEADERS; |
413 else if (str == "responseHeaders") | 749 else if (str == "responseHeaders") |
414 *extra_info_spec |= RESPONSE_HEADERS; | 750 *extra_info_spec |= RESPONSE_HEADERS; |
415 else if (str == "blocking") | 751 else if (str == "blocking") |
416 *extra_info_spec |= BLOCKING; | 752 *extra_info_spec |= BLOCKING; |
417 else if (str == "asyncBlocking") | 753 else if (str == "asyncBlocking") |
418 *extra_info_spec |= ASYNC_BLOCKING; | 754 *extra_info_spec |= ASYNC_BLOCKING; |
755 else if (str == "requestPostData") | |
756 *extra_info_spec |= REQUEST_POST_DATA; | |
419 else | 757 else |
420 return false; | 758 return false; |
421 | 759 |
422 // BLOCKING and ASYNC_BLOCKING are mutually exclusive. | 760 // BLOCKING and ASYNC_BLOCKING are mutually exclusive. |
423 if ((*extra_info_spec & BLOCKING) && (*extra_info_spec & ASYNC_BLOCKING)) | 761 if ((*extra_info_spec & BLOCKING) && (*extra_info_spec & ASYNC_BLOCKING)) |
424 return false; | 762 return false; |
425 } | 763 } |
426 return true; | 764 return true; |
427 } | 765 } |
428 | 766 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
493 | 831 |
494 int extra_info_spec = 0; | 832 int extra_info_spec = 0; |
495 std::vector<const EventListener*> listeners = | 833 std::vector<const EventListener*> listeners = |
496 GetMatchingListeners(profile, extension_info_map, keys::kOnBeforeRequest, | 834 GetMatchingListeners(profile, extension_info_map, keys::kOnBeforeRequest, |
497 request, &extra_info_spec); | 835 request, &extra_info_spec); |
498 if (!listeners.empty() && | 836 if (!listeners.empty() && |
499 !GetAndSetSignaled(request->identifier(), kOnBeforeRequest)) { | 837 !GetAndSetSignaled(request->identifier(), kOnBeforeRequest)) { |
500 ListValue args; | 838 ListValue args; |
501 DictionaryValue* dict = new DictionaryValue(); | 839 DictionaryValue* dict = new DictionaryValue(); |
502 ExtractRequestInfo(request, dict); | 840 ExtractRequestInfo(request, dict); |
841 if (request->method() == "POST" && | |
842 extra_info_spec | ExtraInfoSpec::REQUEST_POST_DATA) | |
battre
2012/07/06 07:36:24
this should probably be extra_info_spec & ...
I w
vabr (Chromium)
2012/07/06 14:09:01
Done. I agree that reversing the order could be a
| |
843 ExtractRequestInfoPost(request, dict); | |
503 args.Append(dict); | 844 args.Append(dict); |
504 | 845 |
505 initialize_blocked_requests |= | 846 initialize_blocked_requests |= |
506 DispatchEvent(profile, request, listeners, args); | 847 DispatchEvent(profile, request, listeners, args); |
507 } | 848 } |
508 | 849 |
509 if (!initialize_blocked_requests) | 850 if (!initialize_blocked_requests) |
510 return net::OK; // Nobody saw a reason for modifying the request. | 851 return net::OK; // Nobody saw a reason for modifying the request. |
511 | 852 |
512 blocked_requests_[request->identifier()].event = kOnBeforeRequest; | 853 blocked_requests_[request->identifier()].event = kOnBeforeRequest; |
(...skipping 1255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1768 } else if ((*it)->name().find("AdBlock") != std::string::npos) { | 2109 } else if ((*it)->name().find("AdBlock") != std::string::npos) { |
1769 adblock = true; | 2110 adblock = true; |
1770 } else { | 2111 } else { |
1771 other = true; | 2112 other = true; |
1772 } | 2113 } |
1773 } | 2114 } |
1774 } | 2115 } |
1775 | 2116 |
1776 host->Send(new ExtensionMsg_UsingWebRequestAPI(adblock, adblock_plus, other)); | 2117 host->Send(new ExtensionMsg_UsingWebRequestAPI(adblock, adblock_plus, other)); |
1777 } | 2118 } |
OLD | NEW |