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