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

Unified Diff: extensions/common/event_filtering_info.h

Issue 2937623002: [Extensions] Simplify EventFilteringInfo (Closed)
Patch Set: karan's Created 3 years, 6 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_filter_unittest.cc ('k') | extensions/common/event_filtering_info.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/common/event_filtering_info.h
diff --git a/extensions/common/event_filtering_info.h b/extensions/common/event_filtering_info.h
index ea7596cabb14ca2b8c2b8ba5573783b232c03da9..9b81c48d85cc471950c77c9c046a31d08d1f0c4d 100644
--- a/extensions/common/event_filtering_info.h
+++ b/extensions/common/event_filtering_info.h
@@ -7,6 +7,7 @@
#include <memory>
+#include "base/optional.h"
#include "url/gurl.h"
namespace base {
@@ -23,61 +24,29 @@ namespace extensions {
// chrome.someApi.onSomeEvent.addListener(cb,
// {url: [{hostSuffix: 'google.com'}],
// tabId: 1});
-class EventFilteringInfo {
+struct EventFilteringInfo {
public:
EventFilteringInfo();
explicit EventFilteringInfo(const base::DictionaryValue& dict);
EventFilteringInfo(const EventFilteringInfo& other);
~EventFilteringInfo();
- void SetWindowExposedByDefault(bool exposed);
- void SetWindowType(const std::string& window_type);
- void SetURL(const GURL& url);
- void SetInstanceID(int instance_id);
- void SetServiceType(const std::string& service_type) {
- service_type_ = service_type;
- }
+
+ base::Optional<GURL> url;
+ base::Optional<std::string> service_type;
+ base::Optional<int> instance_id;
// Note: window type & visible are Chrome concepts, so arguably
// doesn't belong in the extensions module. If the number of Chrome
// concept grows, consider a delegation model with a
// ChromeEventFilteringInfo class.
- bool has_window_type() const { return has_window_type_; }
- const std::string& window_type() const { return window_type_; }
+ base::Optional<std::string> window_type;
// By default events related to windows are filtered based on the
// listener's extension. This parameter will be set if the listener
// didn't set any filter on window types.
- bool has_window_exposed_by_default() const {
- return has_window_exposed_by_default_;
- }
- bool window_exposed_by_default() const { return window_exposed_by_default_; }
-
- bool has_url() const { return has_url_; }
- const GURL& url() const { return url_; }
-
- bool has_instance_id() const { return has_instance_id_; }
- int instance_id() const { return instance_id_; }
-
- bool has_service_type() const { return !service_type_.empty(); }
- const std::string& service_type() const { return service_type_; }
+ base::Optional<bool> window_exposed_by_default;
std::unique_ptr<base::DictionaryValue> AsValue() const;
-
- private:
- bool has_url_;
- GURL url_;
- std::string service_type_;
-
- bool has_instance_id_;
- int instance_id_;
-
- bool has_window_type_;
- std::string window_type_;
-
- bool has_window_exposed_by_default_;
- bool window_exposed_by_default_;
-
- // Allow implicit copy and assignment.
};
} // namespace extensions
« no previous file with comments | « extensions/common/event_filter_unittest.cc ('k') | extensions/common/event_filtering_info.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698