| OLD | NEW |
| 1 // Copyright (c) 2012 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/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_path.h" | 10 #include "base/file_path.h" |
| 11 #include "base/file_util.h" | 11 #include "base/file_util.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/icons/icons_handler.h" |
| 24 #include "chrome/common/extensions/extension.h" | 25 #include "chrome/common/extensions/extension.h" |
| 25 #include "chrome/common/extensions/extension_l10n_util.h" | 26 #include "chrome/common/extensions/extension_l10n_util.h" |
| 26 #include "chrome/common/extensions/extension_manifest_constants.h" | 27 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 27 #include "chrome/common/extensions/extension_messages.h" | 28 #include "chrome/common/extensions/extension_messages.h" |
| 28 #include "chrome/common/extensions/extension_resource.h" | 29 #include "chrome/common/extensions/extension_resource.h" |
| 29 #include "chrome/common/extensions/message_bundle.h" | 30 #include "chrome/common/extensions/message_bundle.h" |
| 30 #include "grit/generated_resources.h" | 31 #include "grit/generated_resources.h" |
| 31 #include "net/base/escape.h" | 32 #include "net/base/escape.h" |
| 32 #include "net/base/file_stream.h" | 33 #include "net/base/file_stream.h" |
| 33 #include "ui/base/l10n/l10n_util.h" | 34 #include "ui/base/l10n/l10n_util.h" |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 } | 241 } |
| 241 | 242 |
| 242 return true; | 243 return true; |
| 243 } | 244 } |
| 244 | 245 |
| 245 bool ValidateExtension(const Extension* extension, | 246 bool ValidateExtension(const Extension* extension, |
| 246 std::string* error, | 247 std::string* error, |
| 247 Extension::InstallWarningVector* warnings) { | 248 Extension::InstallWarningVector* warnings) { |
| 248 // Validate icons exist. | 249 // Validate icons exist. |
| 249 for (ExtensionIconSet::IconMap::const_iterator iter = | 250 for (ExtensionIconSet::IconMap::const_iterator iter = |
| 250 extension->icons().map().begin(); | 251 extensions::IconsInfo::GetIcons(extension).map().begin(); |
| 251 iter != extension->icons().map().end(); | 252 iter != extensions::IconsInfo::GetIcons(extension).map().end(); |
| 252 ++iter) { | 253 ++iter) { |
| 253 const FilePath path = extension->GetResource(iter->second).GetFilePath(); | 254 const FilePath path = extension->GetResource(iter->second).GetFilePath(); |
| 254 if (!ValidateFilePath(path)) { | 255 if (!ValidateFilePath(path)) { |
| 255 *error = | 256 *error = |
| 256 l10n_util::GetStringFUTF8(IDS_EXTENSION_LOAD_ICON_FAILED, | 257 l10n_util::GetStringFUTF8(IDS_EXTENSION_LOAD_ICON_FAILED, |
| 257 UTF8ToUTF16(iter->second)); | 258 UTF8ToUTF16(iter->second)); |
| 258 return false; | 259 return false; |
| 259 } | 260 } |
| 260 } | 261 } |
| 261 | 262 |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 755 return FilePath(); | 756 return FilePath(); |
| 756 } | 757 } |
| 757 return temp_path; | 758 return temp_path; |
| 758 } | 759 } |
| 759 | 760 |
| 760 void DeleteFile(const FilePath& path, bool recursive) { | 761 void DeleteFile(const FilePath& path, bool recursive) { |
| 761 file_util::Delete(path, recursive); | 762 file_util::Delete(path, recursive); |
| 762 } | 763 } |
| 763 | 764 |
| 764 } // namespace extension_file_util | 765 } // namespace extension_file_util |
| OLD | NEW |