| 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/external_protocol/external_protocol_handler.h" | 5 #include "chrome/browser/external_protocol/external_protocol_handler.h" |
| 6 | 6 |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "content/public/test/test_browser_thread.h" | 8 #include "content/public/test/test_browser_thread.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| 11 using content::BrowserThread; | 11 using content::BrowserThread; |
| 12 | 12 |
| 13 class FakeExternalProtocolHandlerWorker | 13 class FakeExternalProtocolHandlerWorker |
| 14 : public ShellIntegration::DefaultProtocolClientWorker { | 14 : public ShellIntegration::DefaultProtocolClientWorker { |
| 15 public: | 15 public: |
| 16 FakeExternalProtocolHandlerWorker( | 16 FakeExternalProtocolHandlerWorker( |
| 17 ShellIntegration::DefaultWebClientObserver* observer, | 17 ShellIntegration::DefaultWebClientObserver* observer, |
| 18 const std::string& protocol, | 18 const std::string& protocol, |
| 19 ShellIntegration::DefaultWebClientState os_state) | 19 ShellIntegration::DefaultWebClientState os_state) |
| 20 : ShellIntegration::DefaultProtocolClientWorker(observer, protocol), | 20 : ShellIntegration::DefaultProtocolClientWorker(observer, protocol), |
| 21 os_state_(os_state) {} | 21 os_state_(os_state) {} |
| 22 | 22 |
| 23 private: | 23 private: |
| 24 ~FakeExternalProtocolHandlerWorker() override {} | 24 ~FakeExternalProtocolHandlerWorker() override {} |
| 25 | 25 |
| 26 ShellIntegration::DefaultWebClientState CheckIsDefault() override { | 26 void CheckIsDefault() override { |
| 27 return os_state_; | 27 BrowserThread::PostTask( |
| 28 BrowserThread::UI, FROM_HERE, |
| 29 base::Bind(&FakeExternalProtocolHandlerWorker::OnCheckIsDefaultComplete, |
| 30 this, os_state_)); |
| 28 } | 31 } |
| 29 | 32 |
| 30 bool SetAsDefault(bool interactive_permitted) override { return true; } | 33 void SetAsDefault(bool interactive_permitted) override { |
| 34 BrowserThread::PostTask( |
| 35 BrowserThread::UI, FROM_HERE, |
| 36 base::Bind( |
| 37 &FakeExternalProtocolHandlerWorker::OnSetAsDefaultAttemptComplete, |
| 38 this, AttemptResult::SUCCESS)); |
| 39 } |
| 31 | 40 |
| 32 ShellIntegration::DefaultWebClientState os_state_; | 41 ShellIntegration::DefaultWebClientState os_state_; |
| 33 }; | 42 }; |
| 34 | 43 |
| 35 class FakeExternalProtocolHandlerDelegate | 44 class FakeExternalProtocolHandlerDelegate |
| 36 : public ExternalProtocolHandler::Delegate { | 45 : public ExternalProtocolHandler::Delegate { |
| 37 public: | 46 public: |
| 38 FakeExternalProtocolHandlerDelegate() | 47 FakeExternalProtocolHandlerDelegate() |
| 39 : block_state_(ExternalProtocolHandler::BLOCK), | 48 : block_state_(ExternalProtocolHandler::BLOCK), |
| 40 os_state_(ShellIntegration::UNKNOWN_DEFAULT), | 49 os_state_(ShellIntegration::UNKNOWN_DEFAULT), |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 DoTest(ExternalProtocolHandler::UNKNOWN, | 194 DoTest(ExternalProtocolHandler::UNKNOWN, |
| 186 ShellIntegration::NOT_DEFAULT, | 195 ShellIntegration::NOT_DEFAULT, |
| 187 true, false, false); | 196 true, false, false); |
| 188 } | 197 } |
| 189 | 198 |
| 190 TEST_F(ExternalProtocolHandlerTest, TestLaunchSchemeUnknownChromeUnknown) { | 199 TEST_F(ExternalProtocolHandlerTest, TestLaunchSchemeUnknownChromeUnknown) { |
| 191 DoTest(ExternalProtocolHandler::UNKNOWN, | 200 DoTest(ExternalProtocolHandler::UNKNOWN, |
| 192 ShellIntegration::UNKNOWN_DEFAULT, | 201 ShellIntegration::UNKNOWN_DEFAULT, |
| 193 true, false, false); | 202 true, false, false); |
| 194 } | 203 } |
| OLD | NEW |