Blink roll 25b6bd3a7a131ffe68d809546ad1a20707915cdc:3a503f41ae42e5b79cfcd2ff10e65afde...
[chromium-blink-merge.git] / extensions / common / event_filtering_info.h
bloba3587986a9ece864024876dab462af867538615a
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 SetURL(const GURL& url);
30 void SetInstanceID(int instance_id);
31 void SetServiceType(const std::string& service_type) {
32 service_type_ = service_type;
35 bool has_url() const { return has_url_; }
36 const GURL& url() const { return url_; }
38 bool has_instance_id() const { return has_instance_id_; }
39 int instance_id() const { return instance_id_; }
41 bool has_service_type() const { return !service_type_.empty(); }
42 const std::string& service_type() const { return service_type_; }
44 scoped_ptr<base::Value> AsValue() const;
45 bool IsEmpty() const;
47 private:
48 bool has_url_;
49 GURL url_;
50 std::string service_type_;
52 bool has_instance_id_;
53 int instance_id_;
55 // Allow implicit copy and assignment.
58 } // namespace extensions
60 #endif // EXTENSIONS_COMMON_EVENT_FILTERING_INFO_H_