Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2512)

Unified Diff: chrome/common/extensions/extension.cc

Issue 10957008: Normalize extension action icon paths before adding them to icon set (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/extension.cc
diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc
index 1b3e947a1b50a4fadc104b8175c0f88978ceaca4..f6df45d0d04ed52f71d3f23c8c147b654c426951 100644
--- a/chrome/common/extensions/extension.cc
+++ b/chrome/common/extensions/extension.cc
@@ -150,14 +150,15 @@ bool LoadIconsFromDictionary(const DictionaryValue* icons_value,
return false;
}
- if (!icon_path.empty() && icon_path[0] == '/')
- icon_path = icon_path.substr(1);
-
if (icon_path.empty()) {
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
errors::kInvalidIconPath, key);
return false;
}
+
+ if (icon_path[0] == '/')
not at google - send to devlin 2012/09/20 06:00:55 should be "while" not "if"? also seems like this
tbarzic 2012/09/20 06:45:06 Done.
+ icon_path = icon_path.substr(1);
+
icons->Add(icon_sizes[i], icon_path);
}
}
@@ -857,6 +858,9 @@ scoped_ptr<ExtensionAction> Extension::LoadExtensionActionHelper(
return scoped_ptr<ExtensionAction>();
}
+ if (path[0] == '/')
not at google - send to devlin 2012/09/20 06:00:55 ditto while? actually it seems like this (and sam
tbarzic 2012/09/20 06:45:06 Yeah, good point.. Done.
+ path = path.substr(1);
+
scoped_ptr<ExtensionIconSet> icon_set(new ExtensionIconSet);
icon_set->Add(extension_misc::EXTENSION_ICON_ACTION, path);
result->set_default_icon(icon_set.Pass());
@@ -895,6 +899,9 @@ scoped_ptr<ExtensionAction> Extension::LoadExtensionActionHelper(
} else if (extension_action->GetString(keys::kPageActionDefaultIcon,
&default_icon) &&
!default_icon.empty()) {
+ if (default_icon[0] == '/')
+ default_icon = default_icon.substr(1);
+
scoped_ptr<ExtensionIconSet> icon_set(new ExtensionIconSet);
icon_set->Add(extension_misc::EXTENSION_ICON_ACTION, default_icon);
result->set_default_icon(icon_set.Pass());
@@ -2417,9 +2424,8 @@ bool Extension::LoadScriptBadge(string16* error) {
for (size_t i = 0; i < extension_misc::kNumScriptBadgeIconSizes; i++) {
std::string path = icons().Get(extension_misc::kScriptBadgeIconSizes[i],
ExtensionIconSet::MATCH_EXACTLY);
- if (!path.empty()) {
+ if (!path.empty())
icon_set->Add(extension_misc::kScriptBadgeIconSizes[i], path);
- }
}
if (!icon_set->map().empty()) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698