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.h" | 10 #include "base/message_loop.h" |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 protected: | 272 protected: |
273 ProtocolHandlerRegistryTest() | 273 ProtocolHandlerRegistryTest() |
274 : ui_thread_(BrowserThread::UI, &loop_), | 274 : ui_thread_(BrowserThread::UI, &loop_), |
275 file_thread_(BrowserThread::FILE, &loop_), | 275 file_thread_(BrowserThread::FILE, &loop_), |
276 io_thread_(BrowserThread::IO, &loop_), | 276 io_thread_(BrowserThread::IO, &loop_), |
277 test_protocol_handler_(CreateProtocolHandler("test", "test")) {} | 277 test_protocol_handler_(CreateProtocolHandler("test", "test")) {} |
278 | 278 |
279 FakeDelegate* delegate() const { return delegate_; } | 279 FakeDelegate* delegate() const { return delegate_; } |
280 ProtocolHandlerRegistry* registry() { return registry_.get(); } | 280 ProtocolHandlerRegistry* registry() { return registry_.get(); } |
281 TestingProfile* profile() const { return profile_.get(); } | 281 TestingProfile* profile() const { return profile_.get(); } |
282 PrefService* pref_service() const { return profile_->GetPrefs(); } | 282 PrefServiceSyncable* pref_service() const { return profile_->GetPrefs(); } |
283 const ProtocolHandler& test_protocol_handler() const { | 283 const ProtocolHandler& test_protocol_handler() const { |
284 return test_protocol_handler_; | 284 return test_protocol_handler_; |
285 } | 285 } |
286 | 286 |
287 ProtocolHandler CreateProtocolHandler(const std::string& protocol, | 287 ProtocolHandler CreateProtocolHandler(const std::string& protocol, |
288 const GURL& url, | 288 const GURL& url, |
289 const std::string& title) { | 289 const std::string& title) { |
290 return ProtocolHandler::CreateProtocolHandler(protocol, url, | 290 return ProtocolHandler::CreateProtocolHandler(protocol, url, |
291 UTF8ToUTF16(title)); | 291 UTF8ToUTF16(title)); |
292 } | 292 } |
(...skipping 18 matching lines...) Expand all Loading... |
311 } | 311 } |
312 | 312 |
313 void TeadDownRegistry() { | 313 void TeadDownRegistry() { |
314 registry_->Shutdown(); | 314 registry_->Shutdown(); |
315 registry_.reset(); | 315 registry_.reset(); |
316 // Registry owns the delegate_ it handles deletion of that object. | 316 // Registry owns the delegate_ it handles deletion of that object. |
317 } | 317 } |
318 | 318 |
319 virtual void SetUp() { | 319 virtual void SetUp() { |
320 profile_.reset(new TestingProfile()); | 320 profile_.reset(new TestingProfile()); |
321 profile_->SetPrefService(new TestingPrefService()); | 321 profile_->SetPrefService(new TestingPrefServiceSyncable()); |
322 SetUpRegistry(true); | 322 SetUpRegistry(true); |
323 test_protocol_handler_ = | 323 test_protocol_handler_ = |
324 CreateProtocolHandler("test", GURL("http://test.com/%s"), "Test"); | 324 CreateProtocolHandler("test", GURL("http://test.com/%s"), "Test"); |
325 ProtocolHandlerRegistry::RegisterPrefs(pref_service()); | 325 ProtocolHandlerRegistry::RegisterUserPrefs(pref_service()); |
326 } | 326 } |
327 | 327 |
328 virtual void TearDown() { | 328 virtual void TearDown() { |
329 TeadDownRegistry(); | 329 TeadDownRegistry(); |
330 } | 330 } |
331 | 331 |
332 TestMessageLoop loop_; | 332 TestMessageLoop loop_; |
333 | 333 |
334 private: | 334 private: |
335 content::TestBrowserThread ui_thread_; | 335 content::TestBrowserThread ui_thread_; |
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
886 | 886 |
887 TEST_F(ProtocolHandlerRegistryTest, MAYBE_TestInstallDefaultHandler) { | 887 TEST_F(ProtocolHandlerRegistryTest, MAYBE_TestInstallDefaultHandler) { |
888 RecreateRegistry(false); | 888 RecreateRegistry(false); |
889 registry()->AddPredefinedHandler(CreateProtocolHandler( | 889 registry()->AddPredefinedHandler(CreateProtocolHandler( |
890 "test", GURL("http://test.com/%s"), "Test")); | 890 "test", GURL("http://test.com/%s"), "Test")); |
891 registry()->InitProtocolSettings(); | 891 registry()->InitProtocolSettings(); |
892 std::vector<std::string> protocols; | 892 std::vector<std::string> protocols; |
893 registry()->GetRegisteredProtocols(&protocols); | 893 registry()->GetRegisteredProtocols(&protocols); |
894 ASSERT_EQ(static_cast<size_t>(1), protocols.size()); | 894 ASSERT_EQ(static_cast<size_t>(1), protocols.size()); |
895 } | 895 } |
OLD | NEW |