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) {}
18 EventFilteringInfo::~EventFilteringInfo() {
21 void EventFilteringInfo::SetWindowType(const std::string
& window_type
) {
22 window_type_
= window_type
;
23 has_window_type_
= true;
26 void EventFilteringInfo::SetURL(const GURL
& url
) {
31 void EventFilteringInfo::SetInstanceID(int instance_id
) {
32 instance_id_
= instance_id
;
33 has_instance_id_
= true;
36 scoped_ptr
<base::Value
> EventFilteringInfo::AsValue() const {
38 return base::Value::CreateNullValue();
40 scoped_ptr
<base::DictionaryValue
> result(new base::DictionaryValue
);
42 result
->SetString("url", url_
.spec());
45 result
->SetInteger("instanceId", instance_id_
);
47 if (!service_type_
.empty())
48 result
->SetString("serviceType", service_type_
);
51 result
->SetString("windowType", window_type_
);
56 bool EventFilteringInfo::IsEmpty() const {
57 return !has_window_type_
&& !has_url_
&& service_type_
.empty() &&
61 } // namespace extensions