Chromium Code Reviews| Index: chrome/common/extensions/extension_file_util.cc |
| diff --git a/chrome/common/extensions/extension_file_util.cc b/chrome/common/extensions/extension_file_util.cc |
| index 4c2fbb00783500b17dc3a91adca890e73b2caab6..687911c279ce59341b7d0d0dc958f8ea4e04afd2 100644 |
| --- a/chrome/common/extensions/extension_file_util.cc |
| +++ b/chrome/common/extensions/extension_file_util.cc |
| @@ -19,6 +19,8 @@ |
| #include "base/utf_string_conversions.h" |
| #include "chrome/common/chrome_constants.h" |
| #include "chrome/common/chrome_paths.h" |
| +#include "chrome/common/extensions/api/extension_action/action_info.h" |
| +#include "chrome/common/extensions/api/icons/icons_handler.h" |
| #include "chrome/common/extensions/extension.h" |
| #include "chrome/common/extensions/extension_icon_set.h" |
| #include "chrome/common/extensions/extension_l10n_util.h" |
| @@ -26,6 +28,7 @@ |
| #include "chrome/common/extensions/extension_messages.h" |
| #include "chrome/common/extensions/manifest.h" |
| #include "chrome/common/extensions/manifest_handler.h" |
| +#include "chrome/common/extensions/manifest_handlers/theme_handler.h" |
| #include "chrome/common/extensions/message_bundle.h" |
| #include "extensions/common/constants.h" |
| #include "extensions/common/extension_resource.h" |
| @@ -45,6 +48,18 @@ namespace { |
| const base::FilePath::CharType kTempDirectoryName[] = FILE_PATH_LITERAL("Temp"); |
| +// Add the image paths contained in the |icon_set| to |image_paths|. |
| +void AddPathsFromIconSet(const ExtensionIconSet& icon_set, |
| + std::set<base::FilePath>* image_paths) { |
| + // TODO(viettrungluu): These |FilePath::FromWStringHack(UTF8ToWide())| |
| + // indicate that we're doing something wrong. |
| + for (ExtensionIconSet::IconMap::const_iterator iter = icon_set.map().begin(); |
| + iter != icon_set.map().end(); ++iter) { |
| + image_paths->insert( |
| + base::FilePath::FromWStringHack(UTF8ToWide(iter->second))); |
|
Yoyo Zhou
2013/04/10 21:44:58
Seems like we should be using FromUTF8Unsafe inste
Devlin
2013/04/12 02:17:06
Done (will change if viettrungluu would prefer som
viettrungluu
2013/04/12 22:33:15
Yes, I agree (assuming that we know for sure that
|
| + } |
| +} |
| + |
| } // namespace |
| namespace extension_file_util { |
| @@ -279,6 +294,36 @@ bool ValidateExtension(const Extension* extension, |
| return true; |
| } |
| +std::set<base::FilePath> GetExtensionBrowserImages(const Extension* extension) { |
| + std::set<base::FilePath> image_paths; |
| + |
| + AddPathsFromIconSet(extensions::IconsInfo::GetIcons(extension), &image_paths); |
| + |
| + // Theme images |
| + const base::DictionaryValue* theme_images = |
| + extensions::ThemeInfo::GetImages(extension); |
| + if (theme_images) { |
| + for (base::DictionaryValue::Iterator it(*theme_images); !it.IsAtEnd(); |
| + it.Advance()) { |
| + base::FilePath::StringType path; |
| + if (it.value().GetAsString(&path)) |
| + image_paths.insert(base::FilePath(path)); |
| + } |
| + } |
| + |
| + const extensions::ActionInfo* page_action = |
| + extensions::ActionInfo::GetPageActionInfo(extension); |
| + if (page_action && !page_action->default_icon.empty()) |
| + AddPathsFromIconSet(page_action->default_icon, &image_paths); |
| + |
| + const extensions::ActionInfo* browser_action = |
| + extensions::ActionInfo::GetBrowserActionInfo(extension); |
| + if (browser_action && !browser_action->default_icon.empty()) |
| + AddPathsFromIconSet(browser_action->default_icon, &image_paths); |
| + |
| + return image_paths; |
| +} |
| + |
| void GarbageCollectExtensions( |
| const base::FilePath& install_directory, |
| const std::multimap<std::string, base::FilePath>& extension_paths) { |