1 // Copyright (c) 2013 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/api/system_indicator/system_indicator_handler.h"
7 #include "base/memory/scoped_ptr.h"
8 #include "base/strings/utf_string_conversions.h"
9 #include "base/values.h"
10 #include "chrome/common/extensions/api/extension_action/action_info.h"
11 #include "extensions/common/extension.h"
12 #include "extensions/common/manifest_constants.h"
13 #include "extensions/common/permissions/api_permission_set.h"
14 #include "extensions/common/permissions/permissions_data.h"
16 namespace extensions {
18 SystemIndicatorHandler::SystemIndicatorHandler() {
21 SystemIndicatorHandler::~SystemIndicatorHandler() {
24 bool SystemIndicatorHandler::Parse(Extension* extension,
25 base::string16* error) {
26 const base::DictionaryValue* system_indicator_value = NULL;
27 if (!extension->manifest()->GetDictionary(
28 manifest_keys::kSystemIndicator, &system_indicator_value)) {
29 *error = base::ASCIIToUTF16(manifest_errors::kInvalidSystemIndicator);
33 scoped_ptr<ActionInfo> action_info = ActionInfo::Load(
34 extension, system_indicator_value, error);
36 if (!action_info.get())
39 // Because the manifest was successfully parsed, auto-grant the permission.
40 // TODO(dewittj) Add this for all extension action APIs.
41 PermissionsData::GetInitialAPIPermissions(extension)->insert(
42 APIPermission::kSystemIndicator);
44 ActionInfo::SetSystemIndicatorInfo(extension, action_info.release());
48 const std::vector<std::string> SystemIndicatorHandler::Keys() const {
49 return SingleKey(manifest_keys::kSystemIndicator);
52 } // namespace extensions