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 "extensions/common/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" |
11 #include "chrome/common/extensions/api/bluetooth/bluetooth_manifest_data.h" | |
12 #include "chrome/common/extensions/api/manifest_types.h" | |
13 #include "chrome/grit/generated_resources.h" | |
14 #include "device/bluetooth/bluetooth_uuid.h" | 11 #include "device/bluetooth/bluetooth_uuid.h" |
| 12 #include "extensions/common/api/bluetooth/bluetooth_manifest_data.h" |
| 13 #include "extensions/common/api/extensions_manifest_types.h" |
15 #include "extensions/common/error_utils.h" | 14 #include "extensions/common/error_utils.h" |
16 #include "extensions/common/extension_messages.h" | 15 #include "extensions/common/extension_messages.h" |
17 #include "extensions/common/manifest_constants.h" | 16 #include "extensions/common/manifest_constants.h" |
| 17 #include "grit/extensions_strings.h" |
18 #include "ipc/ipc_message.h" | 18 #include "ipc/ipc_message.h" |
19 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
20 | 20 |
21 namespace extensions { | 21 namespace extensions { |
22 | 22 |
23 namespace bluetooth_errors { | 23 namespace bluetooth_errors { |
24 const char kErrorInvalidUuid[] = "Invalid UUID '*'"; | 24 const char kErrorInvalidUuid[] = "Invalid UUID '*'"; |
25 } | 25 } |
26 | 26 |
27 namespace errors = bluetooth_errors; | 27 namespace errors = bluetooth_errors; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 BluetoothManifestPermission::BluetoothManifestPermission() | 59 BluetoothManifestPermission::BluetoothManifestPermission() |
60 : socket_(false), | 60 : socket_(false), |
61 low_energy_(false) {} | 61 low_energy_(false) {} |
62 | 62 |
63 BluetoothManifestPermission::~BluetoothManifestPermission() {} | 63 BluetoothManifestPermission::~BluetoothManifestPermission() {} |
64 | 64 |
65 // static | 65 // static |
66 scoped_ptr<BluetoothManifestPermission> BluetoothManifestPermission::FromValue( | 66 scoped_ptr<BluetoothManifestPermission> BluetoothManifestPermission::FromValue( |
67 const base::Value& value, | 67 const base::Value& value, |
68 base::string16* error) { | 68 base::string16* error) { |
69 scoped_ptr<api::manifest_types::Bluetooth> bluetooth = | 69 scoped_ptr<core_api::extensions_manifest_types::Bluetooth> bluetooth = |
70 api::manifest_types::Bluetooth::FromValue(value, error); | 70 core_api::extensions_manifest_types::Bluetooth::FromValue(value, error); |
71 if (!bluetooth) | 71 if (!bluetooth) |
72 return scoped_ptr<BluetoothManifestPermission>(); | 72 return scoped_ptr<BluetoothManifestPermission>(); |
73 | 73 |
74 scoped_ptr<BluetoothManifestPermission> result( | 74 scoped_ptr<BluetoothManifestPermission> result( |
75 new BluetoothManifestPermission()); | 75 new BluetoothManifestPermission()); |
76 if (bluetooth->uuids) { | 76 if (bluetooth->uuids) { |
77 if (!ParseUuidArray(result.get(), bluetooth->uuids, error)) { | 77 if (!ParseUuidArray(result.get(), bluetooth->uuids, error)) { |
78 return scoped_ptr<BluetoothManifestPermission>(); | 78 return scoped_ptr<BluetoothManifestPermission>(); |
79 } | 79 } |
80 } | 80 } |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 BluetoothManifestPermission::FromValue(*value, &error)); | 146 BluetoothManifestPermission::FromValue(*value, &error)); |
147 | 147 |
148 if (!manifest_permission) | 148 if (!manifest_permission) |
149 return false; | 149 return false; |
150 | 150 |
151 uuids_ = manifest_permission->uuids_; | 151 uuids_ = manifest_permission->uuids_; |
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 core_api::extensions_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::Diff( | 162 ManifestPermission* BluetoothManifestPermission::Diff( |
163 const ManifestPermission* rhs) const { | 163 const ManifestPermission* rhs) const { |
164 const BluetoothManifestPermission* other = | 164 const BluetoothManifestPermission* other = |
165 static_cast<const BluetoothManifestPermission*>(rhs); | 165 static_cast<const BluetoothManifestPermission*>(rhs); |
166 | 166 |
(...skipping 26 matching lines...) Expand all Loading... |
193 result->uuids_ = base::STLSetIntersection<BluetoothUuidSet>( | 193 result->uuids_ = base::STLSetIntersection<BluetoothUuidSet>( |
194 uuids_, other->uuids_); | 194 uuids_, other->uuids_); |
195 return result.release(); | 195 return result.release(); |
196 } | 196 } |
197 | 197 |
198 void BluetoothManifestPermission::AddPermission(const std::string& uuid) { | 198 void BluetoothManifestPermission::AddPermission(const std::string& uuid) { |
199 uuids_.insert(uuid); | 199 uuids_.insert(uuid); |
200 } | 200 } |
201 | 201 |
202 } // namespace extensions | 202 } // namespace extensions |
OLD | NEW |