| 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/files/file_util.h" | 7 #include "base/files/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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 = base::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::SizeTToString(i)); |
| 89 return false; | 89 return false; |
| 90 } | 90 } |
| 91 | 91 |
| 92 // Get plugins[i].content (optional). | 92 // Get plugins[i].content (optional). |
| 93 bool is_public = false; | 93 bool is_public = false; |
| 94 if (plugin_value->HasKey(keys::kPluginsPublic)) { | 94 if (plugin_value->HasKey(keys::kPluginsPublic)) { |
| 95 if (!plugin_value->GetBoolean(keys::kPluginsPublic, &is_public)) { | 95 if (!plugin_value->GetBoolean(keys::kPluginsPublic, &is_public)) { |
| 96 *error = ErrorUtils::FormatErrorMessageUTF16( | 96 *error = ErrorUtils::FormatErrorMessageUTF16( |
| 97 manifest_errors::kInvalidPluginsPublic, | 97 manifest_errors::kInvalidPluginsPublic, base::SizeTToString(i)); |
| 98 base::IntToString(i)); | |
| 99 return false; | 98 return false; |
| 100 } | 99 } |
| 101 } | 100 } |
| 102 | 101 |
| 103 // We don't allow extensions to load NPAPI plugins on Chrome OS, or under | 102 // We don't allow extensions to load NPAPI plugins on Chrome OS, or under |
| 104 // Windows 8 Metro mode, but still parse the entries to display consistent | 103 // Windows 8 Metro mode, but still parse the entries to display consistent |
| 105 // error messages. If the extension actually requires the plugins then | 104 // error messages. If the extension actually requires the plugins then |
| 106 // LoadRequirements will prevent it loading. | 105 // LoadRequirements will prevent it loading. |
| 107 #if defined(OS_CHROMEOS) | 106 #if defined(OS_CHROMEOS) |
| 108 continue; | 107 continue; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 IDS_EXTENSION_LOAD_PLUGIN_PATH_FAILED, | 139 IDS_EXTENSION_LOAD_PLUGIN_PATH_FAILED, |
| 141 plugin->path.LossyDisplayName()); | 140 plugin->path.LossyDisplayName()); |
| 142 return false; | 141 return false; |
| 143 } | 142 } |
| 144 } | 143 } |
| 145 } | 144 } |
| 146 return true; | 145 return true; |
| 147 } | 146 } |
| 148 | 147 |
| 149 } // namespace extensions | 148 } // namespace extensions |
| OLD | NEW |