| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/common/extensions/api/bluetooth/bluetooth_manifest_permission.h
" | 5 #include "chrome/common/extensions/api/bluetooth/bluetooth_manifest_permission.h
" |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 return true; | 152 return true; |
| 153 } | 153 } |
| 154 | 154 |
| 155 scoped_ptr<base::Value> BluetoothManifestPermission::ToValue() const { | 155 scoped_ptr<base::Value> BluetoothManifestPermission::ToValue() const { |
| 156 api::manifest_types::Bluetooth bluetooth; | 156 api::manifest_types::Bluetooth bluetooth; |
| 157 bluetooth.uuids.reset(new std::vector<std::string>(uuids_.begin(), | 157 bluetooth.uuids.reset(new std::vector<std::string>(uuids_.begin(), |
| 158 uuids_.end())); | 158 uuids_.end())); |
| 159 return bluetooth.ToValue().PassAs<base::Value>(); | 159 return bluetooth.ToValue().PassAs<base::Value>(); |
| 160 } | 160 } |
| 161 | 161 |
| 162 ManifestPermission* BluetoothManifestPermission::Clone() const { | |
| 163 scoped_ptr<BluetoothManifestPermission> result( | |
| 164 new BluetoothManifestPermission()); | |
| 165 result->uuids_ = uuids_; | |
| 166 return result.release(); | |
| 167 } | |
| 168 | |
| 169 ManifestPermission* BluetoothManifestPermission::Diff( | 162 ManifestPermission* BluetoothManifestPermission::Diff( |
| 170 const ManifestPermission* rhs) const { | 163 const ManifestPermission* rhs) const { |
| 171 const BluetoothManifestPermission* other = | 164 const BluetoothManifestPermission* other = |
| 172 static_cast<const BluetoothManifestPermission*>(rhs); | 165 static_cast<const BluetoothManifestPermission*>(rhs); |
| 173 | 166 |
| 174 scoped_ptr<BluetoothManifestPermission> result( | 167 scoped_ptr<BluetoothManifestPermission> result( |
| 175 new BluetoothManifestPermission()); | 168 new BluetoothManifestPermission()); |
| 176 result->uuids_ = base::STLSetDifference<BluetoothUuidSet>( | 169 result->uuids_ = base::STLSetDifference<BluetoothUuidSet>( |
| 177 uuids_, other->uuids_); | 170 uuids_, other->uuids_); |
| 178 return result.release(); | 171 return result.release(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 195 const BluetoothManifestPermission* other = | 188 const BluetoothManifestPermission* other = |
| 196 static_cast<const BluetoothManifestPermission*>(rhs); | 189 static_cast<const BluetoothManifestPermission*>(rhs); |
| 197 | 190 |
| 198 scoped_ptr<BluetoothManifestPermission> result( | 191 scoped_ptr<BluetoothManifestPermission> result( |
| 199 new BluetoothManifestPermission()); | 192 new BluetoothManifestPermission()); |
| 200 result->uuids_ = base::STLSetIntersection<BluetoothUuidSet>( | 193 result->uuids_ = base::STLSetIntersection<BluetoothUuidSet>( |
| 201 uuids_, other->uuids_); | 194 uuids_, other->uuids_); |
| 202 return result.release(); | 195 return result.release(); |
| 203 } | 196 } |
| 204 | 197 |
| 205 bool BluetoothManifestPermission::Contains(const ManifestPermission* rhs) | |
| 206 const { | |
| 207 const BluetoothManifestPermission* other = | |
| 208 static_cast<const BluetoothManifestPermission*>(rhs); | |
| 209 | |
| 210 return base::STLIncludes(uuids_, other->uuids_); | |
| 211 } | |
| 212 | |
| 213 bool BluetoothManifestPermission::Equal(const ManifestPermission* rhs) const { | |
| 214 const BluetoothManifestPermission* other = | |
| 215 static_cast<const BluetoothManifestPermission*>(rhs); | |
| 216 | |
| 217 return (uuids_ == other->uuids_); | |
| 218 } | |
| 219 | |
| 220 void BluetoothManifestPermission::Write(IPC::Message* m) const { | |
| 221 IPC::WriteParam(m, uuids_); | |
| 222 } | |
| 223 | |
| 224 bool BluetoothManifestPermission::Read(const IPC::Message* m, | |
| 225 PickleIterator* iter) { | |
| 226 return IPC::ReadParam(m, iter, &uuids_); | |
| 227 } | |
| 228 | |
| 229 void BluetoothManifestPermission::Log(std::string* log) const { | |
| 230 IPC::LogParam(uuids_, log); | |
| 231 } | |
| 232 | |
| 233 void BluetoothManifestPermission::AddPermission(const std::string& uuid) { | 198 void BluetoothManifestPermission::AddPermission(const std::string& uuid) { |
| 234 uuids_.insert(uuid); | 199 uuids_.insert(uuid); |
| 235 } | 200 } |
| 236 | 201 |
| 237 } // namespace extensions | 202 } // namespace extensions |
| OLD | NEW |