| 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 <algorithm> | 5 #include <algorithm> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/pickle.h" | 8 #include "base/pickle.h" |
| 9 #include "base/time.h" | 9 #include "base/time.h" |
| 10 #include "chrome/browser/history/history.h" | 10 #include "chrome/browser/history/history.h" |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 class MalwareDetailsWrap : public MalwareDetails { | 131 class MalwareDetailsWrap : public MalwareDetails { |
| 132 public: | 132 public: |
| 133 MalwareDetailsWrap(SafeBrowsingService* sb_service, | 133 MalwareDetailsWrap(SafeBrowsingService* sb_service, |
| 134 WebContents* web_contents, | 134 WebContents* web_contents, |
| 135 const SafeBrowsingService::UnsafeResource& unsafe_resource, | 135 const SafeBrowsingService::UnsafeResource& unsafe_resource, |
| 136 net::URLRequestContextGetter* request_context_getter) | 136 net::URLRequestContextGetter* request_context_getter) |
| 137 : MalwareDetails(sb_service, web_contents, unsafe_resource) { | 137 : MalwareDetails(sb_service, web_contents, unsafe_resource) { |
| 138 request_context_getter_ = request_context_getter; | 138 request_context_getter_ = request_context_getter; |
| 139 } | 139 } |
| 140 | 140 |
| 141 private: |
| 141 virtual ~MalwareDetailsWrap() {} | 142 virtual ~MalwareDetailsWrap() {} |
| 142 }; | 143 }; |
| 143 | 144 |
| 144 class MockSafeBrowsingService : public SafeBrowsingService { | 145 class MockSafeBrowsingService : public SafeBrowsingService { |
| 145 public: | 146 public: |
| 146 MockSafeBrowsingService() {} | 147 MockSafeBrowsingService() {} |
| 147 virtual ~MockSafeBrowsingService() {} | |
| 148 | 148 |
| 149 // When the MalwareDetails is done, this is called. | 149 // When the MalwareDetails is done, this is called. |
| 150 virtual void SendSerializedMalwareDetails(const std::string& serialized) { | 150 virtual void SendSerializedMalwareDetails(const std::string& serialized) { |
| 151 DVLOG(1) << "SendSerializedMalwareDetails"; | 151 DVLOG(1) << "SendSerializedMalwareDetails"; |
| 152 // Notify WaitForSerializedReport. | 152 // Notify WaitForSerializedReport. |
| 153 BrowserThread::PostTask(BrowserThread::IO, | 153 BrowserThread::PostTask(BrowserThread::IO, |
| 154 FROM_HERE, | 154 FROM_HERE, |
| 155 base::Bind(&QuitUIMessageLoop)); | 155 base::Bind(&QuitUIMessageLoop)); |
| 156 serialized_ = serialized; | 156 serialized_ = serialized; |
| 157 } | 157 } |
| 158 | 158 |
| 159 const std::string& GetSerialized() { | 159 const std::string& GetSerialized() { |
| 160 return serialized_; | 160 return serialized_; |
| 161 } | 161 } |
| 162 | 162 |
| 163 private: | 163 private: |
| 164 virtual ~MockSafeBrowsingService() {} |
| 165 |
| 164 std::string serialized_; | 166 std::string serialized_; |
| 165 DISALLOW_COPY_AND_ASSIGN(MockSafeBrowsingService); | 167 DISALLOW_COPY_AND_ASSIGN(MockSafeBrowsingService); |
| 166 }; | 168 }; |
| 167 | 169 |
| 168 } // namespace. | 170 } // namespace. |
| 169 | 171 |
| 170 class MalwareDetailsTest : public ChromeRenderViewHostTestHarness { | 172 class MalwareDetailsTest : public ChromeRenderViewHostTestHarness { |
| 171 public: | 173 public: |
| 172 MalwareDetailsTest() | 174 MalwareDetailsTest() |
| 173 : ui_thread_(BrowserThread::UI, &message_loop_), | 175 : ui_thread_(BrowserThread::UI, &message_loop_), |
| (...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 pb_resource = expected.add_resources(); | 681 pb_resource = expected.add_resources(); |
| 680 pb_resource->set_id(2); | 682 pb_resource->set_id(2); |
| 681 pb_resource->set_parent_id(3); | 683 pb_resource->set_parent_id(3); |
| 682 pb_resource->set_url(kSecondRedirectURL); | 684 pb_resource->set_url(kSecondRedirectURL); |
| 683 pb_resource = expected.add_resources(); | 685 pb_resource = expected.add_resources(); |
| 684 pb_resource->set_id(3); | 686 pb_resource->set_id(3); |
| 685 pb_resource->set_url(kFirstRedirectURL); | 687 pb_resource->set_url(kFirstRedirectURL); |
| 686 | 688 |
| 687 VerifyResults(actual, expected); | 689 VerifyResults(actual, expected); |
| 688 } | 690 } |
| OLD | NEW |