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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 FakeDelegate* delegate_; | 217 FakeDelegate* delegate_; |
218 }; | 218 }; |
219 | 219 |
220 class FakeProtocolClientWorker | 220 class FakeProtocolClientWorker |
221 : public shell_integration::DefaultProtocolClientWorker { | 221 : public shell_integration::DefaultProtocolClientWorker { |
222 public: | 222 public: |
223 FakeProtocolClientWorker( | 223 FakeProtocolClientWorker( |
224 shell_integration::DefaultWebClientObserver* observer, | 224 shell_integration::DefaultWebClientObserver* observer, |
225 const std::string& protocol, | 225 const std::string& protocol, |
226 bool force_failure) | 226 bool force_failure) |
227 : shell_integration::DefaultProtocolClientWorker(observer, protocol), | 227 : shell_integration::DefaultProtocolClientWorker( |
| 228 observer, |
| 229 protocol, |
| 230 /*delete_observer*/ true), |
228 force_failure_(force_failure) {} | 231 force_failure_(force_failure) {} |
229 | 232 |
230 private: | 233 private: |
231 ~FakeProtocolClientWorker() override {} | 234 ~FakeProtocolClientWorker() override {} |
232 | 235 |
233 void CheckIsDefault() override { | 236 void CheckIsDefault() override { |
234 shell_integration::DefaultWebClientState state = | 237 shell_integration::DefaultWebClientState state = |
235 shell_integration::IS_DEFAULT; | 238 shell_integration::IS_DEFAULT; |
236 if (force_failure_) | 239 if (force_failure_) |
237 state = shell_integration::NOT_DEFAULT; | 240 state = shell_integration::NOT_DEFAULT; |
238 | 241 |
239 BrowserThread::PostTask( | 242 BrowserThread::PostTask( |
240 BrowserThread::UI, FROM_HERE, | 243 BrowserThread::UI, FROM_HERE, |
241 base::Bind(&FakeProtocolClientWorker::OnCheckIsDefaultComplete, this, | 244 base::Bind(&FakeProtocolClientWorker::OnCheckIsDefaultComplete, this, |
242 state)); | 245 state)); |
243 } | 246 } |
244 | 247 |
245 void SetAsDefault(bool interactive_permitted) override { | 248 void SetAsDefault() override { |
246 BrowserThread::PostTask( | 249 BrowserThread::PostTask( |
247 BrowserThread::UI, FROM_HERE, | 250 BrowserThread::UI, FROM_HERE, |
248 base::Bind(&FakeProtocolClientWorker::OnSetAsDefaultAttemptComplete, | 251 base::Bind(&FakeProtocolClientWorker::OnSetAsDefaultAttemptComplete, |
249 this, AttemptResult::SUCCESS)); | 252 this, AttemptResult::SUCCESS)); |
250 } | 253 } |
251 | 254 |
252 private: | 255 private: |
253 bool force_failure_; | 256 bool force_failure_; |
254 }; | 257 }; |
255 | 258 |
(...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1103 // added to pref. | 1106 // added to pref. |
1104 ASSERT_EQ(InPrefIgnoredHandlerCount(), 2); | 1107 ASSERT_EQ(InPrefIgnoredHandlerCount(), 2); |
1105 ASSERT_EQ(InMemoryIgnoredHandlerCount(), 4); | 1108 ASSERT_EQ(InMemoryIgnoredHandlerCount(), 4); |
1106 | 1109 |
1107 registry()->RemoveIgnoredHandler(p2u1); | 1110 registry()->RemoveIgnoredHandler(p2u1); |
1108 | 1111 |
1109 // p2u1 installed by user and policy, so it is removed from pref alone. | 1112 // p2u1 installed by user and policy, so it is removed from pref alone. |
1110 ASSERT_EQ(InPrefIgnoredHandlerCount(), 1); | 1113 ASSERT_EQ(InPrefIgnoredHandlerCount(), 1); |
1111 ASSERT_EQ(InMemoryIgnoredHandlerCount(), 4); | 1114 ASSERT_EQ(InMemoryIgnoredHandlerCount(), 4); |
1112 } | 1115 } |
OLD | NEW |