Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Side by Side Diff: trunk/src/extensions/common/event_matcher.cc

Issue 23945003: Revert 221619 "Initial chrome.mdns API." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « trunk/src/extensions/common/event_matcher.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "extensions/common/event_matcher.h" 5 #include "extensions/common/event_matcher.h"
6 6
7 #include "extensions/common/event_filtering_info.h" 7 #include "extensions/common/event_filtering_info.h"
8 8
9 namespace { 9 namespace {
10 const char kUrlFiltersKey[] = "url"; 10 const char kUrlFiltersKey[] = "url";
11 } 11 }
12 12
13 namespace extensions { 13 namespace extensions {
14 14
15 const char kEventFilterServiceTypeKey[] = "serviceType";
16
17 EventMatcher::EventMatcher(scoped_ptr<base::DictionaryValue> filter, 15 EventMatcher::EventMatcher(scoped_ptr<base::DictionaryValue> filter,
18 int routing_id) 16 int routing_id)
19 : filter_(filter.Pass()), 17 : filter_(filter.Pass()),
20 routing_id_(routing_id) { 18 routing_id_(routing_id) {
21 } 19 }
22 20
23 EventMatcher::~EventMatcher() { 21 EventMatcher::~EventMatcher() {
24 } 22 }
25 23
26 bool EventMatcher::MatchNonURLCriteria( 24 bool EventMatcher::MatchNonURLCriteria(
27 const EventFilteringInfo& event_info) const { 25 const EventFilteringInfo& event_info) const {
28 if (event_info.has_instance_id()) { 26 if (!event_info.has_instance_id())
29 return event_info.instance_id() == GetInstanceID(); 27 return true;
30 }
31 28
32 const std::string& service_type_filter = GetServiceTypeFilter(); 29 return event_info.instance_id() == GetInstanceID();
33 return service_type_filter.empty() ||
34 service_type_filter == event_info.service_type();
35 } 30 }
36 31
37 int EventMatcher::GetURLFilterCount() const { 32 int EventMatcher::GetURLFilterCount() const {
38 base::ListValue* url_filters = NULL; 33 base::ListValue* url_filters = NULL;
39 if (filter_->GetList(kUrlFiltersKey, &url_filters)) 34 if (filter_->GetList(kUrlFiltersKey, &url_filters))
40 return url_filters->GetSize(); 35 return url_filters->GetSize();
41 return 0; 36 return 0;
42 } 37 }
43 38
44 bool EventMatcher::GetURLFilter(int i, base::DictionaryValue** url_filter_out) { 39 bool EventMatcher::GetURLFilter(int i, base::DictionaryValue** url_filter_out) {
45 base::ListValue* url_filters = NULL; 40 base::ListValue* url_filters = NULL;
46 if (filter_->GetList(kUrlFiltersKey, &url_filters)) { 41 if (filter_->GetList(kUrlFiltersKey, &url_filters)) {
47 return url_filters->GetDictionary(i, url_filter_out); 42 return url_filters->GetDictionary(i, url_filter_out);
48 } 43 }
49 return false; 44 return false;
50 } 45 }
51 46
52 int EventMatcher::HasURLFilters() const { 47 int EventMatcher::HasURLFilters() const {
53 return GetURLFilterCount() != 0; 48 return GetURLFilterCount() != 0;
54 } 49 }
55 50
56 std::string EventMatcher::GetServiceTypeFilter() const {
57 std::string service_type_filter;
58 filter_->GetStringASCII(kEventFilterServiceTypeKey, &service_type_filter);
59 return service_type_filter;
60 }
61
62 int EventMatcher::GetInstanceID() const { 51 int EventMatcher::GetInstanceID() const {
63 int instance_id = 0; 52 int instance_id = 0;
64 filter_->GetInteger("instanceId", &instance_id); 53 filter_->GetInteger("instanceId", &instance_id);
65 return instance_id; 54 return instance_id;
66 } 55 }
67 56
68 int EventMatcher::GetRoutingID() const { 57 int EventMatcher::GetRoutingID() const {
69 return routing_id_; 58 return routing_id_;
70 } 59 }
71 60
72 } // namespace extensions 61 } // namespace extensions
OLDNEW
« no previous file with comments | « trunk/src/extensions/common/event_matcher.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698