OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/ui/webui/settings/protocol_handlers_handler.h" | 5 #include "chrome/browser/ui/webui/settings/protocol_handlers_handler.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/ptr_util.h" |
14 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
15 #include "base/values.h" | 16 #include "base/values.h" |
16 #include "chrome/browser/chrome_notification_types.h" | 17 #include "chrome/browser/chrome_notification_types.h" |
17 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" | 18 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" |
18 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
19 #include "chrome/common/url_constants.h" | 20 #include "chrome/common/url_constants.h" |
20 #include "components/google/core/browser/google_util.h" | 21 #include "components/google/core/browser/google_util.h" |
21 #include "components/prefs/pref_service.h" | 22 #include "components/prefs/pref_service.h" |
22 #include "content/public/browser/web_ui.h" | 23 #include "content/public/browser/web_ui.h" |
23 | 24 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 // for Handlers. Please update them whenever you add or remove any keys here. | 93 // for Handlers. Please update them whenever you add or remove any keys here. |
93 handlers_value->SetString("protocol", protocol); | 94 handlers_value->SetString("protocol", protocol); |
94 handlers_value->SetInteger("default_handler", | 95 handlers_value->SetInteger("default_handler", |
95 registry->GetHandlerIndex(protocol)); | 96 registry->GetHandlerIndex(protocol)); |
96 handlers_value->SetBoolean( | 97 handlers_value->SetBoolean( |
97 "is_default_handler_set_by_user", | 98 "is_default_handler_set_by_user", |
98 registry->IsRegisteredByUser(registry->GetHandlerFor(protocol))); | 99 registry->IsRegisteredByUser(registry->GetHandlerFor(protocol))); |
99 handlers_value->SetBoolean("has_policy_recommendations", | 100 handlers_value->SetBoolean("has_policy_recommendations", |
100 registry->HasPolicyRegisteredHandler(protocol)); | 101 registry->HasPolicyRegisteredHandler(protocol)); |
101 | 102 |
102 base::ListValue* handlers_list = new base::ListValue(); | 103 auto handlers_list = base::MakeUnique<base::ListValue>(); |
103 GetHandlersAsListValue(registry->GetHandlersFor(protocol), handlers_list); | 104 GetHandlersAsListValue(registry->GetHandlersFor(protocol), |
104 handlers_value->Set("handlers", handlers_list); | 105 handlers_list.get()); |
| 106 handlers_value->Set("handlers", std::move(handlers_list)); |
105 } | 107 } |
106 | 108 |
107 void ProtocolHandlersHandler::GetIgnoredHandlers(base::ListValue* handlers) { | 109 void ProtocolHandlersHandler::GetIgnoredHandlers(base::ListValue* handlers) { |
108 ProtocolHandlerRegistry* registry = GetProtocolHandlerRegistry(); | 110 ProtocolHandlerRegistry* registry = GetProtocolHandlerRegistry(); |
109 ProtocolHandlerRegistry::ProtocolHandlerList ignored_handlers = | 111 ProtocolHandlerRegistry::ProtocolHandlerList ignored_handlers = |
110 registry->GetIgnoredHandlers(); | 112 registry->GetIgnoredHandlers(); |
111 return GetHandlersAsListValue(ignored_handlers, handlers); | 113 return GetHandlersAsListValue(ignored_handlers, handlers); |
112 } | 114 } |
113 | 115 |
114 void ProtocolHandlersHandler::UpdateHandlerList() { | 116 void ProtocolHandlersHandler::UpdateHandlerList() { |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 void ProtocolHandlersHandler::Observe( | 222 void ProtocolHandlersHandler::Observe( |
221 int type, | 223 int type, |
222 const content::NotificationSource& source, | 224 const content::NotificationSource& source, |
223 const content::NotificationDetails& details) { | 225 const content::NotificationDetails& details) { |
224 DCHECK_EQ(chrome::NOTIFICATION_PROTOCOL_HANDLER_REGISTRY_CHANGED, type); | 226 DCHECK_EQ(chrome::NOTIFICATION_PROTOCOL_HANDLER_REGISTRY_CHANGED, type); |
225 SendHandlersEnabledValue(); | 227 SendHandlersEnabledValue(); |
226 UpdateHandlerList(); | 228 UpdateHandlerList(); |
227 } | 229 } |
228 | 230 |
229 } // namespace settings | 231 } // namespace settings |
OLD | NEW |