| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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/permissions/bluetooth_permission.h" | 5 #include "chrome/common/extensions/permissions/bluetooth_permission.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| 11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "chrome/common/extensions/permissions/bluetooth_permission_data.h" | 13 #include "chrome/common/extensions/permissions/bluetooth_permission_data.h" |
| 14 #include "extensions/common/permissions/permissions_info.h" | 14 #include "extensions/common/permissions/permissions_info.h" |
| 15 #include "grit/generated_resources.h" | 15 #include "grit/generated_resources.h" |
| 16 #include "ui/base/l10n/l10n_util.h" | 16 #include "ui/base/l10n/l10n_util.h" |
| 17 | 17 |
| 18 namespace extensions { | 18 namespace extensions { |
| 19 | 19 |
| 20 BluetoothPermission::BluetoothPermission(const APIPermissionInfo* info) | 20 BluetoothPermission::BluetoothPermission(const APIPermissionInfo* info) |
| 21 : SetDisjunctionPermission<BluetoothPermissionData, | 21 : SetDisjunctionPermission<BluetoothPermissionData, |
| 22 BluetoothPermission>(info) { | 22 BluetoothPermission>(info) { |
| 23 } | 23 } |
| 24 | 24 |
| 25 BluetoothPermission::~BluetoothPermission() { | 25 BluetoothPermission::~BluetoothPermission() { |
| 26 } | 26 } |
| 27 | 27 |
| 28 bool BluetoothPermission::FromValue(const base::Value* value) { | 28 bool BluetoothPermission::FromValue(const base::Value* value, |
| 29 std::string* error) { |
| 29 // Value may be omitted to gain access to non-profile functions. | 30 // Value may be omitted to gain access to non-profile functions. |
| 30 if (!value) | 31 if (!value) |
| 31 return true; | 32 return true; |
| 32 | 33 |
| 33 // Value may be an empty list for the same reason. | 34 // Value may be an empty list for the same reason. |
| 34 const base::ListValue* list = NULL; | 35 const base::ListValue* list = NULL; |
| 35 if (value->GetAsList(&list) && list->GetSize() == 0) | 36 if (value->GetAsList(&list) && list->GetSize() == 0) |
| 36 return true; | 37 return true; |
| 37 | 38 |
| 38 if (!SetDisjunctionPermission<BluetoothPermissionData, | 39 if (!SetDisjunctionPermission<BluetoothPermissionData, |
| 39 BluetoothPermission>::FromValue(value)) { | 40 BluetoothPermission>::FromValue(value, error)) { |
| 40 return false; | 41 return false; |
| 41 } | 42 } |
| 42 | 43 |
| 43 return true; | 44 return true; |
| 44 } | 45 } |
| 45 | 46 |
| 46 PermissionMessages BluetoothPermission::GetMessages() const { | 47 PermissionMessages BluetoothPermission::GetMessages() const { |
| 47 DCHECK(HasMessages()); | 48 DCHECK(HasMessages()); |
| 48 PermissionMessages result; | 49 PermissionMessages result; |
| 49 | 50 |
| 50 result.push_back(PermissionMessage( | 51 result.push_back(PermissionMessage( |
| 51 PermissionMessage::kBluetooth, | 52 PermissionMessage::kBluetooth, |
| 52 l10n_util::GetStringUTF16( | 53 l10n_util::GetStringUTF16( |
| 53 IDS_EXTENSION_PROMPT_WARNING_BLUETOOTH))); | 54 IDS_EXTENSION_PROMPT_WARNING_BLUETOOTH))); |
| 54 | 55 |
| 55 if (!data_set_.empty()) { | 56 if (!data_set_.empty()) { |
| 56 result.push_back(PermissionMessage( | 57 result.push_back(PermissionMessage( |
| 57 PermissionMessage::kBluetoothDevices, | 58 PermissionMessage::kBluetoothDevices, |
| 58 l10n_util::GetStringUTF16( | 59 l10n_util::GetStringUTF16( |
| 59 IDS_EXTENSION_PROMPT_WARNING_BLUETOOTH_DEVICES))); | 60 IDS_EXTENSION_PROMPT_WARNING_BLUETOOTH_DEVICES))); |
| 60 } | 61 } |
| 61 | 62 |
| 62 return result; | 63 return result; |
| 63 } | 64 } |
| 64 | 65 |
| 65 } // namespace extensions | 66 } // namespace extensions |
| OLD | NEW |