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 "chrome/common/extensions/manifest_handlers/copresence_manifest.h"
10 #include "base/strings/utf_string_conversions.h"
11 #include "base/values.h"
12 #include "extensions/common/manifest_constants.h"
14 namespace extensions
{
16 CopresenceManifestHandler::CopresenceManifestHandler() {
19 CopresenceManifestHandler::~CopresenceManifestHandler() {
22 bool CopresenceManifestHandler::Parse(Extension
* extension
,
23 base::string16
* error
) {
24 const base::DictionaryValue
* copresence_config
= nullptr;
26 if (!extension
->manifest()->GetDictionary(manifest_keys::kCopresence
,
27 &copresence_config
)) {
28 *error
= base::ASCIIToUTF16(manifest_errors::kInvalidCopresenceConfig
);
32 scoped_ptr
<CopresenceManifestData
> manifest_data(new CopresenceManifestData
);
33 if (!copresence_config
->GetString(manifest_values::kProjectId
,
34 &manifest_data
->project_id
) ||
35 manifest_data
->project_id
.empty()) {
36 *error
= base::ASCIIToUTF16(manifest_errors::kInvalidCopresenceProjectId
);
40 extension
->SetManifestData(manifest_keys::kCopresence
,
41 manifest_data
.release());
45 const std::vector
<std::string
> CopresenceManifestHandler::Keys() const {
46 return SingleKey(manifest_keys::kCopresence
);
49 CopresenceManifestData::CopresenceManifestData() {
52 CopresenceManifestData::~CopresenceManifestData() {
55 } // namespace extensions