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

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: Disable focus event tests on MacOSX Created 5 years, 5 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
Index: extensions/common/event_matcher.cc
diff --git a/extensions/common/event_matcher.cc b/extensions/common/event_matcher.cc
index 8ae022a00e8845bcb749813c3e973bf847932649..b504b8cf3a9e015510798e6548ea586516a3c16d 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,6 +34,16 @@ 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();
@@ -65,6 +80,24 @@ int EventMatcher::GetInstanceID() const {
return instance_id;
}
+int EventMatcher::GetWindowTypeCount() const {
+ base::ListValue* window_type_filters = NULL;
not at google - send to devlin 2015/07/31 21:48:03 NULL --> nullptr
llandwerlin-old 2015/08/03 10:11:54 Done.
+ 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 = NULL;
+ if (filter_->GetList(kWindowTypesKey, &window_types)) {
+ return window_types->GetString(i, window_type_out);
+ } else if (i >= 0 && i < static_cast<int>(arraysize(kDefaultWindowTypes))) {
not at google - send to devlin 2015/07/31 21:48:03 In this case I think it's clearer if you don't put
llandwerlin-old 2015/08/03 10:11:54 Done, fyi arraysize is defined using sizeof which
+ *window_type_out = kDefaultWindowTypes[i];
+ return true;
+ }
+ return false;
+}
+
int EventMatcher::GetRoutingID() const {
return routing_id_;
}

Powered by Google App Engine
This is Rietveld 408576698