OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "extensions/common/event_filtering_info.h" | 5 #include "extensions/common/event_filtering_info.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 void EventFilteringInfo::SetURL(const GURL& url) { | 37 void EventFilteringInfo::SetURL(const GURL& url) { |
38 url_ = url; | 38 url_ = url; |
39 has_url_ = true; | 39 has_url_ = true; |
40 } | 40 } |
41 | 41 |
42 void EventFilteringInfo::SetInstanceID(int instance_id) { | 42 void EventFilteringInfo::SetInstanceID(int instance_id) { |
43 instance_id_ = instance_id; | 43 instance_id_ = instance_id; |
44 has_instance_id_ = true; | 44 has_instance_id_ = true; |
45 } | 45 } |
46 | 46 |
47 scoped_ptr<base::Value> EventFilteringInfo::AsValue() const { | 47 std::unique_ptr<base::Value> EventFilteringInfo::AsValue() const { |
48 if (IsEmpty()) | 48 if (IsEmpty()) |
49 return base::Value::CreateNullValue(); | 49 return base::Value::CreateNullValue(); |
50 | 50 |
51 scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue); | 51 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue); |
52 if (has_url_) | 52 if (has_url_) |
53 result->SetString("url", url_.spec()); | 53 result->SetString("url", url_.spec()); |
54 | 54 |
55 if (has_instance_id_) | 55 if (has_instance_id_) |
56 result->SetInteger("instanceId", instance_id_); | 56 result->SetInteger("instanceId", instance_id_); |
57 | 57 |
58 if (!service_type_.empty()) | 58 if (!service_type_.empty()) |
59 result->SetString("serviceType", service_type_); | 59 result->SetString("serviceType", service_type_); |
60 | 60 |
61 if (has_window_type_) | 61 if (has_window_type_) |
62 result->SetString("windowType", window_type_); | 62 result->SetString("windowType", window_type_); |
63 | 63 |
64 if (has_window_exposed_by_default_) | 64 if (has_window_exposed_by_default_) |
65 result->SetBoolean("windowExposedByDefault", window_exposed_by_default_); | 65 result->SetBoolean("windowExposedByDefault", window_exposed_by_default_); |
66 | 66 |
67 return std::move(result); | 67 return std::move(result); |
68 } | 68 } |
69 | 69 |
70 bool EventFilteringInfo::IsEmpty() const { | 70 bool EventFilteringInfo::IsEmpty() const { |
71 return !has_window_type_ && !has_url_ && service_type_.empty() && | 71 return !has_window_type_ && !has_url_ && service_type_.empty() && |
72 !has_instance_id_ && !has_window_exposed_by_default_; | 72 !has_instance_id_ && !has_window_exposed_by_default_; |
73 } | 73 } |
74 | 74 |
75 } // namespace extensions | 75 } // namespace extensions |
OLD | NEW |