Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / extensions / common / api / sockets / sockets_manifest_handler.cc
blob113dc6eca5a68ae122a1bc7a04cb4a19d526c0a8
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_handler.h"
7 #include "extensions/common/api/sockets/sockets_manifest_data.h"
8 #include "extensions/common/api/sockets/sockets_manifest_permission.h"
9 #include "extensions/common/extension.h"
10 #include "extensions/common/manifest_constants.h"
12 namespace extensions {
14 SocketsManifestHandler::SocketsManifestHandler() {}
16 SocketsManifestHandler::~SocketsManifestHandler() {}
18 bool SocketsManifestHandler::Parse(Extension* extension,
19 base::string16* error) {
20 const base::Value* sockets = NULL;
21 CHECK(extension->manifest()->Get(manifest_keys::kSockets, &sockets));
22 scoped_ptr<SocketsManifestData> data =
23 SocketsManifestData::FromValue(*sockets, error);
24 if (!data)
25 return false;
27 extension->SetManifestData(manifest_keys::kSockets, data.release());
28 return true;
31 ManifestPermission* SocketsManifestHandler::CreatePermission() {
32 return new SocketsManifestPermission();
35 ManifestPermission* SocketsManifestHandler::CreateInitialRequiredPermission(
36 const Extension* extension) {
37 SocketsManifestData* data = SocketsManifestData::Get(extension);
38 if (data)
39 return data->permission()->Clone();
40 return NULL;
43 const std::vector<std::string> SocketsManifestHandler::Keys() const {
44 return SingleKey(manifest_keys::kSockets);
47 } // namespace extensions