| 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/location.h" |
| 8 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| 11 #include "base/single_thread_task_runner.h" |
| 10 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 12 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
| 13 #include "chrome/browser/ui/browser_commands.h" | 15 #include "chrome/browser/ui/browser_commands.h" |
| 14 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 16 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 15 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
| 16 #include "chrome/common/safe_browsing/csd.pb.h" | 18 #include "chrome/common/safe_browsing/csd.pb.h" |
| 17 #include "chrome/common/safe_browsing/safebrowsing_messages.h" | 19 #include "chrome/common/safe_browsing/safebrowsing_messages.h" |
| 18 #include "chrome/renderer/safe_browsing/features.h" | 20 #include "chrome/renderer/safe_browsing/features.h" |
| 19 #include "chrome/renderer/safe_browsing/phishing_classifier.h" | 21 #include "chrome/renderer/safe_browsing/phishing_classifier.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 quit_closure_.Reset(); | 113 quit_closure_.Reset(); |
| 112 run_loop_.reset(); | 114 run_loop_.reset(); |
| 113 } | 115 } |
| 114 | 116 |
| 115 void OnPhishingDetectionDone(const std::string& verdict_str) { | 117 void OnPhishingDetectionDone(const std::string& verdict_str) { |
| 116 scoped_ptr<ClientPhishingRequest> verdict(new ClientPhishingRequest); | 118 scoped_ptr<ClientPhishingRequest> verdict(new ClientPhishingRequest); |
| 117 if (verdict->ParseFromString(verdict_str) && | 119 if (verdict->ParseFromString(verdict_str) && |
| 118 verdict->IsInitialized()) { | 120 verdict->IsInitialized()) { |
| 119 verdict_.swap(verdict); | 121 verdict_.swap(verdict); |
| 120 } | 122 } |
| 121 waiting_message_loop_->PostTask(FROM_HERE, quit_closure_); | 123 waiting_message_loop_->task_runner()->PostTask(FROM_HERE, quit_closure_); |
| 122 } | 124 } |
| 123 | 125 |
| 124 private: | 126 private: |
| 125 ~InterceptingMessageFilter() override {} | 127 ~InterceptingMessageFilter() override {} |
| 126 | 128 |
| 127 scoped_ptr<ClientPhishingRequest> verdict_; | 129 scoped_ptr<ClientPhishingRequest> verdict_; |
| 128 base::MessageLoop* waiting_message_loop_; | 130 base::MessageLoop* waiting_message_loop_; |
| 129 base::Closure quit_closure_; | 131 base::Closure quit_closure_; |
| 130 scoped_ptr<base::RunLoop> run_loop_; | 132 scoped_ptr<base::RunLoop> run_loop_; |
| 131 }; | 133 }; |
| (...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 RunClassificationDone(verdict); | 660 RunClassificationDone(verdict); |
| 659 ASSERT_TRUE(intercepting_filter_->verdict()); | 661 ASSERT_TRUE(intercepting_filter_->verdict()); |
| 660 EXPECT_EQ(verdict.SerializeAsString(), | 662 EXPECT_EQ(verdict.SerializeAsString(), |
| 661 intercepting_filter_->verdict()->SerializeAsString()); | 663 intercepting_filter_->verdict()->SerializeAsString()); |
| 662 | 664 |
| 663 // The delegate will cancel pending classification on destruction. | 665 // The delegate will cancel pending classification on destruction. |
| 664 EXPECT_CALL(*classifier_, CancelPendingClassification()); | 666 EXPECT_CALL(*classifier_, CancelPendingClassification()); |
| 665 } | 667 } |
| 666 | 668 |
| 667 } // namespace safe_browsing | 669 } // namespace safe_browsing |
| OLD | NEW |