| 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;
|
| }
|
|
|