| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "extensions/common/manifest_handlers/action_handlers_handler.h" | 5 #include "extensions/common/manifest_handlers/action_handlers_handler.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 ActionHandlersHandler::~ActionHandlersHandler() = default; | 35 ActionHandlersHandler::~ActionHandlersHandler() = default; |
| 36 | 36 |
| 37 bool ActionHandlersHandler::Parse(Extension* extension, base::string16* error) { | 37 bool ActionHandlersHandler::Parse(Extension* extension, base::string16* error) { |
| 38 const base::ListValue* entries = nullptr; | 38 const base::ListValue* entries = nullptr; |
| 39 if (!extension->manifest()->GetList(keys::kActionHandlers, &entries)) { | 39 if (!extension->manifest()->GetList(keys::kActionHandlers, &entries)) { |
| 40 *error = base::ASCIIToUTF16(errors::kInvalidActionHandlersType); | 40 *error = base::ASCIIToUTF16(errors::kInvalidActionHandlersType); |
| 41 return false; | 41 return false; |
| 42 } | 42 } |
| 43 | 43 |
| 44 auto info = base::MakeUnique<ActionHandlersInfo>(); | 44 auto info = base::MakeUnique<ActionHandlersInfo>(); |
| 45 for (const std::unique_ptr<base::Value>& wrapped_value : *entries) { | 45 for (const base::Value& wrapped_value : *entries) { |
| 46 std::string value; | 46 std::string value; |
| 47 if (!wrapped_value->GetAsString(&value)) { | 47 if (!wrapped_value.GetAsString(&value)) { |
| 48 *error = base::ASCIIToUTF16(errors::kInvalidActionHandlersType); | 48 *error = base::ASCIIToUTF16(errors::kInvalidActionHandlersType); |
| 49 return false; | 49 return false; |
| 50 } | 50 } |
| 51 | 51 |
| 52 app_runtime::ActionType action_type = app_runtime::ParseActionType(value); | 52 app_runtime::ActionType action_type = app_runtime::ParseActionType(value); |
| 53 if (action_type == app_runtime::ACTION_TYPE_NONE) { | 53 if (action_type == app_runtime::ACTION_TYPE_NONE) { |
| 54 *error = ErrorUtils::FormatErrorMessageUTF16( | 54 *error = ErrorUtils::FormatErrorMessageUTF16( |
| 55 errors::kInvalidActionHandlersActionType, value); | 55 errors::kInvalidActionHandlersActionType, value); |
| 56 return false; | 56 return false; |
| 57 } | 57 } |
| 58 | 58 |
| 59 info->action_handlers.insert(action_type); | 59 info->action_handlers.insert(action_type); |
| 60 } | 60 } |
| 61 | 61 |
| 62 extension->SetManifestData(keys::kActionHandlers, std::move(info)); | 62 extension->SetManifestData(keys::kActionHandlers, std::move(info)); |
| 63 return true; | 63 return true; |
| 64 } | 64 } |
| 65 | 65 |
| 66 const std::vector<std::string> ActionHandlersHandler::Keys() const { | 66 const std::vector<std::string> ActionHandlersHandler::Keys() const { |
| 67 return SingleKey(keys::kActionHandlers); | 67 return SingleKey(keys::kActionHandlers); |
| 68 } | 68 } |
| 69 | 69 |
| 70 } // namespace extensions | 70 } // namespace extensions |
| OLD | NEW |