| 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 shell_integration::DefaultProtocolClientWorker { | 14 : public shell_integration::DefaultProtocolClientWorker { |
| 15 public: | 15 public: |
| 16 FakeExternalProtocolHandlerWorker( | 16 FakeExternalProtocolHandlerWorker( |
| 17 shell_integration::DefaultWebClientObserver* observer, | 17 shell_integration::DefaultWebClientObserver* observer, |
| 18 const std::string& protocol, | 18 const std::string& protocol, |
| 19 shell_integration::DefaultWebClientState os_state) | 19 shell_integration::DefaultWebClientState os_state) |
| 20 : shell_integration::DefaultProtocolClientWorker(observer, protocol), | 20 : shell_integration::DefaultProtocolClientWorker( |
| 21 observer, |
| 22 protocol, |
| 23 /*delete_observer=*/true), |
| 21 os_state_(os_state) {} | 24 os_state_(os_state) {} |
| 22 | 25 |
| 23 private: | 26 private: |
| 24 ~FakeExternalProtocolHandlerWorker() override {} | 27 ~FakeExternalProtocolHandlerWorker() override {} |
| 25 | 28 |
| 26 void CheckIsDefault() override { | 29 void CheckIsDefault() override { |
| 27 BrowserThread::PostTask( | 30 BrowserThread::PostTask( |
| 28 BrowserThread::UI, FROM_HERE, | 31 BrowserThread::UI, FROM_HERE, |
| 29 base::Bind(&FakeExternalProtocolHandlerWorker::OnCheckIsDefaultComplete, | 32 base::Bind(&FakeExternalProtocolHandlerWorker::OnCheckIsDefaultComplete, |
| 30 this, os_state_)); | 33 this, os_state_)); |
| 31 } | 34 } |
| 32 | 35 |
| 33 void SetAsDefault(bool interactive_permitted) override { | 36 void SetAsDefault() override { |
| 34 BrowserThread::PostTask( | 37 BrowserThread::PostTask( |
| 35 BrowserThread::UI, FROM_HERE, | 38 BrowserThread::UI, FROM_HERE, |
| 36 base::Bind( | 39 base::Bind( |
| 37 &FakeExternalProtocolHandlerWorker::OnSetAsDefaultAttemptComplete, | 40 &FakeExternalProtocolHandlerWorker::OnSetAsDefaultAttemptComplete, |
| 38 this, AttemptResult::SUCCESS)); | 41 this, AttemptResult::SUCCESS)); |
| 39 } | 42 } |
| 40 | 43 |
| 41 shell_integration::DefaultWebClientState os_state_; | 44 shell_integration::DefaultWebClientState os_state_; |
| 42 }; | 45 }; |
| 43 | 46 |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 | 190 |
| 188 TEST_F(ExternalProtocolHandlerTest, TestLaunchSchemeUnknownChromeNotDefault) { | 191 TEST_F(ExternalProtocolHandlerTest, TestLaunchSchemeUnknownChromeNotDefault) { |
| 189 DoTest(ExternalProtocolHandler::UNKNOWN, shell_integration::NOT_DEFAULT, true, | 192 DoTest(ExternalProtocolHandler::UNKNOWN, shell_integration::NOT_DEFAULT, true, |
| 190 false, false); | 193 false, false); |
| 191 } | 194 } |
| 192 | 195 |
| 193 TEST_F(ExternalProtocolHandlerTest, TestLaunchSchemeUnknownChromeUnknown) { | 196 TEST_F(ExternalProtocolHandlerTest, TestLaunchSchemeUnknownChromeUnknown) { |
| 194 DoTest(ExternalProtocolHandler::UNKNOWN, shell_integration::UNKNOWN_DEFAULT, | 197 DoTest(ExternalProtocolHandler::UNKNOWN, shell_integration::UNKNOWN_DEFAULT, |
| 195 true, false, false); | 198 true, false, false); |
| 196 } | 199 } |
| OLD | NEW |