| 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 ShellIntegration::DefaultWebClientState CheckIsDefault() override { |
| 27 return os_state_; | 27 return os_state_; |
| 28 } | 28 } |
| 29 | 29 |
| 30 bool SetAsDefault(bool interactive_permitted) override { return true; } | 30 void SetAsDefault(bool interactive_permitted) override { |
| 31 BrowserThread::PostTask( |
| 32 BrowserThread::UI, FROM_HERE, |
| 33 base::Bind(&FakeExternalProtocolHandlerWorker::CompleteSetAsDefault, |
| 34 this, true)); |
| 35 } |
| 31 | 36 |
| 32 ShellIntegration::DefaultWebClientState os_state_; | 37 ShellIntegration::DefaultWebClientState os_state_; |
| 33 }; | 38 }; |
| 34 | 39 |
| 35 class FakeExternalProtocolHandlerDelegate | 40 class FakeExternalProtocolHandlerDelegate |
| 36 : public ExternalProtocolHandler::Delegate { | 41 : public ExternalProtocolHandler::Delegate { |
| 37 public: | 42 public: |
| 38 FakeExternalProtocolHandlerDelegate() | 43 FakeExternalProtocolHandlerDelegate() |
| 39 : block_state_(ExternalProtocolHandler::BLOCK), | 44 : block_state_(ExternalProtocolHandler::BLOCK), |
| 40 os_state_(ShellIntegration::UNKNOWN_DEFAULT), | 45 os_state_(ShellIntegration::UNKNOWN_DEFAULT), |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 DoTest(ExternalProtocolHandler::UNKNOWN, | 190 DoTest(ExternalProtocolHandler::UNKNOWN, |
| 186 ShellIntegration::NOT_DEFAULT, | 191 ShellIntegration::NOT_DEFAULT, |
| 187 true, false, false); | 192 true, false, false); |
| 188 } | 193 } |
| 189 | 194 |
| 190 TEST_F(ExternalProtocolHandlerTest, TestLaunchSchemeUnknownChromeUnknown) { | 195 TEST_F(ExternalProtocolHandlerTest, TestLaunchSchemeUnknownChromeUnknown) { |
| 191 DoTest(ExternalProtocolHandler::UNKNOWN, | 196 DoTest(ExternalProtocolHandler::UNKNOWN, |
| 192 ShellIntegration::UNKNOWN_DEFAULT, | 197 ShellIntegration::UNKNOWN_DEFAULT, |
| 193 true, false, false); | 198 true, false, false); |
| 194 } | 199 } |
| OLD | NEW |