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/ui/webui/options/handler_options_handler.h" | 5 #include "chrome/browser/ui/webui/options/handler_options_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 "chrome/grit/generated_resources.h" | 21 #include "chrome/grit/generated_resources.h" |
21 #include "components/google/core/browser/google_util.h" | 22 #include "components/google/core/browser/google_util.h" |
22 #include "components/prefs/pref_service.h" | 23 #include "components/prefs/pref_service.h" |
23 #include "content/public/browser/web_ui.h" | 24 #include "content/public/browser/web_ui.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 // for Handlers. Please update them whenever you add or remove any keys here. | 109 // for Handlers. Please update them whenever you add or remove any keys here. |
109 handlers_value->SetString("protocol", protocol); | 110 handlers_value->SetString("protocol", protocol); |
110 handlers_value->SetInteger("default_handler", | 111 handlers_value->SetInteger("default_handler", |
111 registry->GetHandlerIndex(protocol)); | 112 registry->GetHandlerIndex(protocol)); |
112 handlers_value->SetBoolean( | 113 handlers_value->SetBoolean( |
113 "is_default_handler_set_by_user", | 114 "is_default_handler_set_by_user", |
114 registry->IsRegisteredByUser(registry->GetHandlerFor(protocol))); | 115 registry->IsRegisteredByUser(registry->GetHandlerFor(protocol))); |
115 handlers_value->SetBoolean("has_policy_recommendations", | 116 handlers_value->SetBoolean("has_policy_recommendations", |
116 registry->HasPolicyRegisteredHandler(protocol)); | 117 registry->HasPolicyRegisteredHandler(protocol)); |
117 | 118 |
118 base::ListValue* handlers_list = new base::ListValue(); | 119 auto handlers_list = base::MakeUnique<base::ListValue>(); |
119 GetHandlersAsListValue(registry->GetHandlersFor(protocol), handlers_list); | 120 GetHandlersAsListValue(registry->GetHandlersFor(protocol), |
120 handlers_value->Set("handlers", handlers_list); | 121 handlers_list.get()); |
| 122 handlers_value->Set("handlers", std::move(handlers_list)); |
121 } | 123 } |
122 | 124 |
123 void HandlerOptionsHandler::GetIgnoredHandlers(base::ListValue* handlers) { | 125 void HandlerOptionsHandler::GetIgnoredHandlers(base::ListValue* handlers) { |
124 ProtocolHandlerRegistry* registry = GetProtocolHandlerRegistry(); | 126 ProtocolHandlerRegistry* registry = GetProtocolHandlerRegistry(); |
125 ProtocolHandlerRegistry::ProtocolHandlerList ignored_handlers = | 127 ProtocolHandlerRegistry::ProtocolHandlerList ignored_handlers = |
126 registry->GetIgnoredHandlers(); | 128 registry->GetIgnoredHandlers(); |
127 return GetHandlersAsListValue(ignored_handlers, handlers); | 129 return GetHandlersAsListValue(ignored_handlers, handlers); |
128 } | 130 } |
129 | 131 |
130 void HandlerOptionsHandler::UpdateHandlerList() { | 132 void HandlerOptionsHandler::UpdateHandlerList() { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 | 215 |
214 void HandlerOptionsHandler::Observe( | 216 void HandlerOptionsHandler::Observe( |
215 int type, | 217 int type, |
216 const content::NotificationSource& source, | 218 const content::NotificationSource& source, |
217 const content::NotificationDetails& details) { | 219 const content::NotificationDetails& details) { |
218 DCHECK_EQ(chrome::NOTIFICATION_PROTOCOL_HANDLER_REGISTRY_CHANGED, type); | 220 DCHECK_EQ(chrome::NOTIFICATION_PROTOCOL_HANDLER_REGISTRY_CHANGED, type); |
219 UpdateHandlerList(); | 221 UpdateHandlerList(); |
220 } | 222 } |
221 | 223 |
222 } // namespace options | 224 } // namespace options |
OLD | NEW |