| 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/plugins/plugins_handler.h" | 5 #include "chrome/common/extensions/api/plugins/plugins_handler.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 PluginsHandler::~PluginsHandler() { | 62 PluginsHandler::~PluginsHandler() { |
| 63 } | 63 } |
| 64 | 64 |
| 65 const std::vector<std::string> PluginsHandler::Keys() const { | 65 const std::vector<std::string> PluginsHandler::Keys() const { |
| 66 return SingleKey(keys::kPlugins); | 66 return SingleKey(keys::kPlugins); |
| 67 } | 67 } |
| 68 | 68 |
| 69 bool PluginsHandler::Parse(Extension* extension, base::string16* error) { | 69 bool PluginsHandler::Parse(Extension* extension, base::string16* error) { |
| 70 const base::ListValue* list_value = NULL; | 70 const base::ListValue* list_value = NULL; |
| 71 if (!extension->manifest()->GetList(keys::kPlugins, &list_value)) { | 71 if (!extension->manifest()->GetList(keys::kPlugins, &list_value)) { |
| 72 *error = ASCIIToUTF16(manifest_errors::kInvalidPlugins); | 72 *error = base::ASCIIToUTF16(manifest_errors::kInvalidPlugins); |
| 73 return false; | 73 return false; |
| 74 } | 74 } |
| 75 | 75 |
| 76 scoped_ptr<PluginManifestData> plugins_data(new PluginManifestData); | 76 scoped_ptr<PluginManifestData> plugins_data(new PluginManifestData); |
| 77 | 77 |
| 78 for (size_t i = 0; i < list_value->GetSize(); ++i) { | 78 for (size_t i = 0; i < list_value->GetSize(); ++i) { |
| 79 const base::DictionaryValue* plugin_value = NULL; | 79 const base::DictionaryValue* plugin_value = NULL; |
| 80 if (!list_value->GetDictionary(i, &plugin_value)) { | 80 if (!list_value->GetDictionary(i, &plugin_value)) { |
| 81 *error = ASCIIToUTF16(manifest_errors::kInvalidPlugins); | 81 *error = base::ASCIIToUTF16(manifest_errors::kInvalidPlugins); |
| 82 return false; | 82 return false; |
| 83 } | 83 } |
| 84 // Get plugins[i].path. | 84 // Get plugins[i].path. |
| 85 std::string path_str; | 85 std::string path_str; |
| 86 if (!plugin_value->GetString(keys::kPluginsPath, &path_str)) { | 86 if (!plugin_value->GetString(keys::kPluginsPath, &path_str)) { |
| 87 *error = ErrorUtils::FormatErrorMessageUTF16( | 87 *error = ErrorUtils::FormatErrorMessageUTF16( |
| 88 manifest_errors::kInvalidPluginsPath, base::IntToString(i)); | 88 manifest_errors::kInvalidPluginsPath, base::IntToString(i)); |
| 89 return false; | 89 return false; |
| 90 } | 90 } |
| 91 | 91 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 IDS_EXTENSION_LOAD_PLUGIN_PATH_FAILED, | 141 IDS_EXTENSION_LOAD_PLUGIN_PATH_FAILED, |
| 142 plugin->path.LossyDisplayName()); | 142 plugin->path.LossyDisplayName()); |
| 143 return false; | 143 return false; |
| 144 } | 144 } |
| 145 } | 145 } |
| 146 } | 146 } |
| 147 return true; | 147 return true; |
| 148 } | 148 } |
| 149 | 149 |
| 150 } // namespace extensions | 150 } // namespace extensions |
| OLD | NEW |