| Index: extensions/common/event_filtering_info.cc
|
| diff --git a/extensions/common/event_filtering_info.cc b/extensions/common/event_filtering_info.cc
|
| index b8040e9c2cd9dcc1e748452a9af3dd62d719652c..17ea7a079f123963d6d2611ca42bbb8ef4850e15 100644
|
| --- a/extensions/common/event_filtering_info.cc
|
| +++ b/extensions/common/event_filtering_info.cc
|
| @@ -21,73 +21,66 @@ const char kWindowExposedByDefault[] = "windowExposedByDefault";
|
|
|
| }
|
|
|
| -EventFilteringInfo::EventFilteringInfo()
|
| - : has_url_(false),
|
| - has_instance_id_(false),
|
| - instance_id_(0),
|
| - has_window_type_(false),
|
| - has_window_exposed_by_default_(false) {}
|
| +EventFilteringInfo::EventFilteringInfo() {}
|
|
|
| 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);
|
| + {
|
| + std::string dict_url;
|
| + if (dict.GetString("url", &dict_url)) {
|
| + GURL maybe_url(dict_url);
|
| + if (maybe_url.is_valid())
|
| + url = std::move(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;
|
| + {
|
| + int dict_instance_id = 0;
|
| + if (dict.GetInteger(kInstanceId, &dict_instance_id))
|
| + instance_id = dict_instance_id;
|
| + }
|
|
|
| -EventFilteringInfo::~EventFilteringInfo() {
|
| -}
|
| + {
|
| + std::string dict_service_type;
|
| + if (dict.GetString(kServiceType, &dict_service_type))
|
| + service_type = std::move(dict_service_type);
|
| + }
|
|
|
| -void EventFilteringInfo::SetWindowType(const std::string& window_type) {
|
| - window_type_ = window_type;
|
| - has_window_type_ = true;
|
| -}
|
| + {
|
| + std::string dict_window_type;
|
| + if (dict.GetString(kWindowType, &dict_window_type))
|
| + window_type = std::move(dict_window_type);
|
| + }
|
|
|
| -void EventFilteringInfo::SetWindowExposedByDefault(const bool exposed) {
|
| - window_exposed_by_default_ = exposed;
|
| - has_window_exposed_by_default_ = true;
|
| + {
|
| + bool dict_window_exposed_by_default = false;
|
| + if (dict.GetBoolean(kWindowExposedByDefault,
|
| + &dict_window_exposed_by_default))
|
| + window_exposed_by_default = dict_window_exposed_by_default;
|
| + }
|
| }
|
|
|
| -void EventFilteringInfo::SetURL(const GURL& url) {
|
| - url_ = url;
|
| - has_url_ = true;
|
| -}
|
| +EventFilteringInfo::EventFilteringInfo(const EventFilteringInfo& other) =
|
| + default;
|
|
|
| -void EventFilteringInfo::SetInstanceID(int instance_id) {
|
| - instance_id_ = instance_id;
|
| - has_instance_id_ = true;
|
| -}
|
| +EventFilteringInfo::~EventFilteringInfo() {}
|
|
|
| std::unique_ptr<base::DictionaryValue> EventFilteringInfo::AsValue() const {
|
| auto result = base::MakeUnique<base::DictionaryValue>();
|
| - if (has_url_)
|
| - result->SetString("url", url_.spec());
|
| + if (url)
|
| + result->SetString("url", url->spec());
|
|
|
| - if (has_instance_id_)
|
| - result->SetInteger(kInstanceId, instance_id_);
|
| + if (instance_id)
|
| + result->SetInteger(kInstanceId, *instance_id);
|
|
|
| - if (!service_type_.empty())
|
| - result->SetString(kServiceType, service_type_);
|
| + if (service_type)
|
| + result->SetString(kServiceType, *service_type);
|
|
|
| - if (has_window_type_)
|
| - result->SetString(kWindowType, window_type_);
|
| + if (window_type)
|
| + result->SetString(kWindowType, *window_type);
|
|
|
| - if (has_window_exposed_by_default_)
|
| - result->SetBoolean(kWindowExposedByDefault, window_exposed_by_default_);
|
| + if (window_exposed_by_default)
|
| + result->SetBoolean(kWindowExposedByDefault, *window_exposed_by_default);
|
|
|
| return result;
|
| }
|
|
|