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

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 const std::vector<std::string> SystemIndicatorHandler::Keys() const {
Yoyo Zhou 2013/03/21 00:07:50 Define in same order declared in .h file.
Devlin 2013/03/23 22:23:08 Done.
24 return SingleKey(extension_manifest_keys::kSystemIndicator);
25 }
26
27 bool SystemIndicatorHandler::Parse(Extension* extension, string16* error) {
28 const DictionaryValue* system_indicator_value = NULL;
29 if (!extension->manifest()->GetDictionary(
30 extension_manifest_keys::kSystemIndicator, &system_indicator_value)) {
31 *error = ASCIIToUTF16(extension_manifest_errors::kInvalidSystemIndicator);
32 return false;
33 }
34
35 scoped_ptr<ActionInfo> action_info = ActionInfo::Load(
36 extension, system_indicator_value, error);
37
38 if (!action_info.get())
39 return false;
40
41 // Because the manifest was successfully parsed, auto-grant the permission.
42 // TODO(dewittj) Add this for all extension action APIs.
43 extension->initial_api_permissions()->insert(APIPermission::kSystemIndicator);
44
45 ActionInfo::SetSystemIndicatorInfo(extension, action_info.release());
46 return true;
47 }
48
49 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698