diff options
author | justinlin@chromium.org <justinlin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-06 07:21:08 +0000 |
---|---|---|
committer | justinlin@chromium.org <justinlin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-06 07:21:08 +0000 |
commit | 5556c5d23047abd3a19705103a1ec14b1026d92e (patch) | |
tree | 94349edac8fb53dd7aadacf74122f16cc9eb0a47 /extensions/common/event_matcher.cc | |
parent | 9bbaad67d5fe08d314c9e9e3cdd88bb6ddabcd1c (diff) | |
download | chromium_src-5556c5d23047abd3a19705103a1ec14b1026d92e.zip chromium_src-5556c5d23047abd3a19705103a1ec14b1026d92e.tar.gz chromium_src-5556c5d23047abd3a19705103a1ec14b1026d92e.tar.bz2 |
Initial chrome.mdns API.
Currently just implements the API layer which allows adding a listener and defines a manifest key to specify mdns service types to watch.
BUG=280900
TBR=erg
Review URL: https://chromiumcodereview.appspot.com/23437015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221619 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'extensions/common/event_matcher.cc')
-rw-r--r-- | extensions/common/event_matcher.cc | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/extensions/common/event_matcher.cc b/extensions/common/event_matcher.cc index ad76c89..8ae022a 100644 --- a/extensions/common/event_matcher.cc +++ b/extensions/common/event_matcher.cc @@ -12,6 +12,8 @@ const char kUrlFiltersKey[] = "url"; namespace extensions { +const char kEventFilterServiceTypeKey[] = "serviceType"; + EventMatcher::EventMatcher(scoped_ptr<base::DictionaryValue> filter, int routing_id) : filter_(filter.Pass()), @@ -23,10 +25,13 @@ EventMatcher::~EventMatcher() { bool EventMatcher::MatchNonURLCriteria( const EventFilteringInfo& event_info) const { - if (!event_info.has_instance_id()) - return true; + if (event_info.has_instance_id()) { + return event_info.instance_id() == GetInstanceID(); + } - return event_info.instance_id() == GetInstanceID(); + const std::string& service_type_filter = GetServiceTypeFilter(); + return service_type_filter.empty() || + service_type_filter == event_info.service_type(); } int EventMatcher::GetURLFilterCount() const { @@ -48,6 +53,12 @@ int EventMatcher::HasURLFilters() const { return GetURLFilterCount() != 0; } +std::string EventMatcher::GetServiceTypeFilter() const { + std::string service_type_filter; + filter_->GetStringASCII(kEventFilterServiceTypeKey, &service_type_filter); + return service_type_filter; +} + int EventMatcher::GetInstanceID() const { int instance_id = 0; filter_->GetInteger("instanceId", &instance_id); |