| 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 // TODO(joi): Check if this can be removed, as well as the call to |
| 283 // SetPrefService in SetUp. |
| 284 PrefServiceSyncable* pref_service() const { return profile_->GetPrefs(); } |
| 283 const ProtocolHandler& test_protocol_handler() const { | 285 const ProtocolHandler& test_protocol_handler() const { |
| 284 return test_protocol_handler_; | 286 return test_protocol_handler_; |
| 285 } | 287 } |
| 286 | 288 |
| 287 ProtocolHandler CreateProtocolHandler(const std::string& protocol, | 289 ProtocolHandler CreateProtocolHandler(const std::string& protocol, |
| 288 const GURL& url, | 290 const GURL& url, |
| 289 const std::string& title) { | 291 const std::string& title) { |
| 290 return ProtocolHandler::CreateProtocolHandler(protocol, url, | 292 return ProtocolHandler::CreateProtocolHandler(protocol, url, |
| 291 UTF8ToUTF16(title)); | 293 UTF8ToUTF16(title)); |
| 292 } | 294 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 311 } | 313 } |
| 312 | 314 |
| 313 void TeadDownRegistry() { | 315 void TeadDownRegistry() { |
| 314 registry_->Shutdown(); | 316 registry_->Shutdown(); |
| 315 registry_.reset(); | 317 registry_.reset(); |
| 316 // Registry owns the delegate_ it handles deletion of that object. | 318 // Registry owns the delegate_ it handles deletion of that object. |
| 317 } | 319 } |
| 318 | 320 |
| 319 virtual void SetUp() { | 321 virtual void SetUp() { |
| 320 profile_.reset(new TestingProfile()); | 322 profile_.reset(new TestingProfile()); |
| 321 profile_->SetPrefService(new TestingPrefService()); | 323 profile_->SetPrefService(new TestingPrefServiceSyncable()); |
| 322 SetUpRegistry(true); | 324 SetUpRegistry(true); |
| 323 test_protocol_handler_ = | 325 test_protocol_handler_ = |
| 324 CreateProtocolHandler("test", GURL("http://test.com/%s"), "Test"); | 326 CreateProtocolHandler("test", GURL("http://test.com/%s"), "Test"); |
| 325 ProtocolHandlerRegistry::RegisterPrefs(pref_service()); | 327 |
| 328 // TODO(joi): If pref_service() and the SetPrefService above go, |
| 329 // then this could go. |
| 330 ProtocolHandlerRegistry::RegisterUserPrefs(pref_service()); |
| 326 } | 331 } |
| 327 | 332 |
| 328 virtual void TearDown() { | 333 virtual void TearDown() { |
| 329 TeadDownRegistry(); | 334 TeadDownRegistry(); |
| 330 } | 335 } |
| 331 | 336 |
| 332 TestMessageLoop loop_; | 337 TestMessageLoop loop_; |
| 333 | 338 |
| 334 private: | 339 private: |
| 335 content::TestBrowserThread ui_thread_; | 340 content::TestBrowserThread ui_thread_; |
| (...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 886 | 891 |
| 887 TEST_F(ProtocolHandlerRegistryTest, MAYBE_TestInstallDefaultHandler) { | 892 TEST_F(ProtocolHandlerRegistryTest, MAYBE_TestInstallDefaultHandler) { |
| 888 RecreateRegistry(false); | 893 RecreateRegistry(false); |
| 889 registry()->AddPredefinedHandler(CreateProtocolHandler( | 894 registry()->AddPredefinedHandler(CreateProtocolHandler( |
| 890 "test", GURL("http://test.com/%s"), "Test")); | 895 "test", GURL("http://test.com/%s"), "Test")); |
| 891 registry()->InitProtocolSettings(); | 896 registry()->InitProtocolSettings(); |
| 892 std::vector<std::string> protocols; | 897 std::vector<std::string> protocols; |
| 893 registry()->GetRegisteredProtocols(&protocols); | 898 registry()->GetRegisteredProtocols(&protocols); |
| 894 ASSERT_EQ(static_cast<size_t>(1), protocols.size()); | 899 ASSERT_EQ(static_cast<size_t>(1), protocols.size()); |
| 895 } | 900 } |
| OLD | NEW |