• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/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 
14 namespace extensions {
15 
SystemIndicatorHandler()16 SystemIndicatorHandler::SystemIndicatorHandler() {
17 }
18 
~SystemIndicatorHandler()19 SystemIndicatorHandler::~SystemIndicatorHandler() {
20 }
21 
Parse(Extension * extension,base::string16 * error)22 bool SystemIndicatorHandler::Parse(Extension* extension,
23                                    base::string16* error) {
24   const base::DictionaryValue* system_indicator_value = NULL;
25   if (!extension->manifest()->GetDictionary(
26           manifest_keys::kSystemIndicator, &system_indicator_value)) {
27     *error = base::ASCIIToUTF16(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   ActionInfo::SetSystemIndicatorInfo(extension, action_info.release());
38   return true;
39 }
40 
Keys() const41 const std::vector<std::string> SystemIndicatorHandler::Keys() const {
42   return SingleKey(manifest_keys::kSystemIndicator);
43 }
44 
45 }  // namespace extensions
46