Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(130)

Side by Side Diff: chrome/common/extensions/api/system_indicator/system_indicator_handler.cc

Issue 12618009: Move SystemIndicator parsing out of Extension class (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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.
4
5 #include "chrome/common/extensions/api/system_indicator/system_indicator_handler .h"
6
7 #include "base/memory/scoped_ptr.h"
8 #include "base/utf_string_conversions.h"
9 #include "base/values.h"
10 #include "chrome/common/extensions/api/extension_action/action_info.h"
11 #include "chrome/common/extensions/extension.h"
12 #include "chrome/common/extensions/extension_manifest_constants.h"
13 #include "chrome/common/extensions/permissions/api_permission_set.h"
14
15 namespace extensions {
16
17 SystemIndicatorHandler::SystemIndicatorHandler() {
18 }
19
20 SystemIndicatorHandler::~SystemIndicatorHandler() {
21 }
22
23 bool SystemIndicatorHandler::Parse(Extension* extension, string16* error) {
24 const DictionaryValue* system_indicator_value = NULL;
25 if (!extension->manifest()->GetDictionary(
26 extension_manifest_keys::kSystemIndicator, &system_indicator_value)) {
27 *error = ASCIIToUTF16(extension_manifest_errors::kInvalidSystemIndicator);
28 return false;
29 }
30
31 scoped_ptr<ActionInfo> action_info = ActionInfo::Load(
32 extension, system_indicator_value, error);
33
34 if (!action_info.get())
35 return false;
36
37 // Because the manifest was successfully parsed, auto-grant the permission.
38 // TODO(dewittj) Add this for all extension action APIs.
39 extension->initial_api_permissions()->insert(APIPermission::kSystemIndicator);
40
41 ActionInfo::SetSystemIndicatorInfo(extension, action_info.release());
42 return true;
43 }
44
45 const std::vector<std::string> SystemIndicatorHandler::Keys() const {
46 return SingleKey(extension_manifest_keys::kSystemIndicator);
47 }
48
49 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/common/extensions/api/system_indicator/system_indicator_handler.h ('k') | chrome/common/extensions/extension.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698