| 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_rules_
registry.h" | 5 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_
registry.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 // How many rules are there which have some conditions not triggered by URL | 53 // How many rules are there which have some conditions not triggered by URL |
| 54 // matches. | 54 // matches. |
| 55 size_t RulesWithoutTriggers() const { | 55 size_t RulesWithoutTriggers() const { |
| 56 return rules_with_untriggered_conditions_for_test().size(); | 56 return rules_with_untriggered_conditions_for_test().size(); |
| 57 } | 57 } |
| 58 | 58 |
| 59 protected: | 59 protected: |
| 60 virtual ~TestWebRequestRulesRegistry() {} | 60 virtual ~TestWebRequestRulesRegistry() {} |
| 61 | 61 |
| 62 virtual base::Time GetExtensionInstallationTime( | 62 virtual base::Time GetExtensionInstallationTime( |
| 63 const std::string& extension_id) const { | 63 const std::string& extension_id) const OVERRIDE { |
| 64 if (extension_id == kExtensionId) | 64 if (extension_id == kExtensionId) |
| 65 return base::Time() + base::TimeDelta::FromDays(1); | 65 return base::Time() + base::TimeDelta::FromDays(1); |
| 66 else if (extension_id == kExtensionId2) | 66 else if (extension_id == kExtensionId2) |
| 67 return base::Time() + base::TimeDelta::FromDays(2); | 67 return base::Time() + base::TimeDelta::FromDays(2); |
| 68 else | 68 else |
| 69 return base::Time(); | 69 return base::Time(); |
| 70 } | 70 } |
| 71 | 71 |
| 72 virtual void ClearCacheOnNavigation() { | 72 virtual void ClearCacheOnNavigation() OVERRIDE { |
| 73 ++num_clear_cache_calls_; | 73 ++num_clear_cache_calls_; |
| 74 } | 74 } |
| 75 | 75 |
| 76 private: | 76 private: |
| 77 int num_clear_cache_calls_; | 77 int num_clear_cache_calls_; |
| 78 }; | 78 }; |
| 79 | 79 |
| 80 class WebRequestRulesRegistryTest : public testing::Test { | 80 class WebRequestRulesRegistryTest : public testing::Test { |
| 81 public: | 81 public: |
| 82 WebRequestRulesRegistryTest() | 82 WebRequestRulesRegistryTest() |
| (...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 new TestWebRequestRulesRegistry()); | 587 new TestWebRequestRulesRegistry()); |
| 588 | 588 |
| 589 URLMatcher matcher; | 589 URLMatcher matcher; |
| 590 std::string error = registry->AddRulesImpl(kExtensionId, rules); | 590 std::string error = registry->AddRulesImpl(kExtensionId, rules); |
| 591 EXPECT_THAT(error, HasSubstr("no time in the request life-cycle")); | 591 EXPECT_THAT(error, HasSubstr("no time in the request life-cycle")); |
| 592 EXPECT_TRUE(registry->IsEmpty()); | 592 EXPECT_TRUE(registry->IsEmpty()); |
| 593 } | 593 } |
| 594 | 594 |
| 595 | 595 |
| 596 } // namespace extensions | 596 } // namespace extensions |
| OLD | NEW |