| 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 <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 public: | 219 public: |
| 220 FakeProtocolClientWorker(ShellIntegration::DefaultWebClientObserver* observer, | 220 FakeProtocolClientWorker(ShellIntegration::DefaultWebClientObserver* observer, |
| 221 const std::string& protocol, | 221 const std::string& protocol, |
| 222 bool force_failure) | 222 bool force_failure) |
| 223 : ShellIntegration::DefaultProtocolClientWorker(observer, protocol), | 223 : ShellIntegration::DefaultProtocolClientWorker(observer, protocol), |
| 224 force_failure_(force_failure) {} | 224 force_failure_(force_failure) {} |
| 225 | 225 |
| 226 private: | 226 private: |
| 227 ~FakeProtocolClientWorker() override {} | 227 ~FakeProtocolClientWorker() override {} |
| 228 | 228 |
| 229 ShellIntegration::DefaultWebClientState CheckIsDefault() override { | 229 void CheckIsDefault() override { |
| 230 if (force_failure_) { | 230 ShellIntegration::DefaultWebClientState state = |
| 231 return ShellIntegration::NOT_DEFAULT; | 231 ShellIntegration::IS_DEFAULT; |
| 232 } else { | 232 if (force_failure_) |
| 233 return ShellIntegration::IS_DEFAULT; | 233 state = ShellIntegration::NOT_DEFAULT; |
| 234 } | 234 |
| 235 BrowserThread::PostTask( |
| 236 BrowserThread::UI, FROM_HERE, |
| 237 base::Bind(&FakeProtocolClientWorker::OnCheckIsDefaultComplete, this, |
| 238 state)); |
| 235 } | 239 } |
| 236 | 240 |
| 237 bool SetAsDefault(bool interactive_permitted) override { return true; } | 241 void SetAsDefault(bool interactive_permitted) override { |
| 242 BrowserThread::PostTask( |
| 243 BrowserThread::UI, FROM_HERE, |
| 244 base::Bind(&FakeProtocolClientWorker::OnSetAsDefaultAttemptComplete, |
| 245 this, AttemptResult::SUCCESS)); |
| 246 } |
| 238 | 247 |
| 239 private: | 248 private: |
| 240 bool force_failure_; | 249 bool force_failure_; |
| 241 }; | 250 }; |
| 242 | 251 |
| 243 ProtocolHandlerRegistry::DefaultClientObserver* | 252 ProtocolHandlerRegistry::DefaultClientObserver* |
| 244 FakeDelegate::CreateShellObserver(ProtocolHandlerRegistry* registry) { | 253 FakeDelegate::CreateShellObserver(ProtocolHandlerRegistry* registry) { |
| 245 return new FakeClientObserver(registry, this); | 254 return new FakeClientObserver(registry, this); |
| 246 } | 255 } |
| 247 | 256 |
| (...skipping 874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1122 // added to pref. | 1131 // added to pref. |
| 1123 ASSERT_EQ(InPrefIgnoredHandlerCount(), 2); | 1132 ASSERT_EQ(InPrefIgnoredHandlerCount(), 2); |
| 1124 ASSERT_EQ(InMemoryIgnoredHandlerCount(), 4); | 1133 ASSERT_EQ(InMemoryIgnoredHandlerCount(), 4); |
| 1125 | 1134 |
| 1126 registry()->RemoveIgnoredHandler(p2u1); | 1135 registry()->RemoveIgnoredHandler(p2u1); |
| 1127 | 1136 |
| 1128 // p2u1 installed by user and policy, so it is removed from pref alone. | 1137 // p2u1 installed by user and policy, so it is removed from pref alone. |
| 1129 ASSERT_EQ(InPrefIgnoredHandlerCount(), 1); | 1138 ASSERT_EQ(InPrefIgnoredHandlerCount(), 1); |
| 1130 ASSERT_EQ(InMemoryIgnoredHandlerCount(), 4); | 1139 ASSERT_EQ(InMemoryIgnoredHandlerCount(), 4); |
| 1131 } | 1140 } |
| OLD | NEW |