Chromium Code Reviews| Index: chrome/browser/extensions/api/mdns/mdns_api.cc |
| diff --git a/chrome/browser/extensions/api/mdns/mdns_api.cc b/chrome/browser/extensions/api/mdns/mdns_api.cc |
| index 572ae1eec7b08e50906f96f94aeda0314b75d1c0..d27c448bca168a0a37a171f91f9abcf5deb2fde0 100644 |
| --- a/chrome/browser/extensions/api/mdns/mdns_api.cc |
| +++ b/chrome/browser/extensions/api/mdns/mdns_api.cc |
| @@ -10,6 +10,7 @@ |
| #include "base/profiler/scoped_profile.h" |
| #include "chrome/browser/extensions/extension_service.h" |
| #include "chrome/common/extensions/api/mdns.h" |
| +#include "extensions/browser/extension_registry.h" |
| namespace extensions { |
| @@ -22,7 +23,11 @@ const char kCastServiceType[] = "_googlecast._tcp.local"; |
| const char kPrivetServiceType[] = "_privet._tcp.local"; |
| const char kTestServiceType[] = "_testing._tcp.local"; |
| -bool IsServiceTypeWhitelisted(const std::string& service_type) { |
| +bool IsServiceTypeWhitelisted(const std::string& service_type, |
| + bool is_extension) { |
| + if (!is_extension) { |
| + return true; |
| + } |
| return service_type == kCastServiceType || |
| service_type == kPrivetServiceType || |
| service_type == kTestServiceType; |
| @@ -109,21 +114,33 @@ void MDnsAPI::UpdateMDnsListeners(const EventListenerInfo& details) { |
| std::set<std::string> removed_service_types = |
| base::STLSetDifference<std::set<std::string> >( |
| service_types_, new_service_types); |
| + service_types_ = new_service_types; |
| // Update the registry. |
| DnsSdRegistry* registry = dns_sd_registry(); |
| + |
| + const extensions::ExtensionRegistry* ext_registry = |
|
not at google - send to devlin
2014/11/17 23:22:15
This file is in the extensions namespace, no exten
Red Daly
2014/11/19 21:31:50
Done.
|
| + extensions::ExtensionRegistry::Get(details.browser_context); |
| + if (!ext_registry) { |
|
not at google - send to devlin
2014/11/17 23:22:15
There should always be an ExtensionRegistry, since
Red Daly
2014/11/19 21:31:50
Done.
|
| + return; |
| + } |
| + const extensions::Extension* extension = ext_registry->GetExtensionById( |
|
not at google - send to devlin
2014/11/17 23:22:15
Why do you want all extensions, rather than just t
Red Daly
2014/11/19 21:31:50
I assumed the extension is enabled if UpdateMDnsLi
Red Daly
2015/01/26 21:55:33
I checked and this assumption was incorrect: This
|
| + details.extension_id, |
| + extensions::ExtensionRegistry::EVERYTHING); |
| + if (!extension) { |
| + return; |
| + } |
| + |
| for (std::set<std::string>::iterator it = added_service_types.begin(); |
| it != added_service_types.end(); ++it) { |
| - if (IsServiceTypeWhitelisted(*it)) |
| + if (IsServiceTypeWhitelisted(*it, extension->is_extension())) |
|
not at google - send to devlin
2014/11/17 23:22:15
I don't understand what the fact that an Extension
Red Daly
2014/11/19 21:31:50
This change is in response to Mark's earlier comme
|
| registry->RegisterDnsSdListener(*it); |
| } |
| for (std::set<std::string>::iterator it = removed_service_types.begin(); |
| it != removed_service_types.end(); ++it) { |
| - if (IsServiceTypeWhitelisted(*it)) |
| + if (IsServiceTypeWhitelisted(*it, extension->is_extension())) |
| registry->UnregisterDnsSdListener(*it); |
| } |
| - |
| - service_types_ = new_service_types; |
| } |
| void MDnsAPI::OnDnsSdEvent(const std::string& service_type, |