| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/extension_file_util.h" | 5 #include "chrome/common/extensions/extension_file_util.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/files/scoped_temp_dir.h" | 12 #include "base/files/scoped_temp_dir.h" |
| 13 #include "base/json/json_file_value_serializer.h" | 13 #include "base/json/json_file_value_serializer.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
| 16 #include "base/path_service.h" | 16 #include "base/path_service.h" |
| 17 #include "base/stringprintf.h" | 17 #include "base/stringprintf.h" |
| 18 #include "base/threading/thread_restrictions.h" | 18 #include "base/threading/thread_restrictions.h" |
| 19 #include "base/utf_string_conversions.h" | 19 #include "base/utf_string_conversions.h" |
| 20 #include "chrome/common/chrome_constants.h" | 20 #include "chrome/common/chrome_constants.h" |
| 21 #include "chrome/common/chrome_paths.h" | 21 #include "chrome/common/chrome_paths.h" |
| 22 #include "chrome/common/extensions/api/extension_action/action_info.h" | 22 #include "chrome/common/extensions/api/extension_action/action_info.h" |
| 23 #include "chrome/common/extensions/api/extension_action/browser_action_handler.h
" | 23 #include "chrome/common/extensions/api/extension_action/browser_action_handler.h
" |
| 24 #include "chrome/common/extensions/api/i18n/default_locale_handler.h" | 24 #include "chrome/common/extensions/api/i18n/default_locale_handler.h" |
| 25 #include "chrome/common/extensions/api/icons/icons_handler.h" |
| 25 #include "chrome/common/extensions/api/themes/theme_handler.h" | 26 #include "chrome/common/extensions/api/themes/theme_handler.h" |
| 26 #include "chrome/common/extensions/extension.h" | 27 #include "chrome/common/extensions/extension.h" |
| 27 #include "chrome/common/extensions/extension_l10n_util.h" | 28 #include "chrome/common/extensions/extension_l10n_util.h" |
| 28 #include "chrome/common/extensions/extension_manifest_constants.h" | 29 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 29 #include "chrome/common/extensions/extension_messages.h" | 30 #include "chrome/common/extensions/extension_messages.h" |
| 30 #include "chrome/common/extensions/extension_resource.h" | 31 #include "chrome/common/extensions/extension_resource.h" |
| 31 #include "chrome/common/extensions/manifest.h" | 32 #include "chrome/common/extensions/manifest.h" |
| 32 #include "chrome/common/extensions/manifest_url_handler.h" | 33 #include "chrome/common/extensions/manifest_url_handler.h" |
| 33 #include "chrome/common/extensions/message_bundle.h" | 34 #include "chrome/common/extensions/message_bundle.h" |
| 34 #include "extensions/common/install_warning.h" | 35 #include "extensions/common/install_warning.h" |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 } | 250 } |
| 250 | 251 |
| 251 return true; | 252 return true; |
| 252 } | 253 } |
| 253 | 254 |
| 254 bool ValidateExtension(const Extension* extension, | 255 bool ValidateExtension(const Extension* extension, |
| 255 std::string* error, | 256 std::string* error, |
| 256 std::vector<extensions::InstallWarning>* warnings) { | 257 std::vector<extensions::InstallWarning>* warnings) { |
| 257 // Validate icons exist. | 258 // Validate icons exist. |
| 258 for (ExtensionIconSet::IconMap::const_iterator iter = | 259 for (ExtensionIconSet::IconMap::const_iterator iter = |
| 259 extension->icons().map().begin(); | 260 extensions::IconsInfo::GetIcons(extension).map().begin(); |
| 260 iter != extension->icons().map().end(); | 261 iter != extensions::IconsInfo::GetIcons(extension).map().end(); |
| 261 ++iter) { | 262 ++iter) { |
| 262 const base::FilePath path = | 263 const base::FilePath path = |
| 263 extension->GetResource(iter->second).GetFilePath(); | 264 extension->GetResource(iter->second).GetFilePath(); |
| 264 if (!ValidateFilePath(path)) { | 265 if (!ValidateFilePath(path)) { |
| 265 *error = | 266 *error = |
| 266 l10n_util::GetStringFUTF8(IDS_EXTENSION_LOAD_ICON_FAILED, | 267 l10n_util::GetStringFUTF8(IDS_EXTENSION_LOAD_ICON_FAILED, |
| 267 UTF8ToUTF16(iter->second)); | 268 UTF8ToUTF16(iter->second)); |
| 268 return false; | 269 return false; |
| 269 } | 270 } |
| 270 } | 271 } |
| (...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 772 return base::FilePath(); | 773 return base::FilePath(); |
| 773 } | 774 } |
| 774 return temp_path; | 775 return temp_path; |
| 775 } | 776 } |
| 776 | 777 |
| 777 void DeleteFile(const base::FilePath& path, bool recursive) { | 778 void DeleteFile(const base::FilePath& path, bool recursive) { |
| 778 file_util::Delete(path, recursive); | 779 file_util::Delete(path, recursive); |
| 779 } | 780 } |
| 780 | 781 |
| 781 } // namespace extension_file_util | 782 } // namespace extension_file_util |
| OLD | NEW |