Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(136)

Side by Side Diff: trunk/src/chrome/common/extensions/api/bluetooth/bluetooth_manifest_permission.cc

Issue 224763003: Revert 261566 "device/bluetooth: Rename device::bluetooth_utils:..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
11 #include "chrome/common/extensions/api/bluetooth/bluetooth_manifest_data.h" 11 #include "chrome/common/extensions/api/bluetooth/bluetooth_manifest_data.h"
12 #include "chrome/common/extensions/api/manifest_types.h" 12 #include "chrome/common/extensions/api/manifest_types.h"
13 #include "device/bluetooth/bluetooth_uuid.h" 13 #include "device/bluetooth/bluetooth_utils.h"
14 #include "extensions/common/error_utils.h" 14 #include "extensions/common/error_utils.h"
15 #include "extensions/common/extension_messages.h" 15 #include "extensions/common/extension_messages.h"
16 #include "extensions/common/manifest_constants.h" 16 #include "extensions/common/manifest_constants.h"
17 #include "grit/generated_resources.h" 17 #include "grit/generated_resources.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;
28 28
29 namespace { 29 namespace {
30 30
31 bool ParseUuid(BluetoothManifestPermission* permission, 31 bool ParseUuid(BluetoothManifestPermission* permission,
32 const std::string& uuid, 32 const std::string& uuid,
33 base::string16* error) { 33 base::string16* error) {
34 device::BluetoothUUID bt_uuid(uuid); 34 std::string canonical_uuid = device::bluetooth_utils::CanonicalUuid(uuid);
35 if (!bt_uuid.IsValid()) { 35 if (canonical_uuid.empty()) {
36 *error = ErrorUtils::FormatErrorMessageUTF16( 36 *error = ErrorUtils::FormatErrorMessageUTF16(
37 errors::kErrorInvalidUuid, uuid); 37 errors::kErrorInvalidUuid, uuid);
38 return false; 38 return false;
39 } 39 }
40 permission->AddPermission(uuid); 40 permission->AddPermission(uuid);
41 return true; 41 return true;
42 } 42 }
43 43
44 bool ParseUuidArray(BluetoothManifestPermission* permission, 44 bool ParseUuidArray(BluetoothManifestPermission* permission,
45 const scoped_ptr<std::vector<std::string> >& uuids, 45 const scoped_ptr<std::vector<std::string> >& uuids,
(...skipping 30 matching lines...) Expand all
76 return scoped_ptr<BluetoothManifestPermission>(); 76 return scoped_ptr<BluetoothManifestPermission>();
77 } 77 }
78 } 78 }
79 return result.Pass(); 79 return result.Pass();
80 } 80 }
81 81
82 bool BluetoothManifestPermission::CheckRequest( 82 bool BluetoothManifestPermission::CheckRequest(
83 const Extension* extension, 83 const Extension* extension,
84 const BluetoothPermissionRequest& request) const { 84 const BluetoothPermissionRequest& request) const {
85 85
86 device::BluetoothUUID param_uuid(request.uuid); 86 std::string canonical_param_uuid =
87 device::bluetooth_utils::CanonicalUuid(request.uuid);
87 for (BluetoothUuidSet::const_iterator it = uuids_.begin(); 88 for (BluetoothUuidSet::const_iterator it = uuids_.begin();
88 it != uuids_.end(); 89 it != uuids_.end();
89 ++it) { 90 ++it) {
90 device::BluetoothUUID uuid(*it); 91 std::string canonical_uuid = device::bluetooth_utils::CanonicalUuid(*it);
91 if (param_uuid == uuid) 92 if (canonical_uuid == canonical_param_uuid)
92 return true; 93 return true;
93 } 94 }
94 return false; 95 return false;
95 } 96 }
96 97
97 std::string BluetoothManifestPermission::name() const { 98 std::string BluetoothManifestPermission::name() const {
98 return manifest_keys::kBluetooth; 99 return manifest_keys::kBluetooth;
99 } 100 }
100 101
101 std::string BluetoothManifestPermission::id() const { return name(); } 102 std::string BluetoothManifestPermission::id() const { return name(); }
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 211
211 void BluetoothManifestPermission::Log(std::string* log) const { 212 void BluetoothManifestPermission::Log(std::string* log) const {
212 IPC::LogParam(uuids_, log); 213 IPC::LogParam(uuids_, log);
213 } 214 }
214 215
215 void BluetoothManifestPermission::AddPermission(const std::string& uuid) { 216 void BluetoothManifestPermission::AddPermission(const std::string& uuid) {
216 uuids_.insert(uuid); 217 uuids_.insert(uuid);
217 } 218 }
218 219
219 } // namespace extensions 220 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698