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 |
(...skipping 22 matching lines...) Expand all Loading... |
33 }; | 33 }; |
34 | 34 |
35 class FakeExternalProtocolHandlerDelegate | 35 class FakeExternalProtocolHandlerDelegate |
36 : public ExternalProtocolHandler::Delegate { | 36 : public ExternalProtocolHandler::Delegate { |
37 public: | 37 public: |
38 FakeExternalProtocolHandlerDelegate() | 38 FakeExternalProtocolHandlerDelegate() |
39 : block_state_(ExternalProtocolHandler::BLOCK), | 39 : block_state_(ExternalProtocolHandler::BLOCK), |
40 os_state_(ShellIntegration::UNKNOWN_DEFAULT), | 40 os_state_(ShellIntegration::UNKNOWN_DEFAULT), |
41 has_launched_(false), | 41 has_launched_(false), |
42 has_prompted_(false), | 42 has_prompted_(false), |
43 has_blocked_ (false) {} | 43 has_blocked_(false) {} |
44 | 44 |
45 ShellIntegration::DefaultProtocolClientWorker* CreateShellWorker( | 45 ShellIntegration::DefaultProtocolClientWorker* CreateShellWorker( |
46 ShellIntegration::DefaultWebClientObserver* observer, | 46 ShellIntegration::DefaultWebClientObserver* observer, |
47 const std::string& protocol) override { | 47 const std::string& protocol) override { |
48 return new FakeExternalProtocolHandlerWorker(observer, protocol, os_state_); | 48 return new FakeExternalProtocolHandlerWorker(observer, protocol, os_state_); |
49 } | 49 } |
50 | 50 |
51 ExternalProtocolHandler::BlockState GetBlockState( | 51 ExternalProtocolHandler::BlockState GetBlockState( |
52 const std::string& scheme) override { | 52 const std::string& scheme) override { |
53 return block_state_; | 53 return block_state_; |
54 } | 54 } |
55 | 55 |
56 void BlockRequest() override { | 56 void BlockRequest() override { |
57 ASSERT_TRUE(block_state_ == ExternalProtocolHandler::BLOCK || | 57 ASSERT_TRUE(block_state_ == ExternalProtocolHandler::BLOCK || |
58 os_state_ == ShellIntegration::IS_DEFAULT); | 58 os_state_ == ShellIntegration::IS_DEFAULT); |
59 has_blocked_ = true; | 59 has_blocked_ = true; |
60 } | 60 } |
61 | 61 |
62 void RunExternalProtocolDialog(const GURL& url, | 62 void RunExternalProtocolDialog(const GURL& url, |
63 int render_process_host_id, | 63 int render_process_host_id, |
64 int routing_id) override { | 64 int routing_id, |
| 65 ui::PageTransition page_transition) override { |
65 ASSERT_EQ(block_state_, ExternalProtocolHandler::UNKNOWN); | 66 ASSERT_EQ(block_state_, ExternalProtocolHandler::UNKNOWN); |
66 ASSERT_NE(os_state_, ShellIntegration::IS_DEFAULT); | 67 ASSERT_NE(os_state_, ShellIntegration::IS_DEFAULT); |
67 has_prompted_ = true; | 68 has_prompted_ = true; |
68 } | 69 } |
69 | 70 |
70 void LaunchUrlWithoutSecurityCheck(const GURL& url) override { | 71 void LaunchUrlWithoutSecurityCheck(const GURL& url) override { |
71 ASSERT_EQ(block_state_, ExternalProtocolHandler::DONT_BLOCK); | 72 ASSERT_EQ(block_state_, ExternalProtocolHandler::DONT_BLOCK); |
72 ASSERT_NE(os_state_, ShellIntegration::IS_DEFAULT); | 73 ASSERT_NE(os_state_, ShellIntegration::IS_DEFAULT); |
73 has_launched_ = true; | 74 has_launched_ = true; |
74 } | 75 } |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 DoTest(ExternalProtocolHandler::UNKNOWN, | 183 DoTest(ExternalProtocolHandler::UNKNOWN, |
183 ShellIntegration::NOT_DEFAULT, | 184 ShellIntegration::NOT_DEFAULT, |
184 true, false, false); | 185 true, false, false); |
185 } | 186 } |
186 | 187 |
187 TEST_F(ExternalProtocolHandlerTest, TestLaunchSchemeUnknownChromeUnknown) { | 188 TEST_F(ExternalProtocolHandlerTest, TestLaunchSchemeUnknownChromeUnknown) { |
188 DoTest(ExternalProtocolHandler::UNKNOWN, | 189 DoTest(ExternalProtocolHandler::UNKNOWN, |
189 ShellIntegration::UNKNOWN_DEFAULT, | 190 ShellIntegration::UNKNOWN_DEFAULT, |
190 true, false, false); | 191 true, false, false); |
191 } | 192 } |
OLD | NEW |