summaryrefslogtreecommitdiffstats
path: root/extensions/common/event_matcher.cc
diff options
context:
space:
mode:
authorjustinlin@chromium.org <justinlin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-06 18:25:57 +0000
committerjustinlin@chromium.org <justinlin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-06 18:25:57 +0000
commit267864ead556030ad3413bcb8e466cbdc31986bb (patch)
treeab373536392771465b31367f037b0866b39fb851 /extensions/common/event_matcher.cc
parent779a78fb020cba65f0038a0e7818893ebb509877 (diff)
downloadchromium_src-267864ead556030ad3413bcb8e466cbdc31986bb.zip
chromium_src-267864ead556030ad3413bcb8e466cbdc31986bb.tar.gz
chromium_src-267864ead556030ad3413bcb8e466cbdc31986bb.tar.bz2
Initial chrome.mdns API.
BUG=280900 TBR=erg Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=221619 Review URL: https://chromiumcodereview.appspot.com/23437015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221738 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'extensions/common/event_matcher.cc')
-rw-r--r--extensions/common/event_matcher.cc17
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);