blob: d13b94dd51cbd4cf07b65fe7fc14e9d0532779c1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/common/extensions/api/system_indicator/system_indicator_handler.h"
#include "base/memory/scoped_ptr.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "chrome/common/extensions/api/extension_action/action_info.h"
#include "extensions/common/extension.h"
#include "extensions/common/manifest_constants.h"
#include "extensions/common/permissions/api_permission_set.h"
#include "extensions/common/permissions/permissions_data.h"
namespace extensions {
SystemIndicatorHandler::SystemIndicatorHandler() {
}
SystemIndicatorHandler::~SystemIndicatorHandler() {
}
bool SystemIndicatorHandler::Parse(Extension* extension, string16* error) {
const base::DictionaryValue* system_indicator_value = NULL;
if (!extension->manifest()->GetDictionary(
manifest_keys::kSystemIndicator, &system_indicator_value)) {
*error = ASCIIToUTF16(manifest_errors::kInvalidSystemIndicator);
return false;
}
scoped_ptr<ActionInfo> action_info = ActionInfo::Load(
extension, system_indicator_value, error);
if (!action_info.get())
return false;
// Because the manifest was successfully parsed, auto-grant the permission.
// TODO(dewittj) Add this for all extension action APIs.
PermissionsData::GetInitialAPIPermissions(extension)->insert(
APIPermission::kSystemIndicator);
ActionInfo::SetSystemIndicatorInfo(extension, action_info.release());
return true;
}
const std::vector<std::string> SystemIndicatorHandler::Keys() const {
return SingleKey(manifest_keys::kSystemIndicator);
}
} // namespace extensions
|