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" | |
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 "components/google/core/browser/google_util.h" | 20 #include "components/google/core/browser/google_util.h" |
22 #include "components/prefs/pref_service.h" | 21 #include "components/prefs/pref_service.h" |
23 #include "content/public/browser/web_ui.h" | 22 #include "content/public/browser/web_ui.h" |
24 | 23 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 // for Handlers. Please update them whenever you add or remove any keys here. | 92 // for Handlers. Please update them whenever you add or remove any keys here. |
94 handlers_value->SetString("protocol", protocol); | 93 handlers_value->SetString("protocol", protocol); |
95 handlers_value->SetInteger("default_handler", | 94 handlers_value->SetInteger("default_handler", |
96 registry->GetHandlerIndex(protocol)); | 95 registry->GetHandlerIndex(protocol)); |
97 handlers_value->SetBoolean( | 96 handlers_value->SetBoolean( |
98 "is_default_handler_set_by_user", | 97 "is_default_handler_set_by_user", |
99 registry->IsRegisteredByUser(registry->GetHandlerFor(protocol))); | 98 registry->IsRegisteredByUser(registry->GetHandlerFor(protocol))); |
100 handlers_value->SetBoolean("has_policy_recommendations", | 99 handlers_value->SetBoolean("has_policy_recommendations", |
101 registry->HasPolicyRegisteredHandler(protocol)); | 100 registry->HasPolicyRegisteredHandler(protocol)); |
102 | 101 |
103 auto handlers_list = base::MakeUnique<base::ListValue>(); | 102 base::ListValue* handlers_list = new base::ListValue(); |
104 GetHandlersAsListValue(registry->GetHandlersFor(protocol), | 103 GetHandlersAsListValue(registry->GetHandlersFor(protocol), handlers_list); |
105 handlers_list.get()); | 104 handlers_value->Set("handlers", handlers_list); |
106 handlers_value->Set("handlers", std::move(handlers_list)); | |
107 } | 105 } |
108 | 106 |
109 void ProtocolHandlersHandler::GetIgnoredHandlers(base::ListValue* handlers) { | 107 void ProtocolHandlersHandler::GetIgnoredHandlers(base::ListValue* handlers) { |
110 ProtocolHandlerRegistry* registry = GetProtocolHandlerRegistry(); | 108 ProtocolHandlerRegistry* registry = GetProtocolHandlerRegistry(); |
111 ProtocolHandlerRegistry::ProtocolHandlerList ignored_handlers = | 109 ProtocolHandlerRegistry::ProtocolHandlerList ignored_handlers = |
112 registry->GetIgnoredHandlers(); | 110 registry->GetIgnoredHandlers(); |
113 return GetHandlersAsListValue(ignored_handlers, handlers); | 111 return GetHandlersAsListValue(ignored_handlers, handlers); |
114 } | 112 } |
115 | 113 |
116 void ProtocolHandlersHandler::UpdateHandlerList() { | 114 void ProtocolHandlersHandler::UpdateHandlerList() { |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 void ProtocolHandlersHandler::Observe( | 220 void ProtocolHandlersHandler::Observe( |
223 int type, | 221 int type, |
224 const content::NotificationSource& source, | 222 const content::NotificationSource& source, |
225 const content::NotificationDetails& details) { | 223 const content::NotificationDetails& details) { |
226 DCHECK_EQ(chrome::NOTIFICATION_PROTOCOL_HANDLER_REGISTRY_CHANGED, type); | 224 DCHECK_EQ(chrome::NOTIFICATION_PROTOCOL_HANDLER_REGISTRY_CHANGED, type); |
227 SendHandlersEnabledValue(); | 225 SendHandlersEnabledValue(); |
228 UpdateHandlerList(); | 226 UpdateHandlerList(); |
229 } | 227 } |
230 | 228 |
231 } // namespace settings | 229 } // namespace settings |
OLD | NEW |