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/sockets/sockets_manifest_data.h"
7 #include "extensions/common/api/sockets/sockets_manifest_permission.h"
8 #include "extensions/common/manifest_constants.h"
10 namespace extensions
{
12 SocketsManifestData::SocketsManifestData(
13 scoped_ptr
<SocketsManifestPermission
> permission
)
14 : permission_(permission
.Pass()) {
18 SocketsManifestData::~SocketsManifestData() {}
21 SocketsManifestData
* SocketsManifestData::Get(const Extension
* extension
) {
22 return static_cast<SocketsManifestData
*>(
23 extension
->GetManifestData(manifest_keys::kSockets
));
27 bool SocketsManifestData::CheckRequest(
28 const Extension
* extension
,
29 const content::SocketPermissionRequest
& request
) {
30 const SocketsManifestData
* data
= SocketsManifestData::Get(extension
);
32 return data
->permission()->CheckRequest(extension
, request
);
38 scoped_ptr
<SocketsManifestData
> SocketsManifestData::FromValue(
39 const base::Value
& value
,
40 base::string16
* error
) {
41 scoped_ptr
<SocketsManifestPermission
> permission
=
42 SocketsManifestPermission::FromValue(value
, error
);
44 return scoped_ptr
<SocketsManifestData
>();
46 return scoped_ptr
<SocketsManifestData
>(
47 new SocketsManifestData(permission
.Pass())).Pass();
50 } // namespace extensions