Blink roll 25b6bd3a7a131ffe68d809546ad1a20707915cdc:3a503f41ae42e5b79cfcd2ff10e65afde...
[chromium-blink-merge.git] / extensions / common / api / bluetooth / bluetooth_manifest_handler.cc
blobda143fa8c2fb52262f17a4a848b4a9ec88a9bdd3
1 // Copyright 2014 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 "extensions/common/api/bluetooth/bluetooth_manifest_handler.h"
7 #include "extensions/common/api/bluetooth/bluetooth_manifest_data.h"
8 #include "extensions/common/api/bluetooth/bluetooth_manifest_permission.h"
9 #include "extensions/common/extension.h"
10 #include "extensions/common/manifest_constants.h"
12 namespace extensions {
14 BluetoothManifestHandler::BluetoothManifestHandler() {}
16 BluetoothManifestHandler::~BluetoothManifestHandler() {}
18 bool BluetoothManifestHandler::Parse(Extension* extension,
19 base::string16* error) {
20 const base::Value* bluetooth = NULL;
21 CHECK(extension->manifest()->Get(manifest_keys::kBluetooth, &bluetooth));
22 scoped_ptr<BluetoothManifestData> data =
23 BluetoothManifestData::FromValue(*bluetooth, error);
24 if (!data)
25 return false;
27 extension->SetManifestData(manifest_keys::kBluetooth, data.release());
28 return true;
31 ManifestPermission* BluetoothManifestHandler::CreatePermission() {
32 return new BluetoothManifestPermission();
35 ManifestPermission* BluetoothManifestHandler::CreateInitialRequiredPermission(
36 const Extension* extension) {
37 BluetoothManifestData* data = BluetoothManifestData::Get(extension);
38 if (data)
39 return data->permission()->Clone();
40 return NULL;
43 const std::vector<std::string> BluetoothManifestHandler::Keys() const {
44 return SingleKey(manifest_keys::kBluetooth);
47 } // namespace extensions