diff options
author | bryeung@chromium.org <bryeung@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-06 19:30:25 +0000 |
---|---|---|
committer | bryeung@chromium.org <bryeung@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-06 19:30:25 +0000 |
commit | f3cc80630260b4638c9dbe92d06dc7a8213e92da (patch) | |
tree | 9ebac78d617c12347bcc687f24ce2113b6f2034f /chrome/common/extensions/permissions/bluetooth_device_permission_data.cc | |
parent | a7ed0caee52c25c7df1031bbf9aa965def8f57cf (diff) | |
download | chromium_src-f3cc80630260b4638c9dbe92d06dc7a8213e92da.zip chromium_src-f3cc80630260b4638c9dbe92d06dc7a8213e92da.tar.gz chromium_src-f3cc80630260b4638c9dbe92d06dc7a8213e92da.tar.bz2 |
Refactor (Socket|BlueoothDevice)Permission.
This eliminates much code duplication between specialized extension
permission types.
BUG=147531
TBR=sky@chromium.org
Review URL: https://chromiumcodereview.appspot.com/11418315
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@171559 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/extensions/permissions/bluetooth_device_permission_data.cc')
-rw-r--r-- | chrome/common/extensions/permissions/bluetooth_device_permission_data.cc | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/chrome/common/extensions/permissions/bluetooth_device_permission_data.cc b/chrome/common/extensions/permissions/bluetooth_device_permission_data.cc new file mode 100644 index 0000000..fc9edee --- /dev/null +++ b/chrome/common/extensions/permissions/bluetooth_device_permission_data.cc @@ -0,0 +1,49 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/common/extensions/permissions/bluetooth_device_permission_data.h" + +#include <string> + +#include "chrome/common/extensions/permissions/bluetooth_device_permission.h" + +namespace extensions { + +BluetoothDevicePermissionData::BluetoothDevicePermissionData() + : device_address_("") { +} + +BluetoothDevicePermissionData::BluetoothDevicePermissionData( + const std::string& device_address) : device_address_(device_address) { +} + +bool BluetoothDevicePermissionData::Check( + const APIPermission::CheckParam* param) const { + if (!param) + return false; + const BluetoothDevicePermission::CheckParam& specific_param = + *static_cast<const BluetoothDevicePermission::CheckParam*>(param); + return device_address_ == specific_param.device_address; +} + +bool BluetoothDevicePermissionData::Parse(const std::string& spec) { + device_address_ = spec; + return true; +} + +const std::string &BluetoothDevicePermissionData::GetAsString() const { + return device_address_; +} + +bool BluetoothDevicePermissionData::operator<( + const BluetoothDevicePermissionData& rhs) const { + return device_address_ < rhs.device_address_; +} + +bool BluetoothDevicePermissionData::operator==( + const BluetoothDevicePermissionData& rhs) const { + return device_address_ == rhs.device_address_; +} + +} // namespace extensions |