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.h" | 7 #include "base/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 28 matching lines...) Expand all Loading... |
39 public: | 39 public: |
40 FakeExternalProtocolHandlerDelegate() | 40 FakeExternalProtocolHandlerDelegate() |
41 : block_state_(ExternalProtocolHandler::BLOCK), | 41 : block_state_(ExternalProtocolHandler::BLOCK), |
42 os_state_(ShellIntegration::UNKNOWN_DEFAULT), | 42 os_state_(ShellIntegration::UNKNOWN_DEFAULT), |
43 has_launched_(false), | 43 has_launched_(false), |
44 has_prompted_(false), | 44 has_prompted_(false), |
45 has_blocked_ (false) {} | 45 has_blocked_ (false) {} |
46 | 46 |
47 virtual ShellIntegration::DefaultProtocolClientWorker* CreateShellWorker( | 47 virtual ShellIntegration::DefaultProtocolClientWorker* CreateShellWorker( |
48 ShellIntegration::DefaultWebClientObserver* observer, | 48 ShellIntegration::DefaultWebClientObserver* observer, |
49 const std::string& protocol) { | 49 const std::string& protocol) OVERRIDE { |
50 return new FakeExternalProtocolHandlerWorker(observer, protocol, os_state_); | 50 return new FakeExternalProtocolHandlerWorker(observer, protocol, os_state_); |
51 } | 51 } |
52 | 52 |
53 virtual ExternalProtocolHandler::BlockState GetBlockState( | 53 virtual ExternalProtocolHandler::BlockState GetBlockState( |
54 const std::string& scheme) { return block_state_; } | 54 const std::string& scheme) OVERRIDE { return block_state_; } |
55 | 55 |
56 virtual void BlockRequest() { | 56 virtual 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 virtual void RunExternalProtocolDialog(const GURL& url, | 62 virtual void RunExternalProtocolDialog(const GURL& url, |
63 int render_process_host_id, | 63 int render_process_host_id, |
64 int routing_id) { | 64 int routing_id) OVERRIDE { |
65 ASSERT_EQ(block_state_, ExternalProtocolHandler::UNKNOWN); | 65 ASSERT_EQ(block_state_, ExternalProtocolHandler::UNKNOWN); |
66 ASSERT_NE(os_state_, ShellIntegration::IS_DEFAULT); | 66 ASSERT_NE(os_state_, ShellIntegration::IS_DEFAULT); |
67 has_prompted_ = true; | 67 has_prompted_ = true; |
68 } | 68 } |
69 | 69 |
70 virtual void LaunchUrlWithoutSecurityCheck(const GURL& url) { | 70 virtual void LaunchUrlWithoutSecurityCheck(const GURL& url) OVERRIDE { |
71 ASSERT_EQ(block_state_, ExternalProtocolHandler::DONT_BLOCK); | 71 ASSERT_EQ(block_state_, ExternalProtocolHandler::DONT_BLOCK); |
72 ASSERT_NE(os_state_, ShellIntegration::IS_DEFAULT); | 72 ASSERT_NE(os_state_, ShellIntegration::IS_DEFAULT); |
73 has_launched_ = true; | 73 has_launched_ = true; |
74 } | 74 } |
75 | 75 |
76 virtual void FinishedProcessingCheck() { | 76 virtual void FinishedProcessingCheck() OVERRIDE { |
77 MessageLoop::current()->Quit(); | 77 MessageLoop::current()->Quit(); |
78 } | 78 } |
79 | 79 |
80 void set_os_state(ShellIntegration::DefaultWebClientState value) { | 80 void set_os_state(ShellIntegration::DefaultWebClientState value) { |
81 os_state_ = value; | 81 os_state_ = value; |
82 } | 82 } |
83 | 83 |
84 void set_block_state(ExternalProtocolHandler::BlockState value) { | 84 void set_block_state(ExternalProtocolHandler::BlockState value) { |
85 block_state_ = value; | 85 block_state_ = value; |
86 } | 86 } |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 DoTest(ExternalProtocolHandler::UNKNOWN, | 184 DoTest(ExternalProtocolHandler::UNKNOWN, |
185 ShellIntegration::NOT_DEFAULT, | 185 ShellIntegration::NOT_DEFAULT, |
186 true, false, false); | 186 true, false, false); |
187 } | 187 } |
188 | 188 |
189 TEST_F(ExternalProtocolHandlerTest, TestLaunchSchemeUnknownChromeUnknown) { | 189 TEST_F(ExternalProtocolHandlerTest, TestLaunchSchemeUnknownChromeUnknown) { |
190 DoTest(ExternalProtocolHandler::UNKNOWN, | 190 DoTest(ExternalProtocolHandler::UNKNOWN, |
191 ShellIntegration::UNKNOWN_DEFAULT, | 191 ShellIntegration::UNKNOWN_DEFAULT, |
192 true, false, false); | 192 true, false, false); |
193 } | 193 } |
OLD | NEW |