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