| 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/custom_handlers/protocol_handler_registry.h" | 5 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 FakeProtocolClientWorker( | 142 FakeProtocolClientWorker( |
| 143 const shell_integration::DefaultWebClientWorkerCallback& callback, | 143 const shell_integration::DefaultWebClientWorkerCallback& callback, |
| 144 const std::string& protocol, | 144 const std::string& protocol, |
| 145 bool force_failure) | 145 bool force_failure) |
| 146 : shell_integration::DefaultProtocolClientWorker(callback, protocol), | 146 : shell_integration::DefaultProtocolClientWorker(callback, protocol), |
| 147 force_failure_(force_failure) {} | 147 force_failure_(force_failure) {} |
| 148 | 148 |
| 149 private: | 149 private: |
| 150 ~FakeProtocolClientWorker() override {} | 150 ~FakeProtocolClientWorker() override {} |
| 151 | 151 |
| 152 void CheckIsDefault() override { | 152 void CheckIsDefault(bool is_following_set_as_default) override { |
| 153 shell_integration::DefaultWebClientState state = | 153 shell_integration::DefaultWebClientState state = |
| 154 shell_integration::IS_DEFAULT; | 154 shell_integration::IS_DEFAULT; |
| 155 if (force_failure_) | 155 if (force_failure_) |
| 156 state = shell_integration::NOT_DEFAULT; | 156 state = shell_integration::NOT_DEFAULT; |
| 157 | 157 |
| 158 BrowserThread::PostTask( | 158 BrowserThread::PostTask( |
| 159 BrowserThread::UI, FROM_HERE, | 159 BrowserThread::UI, FROM_HERE, |
| 160 base::Bind(&FakeProtocolClientWorker::OnCheckIsDefaultComplete, this, | 160 base::Bind(&FakeProtocolClientWorker::OnCheckIsDefaultComplete, this, |
| 161 state)); | 161 state, is_following_set_as_default)); |
| 162 } | 162 } |
| 163 | 163 |
| 164 void SetAsDefault() override { | 164 void SetAsDefault() override { CheckIsDefault(true); } |
| 165 BrowserThread::PostTask( | |
| 166 BrowserThread::UI, FROM_HERE, | |
| 167 base::Bind(&FakeProtocolClientWorker::OnSetAsDefaultAttemptComplete, | |
| 168 this, AttemptResult::SUCCESS)); | |
| 169 } | |
| 170 | 165 |
| 171 private: | 166 private: |
| 172 bool force_failure_; | 167 bool force_failure_; |
| 173 }; | 168 }; |
| 174 | 169 |
| 175 class FakeDelegate : public ProtocolHandlerRegistry::Delegate { | 170 class FakeDelegate : public ProtocolHandlerRegistry::Delegate { |
| 176 public: | 171 public: |
| 177 FakeDelegate() : force_os_failure_(false) {} | 172 FakeDelegate() : force_os_failure_(false) {} |
| 178 ~FakeDelegate() override {} | 173 ~FakeDelegate() override {} |
| 179 void RegisterExternalHandler(const std::string& protocol) override { | 174 void RegisterExternalHandler(const std::string& protocol) override { |
| (...skipping 909 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1089 // added to pref. | 1084 // added to pref. |
| 1090 ASSERT_EQ(InPrefIgnoredHandlerCount(), 2); | 1085 ASSERT_EQ(InPrefIgnoredHandlerCount(), 2); |
| 1091 ASSERT_EQ(InMemoryIgnoredHandlerCount(), 4); | 1086 ASSERT_EQ(InMemoryIgnoredHandlerCount(), 4); |
| 1092 | 1087 |
| 1093 registry()->RemoveIgnoredHandler(p2u1); | 1088 registry()->RemoveIgnoredHandler(p2u1); |
| 1094 | 1089 |
| 1095 // p2u1 installed by user and policy, so it is removed from pref alone. | 1090 // p2u1 installed by user and policy, so it is removed from pref alone. |
| 1096 ASSERT_EQ(InPrefIgnoredHandlerCount(), 1); | 1091 ASSERT_EQ(InPrefIgnoredHandlerCount(), 1); |
| 1097 ASSERT_EQ(InMemoryIgnoredHandlerCount(), 4); | 1092 ASSERT_EQ(InMemoryIgnoredHandlerCount(), 4); |
| 1098 } | 1093 } |
| OLD | NEW |