summaryrefslogtreecommitdiffstats
path: root/extensions/common/event_matcher.cc
diff options
context:
space:
mode:
authorlionel.g.landwerlin <lionel.g.landwerlin@intel.com>2015-08-24 14:26:57 -0700
committerCommit bot <commit-bot@chromium.org>2015-08-24 21:27:40 +0000
commit63f0e25e37e32f84652883f02c3997f80a5a061c (patch)
treefaf3549ee07c4505134a7bcd81ddfd3b53e1ebaf /extensions/common/event_matcher.cc
parentb48815ca35b565e6ca372640ac25f79ee1a84c7e (diff)
downloadchromium_src-63f0e25e37e32f84652883f02c3997f80a5a061c.zip
chromium_src-63f0e25e37e32f84652883f02c3997f80a5a061c.tar.gz
chromium_src-63f0e25e37e32f84652883f02c3997f80a5a061c.tar.bz2
extensions: windows: list app windows of the current extension
When window types filter was added to the chrome.windows API, the behavior of the API changed to not list the extension's own application windows. This CL reverts back to the original behavior of the API : When no window types filter is given, all normal and popup windows are listed and additionally the current extension's application and panel windows are also listed. But application and panel windows of other extensions are not. The addition to the original behavior is : When a window types filter is given, all windows regardless of what extension created them, will be listed and filtered using the given window types. BUG=518745 Review URL: https://codereview.chromium.org/1287653002 Cr-Commit-Position: refs/heads/master@{#345182}
Diffstat (limited to 'extensions/common/event_matcher.cc')
-rw-r--r--extensions/common/event_matcher.cc22
1 files changed, 14 insertions, 8 deletions
diff --git a/extensions/common/event_matcher.cc b/extensions/common/event_matcher.cc
index 0071111..a5e6fc5 100644
--- a/extensions/common/event_matcher.cc
+++ b/extensions/common/event_matcher.cc
@@ -11,8 +11,6 @@
namespace {
const char kUrlFiltersKey[] = "url";
const char kWindowTypesKey[] = "windowTypes";
-
-const char* const kDefaultWindowTypes[] = {"normal", "panel", "popup"};
}
namespace extensions {
@@ -44,6 +42,14 @@ bool EventMatcher::MatchNonURLCriteria(
return false;
}
+ if (event_info.has_window_exposed_by_default()) {
+ // An event with a |window_exposed_by_default| set is only
+ // relevant to the listener if no window type filter is set.
+ if (HasWindowTypes())
+ return false;
+ return event_info.window_exposed_by_default();
+ }
+
const std::string& service_type_filter = GetServiceTypeFilter();
return service_type_filter.empty() ||
service_type_filter == event_info.service_type();
@@ -64,7 +70,7 @@ bool EventMatcher::GetURLFilter(int i, base::DictionaryValue** url_filter_out) {
return false;
}
-int EventMatcher::HasURLFilters() const {
+bool EventMatcher::HasURLFilters() const {
return GetURLFilterCount() != 0;
}
@@ -84,7 +90,7 @@ int EventMatcher::GetWindowTypeCount() const {
base::ListValue* window_type_filters = nullptr;
if (filter_->GetList(kWindowTypesKey, &window_type_filters))
return window_type_filters->GetSize();
- return arraysize(kDefaultWindowTypes);
+ return 0;
}
bool EventMatcher::GetWindowType(int i, std::string* window_type_out) const {
@@ -92,13 +98,13 @@ bool EventMatcher::GetWindowType(int i, std::string* window_type_out) const {
if (filter_->GetList(kWindowTypesKey, &window_types)) {
return window_types->GetString(i, window_type_out);
}
- if (i >= 0 && i < static_cast<int>(arraysize(kDefaultWindowTypes))) {
- *window_type_out = kDefaultWindowTypes[i];
- return true;
- }
return false;
}
+bool EventMatcher::HasWindowTypes() const {
+ return GetWindowTypeCount() != 0;
+}
+
int EventMatcher::GetRoutingID() const {
return routing_id_;
}