blob: aaa03a4200c044bfda002bd0871768676c588edb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef EXTENSIONS_COMMON_EVENT_FILTERING_INFO_H_
#define EXTENSIONS_COMMON_EVENT_FILTERING_INFO_H_
#include "base/memory/scoped_ptr.h"
#include "url/gurl.h"
namespace base {
class Value;
}
namespace extensions {
// Extra information about an event that is used in event filtering.
//
// This is the information that is matched against criteria specified in JS
// extension event listeners. Eg:
//
// chrome.someApi.onSomeEvent.addListener(cb,
// {url: [{hostSuffix: 'google.com'}],
// tabId: 1});
class EventFilteringInfo {
public:
EventFilteringInfo();
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;
}
// 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_; }
// 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_; }
scoped_ptr<base::Value> AsValue() const;
bool IsEmpty() 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
#endif // EXTENSIONS_COMMON_EVENT_FILTERING_INFO_H_
|