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

Unified Diff: extensions/common/event_matcher.cc

Issue 1099553002: extensions: windows: list all windows from the current profile (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « extensions/common/event_matcher.h ('k') | extensions/renderer/event_bindings.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/common/event_matcher.cc
diff --git a/extensions/common/event_matcher.cc b/extensions/common/event_matcher.cc
index 8ae022a00e8845bcb749813c3e973bf847932649..007111186aefe10b8ab6189a88100aea3b1388d2 100644
--- a/extensions/common/event_matcher.cc
+++ b/extensions/common/event_matcher.cc
@@ -2,12 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/callback.h"
+
#include "extensions/common/event_matcher.h"
#include "extensions/common/event_filtering_info.h"
namespace {
const char kUrlFiltersKey[] = "url";
+const char kWindowTypesKey[] = "windowTypes";
+
+const char* const kDefaultWindowTypes[] = {"normal", "panel", "popup"};
}
namespace extensions {
@@ -29,20 +34,30 @@ bool EventMatcher::MatchNonURLCriteria(
return event_info.instance_id() == GetInstanceID();
}
+ if (event_info.has_window_type()) {
+ for (int i = 0; i < GetWindowTypeCount(); i++) {
+ std::string window_type;
+ if (GetWindowType(i, &window_type) &&
+ window_type == event_info.window_type())
+ return true;
+ }
+ return false;
+ }
+
const std::string& service_type_filter = GetServiceTypeFilter();
return service_type_filter.empty() ||
service_type_filter == event_info.service_type();
}
int EventMatcher::GetURLFilterCount() const {
- base::ListValue* url_filters = NULL;
+ base::ListValue* url_filters = nullptr;
if (filter_->GetList(kUrlFiltersKey, &url_filters))
return url_filters->GetSize();
return 0;
}
bool EventMatcher::GetURLFilter(int i, base::DictionaryValue** url_filter_out) {
- base::ListValue* url_filters = NULL;
+ base::ListValue* url_filters = nullptr;
if (filter_->GetList(kUrlFiltersKey, &url_filters)) {
return url_filters->GetDictionary(i, url_filter_out);
}
@@ -65,6 +80,25 @@ int EventMatcher::GetInstanceID() const {
return instance_id;
}
+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);
+}
+
+bool EventMatcher::GetWindowType(int i, std::string* window_type_out) const {
+ base::ListValue* window_types = nullptr;
+ 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;
+}
+
int EventMatcher::GetRoutingID() const {
return routing_id_;
}
« no previous file with comments | « extensions/common/event_matcher.h ('k') | extensions/renderer/event_bindings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698