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

Side by Side Diff: extensions/browser/api/declarative_webrequest/webrequest_condition_attribute.cc

Issue 1902873002: Convert //extensions/browser/api from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
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 #include "extensions/browser/api/declarative_webrequest/webrequest_condition_att ribute.h" 5 #include "extensions/browser/api/declarative_webrequest/webrequest_condition_att ribute.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <utility> 10 #include <utility>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/lazy_instance.h" 13 #include "base/lazy_instance.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/memory/ptr_util.h"
16 #include "base/strings/string_util.h" 17 #include "base/strings/string_util.h"
17 #include "base/strings/stringprintf.h" 18 #include "base/strings/stringprintf.h"
18 #include "base/values.h" 19 #include "base/values.h"
19 #include "content/public/browser/resource_request_info.h" 20 #include "content/public/browser/resource_request_info.h"
20 #include "extensions/browser/api/declarative/deduping_factory.h" 21 #include "extensions/browser/api/declarative/deduping_factory.h"
21 #include "extensions/browser/api/declarative_webrequest/request_stage.h" 22 #include "extensions/browser/api/declarative_webrequest/request_stage.h"
22 #include "extensions/browser/api/declarative_webrequest/webrequest_condition.h" 23 #include "extensions/browser/api/declarative_webrequest/webrequest_condition.h"
23 #include "extensions/browser/api/declarative_webrequest/webrequest_constants.h" 24 #include "extensions/browser/api/declarative_webrequest/webrequest_constants.h"
24 #include "extensions/browser/api/web_request/web_request_api_helpers.h" 25 #include "extensions/browser/api/web_request/web_request_api_helpers.h"
25 #include "extensions/common/error_utils.h" 26 #include "extensions/common/error_utils.h"
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 // headers. This is a helper class to header-related condition attributes. 299 // headers. This is a helper class to header-related condition attributes.
299 // It contains a set of test groups. A name-value pair satisfies the whole 300 // It contains a set of test groups. A name-value pair satisfies the whole
300 // set of test groups iff it passes at least one test group. 301 // set of test groups iff it passes at least one test group.
301 class HeaderMatcher { 302 class HeaderMatcher {
302 public: 303 public:
303 ~HeaderMatcher(); 304 ~HeaderMatcher();
304 305
305 // Creates an instance based on a list |tests| of test groups, encoded as 306 // Creates an instance based on a list |tests| of test groups, encoded as
306 // dictionaries of the type declarativeWebRequest.HeaderFilter (see 307 // dictionaries of the type declarativeWebRequest.HeaderFilter (see
307 // declarative_web_request.json). 308 // declarative_web_request.json).
308 static scoped_ptr<const HeaderMatcher> Create(const base::ListValue* tests); 309 static std::unique_ptr<const HeaderMatcher> Create(
310 const base::ListValue* tests);
309 311
310 // Does |this| match the header "|name|: |value|"? 312 // Does |this| match the header "|name|: |value|"?
311 bool TestNameValue(const std::string& name, const std::string& value) const; 313 bool TestNameValue(const std::string& name, const std::string& value) const;
312 314
313 private: 315 private:
314 // Represents a single string-matching test. 316 // Represents a single string-matching test.
315 class StringMatchTest { 317 class StringMatchTest {
316 public: 318 public:
317 enum MatchType { kPrefix, kSuffix, kEquals, kContains }; 319 enum MatchType { kPrefix, kSuffix, kEquals, kContains };
318 320
319 // |data| is the pattern to be matched in the position given by |type|. 321 // |data| is the pattern to be matched in the position given by |type|.
320 // Note that |data| must point to a StringValue object. 322 // Note that |data| must point to a StringValue object.
321 static scoped_ptr<StringMatchTest> Create(const base::Value* data, 323 static std::unique_ptr<StringMatchTest> Create(const base::Value* data,
322 MatchType type, 324 MatchType type,
323 bool case_sensitive); 325 bool case_sensitive);
324 ~StringMatchTest(); 326 ~StringMatchTest();
325 327
326 // Does |str| pass |this| StringMatchTest? 328 // Does |str| pass |this| StringMatchTest?
327 bool Matches(const std::string& str) const; 329 bool Matches(const std::string& str) const;
328 330
329 private: 331 private:
330 StringMatchTest(const std::string& data, 332 StringMatchTest(const std::string& data,
331 MatchType type, 333 MatchType type,
332 bool case_sensitive); 334 bool case_sensitive);
333 335
334 const std::string data_; 336 const std::string data_;
335 const MatchType type_; 337 const MatchType type_;
336 const base::CompareCase case_sensitive_; 338 const base::CompareCase case_sensitive_;
337 DISALLOW_COPY_AND_ASSIGN(StringMatchTest); 339 DISALLOW_COPY_AND_ASSIGN(StringMatchTest);
338 }; 340 };
339 341
340 // Represents a test group -- a set of string matching tests to be applied to 342 // Represents a test group -- a set of string matching tests to be applied to
341 // both the header name and value. 343 // both the header name and value.
342 class HeaderMatchTest { 344 class HeaderMatchTest {
343 public: 345 public:
344 ~HeaderMatchTest(); 346 ~HeaderMatchTest();
345 347
346 // Gets the test group description in |tests| and creates the corresponding 348 // Gets the test group description in |tests| and creates the corresponding
347 // HeaderMatchTest. On failure returns NULL. 349 // HeaderMatchTest. On failure returns NULL.
348 static scoped_ptr<const HeaderMatchTest> Create( 350 static std::unique_ptr<const HeaderMatchTest> Create(
349 const base::DictionaryValue* tests); 351 const base::DictionaryValue* tests);
350 352
351 // Does the header "|name|: |value|" match all tests in |this|? 353 // Does the header "|name|: |value|" match all tests in |this|?
352 bool Matches(const std::string& name, const std::string& value) const; 354 bool Matches(const std::string& name, const std::string& value) const;
353 355
354 private: 356 private:
355 // Takes ownership of the content of both |name_match| and |value_match|. 357 // Takes ownership of the content of both |name_match| and |value_match|.
356 HeaderMatchTest(std::vector<scoped_ptr<const StringMatchTest>> name_match, 358 HeaderMatchTest(
357 std::vector<scoped_ptr<const StringMatchTest>> value_match); 359 std::vector<std::unique_ptr<const StringMatchTest>> name_match,
360 std::vector<std::unique_ptr<const StringMatchTest>> value_match);
358 361
359 // Tests to be passed by a header's name. 362 // Tests to be passed by a header's name.
360 const std::vector<scoped_ptr<const StringMatchTest>> name_match_; 363 const std::vector<std::unique_ptr<const StringMatchTest>> name_match_;
361 // Tests to be passed by a header's value. 364 // Tests to be passed by a header's value.
362 const std::vector<scoped_ptr<const StringMatchTest>> value_match_; 365 const std::vector<std::unique_ptr<const StringMatchTest>> value_match_;
363 366
364 DISALLOW_COPY_AND_ASSIGN(HeaderMatchTest); 367 DISALLOW_COPY_AND_ASSIGN(HeaderMatchTest);
365 }; 368 };
366 369
367 explicit HeaderMatcher(std::vector<scoped_ptr<const HeaderMatchTest>> tests); 370 explicit HeaderMatcher(
371 std::vector<std::unique_ptr<const HeaderMatchTest>> tests);
368 372
369 const std::vector<scoped_ptr<const HeaderMatchTest>> tests_; 373 const std::vector<std::unique_ptr<const HeaderMatchTest>> tests_;
370 374
371 DISALLOW_COPY_AND_ASSIGN(HeaderMatcher); 375 DISALLOW_COPY_AND_ASSIGN(HeaderMatcher);
372 }; 376 };
373 377
374 // HeaderMatcher implementation. 378 // HeaderMatcher implementation.
375 379
376 HeaderMatcher::~HeaderMatcher() {} 380 HeaderMatcher::~HeaderMatcher() {}
377 381
378 // static 382 // static
379 scoped_ptr<const HeaderMatcher> HeaderMatcher::Create( 383 std::unique_ptr<const HeaderMatcher> HeaderMatcher::Create(
380 const base::ListValue* tests) { 384 const base::ListValue* tests) {
381 std::vector<scoped_ptr<const HeaderMatchTest>> header_tests; 385 std::vector<std::unique_ptr<const HeaderMatchTest>> header_tests;
382 for (base::ListValue::const_iterator it = tests->begin(); 386 for (base::ListValue::const_iterator it = tests->begin();
383 it != tests->end(); ++it) { 387 it != tests->end(); ++it) {
384 const base::DictionaryValue* tests = NULL; 388 const base::DictionaryValue* tests = NULL;
385 if (!(*it)->GetAsDictionary(&tests)) 389 if (!(*it)->GetAsDictionary(&tests))
386 return scoped_ptr<const HeaderMatcher>(); 390 return std::unique_ptr<const HeaderMatcher>();
387 391
388 scoped_ptr<const HeaderMatchTest> header_test( 392 std::unique_ptr<const HeaderMatchTest> header_test(
389 HeaderMatchTest::Create(tests)); 393 HeaderMatchTest::Create(tests));
390 if (header_test.get() == NULL) 394 if (header_test.get() == NULL)
391 return scoped_ptr<const HeaderMatcher>(); 395 return std::unique_ptr<const HeaderMatcher>();
392 header_tests.push_back(std::move(header_test)); 396 header_tests.push_back(std::move(header_test));
393 } 397 }
394 398
395 return scoped_ptr<const HeaderMatcher>( 399 return std::unique_ptr<const HeaderMatcher>(
396 new HeaderMatcher(std::move(header_tests))); 400 new HeaderMatcher(std::move(header_tests)));
397 } 401 }
398 402
399 bool HeaderMatcher::TestNameValue(const std::string& name, 403 bool HeaderMatcher::TestNameValue(const std::string& name,
400 const std::string& value) const { 404 const std::string& value) const {
401 for (size_t i = 0; i < tests_.size(); ++i) { 405 for (size_t i = 0; i < tests_.size(); ++i) {
402 if (tests_[i]->Matches(name, value)) 406 if (tests_[i]->Matches(name, value))
403 return true; 407 return true;
404 } 408 }
405 return false; 409 return false;
406 } 410 }
407 411
408 HeaderMatcher::HeaderMatcher( 412 HeaderMatcher::HeaderMatcher(
409 std::vector<scoped_ptr<const HeaderMatchTest>> tests) 413 std::vector<std::unique_ptr<const HeaderMatchTest>> tests)
410 : tests_(std::move(tests)) {} 414 : tests_(std::move(tests)) {}
411 415
412 // HeaderMatcher::StringMatchTest implementation. 416 // HeaderMatcher::StringMatchTest implementation.
413 417
414 // static 418 // static
415 scoped_ptr<HeaderMatcher::StringMatchTest> 419 std::unique_ptr<HeaderMatcher::StringMatchTest>
416 HeaderMatcher::StringMatchTest::Create(const base::Value* data, 420 HeaderMatcher::StringMatchTest::Create(const base::Value* data,
417 MatchType type, 421 MatchType type,
418 bool case_sensitive) { 422 bool case_sensitive) {
419 std::string str; 423 std::string str;
420 CHECK(data->GetAsString(&str)); 424 CHECK(data->GetAsString(&str));
421 return scoped_ptr<StringMatchTest>( 425 return std::unique_ptr<StringMatchTest>(
422 new StringMatchTest(str, type, case_sensitive)); 426 new StringMatchTest(str, type, case_sensitive));
423 } 427 }
424 428
425 HeaderMatcher::StringMatchTest::~StringMatchTest() {} 429 HeaderMatcher::StringMatchTest::~StringMatchTest() {}
426 430
427 bool HeaderMatcher::StringMatchTest::Matches( 431 bool HeaderMatcher::StringMatchTest::Matches(
428 const std::string& str) const { 432 const std::string& str) const {
429 switch (type_) { 433 switch (type_) {
430 case kPrefix: 434 case kPrefix:
431 return base::StartsWith(str, data_, case_sensitive_); 435 return base::StartsWith(str, data_, case_sensitive_);
(...skipping 19 matching lines...) Expand all
451 MatchType type, 455 MatchType type,
452 bool case_sensitive) 456 bool case_sensitive)
453 : data_(data), 457 : data_(data),
454 type_(type), 458 type_(type),
455 case_sensitive_(case_sensitive ? base::CompareCase::SENSITIVE 459 case_sensitive_(case_sensitive ? base::CompareCase::SENSITIVE
456 : base::CompareCase::INSENSITIVE_ASCII) {} 460 : base::CompareCase::INSENSITIVE_ASCII) {}
457 461
458 // HeaderMatcher::HeaderMatchTest implementation. 462 // HeaderMatcher::HeaderMatchTest implementation.
459 463
460 HeaderMatcher::HeaderMatchTest::HeaderMatchTest( 464 HeaderMatcher::HeaderMatchTest::HeaderMatchTest(
461 std::vector<scoped_ptr<const StringMatchTest>> name_match, 465 std::vector<std::unique_ptr<const StringMatchTest>> name_match,
462 std::vector<scoped_ptr<const StringMatchTest>> value_match) 466 std::vector<std::unique_ptr<const StringMatchTest>> value_match)
463 : name_match_(std::move(name_match)), 467 : name_match_(std::move(name_match)),
464 value_match_(std::move(value_match)) {} 468 value_match_(std::move(value_match)) {}
465 469
466 HeaderMatcher::HeaderMatchTest::~HeaderMatchTest() {} 470 HeaderMatcher::HeaderMatchTest::~HeaderMatchTest() {}
467 471
468 // static 472 // static
469 scoped_ptr<const HeaderMatcher::HeaderMatchTest> 473 std::unique_ptr<const HeaderMatcher::HeaderMatchTest>
470 HeaderMatcher::HeaderMatchTest::Create(const base::DictionaryValue* tests) { 474 HeaderMatcher::HeaderMatchTest::Create(const base::DictionaryValue* tests) {
471 std::vector<scoped_ptr<const StringMatchTest>> name_match; 475 std::vector<std::unique_ptr<const StringMatchTest>> name_match;
472 std::vector<scoped_ptr<const StringMatchTest>> value_match; 476 std::vector<std::unique_ptr<const StringMatchTest>> value_match;
473 477
474 for (base::DictionaryValue::Iterator it(*tests); 478 for (base::DictionaryValue::Iterator it(*tests);
475 !it.IsAtEnd(); it.Advance()) { 479 !it.IsAtEnd(); it.Advance()) {
476 bool is_name = false; // Is this test for header name? 480 bool is_name = false; // Is this test for header name?
477 StringMatchTest::MatchType match_type; 481 StringMatchTest::MatchType match_type;
478 if (it.key() == keys::kNamePrefixKey) { 482 if (it.key() == keys::kNamePrefixKey) {
479 is_name = true; 483 is_name = true;
480 match_type = StringMatchTest::kPrefix; 484 match_type = StringMatchTest::kPrefix;
481 } else if (it.key() == keys::kNameSuffixKey) { 485 } else if (it.key() == keys::kNameSuffixKey) {
482 is_name = true; 486 is_name = true;
483 match_type = StringMatchTest::kSuffix; 487 match_type = StringMatchTest::kSuffix;
484 } else if (it.key() == keys::kNameContainsKey) { 488 } else if (it.key() == keys::kNameContainsKey) {
485 is_name = true; 489 is_name = true;
486 match_type = StringMatchTest::kContains; 490 match_type = StringMatchTest::kContains;
487 } else if (it.key() == keys::kNameEqualsKey) { 491 } else if (it.key() == keys::kNameEqualsKey) {
488 is_name = true; 492 is_name = true;
489 match_type = StringMatchTest::kEquals; 493 match_type = StringMatchTest::kEquals;
490 } else if (it.key() == keys::kValuePrefixKey) { 494 } else if (it.key() == keys::kValuePrefixKey) {
491 match_type = StringMatchTest::kPrefix; 495 match_type = StringMatchTest::kPrefix;
492 } else if (it.key() == keys::kValueSuffixKey) { 496 } else if (it.key() == keys::kValueSuffixKey) {
493 match_type = StringMatchTest::kSuffix; 497 match_type = StringMatchTest::kSuffix;
494 } else if (it.key() == keys::kValueContainsKey) { 498 } else if (it.key() == keys::kValueContainsKey) {
495 match_type = StringMatchTest::kContains; 499 match_type = StringMatchTest::kContains;
496 } else if (it.key() == keys::kValueEqualsKey) { 500 } else if (it.key() == keys::kValueEqualsKey) {
497 match_type = StringMatchTest::kEquals; 501 match_type = StringMatchTest::kEquals;
498 } else { 502 } else {
499 NOTREACHED(); // JSON schema type checking should prevent this. 503 NOTREACHED(); // JSON schema type checking should prevent this.
500 return scoped_ptr<const HeaderMatchTest>(); 504 return std::unique_ptr<const HeaderMatchTest>();
501 } 505 }
502 const base::Value* content = &it.value(); 506 const base::Value* content = &it.value();
503 507
504 std::vector<scoped_ptr<const StringMatchTest>>* tests = 508 std::vector<std::unique_ptr<const StringMatchTest>>* tests =
505 is_name ? &name_match : &value_match; 509 is_name ? &name_match : &value_match;
506 switch (content->GetType()) { 510 switch (content->GetType()) {
507 case base::Value::TYPE_LIST: { 511 case base::Value::TYPE_LIST: {
508 const base::ListValue* list = NULL; 512 const base::ListValue* list = NULL;
509 CHECK(content->GetAsList(&list)); 513 CHECK(content->GetAsList(&list));
510 for (base::ListValue::const_iterator it = list->begin(); 514 for (base::ListValue::const_iterator it = list->begin();
511 it != list->end(); ++it) { 515 it != list->end(); ++it) {
512 tests->push_back(make_scoped_ptr( 516 tests->push_back(base::WrapUnique(
513 StringMatchTest::Create(*it, match_type, !is_name).release())); 517 StringMatchTest::Create(*it, match_type, !is_name).release()));
514 } 518 }
515 break; 519 break;
516 } 520 }
517 case base::Value::TYPE_STRING: { 521 case base::Value::TYPE_STRING: {
518 tests->push_back(make_scoped_ptr( 522 tests->push_back(base::WrapUnique(
519 StringMatchTest::Create(content, match_type, !is_name).release())); 523 StringMatchTest::Create(content, match_type, !is_name).release()));
520 break; 524 break;
521 } 525 }
522 default: { 526 default: {
523 NOTREACHED(); // JSON schema type checking should prevent this. 527 NOTREACHED(); // JSON schema type checking should prevent this.
524 return scoped_ptr<const HeaderMatchTest>(); 528 return std::unique_ptr<const HeaderMatchTest>();
525 } 529 }
526 } 530 }
527 } 531 }
528 532
529 return scoped_ptr<const HeaderMatchTest>( 533 return std::unique_ptr<const HeaderMatchTest>(
530 new HeaderMatchTest(std::move(name_match), std::move(value_match))); 534 new HeaderMatchTest(std::move(name_match), std::move(value_match)));
531 } 535 }
532 536
533 bool HeaderMatcher::HeaderMatchTest::Matches(const std::string& name, 537 bool HeaderMatcher::HeaderMatchTest::Matches(const std::string& name,
534 const std::string& value) const { 538 const std::string& value) const {
535 for (size_t i = 0; i < name_match_.size(); ++i) { 539 for (size_t i = 0; i < name_match_.size(); ++i) {
536 if (!name_match_[i]->Matches(name)) 540 if (!name_match_[i]->Matches(name))
537 return false; 541 return false;
538 } 542 }
539 543
540 for (size_t i = 0; i < value_match_.size(); ++i) { 544 for (size_t i = 0; i < value_match_.size(); ++i) {
541 if (!value_match_[i]->Matches(value)) 545 if (!value_match_[i]->Matches(value))
542 return false; 546 return false;
543 } 547 }
544 548
545 return true; 549 return true;
546 } 550 }
547 551
548 // 552 //
549 // WebRequestConditionAttributeRequestHeaders 553 // WebRequestConditionAttributeRequestHeaders
550 // 554 //
551 555
552 WebRequestConditionAttributeRequestHeaders:: 556 WebRequestConditionAttributeRequestHeaders::
553 WebRequestConditionAttributeRequestHeaders( 557 WebRequestConditionAttributeRequestHeaders(
554 scoped_ptr<const HeaderMatcher> header_matcher, 558 std::unique_ptr<const HeaderMatcher> header_matcher,
555 bool positive) 559 bool positive)
556 : header_matcher_(std::move(header_matcher)), positive_(positive) {} 560 : header_matcher_(std::move(header_matcher)), positive_(positive) {}
557 561
558 WebRequestConditionAttributeRequestHeaders:: 562 WebRequestConditionAttributeRequestHeaders::
559 ~WebRequestConditionAttributeRequestHeaders() {} 563 ~WebRequestConditionAttributeRequestHeaders() {}
560 564
561 namespace { 565 namespace {
562 566
563 scoped_ptr<const HeaderMatcher> PrepareHeaderMatcher( 567 std::unique_ptr<const HeaderMatcher> PrepareHeaderMatcher(
564 const std::string& name, 568 const std::string& name,
565 const base::Value* value, 569 const base::Value* value,
566 std::string* error) { 570 std::string* error) {
567 const base::ListValue* value_as_list = NULL; 571 const base::ListValue* value_as_list = NULL;
568 if (!value->GetAsList(&value_as_list)) { 572 if (!value->GetAsList(&value_as_list)) {
569 *error = ErrorUtils::FormatErrorMessage(kInvalidValue, name); 573 *error = ErrorUtils::FormatErrorMessage(kInvalidValue, name);
570 return scoped_ptr<const HeaderMatcher>(); 574 return std::unique_ptr<const HeaderMatcher>();
571 } 575 }
572 576
573 scoped_ptr<const HeaderMatcher> header_matcher( 577 std::unique_ptr<const HeaderMatcher> header_matcher(
574 HeaderMatcher::Create(value_as_list)); 578 HeaderMatcher::Create(value_as_list));
575 if (header_matcher.get() == NULL) 579 if (header_matcher.get() == NULL)
576 *error = ErrorUtils::FormatErrorMessage(kInvalidValue, name); 580 *error = ErrorUtils::FormatErrorMessage(kInvalidValue, name);
577 return header_matcher; 581 return header_matcher;
578 } 582 }
579 583
580 } // namespace 584 } // namespace
581 585
582 // static 586 // static
583 scoped_refptr<const WebRequestConditionAttribute> 587 scoped_refptr<const WebRequestConditionAttribute>
584 WebRequestConditionAttributeRequestHeaders::Create( 588 WebRequestConditionAttributeRequestHeaders::Create(
585 const std::string& name, 589 const std::string& name,
586 const base::Value* value, 590 const base::Value* value,
587 std::string* error, 591 std::string* error,
588 bool* bad_message) { 592 bool* bad_message) {
589 DCHECK(name == keys::kRequestHeadersKey || 593 DCHECK(name == keys::kRequestHeadersKey ||
590 name == keys::kExcludeRequestHeadersKey); 594 name == keys::kExcludeRequestHeadersKey);
591 595
592 scoped_ptr<const HeaderMatcher> header_matcher( 596 std::unique_ptr<const HeaderMatcher> header_matcher(
593 PrepareHeaderMatcher(name, value, error)); 597 PrepareHeaderMatcher(name, value, error));
594 if (header_matcher.get() == NULL) 598 if (header_matcher.get() == NULL)
595 return scoped_refptr<const WebRequestConditionAttribute>(NULL); 599 return scoped_refptr<const WebRequestConditionAttribute>(NULL);
596 600
597 return scoped_refptr<const WebRequestConditionAttribute>( 601 return scoped_refptr<const WebRequestConditionAttribute>(
598 new WebRequestConditionAttributeRequestHeaders( 602 new WebRequestConditionAttributeRequestHeaders(
599 std::move(header_matcher), name == keys::kRequestHeadersKey)); 603 std::move(header_matcher), name == keys::kRequestHeadersKey));
600 } 604 }
601 605
602 int WebRequestConditionAttributeRequestHeaders::GetStages() const { 606 int WebRequestConditionAttributeRequestHeaders::GetStages() const {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 // Comparing headers is too heavy, so we skip it entirely. 642 // Comparing headers is too heavy, so we skip it entirely.
639 return false; 643 return false;
640 } 644 }
641 645
642 // 646 //
643 // WebRequestConditionAttributeResponseHeaders 647 // WebRequestConditionAttributeResponseHeaders
644 // 648 //
645 649
646 WebRequestConditionAttributeResponseHeaders:: 650 WebRequestConditionAttributeResponseHeaders::
647 WebRequestConditionAttributeResponseHeaders( 651 WebRequestConditionAttributeResponseHeaders(
648 scoped_ptr<const HeaderMatcher> header_matcher, 652 std::unique_ptr<const HeaderMatcher> header_matcher,
649 bool positive) 653 bool positive)
650 : header_matcher_(std::move(header_matcher)), positive_(positive) {} 654 : header_matcher_(std::move(header_matcher)), positive_(positive) {}
651 655
652 WebRequestConditionAttributeResponseHeaders:: 656 WebRequestConditionAttributeResponseHeaders::
653 ~WebRequestConditionAttributeResponseHeaders() {} 657 ~WebRequestConditionAttributeResponseHeaders() {}
654 658
655 // static 659 // static
656 scoped_refptr<const WebRequestConditionAttribute> 660 scoped_refptr<const WebRequestConditionAttribute>
657 WebRequestConditionAttributeResponseHeaders::Create( 661 WebRequestConditionAttributeResponseHeaders::Create(
658 const std::string& name, 662 const std::string& name,
659 const base::Value* value, 663 const base::Value* value,
660 std::string* error, 664 std::string* error,
661 bool* bad_message) { 665 bool* bad_message) {
662 DCHECK(name == keys::kResponseHeadersKey || 666 DCHECK(name == keys::kResponseHeadersKey ||
663 name == keys::kExcludeResponseHeadersKey); 667 name == keys::kExcludeResponseHeadersKey);
664 668
665 scoped_ptr<const HeaderMatcher> header_matcher( 669 std::unique_ptr<const HeaderMatcher> header_matcher(
666 PrepareHeaderMatcher(name, value, error)); 670 PrepareHeaderMatcher(name, value, error));
667 if (header_matcher.get() == NULL) 671 if (header_matcher.get() == NULL)
668 return scoped_refptr<const WebRequestConditionAttribute>(NULL); 672 return scoped_refptr<const WebRequestConditionAttribute>(NULL);
669 673
670 return scoped_refptr<const WebRequestConditionAttribute>( 674 return scoped_refptr<const WebRequestConditionAttribute>(
671 new WebRequestConditionAttributeResponseHeaders( 675 new WebRequestConditionAttributeResponseHeaders(
672 std::move(header_matcher), name == keys::kResponseHeadersKey)); 676 std::move(header_matcher), name == keys::kResponseHeadersKey));
673 } 677 }
674 678
675 int WebRequestConditionAttributeResponseHeaders::GetStages() const { 679 int WebRequestConditionAttributeResponseHeaders::GetStages() const {
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
874 bool WebRequestConditionAttributeStages::Equals( 878 bool WebRequestConditionAttributeStages::Equals(
875 const WebRequestConditionAttribute* other) const { 879 const WebRequestConditionAttribute* other) const {
876 if (!WebRequestConditionAttribute::Equals(other)) 880 if (!WebRequestConditionAttribute::Equals(other))
877 return false; 881 return false;
878 const WebRequestConditionAttributeStages* casted_other = 882 const WebRequestConditionAttributeStages* casted_other =
879 static_cast<const WebRequestConditionAttributeStages*>(other); 883 static_cast<const WebRequestConditionAttributeStages*>(other);
880 return allowed_stages_ == casted_other->allowed_stages_; 884 return allowed_stages_ == casted_other->allowed_stages_;
881 } 885 }
882 886
883 } // namespace extensions 887 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698