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"
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'}],
25 class 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
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;
58 std::string service_type_
;
60 bool has_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_