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.
5 #include "chrome/common/extensions/permissions/bluetooth_permission.h"
9 #include "base/logging.h"
10 #include "base/strings/string16.h"
11 #include "base/strings/string_util.h"
12 #include "base/strings/utf_string_conversions.h"
13 #include "chrome/common/extensions/permissions/bluetooth_permission_data.h"
14 #include "extensions/common/permissions/permissions_info.h"
15 #include "grit/generated_resources.h"
16 #include "ui/base/l10n/l10n_util.h"
18 namespace extensions {
20 BluetoothPermission::BluetoothPermission(const APIPermissionInfo* info)
21 : SetDisjunctionPermission<BluetoothPermissionData,
22 BluetoothPermission>(info) {
25 BluetoothPermission::~BluetoothPermission() {
28 bool BluetoothPermission::FromValue(const base::Value* value) {
29 // Value may be omitted to gain access to non-profile functions.
33 // Value may be an empty list for the same reason.
34 const base::ListValue* list = NULL;
35 if (value->GetAsList(&list) && list->GetSize() == 0)
38 if (!SetDisjunctionPermission<BluetoothPermissionData,
39 BluetoothPermission>::FromValue(value)) {
46 PermissionMessages BluetoothPermission::GetMessages() const {
47 DCHECK(HasMessages());
48 PermissionMessages result;
50 result.push_back(PermissionMessage(
51 PermissionMessage::kBluetooth,
52 l10n_util::GetStringUTF16(
53 IDS_EXTENSION_PROMPT_WARNING_BLUETOOTH)));
55 if (!data_set_.empty()) {
56 result.push_back(PermissionMessage(
57 PermissionMessage::kBluetoothDevices,
58 l10n_util::GetStringUTF16(
59 IDS_EXTENSION_PROMPT_WARNING_BLUETOOTH_DEVICES)));
65 } // namespace extensions