| Index: chrome/browser/extensions/api/permissions/permissions_api_helpers.cc
|
| diff --git a/chrome/browser/extensions/api/permissions/permissions_api_helpers.cc b/chrome/browser/extensions/api/permissions/permissions_api_helpers.cc
|
| index f537a910171571ecfae32ee879a4b18724a0ba85..6168852eed9b712bd64925788da7db31fc6ff60c 100644
|
| --- a/chrome/browser/extensions/api/permissions/permissions_api_helpers.cc
|
| +++ b/chrome/browser/extensions/api/permissions/permissions_api_helpers.cc
|
| @@ -7,6 +7,7 @@
|
| #include "base/values.h"
|
| #include "chrome/common/extensions/api/permissions.h"
|
| #include "chrome/common/extensions/extension.h"
|
| +#include "chrome/common/extensions/permissions/bluetooth_device_permission.h"
|
| #include "chrome/common/extensions/permissions/permission_set.h"
|
| #include "chrome/common/extensions/permissions/permissions_info.h"
|
| #include "extensions/common/error_utils.h"
|
| @@ -28,6 +29,8 @@ const char kInvalidOrigin[] =
|
| "Invalid value for origin pattern *: *";
|
| const char kUnknownPermissionError[] =
|
| "'*' is not a recognized permission.";
|
| +const char kNonBluetoothPermissionWithArgument[] =
|
| + "Only the bluetoothDevice permission supports arguments.";
|
|
|
| } // namespace
|
|
|
| @@ -37,7 +40,7 @@ scoped_ptr<Permissions> PackPermissionSet(const PermissionSet* set) {
|
| permissions->permissions.reset(new std::vector<std::string>());
|
| for (APIPermissionSet::const_iterator i = set->apis().begin();
|
| i != set->apis().end(); ++i) {
|
| - permissions->permissions->push_back(i->name());
|
| + permissions->permissions->push_back(i->ToString());
|
| }
|
|
|
| permissions->origins.reset(new std::vector<std::string>());
|
| @@ -56,13 +59,39 @@ scoped_refptr<PermissionSet> UnpackPermissionSet(
|
| PermissionsInfo* info = PermissionsInfo::GetInstance();
|
| for (std::vector<std::string>::iterator it = permissions_list->begin();
|
| it != permissions_list->end(); ++it) {
|
| - const APIPermissionInfo* permission_info = info->GetByName(*it);
|
| - if (!permission_info) {
|
| - *error = ErrorUtils::FormatErrorMessage(
|
| - kUnknownPermissionError, *it);
|
| - return NULL;
|
| + // This is a compromise: we currently can't switch to a blend of
|
| + // objects/strings all the way through the API. Until then, put this
|
| + // processing here.
|
| + // http://code.google.com/p/chromium/issues/detail?id=162042
|
| + if (it->find("|") != std::string::npos) {
|
| + size_t delimiter = it->find("|");
|
| + std::string permission_name = it->substr(0, delimiter);
|
| + std::string permission_arg = it->substr(delimiter + 1);
|
| +
|
| + // Restrict this to the bluetoothDevice permission for now, to
|
| + // discourage the use of this style of permission spreading until it is
|
| + // better supported.
|
| + const APIPermissionInfo* permission_info = info->GetByID(
|
| + APIPermission::kBluetoothDevice);
|
| + if (permission_name != permission_info->name()) {
|
| + *error = kNonBluetoothPermissionWithArgument;
|
| + return NULL;
|
| + }
|
| +
|
| + BluetoothDevicePermission *permission =
|
| + new BluetoothDevicePermission(permission_info);
|
| + permission->AddDevicesFromString(permission_arg);
|
| +
|
| + apis.insert(permission);
|
| + } else {
|
| + const APIPermissionInfo* permission_info = info->GetByName(*it);
|
| + if (!permission_info) {
|
| + *error = ErrorUtils::FormatErrorMessage(
|
| + kUnknownPermissionError, *it);
|
| + return NULL;
|
| + }
|
| + apis.insert(permission_info->id());
|
| }
|
| - apis.insert(permission_info->id());
|
| }
|
| }
|
|
|
|
|