| 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 <memory> | 9 #include <memory> |
| 10 #include <set> | 10 #include <set> |
| 11 | 11 |
| 12 #include "base/memory/ptr_util.h" |
| 12 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 13 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 15 #include "base/synchronization/waitable_event.h" | 16 #include "base/synchronization/waitable_event.h" |
| 16 #include "build/build_config.h" | 17 #include "build/build_config.h" |
| 17 #include "chrome/browser/chrome_notification_types.h" | 18 #include "chrome/browser/chrome_notification_types.h" |
| 18 #include "chrome/common/custom_handlers/protocol_handler.h" | 19 #include "chrome/common/custom_handlers/protocol_handler.h" |
| 19 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
| 20 #include "chrome/test/base/testing_browser_process.h" | 21 #include "chrome/test/base/testing_browser_process.h" |
| 21 #include "chrome/test/base/testing_profile.h" | 22 #include "chrome/test/base/testing_profile.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 115 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 115 BrowserThread::PostTask(BrowserThread::IO, | 116 BrowserThread::PostTask(BrowserThread::IO, |
| 116 FROM_HERE, | 117 FROM_HERE, |
| 117 base::Bind(AssertWillHandleIO, | 118 base::Bind(AssertWillHandleIO, |
| 118 scheme, | 119 scheme, |
| 119 expected, | 120 expected, |
| 120 base::Unretained(interceptor))); | 121 base::Unretained(interceptor))); |
| 121 base::RunLoop().RunUntilIdle(); | 122 base::RunLoop().RunUntilIdle(); |
| 122 } | 123 } |
| 123 | 124 |
| 124 base::DictionaryValue* GetProtocolHandlerValue(std::string protocol, | 125 std::unique_ptr<base::DictionaryValue> GetProtocolHandlerValue( |
| 125 std::string url) { | 126 const std::string& protocol, |
| 126 base::DictionaryValue* value = new base::DictionaryValue(); | 127 const std::string& url) { |
| 128 auto value = base::MakeUnique<base::DictionaryValue>(); |
| 127 value->SetString("protocol", protocol); | 129 value->SetString("protocol", protocol); |
| 128 value->SetString("url", url); | 130 value->SetString("url", url); |
| 129 return value; | 131 return value; |
| 130 } | 132 } |
| 131 | 133 |
| 132 base::DictionaryValue* GetProtocolHandlerValueWithDefault(std::string protocol, | 134 std::unique_ptr<base::DictionaryValue> GetProtocolHandlerValueWithDefault( |
| 133 std::string url, | 135 const std::string& protocol, |
| 134 bool is_default) { | 136 const std::string& url, |
| 135 base::DictionaryValue* value = GetProtocolHandlerValue(protocol, url); | 137 bool is_default) { |
| 138 std::unique_ptr<base::DictionaryValue> value = |
| 139 GetProtocolHandlerValue(protocol, url); |
| 136 value->SetBoolean("default", is_default); | 140 value->SetBoolean("default", is_default); |
| 137 return value; | 141 return value; |
| 138 } | 142 } |
| 139 | 143 |
| 140 class FakeProtocolClientWorker | 144 class FakeProtocolClientWorker |
| 141 : public shell_integration::DefaultProtocolClientWorker { | 145 : public shell_integration::DefaultProtocolClientWorker { |
| 142 public: | 146 public: |
| 143 FakeProtocolClientWorker( | 147 FakeProtocolClientWorker( |
| 144 const shell_integration::DefaultWebClientWorkerCallback& callback, | 148 const shell_integration::DefaultWebClientWorkerCallback& callback, |
| 145 const std::string& protocol, | 149 const std::string& protocol, |
| (...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1080 // added to pref. | 1084 // added to pref. |
| 1081 ASSERT_EQ(InPrefIgnoredHandlerCount(), 2); | 1085 ASSERT_EQ(InPrefIgnoredHandlerCount(), 2); |
| 1082 ASSERT_EQ(InMemoryIgnoredHandlerCount(), 4); | 1086 ASSERT_EQ(InMemoryIgnoredHandlerCount(), 4); |
| 1083 | 1087 |
| 1084 registry()->RemoveIgnoredHandler(p2u1); | 1088 registry()->RemoveIgnoredHandler(p2u1); |
| 1085 | 1089 |
| 1086 // 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. |
| 1087 ASSERT_EQ(InPrefIgnoredHandlerCount(), 1); | 1091 ASSERT_EQ(InPrefIgnoredHandlerCount(), 1); |
| 1088 ASSERT_EQ(InMemoryIgnoredHandlerCount(), 4); | 1092 ASSERT_EQ(InMemoryIgnoredHandlerCount(), 4); |
| 1089 } | 1093 } |
| OLD | NEW |