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

Side by Side Diff: chrome/common/extensions/permissions/bluetooth_permission_data.cc

Issue 145663004: Replace "bluetooth" permission with manifest property. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unused function. Created 6 years, 10 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
OLDNEW
(Empty)
1 // Copyright 2013 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.
4
5 #include "chrome/common/extensions/permissions/bluetooth_permission_data.h"
6
7 #include <string>
8
9 #include "base/memory/scoped_ptr.h"
10 #include "base/values.h"
11 #include "chrome/common/extensions/permissions/bluetooth_permission.h"
12 #include "device/bluetooth/bluetooth_utils.h"
13
14 namespace {
15
16 const char* kUuidKey = "uuid";
17
18 } // namespace
19
20 namespace extensions {
21
22 BluetoothPermissionData::BluetoothPermissionData() {}
23
24 BluetoothPermissionData::BluetoothPermissionData(
25 const std::string& uuid) : uuid_(uuid) {
26 }
27
28 bool BluetoothPermissionData::Check(
29 const APIPermission::CheckParam* param) const {
30 if (!param)
31 return false;
32 const BluetoothPermission::CheckParam& specific_param =
33 *static_cast<const BluetoothPermission::CheckParam*>(param);
34
35 std::string canonical_uuid = device::bluetooth_utils::CanonicalUuid(uuid_);
36 std::string canonical_param_uuid = device::bluetooth_utils::CanonicalUuid(
37 specific_param.uuid);
38 return canonical_uuid == canonical_param_uuid;
39 }
40
41 scoped_ptr<base::Value> BluetoothPermissionData::ToValue() const {
42 base::DictionaryValue* result = new base::DictionaryValue();
43 result->SetString(kUuidKey, uuid_);
44 return scoped_ptr<base::Value>(result);
45 }
46
47 bool BluetoothPermissionData::FromValue(const base::Value* value) {
48 if (!value)
49 return false;
50
51 const base::DictionaryValue* dict_value;
52 if (!value->GetAsDictionary(&dict_value))
53 return false;
54
55 if (!dict_value->GetString(kUuidKey, &uuid_)) {
56 uuid_.clear();
57 return false;
58 }
59
60 return true;
61 }
62
63 bool BluetoothPermissionData::operator<(
64 const BluetoothPermissionData& rhs) const {
65 return uuid_ < rhs.uuid_;
66 }
67
68 bool BluetoothPermissionData::operator==(
69 const BluetoothPermissionData& rhs) const {
70 return uuid_ == rhs.uuid_;
71 }
72
73 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698