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/renderer/safe_browsing/phishing_classifier_delegate.h" | 5 #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 | 75 |
76 MOCK_CONST_METHOD1(ComputeScore, double(const FeatureMap&)); | 76 MOCK_CONST_METHOD1(ComputeScore, double(const FeatureMap&)); |
77 | 77 |
78 private: | 78 private: |
79 DISALLOW_COPY_AND_ASSIGN(MockScorer); | 79 DISALLOW_COPY_AND_ASSIGN(MockScorer); |
80 }; | 80 }; |
81 | 81 |
82 class InterceptingMessageFilter : public content::BrowserMessageFilter { | 82 class InterceptingMessageFilter : public content::BrowserMessageFilter { |
83 public: | 83 public: |
84 InterceptingMessageFilter() | 84 InterceptingMessageFilter() |
85 : waiting_message_loop_(NULL) { | 85 : BrowserMessageFilter(SafeBrowsingMsgStart), |
| 86 waiting_message_loop_(NULL) { |
86 } | 87 } |
87 | 88 |
88 const ClientPhishingRequest* verdict() const { return verdict_.get(); } | 89 const ClientPhishingRequest* verdict() const { return verdict_.get(); } |
89 virtual bool OnMessageReceived(const IPC::Message& message, | 90 virtual bool OnMessageReceived(const IPC::Message& message, |
90 bool* message_was_ok) OVERRIDE { | 91 bool* message_was_ok) OVERRIDE { |
91 bool handled = true; | 92 bool handled = true; |
92 IPC_BEGIN_MESSAGE_MAP(InterceptingMessageFilter, message) | 93 IPC_BEGIN_MESSAGE_MAP(InterceptingMessageFilter, message) |
93 IPC_MESSAGE_HANDLER(SafeBrowsingHostMsg_PhishingDetectionDone, | 94 IPC_MESSAGE_HANDLER(SafeBrowsingHostMsg_PhishingDetectionDone, |
94 OnPhishingDetectionDone) | 95 OnPhishingDetectionDone) |
95 IPC_MESSAGE_UNHANDLED(handled = false); | 96 IPC_MESSAGE_UNHANDLED(handled = false); |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
625 RunClassificationDone(verdict); | 626 RunClassificationDone(verdict); |
626 ASSERT_TRUE(intercepting_filter_->verdict()); | 627 ASSERT_TRUE(intercepting_filter_->verdict()); |
627 EXPECT_EQ(verdict.SerializeAsString(), | 628 EXPECT_EQ(verdict.SerializeAsString(), |
628 intercepting_filter_->verdict()->SerializeAsString()); | 629 intercepting_filter_->verdict()->SerializeAsString()); |
629 | 630 |
630 // The delegate will cancel pending classification on destruction. | 631 // The delegate will cancel pending classification on destruction. |
631 EXPECT_CALL(*classifier_, CancelPendingClassification()); | 632 EXPECT_CALL(*classifier_, CancelPendingClassification()); |
632 } | 633 } |
633 | 634 |
634 } // namespace safe_browsing | 635 } // namespace safe_browsing |
OLD | NEW |