OLD | NEW |
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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 #ifndef CHROME_BROWSER_SAFE_BROWSING_TEST_SAFE_BROWSING_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_TEST_SAFE_BROWSING_SERVICE_H_ |
6 #define CHROME_BROWSER_SAFE_BROWSING_TEST_SAFE_BROWSING_SERVICE_H_ | 6 #define CHROME_BROWSER_SAFE_BROWSING_TEST_SAFE_BROWSING_SERVICE_H_ |
7 | 7 |
8 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 8 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
9 | 9 |
10 #include "chrome/browser/safe_browsing/protocol_manager.h" | 10 #include "chrome/browser/safe_browsing/protocol_manager.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 // (3) Register TestSafeBrowsingServiceFactory | 33 // (3) Register TestSafeBrowsingServiceFactory |
34 // SafeBrowsingService::RegisterFactory(test_sb_factory_); | 34 // SafeBrowsingService::RegisterFactory(test_sb_factory_); |
35 // (4) InProcessBrowserTest::SetUp() or other base class SetUp() function must | 35 // (4) InProcessBrowserTest::SetUp() or other base class SetUp() function must |
36 // be called at last. | 36 // be called at last. |
37 // * When overriding TearDown(): | 37 // * When overriding TearDown(): |
38 // Call base class TearDown() first then call | 38 // Call base class TearDown() first then call |
39 // SafeBrowsingService::RegisterFactory(nullptr) to unregister | 39 // SafeBrowsingService::RegisterFactory(nullptr) to unregister |
40 // test_sb_factory_. | 40 // test_sb_factory_. |
41 class TestSafeBrowsingService : public SafeBrowsingService { | 41 class TestSafeBrowsingService : public SafeBrowsingService { |
42 public: | 42 public: |
43 TestSafeBrowsingService(); | 43 explicit TestSafeBrowsingService( |
| 44 V4FeatureList::V4UsageStatus v4_usage_status); |
44 // SafeBrowsingService overrides | 45 // SafeBrowsingService overrides |
45 SafeBrowsingProtocolConfig GetProtocolConfig() const override; | 46 SafeBrowsingProtocolConfig GetProtocolConfig() const override; |
46 V4ProtocolConfig GetV4ProtocolConfig() const override; | 47 V4ProtocolConfig GetV4ProtocolConfig() const override; |
47 | 48 |
48 std::string serilized_download_report(); | 49 std::string serilized_download_report(); |
49 void ClearDownloadReport(); | 50 void ClearDownloadReport(); |
50 | 51 |
51 // In browser tests, the following setters must be called before | 52 // In browser tests, the following setters must be called before |
52 // SafeBrowsingService::Initialize(). | 53 // SafeBrowsingService::Initialize(). |
53 // The preferable way to use these setters is by calling corresponding | 54 // The preferable way to use these setters is by calling corresponding |
(...skipping 19 matching lines...) Expand all Loading... |
73 bool protocol_manager_delegate_disabled_; | 74 bool protocol_manager_delegate_disabled_; |
74 std::unique_ptr<SafeBrowsingProtocolConfig> protocol_config_; | 75 std::unique_ptr<SafeBrowsingProtocolConfig> protocol_config_; |
75 std::unique_ptr<V4ProtocolConfig> v4_protocol_config_; | 76 std::unique_ptr<V4ProtocolConfig> v4_protocol_config_; |
76 std::string serialized_download_report_; | 77 std::string serialized_download_report_; |
77 | 78 |
78 DISALLOW_COPY_AND_ASSIGN(TestSafeBrowsingService); | 79 DISALLOW_COPY_AND_ASSIGN(TestSafeBrowsingService); |
79 }; | 80 }; |
80 | 81 |
81 class TestSafeBrowsingServiceFactory : public SafeBrowsingServiceFactory { | 82 class TestSafeBrowsingServiceFactory : public SafeBrowsingServiceFactory { |
82 public: | 83 public: |
83 TestSafeBrowsingServiceFactory(); | 84 explicit TestSafeBrowsingServiceFactory( |
| 85 V4FeatureList::V4UsageStatus v4_usage_status = |
| 86 V4FeatureList::V4UsageStatus::V4_DISABLED); |
84 ~TestSafeBrowsingServiceFactory() override; | 87 ~TestSafeBrowsingServiceFactory() override; |
85 | 88 |
86 // Creates test safe browsing service, and configures test UI manager, | 89 // Creates test safe browsing service, and configures test UI manager, |
87 // database manager and so on. | 90 // database manager and so on. |
88 SafeBrowsingService* CreateSafeBrowsingService() override; | 91 SafeBrowsingService* CreateSafeBrowsingService() override; |
89 | 92 |
90 TestSafeBrowsingService* test_safe_browsing_service(); | 93 TestSafeBrowsingService* test_safe_browsing_service(); |
91 | 94 |
92 // Test UI manager, database manager and protocol config need to be set before | 95 // Test UI manager, database manager and protocol config need to be set before |
93 // SafeBrowsingService::Initialize() is called. | 96 // SafeBrowsingService::Initialize() is called. |
94 void SetTestUIManager(TestSafeBrowsingUIManager* ui_manager); | 97 void SetTestUIManager(TestSafeBrowsingUIManager* ui_manager); |
95 void SetTestDatabaseManager( | 98 void SetTestDatabaseManager( |
96 TestSafeBrowsingDatabaseManager* database_manager); | 99 TestSafeBrowsingDatabaseManager* database_manager); |
97 void SetTestProtocolConfig(const SafeBrowsingProtocolConfig& protocol_config); | 100 void SetTestProtocolConfig(const SafeBrowsingProtocolConfig& protocol_config); |
98 | 101 |
99 private: | 102 private: |
100 TestSafeBrowsingService* test_safe_browsing_service_; | 103 TestSafeBrowsingService* test_safe_browsing_service_; |
101 scoped_refptr<TestSafeBrowsingDatabaseManager> test_database_manager_; | 104 scoped_refptr<TestSafeBrowsingDatabaseManager> test_database_manager_; |
102 scoped_refptr<TestSafeBrowsingUIManager> test_ui_manager_; | 105 scoped_refptr<TestSafeBrowsingUIManager> test_ui_manager_; |
103 SafeBrowsingProtocolConfig* test_protocol_config_; | 106 SafeBrowsingProtocolConfig* test_protocol_config_; |
| 107 V4FeatureList::V4UsageStatus v4_usage_status_; |
104 | 108 |
105 DISALLOW_COPY_AND_ASSIGN(TestSafeBrowsingServiceFactory); | 109 DISALLOW_COPY_AND_ASSIGN(TestSafeBrowsingServiceFactory); |
106 }; | 110 }; |
107 | 111 |
108 // This is an implemenation of SafeBrowsingUIManager without actually | 112 // This is an implemenation of SafeBrowsingUIManager without actually |
109 // sending report to safe browsing backend. Safe browsing reports are | 113 // sending report to safe browsing backend. Safe browsing reports are |
110 // stored in strings for easy verification. | 114 // stored in strings for easy verification. |
111 class TestSafeBrowsingUIManager : public SafeBrowsingUIManager { | 115 class TestSafeBrowsingUIManager : public SafeBrowsingUIManager { |
112 public: | 116 public: |
113 TestSafeBrowsingUIManager(); | 117 TestSafeBrowsingUIManager(); |
114 explicit TestSafeBrowsingUIManager( | 118 explicit TestSafeBrowsingUIManager( |
115 const scoped_refptr<SafeBrowsingService>& service); | 119 const scoped_refptr<SafeBrowsingService>& service); |
116 void SendSerializedThreatDetails(const std::string& serialized) override; | 120 void SendSerializedThreatDetails(const std::string& serialized) override; |
117 void SetSafeBrowsingService(SafeBrowsingService* sb_service); | 121 void SetSafeBrowsingService(SafeBrowsingService* sb_service); |
118 std::list<std::string>* GetThreatDetails(); | 122 std::list<std::string>* GetThreatDetails(); |
119 | 123 |
120 protected: | 124 protected: |
121 ~TestSafeBrowsingUIManager() override; | 125 ~TestSafeBrowsingUIManager() override; |
122 std::list<std::string> details_; | 126 std::list<std::string> details_; |
123 | 127 |
124 DISALLOW_COPY_AND_ASSIGN(TestSafeBrowsingUIManager); | 128 DISALLOW_COPY_AND_ASSIGN(TestSafeBrowsingUIManager); |
125 }; | 129 }; |
126 | 130 |
127 } // namespace safe_browsing | 131 } // namespace safe_browsing |
128 | 132 |
129 #endif // CHROME_BROWSER_SAFE_BROWSING_TEST_SAFE_BROWSING_SERVICE_H_ | 133 #endif // CHROME_BROWSER_SAFE_BROWSING_TEST_SAFE_BROWSING_SERVICE_H_ |
OLD | NEW |