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

Unified Diff: extensions/common/event_filtering_info.cc

Issue 2768093002: [Reland][Extensions Bindings] Add support for filtered events (Closed)
Patch Set: Fix Created 3 years, 9 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_filtering_info.h ('k') | extensions/renderer/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/common/event_filtering_info.cc
diff --git a/extensions/common/event_filtering_info.cc b/extensions/common/event_filtering_info.cc
index 4770d9e95227a951ef3ef9b0de41926115a5b69c..b8040e9c2cd9dcc1e748452a9af3dd62d719652c 100644
--- a/extensions/common/event_filtering_info.cc
+++ b/extensions/common/event_filtering_info.cc
@@ -12,6 +12,15 @@
namespace extensions {
+namespace {
+
+const char kInstanceId[] = "instanceId";
+const char kServiceType[] = "serviceType";
+const char kWindowType[] = "windowType";
+const char kWindowExposedByDefault[] = "windowExposedByDefault";
+
+}
+
EventFilteringInfo::EventFilteringInfo()
: has_url_(false),
has_instance_id_(false),
@@ -19,6 +28,24 @@ EventFilteringInfo::EventFilteringInfo()
has_window_type_(false),
has_window_exposed_by_default_(false) {}
+EventFilteringInfo::EventFilteringInfo(const base::DictionaryValue& dict)
+ : EventFilteringInfo() {
+ std::string url;
+ if (dict.GetString("url", &url)) {
+ GURL maybe_url(url);
+ if (maybe_url.is_valid()) {
+ has_url_ = true;
+ url_.Swap(&maybe_url);
+ }
+ }
+
+ has_instance_id_ = dict.GetInteger(kInstanceId, &instance_id_);
+ dict.GetString(kServiceType, &service_type_);
+ has_window_type_ = dict.GetString(kWindowType, &window_type_);
+ has_window_exposed_by_default_ =
+ dict.GetBoolean(kWindowExposedByDefault, &window_exposed_by_default_);
+}
+
EventFilteringInfo::EventFilteringInfo(const EventFilteringInfo& other) =
default;
@@ -51,16 +78,16 @@ std::unique_ptr<base::DictionaryValue> EventFilteringInfo::AsValue() const {
result->SetString("url", url_.spec());
if (has_instance_id_)
- result->SetInteger("instanceId", instance_id_);
+ result->SetInteger(kInstanceId, instance_id_);
if (!service_type_.empty())
- result->SetString("serviceType", service_type_);
+ result->SetString(kServiceType, service_type_);
if (has_window_type_)
- result->SetString("windowType", window_type_);
+ result->SetString(kWindowType, window_type_);
if (has_window_exposed_by_default_)
- result->SetBoolean("windowExposedByDefault", window_exposed_by_default_);
+ result->SetBoolean(kWindowExposedByDefault, window_exposed_by_default_);
return result;
}
« no previous file with comments | « extensions/common/event_filtering_info.h ('k') | extensions/renderer/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698