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 #include "extensions/common/event_filtering_info.h"
7 #include "base/json/json_writer.h"
8 #include "base/values.h"
10 namespace extensions
{
12 EventFilteringInfo::EventFilteringInfo()
14 has_instance_id_(false),
16 has_window_type_(false),
17 has_window_exposed_by_default_(false) {}
19 EventFilteringInfo::~EventFilteringInfo() {
22 void EventFilteringInfo::SetWindowType(const std::string
& window_type
) {
23 window_type_
= window_type
;
24 has_window_type_
= true;
27 void EventFilteringInfo::SetWindowExposedByDefault(const bool exposed
) {
28 window_exposed_by_default_
= exposed
;
29 has_window_exposed_by_default_
= true;
32 void EventFilteringInfo::SetURL(const GURL
& url
) {
37 void EventFilteringInfo::SetInstanceID(int instance_id
) {
38 instance_id_
= instance_id
;
39 has_instance_id_
= true;
42 scoped_ptr
<base::Value
> EventFilteringInfo::AsValue() const {
44 return base::Value::CreateNullValue();
46 scoped_ptr
<base::DictionaryValue
> result(new base::DictionaryValue
);
48 result
->SetString("url", url_
.spec());
51 result
->SetInteger("instanceId", instance_id_
);
53 if (!service_type_
.empty())
54 result
->SetString("serviceType", service_type_
);
57 result
->SetString("windowType", window_type_
);
59 if (has_window_exposed_by_default_
)
60 result
->SetBoolean("windowExposedByDefault", window_exposed_by_default_
);
65 bool EventFilteringInfo::IsEmpty() const {
66 return !has_window_type_
&& !has_url_
&& service_type_
.empty() &&
67 !has_instance_id_
&& !has_window_exposed_by_default_
;
70 } // namespace extensions