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/declarative_webrequest/webrequest_action
.h" | 5 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_action
.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
575 new helpers::EventResponseDelta(extension_id, extension_install_time)); | 575 new helpers::EventResponseDelta(extension_id, extension_install_time)); |
576 result->cancel = true; | 576 result->cancel = true; |
577 return result; | 577 return result; |
578 } | 578 } |
579 | 579 |
580 // | 580 // |
581 // WebRequestRedirectAction | 581 // WebRequestRedirectAction |
582 // | 582 // |
583 | 583 |
584 WebRequestRedirectAction::WebRequestRedirectAction(const GURL& redirect_url) | 584 WebRequestRedirectAction::WebRequestRedirectAction(const GURL& redirect_url) |
585 : WebRequestAction(ON_BEFORE_REQUEST, | 585 : WebRequestAction(ON_BEFORE_REQUEST | ON_HEADERS_RECEIVED, |
586 ACTION_REDIRECT_REQUEST, | 586 ACTION_REDIRECT_REQUEST, |
587 std::numeric_limits<int>::min(), | 587 std::numeric_limits<int>::min(), |
588 STRATEGY_DEFAULT), | 588 STRATEGY_DEFAULT), |
589 redirect_url_(redirect_url) {} | 589 redirect_url_(redirect_url) {} |
590 | 590 |
591 WebRequestRedirectAction::~WebRequestRedirectAction() {} | 591 WebRequestRedirectAction::~WebRequestRedirectAction() {} |
592 | 592 |
593 bool WebRequestRedirectAction::Equals(const WebRequestAction* other) const { | 593 bool WebRequestRedirectAction::Equals(const WebRequestAction* other) const { |
594 return WebRequestAction::Equals(other) && | 594 return WebRequestAction::Equals(other) && |
595 redirect_url_ == | 595 redirect_url_ == |
(...skipping 16 matching lines...) Expand all Loading... |
612 result->new_url = redirect_url_; | 612 result->new_url = redirect_url_; |
613 return result; | 613 return result; |
614 } | 614 } |
615 | 615 |
616 // | 616 // |
617 // WebRequestRedirectToTransparentImageAction | 617 // WebRequestRedirectToTransparentImageAction |
618 // | 618 // |
619 | 619 |
620 WebRequestRedirectToTransparentImageAction:: | 620 WebRequestRedirectToTransparentImageAction:: |
621 WebRequestRedirectToTransparentImageAction() | 621 WebRequestRedirectToTransparentImageAction() |
622 : WebRequestAction(ON_BEFORE_REQUEST, | 622 : WebRequestAction(ON_BEFORE_REQUEST | ON_HEADERS_RECEIVED, |
623 ACTION_REDIRECT_TO_TRANSPARENT_IMAGE, | 623 ACTION_REDIRECT_TO_TRANSPARENT_IMAGE, |
624 std::numeric_limits<int>::min(), | 624 std::numeric_limits<int>::min(), |
625 STRATEGY_NONE) {} | 625 STRATEGY_NONE) {} |
626 | 626 |
627 WebRequestRedirectToTransparentImageAction:: | 627 WebRequestRedirectToTransparentImageAction:: |
628 ~WebRequestRedirectToTransparentImageAction() {} | 628 ~WebRequestRedirectToTransparentImageAction() {} |
629 | 629 |
630 std::string WebRequestRedirectToTransparentImageAction::GetName() const { | 630 std::string WebRequestRedirectToTransparentImageAction::GetName() const { |
631 return keys::kRedirectToTransparentImageType; | 631 return keys::kRedirectToTransparentImageType; |
632 } | 632 } |
633 | 633 |
634 LinkedPtrEventResponseDelta | 634 LinkedPtrEventResponseDelta |
635 WebRequestRedirectToTransparentImageAction::CreateDelta( | 635 WebRequestRedirectToTransparentImageAction::CreateDelta( |
636 const WebRequestData& request_data, | 636 const WebRequestData& request_data, |
637 const std::string& extension_id, | 637 const std::string& extension_id, |
638 const base::Time& extension_install_time) const { | 638 const base::Time& extension_install_time) const { |
639 CHECK(request_data.stage & stages()); | 639 CHECK(request_data.stage & stages()); |
640 LinkedPtrEventResponseDelta result( | 640 LinkedPtrEventResponseDelta result( |
641 new helpers::EventResponseDelta(extension_id, extension_install_time)); | 641 new helpers::EventResponseDelta(extension_id, extension_install_time)); |
642 result->new_url = GURL(kTransparentImageUrl); | 642 result->new_url = GURL(kTransparentImageUrl); |
643 return result; | 643 return result; |
644 } | 644 } |
645 | 645 |
646 // | 646 // |
647 // WebRequestRedirectToEmptyDocumentAction | 647 // WebRequestRedirectToEmptyDocumentAction |
648 // | 648 // |
649 | 649 |
650 WebRequestRedirectToEmptyDocumentAction:: | 650 WebRequestRedirectToEmptyDocumentAction:: |
651 WebRequestRedirectToEmptyDocumentAction() | 651 WebRequestRedirectToEmptyDocumentAction() |
652 : WebRequestAction(ON_BEFORE_REQUEST, | 652 : WebRequestAction(ON_BEFORE_REQUEST | ON_HEADERS_RECEIVED, |
653 ACTION_REDIRECT_TO_EMPTY_DOCUMENT, | 653 ACTION_REDIRECT_TO_EMPTY_DOCUMENT, |
654 std::numeric_limits<int>::min(), | 654 std::numeric_limits<int>::min(), |
655 STRATEGY_NONE) {} | 655 STRATEGY_NONE) {} |
656 | 656 |
657 WebRequestRedirectToEmptyDocumentAction:: | 657 WebRequestRedirectToEmptyDocumentAction:: |
658 ~WebRequestRedirectToEmptyDocumentAction() {} | 658 ~WebRequestRedirectToEmptyDocumentAction() {} |
659 | 659 |
660 std::string WebRequestRedirectToEmptyDocumentAction::GetName() const { | 660 std::string WebRequestRedirectToEmptyDocumentAction::GetName() const { |
661 return keys::kRedirectToEmptyDocumentType; | 661 return keys::kRedirectToEmptyDocumentType; |
662 } | 662 } |
(...skipping 10 matching lines...) Expand all Loading... |
673 return result; | 673 return result; |
674 } | 674 } |
675 | 675 |
676 // | 676 // |
677 // WebRequestRedirectByRegExAction | 677 // WebRequestRedirectByRegExAction |
678 // | 678 // |
679 | 679 |
680 WebRequestRedirectByRegExAction::WebRequestRedirectByRegExAction( | 680 WebRequestRedirectByRegExAction::WebRequestRedirectByRegExAction( |
681 scoped_ptr<RE2> from_pattern, | 681 scoped_ptr<RE2> from_pattern, |
682 const std::string& to_pattern) | 682 const std::string& to_pattern) |
683 : WebRequestAction(ON_BEFORE_REQUEST, | 683 : WebRequestAction(ON_BEFORE_REQUEST | ON_HEADERS_RECEIVED, |
684 ACTION_REDIRECT_BY_REGEX_DOCUMENT, | 684 ACTION_REDIRECT_BY_REGEX_DOCUMENT, |
685 std::numeric_limits<int>::min(), | 685 std::numeric_limits<int>::min(), |
686 STRATEGY_DEFAULT), | 686 STRATEGY_DEFAULT), |
687 from_pattern_(from_pattern.Pass()), | 687 from_pattern_(from_pattern.Pass()), |
688 to_pattern_(to_pattern.data(), to_pattern.size()) {} | 688 to_pattern_(to_pattern.data(), to_pattern.size()) {} |
689 | 689 |
690 WebRequestRedirectByRegExAction::~WebRequestRedirectByRegExAction() {} | 690 WebRequestRedirectByRegExAction::~WebRequestRedirectByRegExAction() {} |
691 | 691 |
692 // About the syntax of the two languages: | 692 // About the syntax of the two languages: |
693 // | 693 // |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1146 const base::Time& extension_install_time) const { | 1146 const base::Time& extension_install_time) const { |
1147 CHECK(request_data.stage & stages()); | 1147 CHECK(request_data.stage & stages()); |
1148 LinkedPtrEventResponseDelta result( | 1148 LinkedPtrEventResponseDelta result( |
1149 new extension_web_request_api_helpers::EventResponseDelta( | 1149 new extension_web_request_api_helpers::EventResponseDelta( |
1150 extension_id, extension_install_time)); | 1150 extension_id, extension_install_time)); |
1151 result->messages_to_extension.insert(message_); | 1151 result->messages_to_extension.insert(message_); |
1152 return result; | 1152 return result; |
1153 } | 1153 } |
1154 | 1154 |
1155 } // namespace extensions | 1155 } // namespace extensions |
OLD | NEW |