Migrate to github hosting of CLD2 project.
[chromium-blink-merge.git] / extensions / common / event_filtering_info.h
blobf51e3d2b5fe3eb598eb7eae3d958e28adb7d919b
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef EXTENSIONS_COMMON_EVENT_FILTERING_INFO_H_
6 #define EXTENSIONS_COMMON_EVENT_FILTERING_INFO_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "url/gurl.h"
11 namespace base {
12 class Value;
15 namespace extensions {
17 // Extra information about an event that is used in event filtering.
19 // This is the information that is matched against criteria specified in JS
20 // extension event listeners. Eg:
22 // chrome.someApi.onSomeEvent.addListener(cb,
23 // {url: [{hostSuffix: 'google.com'}],
24 // tabId: 1});
25 class EventFilteringInfo {
26 public:
27 EventFilteringInfo();
28 ~EventFilteringInfo();
29 void SetWindowType(const std::string& window_type);
30 void SetURL(const GURL& url);
31 void SetInstanceID(int instance_id);
32 void SetServiceType(const std::string& service_type) {
33 service_type_ = service_type;
36 // Note: window type is a Chrome concept, so arguably doesn't belong
37 // in the extensions module. If the number of Chrome concept grows,
38 // consider a delegation model with a ChromeEventFilteringInfo
39 // class.
40 bool has_window_type() const { return has_window_type_; }
41 const std::string& window_type() const { return window_type_; }
43 bool has_url() const { return has_url_; }
44 const GURL& url() const { return url_; }
46 bool has_instance_id() const { return has_instance_id_; }
47 int instance_id() const { return instance_id_; }
49 bool has_service_type() const { return !service_type_.empty(); }
50 const std::string& service_type() const { return service_type_; }
52 scoped_ptr<base::Value> AsValue() const;
53 bool IsEmpty() const;
55 private:
56 bool has_url_;
57 GURL url_;
58 std::string service_type_;
60 bool has_instance_id_;
61 int instance_id_;
63 bool has_window_type_;
64 std::string window_type_;
66 // Allow implicit copy and assignment.
69 } // namespace extensions
71 #endif // EXTENSIONS_COMMON_EVENT_FILTERING_INFO_H_