Chromium Code Reviews| Index: chrome/common/extensions/permissions/bluetooth_device_permission.h |
| diff --git a/chrome/common/extensions/permissions/bluetooth_device_permission.h b/chrome/common/extensions/permissions/bluetooth_device_permission.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..82e15bff587eec88a4f8a471502adce29d98cb45 |
| --- /dev/null |
| +++ b/chrome/common/extensions/permissions/bluetooth_device_permission.h |
| @@ -0,0 +1,66 @@ |
| +// 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. |
| + |
| +#ifndef CHROME_COMMON_EXTENSIONS_PERMISSIONS_BLUETOOTH_DEVICE_PERMISSION_H_ |
| +#define CHROME_COMMON_EXTENSIONS_PERMISSIONS_BLUETOOTH_DEVICE_PERMISSION_H_ |
| + |
| +#include <set> |
| +#include <string> |
| + |
| +#include "chrome/common/extensions/permissions/api_permission.h" |
| + |
| +namespace base { |
| +class Value; |
| +} |
| + |
| +namespace IPC { |
| +class Message; |
| +} |
| + |
| +namespace extensions { |
| + |
| +// There's room to share code with related classes, see http://crbug.com/147531 |
| +class BluetoothDevicePermission : public APIPermission { |
| + public: |
| + struct CheckParam : APIPermission::CheckParam { |
|
Matt Perry
2012/11/27 21:35:32
does this need to use public inheritance?
bryeung
2012/11/28 21:55:05
Yes: we do casts from APIPermission::CheckParam to
|
| + CheckParam(const std::string& device_address) |
| + : device_address(device_address) {} |
| + const std::string device_address; |
| + }; |
| + |
| + explicit BluetoothDevicePermission(const APIPermissionInfo* info); |
| + |
| + virtual ~BluetoothDevicePermission(); |
| + |
| + // Adds BluetoothDevices from |devices| to the set of allowed devices. |
| + // |devices| should be a string of Bluetooth device addresses separated by |. |
| + void AddDevicesFromString(const std::string &devices_string); |
|
Matt Perry
2012/11/27 21:35:32
nit: & before space
bryeung
2012/11/28 21:55:05
Done.
|
| + |
| + // APIPermission overrides |
| + virtual std::string ToString() const OVERRIDE; |
| + virtual bool ManifestEntryRequired() const OVERRIDE; |
| + virtual bool ManifestEntryForbidden() const OVERRIDE; |
| + virtual bool HasMessages() const OVERRIDE; |
| + virtual PermissionMessages GetMessages() const OVERRIDE; |
| + virtual bool Check( |
| + const APIPermission::CheckParam* param) const OVERRIDE; |
| + virtual bool Contains(const APIPermission* rhs) const OVERRIDE; |
| + virtual bool Equal(const APIPermission* rhs) const OVERRIDE; |
| + virtual bool FromValue(const base::Value* value) OVERRIDE; |
| + virtual void ToValue(base::Value** value) const OVERRIDE; |
| + virtual APIPermission* Clone() const OVERRIDE; |
| + virtual APIPermission* Diff(const APIPermission* rhs) const OVERRIDE; |
| + virtual APIPermission* Union(const APIPermission* rhs) const OVERRIDE; |
| + virtual APIPermission* Intersect(const APIPermission* rhs) const OVERRIDE; |
| + virtual void Write(IPC::Message* m) const OVERRIDE; |
| + virtual bool Read(const IPC::Message* m, PickleIterator* iter) OVERRIDE; |
| + virtual void Log(std::string* log) const OVERRIDE; |
| + |
| + private: |
| + std::set<std::string> allowed_devices_; |
|
Matt Perry
2012/11/27 21:35:32
shouldn't this be requested_devices instead?
bryeung
2012/11/28 21:55:05
Depends. If it's a request, then yes. But if thi
Matt Perry
2012/11/28 21:59:00
Sounds good.
(though it seems the latest upload d
|
| +}; |
| + |
| +} // namespace extensions |
| + |
| +#endif // CHROME_COMMON_EXTENSIONS_PERMISSIONS_BLUETOOTH_DEVICE_PERMISSION_H_ |