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

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

Issue 3056029: Move the number conversions from string_util to a new file.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 5 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 | « chrome/common/child_process_logging_win.cc ('k') | chrome/common/extensions/update_manifest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/extension.cc
===================================================================
--- chrome/common/extensions/extension.cc (revision 54340)
+++ chrome/common/extensions/extension.cc (working copy)
@@ -18,6 +18,7 @@
#include "base/stl_util-inl.h"
#include "base/third_party/nss/blapi.h"
#include "base/third_party/nss/sha256.h"
+#include "base/string_number_conversions.h"
#include "base/utf_string_conversions.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_switches.h"
@@ -61,8 +62,13 @@
// completely numeric host, since some software interprets that as an IP
// address.
static void ConvertHexadecimalToIDAlphabet(std::string* id) {
- for (size_t i = 0; i < id->size(); ++i)
- (*id)[i] = HexStringToInt(id->substr(i, 1)) + 'a';
+ for (size_t i = 0; i < id->size(); ++i) {
+ int val;
+ if (base::HexStringToInt(id->substr(i, 1), &val))
+ (*id)[i] = val + 'a';
+ else
+ (*id)[i] = 'a';
+ }
}
const int kValidWebExtentSchemes =
@@ -221,7 +227,7 @@
std::string run_location;
if (!content_script->GetString(keys::kRunAt, &run_location)) {
*error = ExtensionErrorUtils::FormatErrorMessage(errors::kInvalidRunAt,
- IntToString(definition_index));
+ base::IntToString(definition_index));
return false;
}
@@ -233,7 +239,7 @@
result->set_run_location(UserScript::DOCUMENT_IDLE);
} else {
*error = ExtensionErrorUtils::FormatErrorMessage(errors::kInvalidRunAt,
- IntToString(definition_index));
+ base::IntToString(definition_index));
return false;
}
}
@@ -243,7 +249,7 @@
bool all_frames = false;
if (!content_script->GetBoolean(keys::kAllFrames, &all_frames)) {
*error = ExtensionErrorUtils::FormatErrorMessage(
- errors::kInvalidAllFrames, IntToString(definition_index));
+ errors::kInvalidAllFrames, base::IntToString(definition_index));
return false;
}
result->set_match_all_frames(all_frames);
@@ -253,27 +259,27 @@
ListValue* matches = NULL;
if (!content_script->GetList(keys::kMatches, &matches)) {
*error = ExtensionErrorUtils::FormatErrorMessage(errors::kInvalidMatches,
- IntToString(definition_index));
+ base::IntToString(definition_index));
return false;
}
if (matches->GetSize() == 0) {
*error = ExtensionErrorUtils::FormatErrorMessage(errors::kInvalidMatchCount,
- IntToString(definition_index));
+ base::IntToString(definition_index));
return false;
}
for (size_t j = 0; j < matches->GetSize(); ++j) {
std::string match_str;
if (!matches->GetString(j, &match_str)) {
*error = ExtensionErrorUtils::FormatErrorMessage(errors::kInvalidMatch,
- IntToString(definition_index), IntToString(j));
+ base::IntToString(definition_index), base::IntToString(j));
return false;
}
URLPattern pattern(UserScript::kValidUserScriptSchemes);
if (!pattern.Parse(match_str)) {
*error = ExtensionErrorUtils::FormatErrorMessage(errors::kInvalidMatch,
- IntToString(definition_index), IntToString(j));
+ base::IntToString(definition_index), base::IntToString(j));
return false;
}
@@ -296,7 +302,7 @@
if (content_script->HasKey(keys::kJs) &&
!content_script->GetList(keys::kJs, &js)) {
*error = ExtensionErrorUtils::FormatErrorMessage(errors::kInvalidJsList,
- IntToString(definition_index));
+ base::IntToString(definition_index));
return false;
}
@@ -304,14 +310,14 @@
if (content_script->HasKey(keys::kCss) &&
!content_script->GetList(keys::kCss, &css)) {
*error = ExtensionErrorUtils::FormatErrorMessage(errors::kInvalidCssList,
- IntToString(definition_index));
+ base::IntToString(definition_index));
return false;
}
// The manifest needs to have at least one js or css user script definition.
if (((js ? js->GetSize() : 0) + (css ? css->GetSize() : 0)) == 0) {
*error = ExtensionErrorUtils::FormatErrorMessage(errors::kMissingFile,
- IntToString(definition_index));
+ base::IntToString(definition_index));
return false;
}
@@ -322,7 +328,8 @@
std::string relative;
if (!js->Get(script_index, &value) || !value->GetAsString(&relative)) {
*error = ExtensionErrorUtils::FormatErrorMessage(errors::kInvalidJs,
- IntToString(definition_index), IntToString(script_index));
+ base::IntToString(definition_index),
+ base::IntToString(script_index));
return false;
}
GURL url = GetResourceURL(relative);
@@ -339,7 +346,8 @@
std::string relative;
if (!css->Get(script_index, &value) || !value->GetAsString(&relative)) {
*error = ExtensionErrorUtils::FormatErrorMessage(errors::kInvalidCss,
- IntToString(definition_index), IntToString(script_index));
+ base::IntToString(definition_index),
+ base::IntToString(script_index));
return false;
}
GURL url = GetResourceURL(relative);
@@ -365,7 +373,8 @@
ListValue* list = NULL;
if (!content_script->GetList(globs_property_name, &list)) {
*error = ExtensionErrorUtils::FormatErrorMessage(errors::kInvalidGlobList,
- IntToString(content_script_index), WideToASCII(globs_property_name));
+ base::IntToString(content_script_index),
+ WideToUTF8(globs_property_name));
return false;
}
@@ -373,8 +382,9 @@
std::string glob;
if (!list->GetString(i, &glob)) {
*error = ExtensionErrorUtils::FormatErrorMessage(errors::kInvalidGlob,
- IntToString(content_script_index), WideToASCII(globs_property_name),
- IntToString(i));
+ base::IntToString(content_script_index),
+ WideToUTF8(globs_property_name),
+ base::IntToString(i));
return false;
}
@@ -558,14 +568,14 @@
std::string pattern_string;
if (!pattern_list->GetString(i, &pattern_string)) {
*error = ExtensionErrorUtils::FormatErrorMessage(value_error,
- UintToString(i));
+ base::UintToString(i));
return false;
}
URLPattern pattern(kValidWebExtentSchemes);
if (!pattern.Parse(pattern_string)) {
*error = ExtensionErrorUtils::FormatErrorMessage(value_error,
- UintToString(i));
+ base::UintToString(i));
return false;
}
@@ -573,7 +583,7 @@
// imply one at the end.
if (pattern.path().find('*') != std::string::npos) {
*error = ExtensionErrorUtils::FormatErrorMessage(value_error,
- UintToString(i));
+ base::UintToString(i));
return false;
}
pattern.set_path(pattern.path() + '*');
@@ -925,8 +935,8 @@
if (decoded->width() != icon_size || decoded->height() != icon_size) {
LOG(ERROR) << "Icon file has unexpected size: "
- << IntToString(decoded->width()) << "x"
- << IntToString(decoded->height());
+ << base::IntToString(decoded->width()) << "x"
+ << base::IntToString(decoded->height());
return;
}
@@ -1074,7 +1084,7 @@
}
for (size_t i = 0; i < arraysize(kIconSizes); ++i) {
- std::wstring key = ASCIIToWide(IntToString(kIconSizes[i]));
+ std::wstring key = ASCIIToWide(base::IntToString(kIconSizes[i]));
if (icons_value->HasKey(key)) {
std::string icon_path;
if (!icons_value->GetString(key, &icon_path)) {
@@ -1199,7 +1209,7 @@
// Get plugins[i].path.
if (!plugin_value->GetString(keys::kPluginsPath, &path)) {
*error = ExtensionErrorUtils::FormatErrorMessage(
- errors::kInvalidPluginsPath, IntToString(i));
+ errors::kInvalidPluginsPath, base::IntToString(i));
return false;
}
@@ -1207,7 +1217,7 @@
if (plugin_value->HasKey(keys::kPluginsPublic)) {
if (!plugin_value->GetBoolean(keys::kPluginsPublic, &is_public)) {
*error = ExtensionErrorUtils::FormatErrorMessage(
- errors::kInvalidPluginsPublic, IntToString(i));
+ errors::kInvalidPluginsPublic, base::IntToString(i));
return false;
}
}
@@ -1260,7 +1270,7 @@
if (!toolstrip_value->GetString(keys::kToolstripPath,
&toolstrip_path)) {
*error = ExtensionErrorUtils::FormatErrorMessage(
- errors::kInvalidToolstrip, IntToString(i));
+ errors::kInvalidToolstrip, base::IntToString(i));
return false;
}
toolstrip.toolstrip = GetResourceURL(toolstrip_path);
@@ -1269,14 +1279,14 @@
if (!toolstrip_value->GetString(keys::kToolstripMolePath,
&mole_path)) {
*error = ExtensionErrorUtils::FormatErrorMessage(
- errors::kInvalidToolstrip, IntToString(i));
+ errors::kInvalidToolstrip, base::IntToString(i));
return false;
}
int height;
if (!toolstrip_value->GetInteger(keys::kToolstripMoleHeight,
&height) || (height < 0)) {
*error = ExtensionErrorUtils::FormatErrorMessage(
- errors::kInvalidToolstrip, IntToString(i));
+ errors::kInvalidToolstrip, base::IntToString(i));
return false;
}
toolstrip.mole = GetResourceURL(mole_path);
@@ -1284,7 +1294,7 @@
}
} else {
*error = ExtensionErrorUtils::FormatErrorMessage(
- errors::kInvalidToolstrip, IntToString(i));
+ errors::kInvalidToolstrip, base::IntToString(i));
return false;
}
toolstrips_.push_back(toolstrip);
@@ -1303,7 +1313,7 @@
DictionaryValue* content_script;
if (!list_value->GetDictionary(i, &content_script)) {
*error = ExtensionErrorUtils::FormatErrorMessage(
- errors::kInvalidContentScript, IntToString(i));
+ errors::kInvalidContentScript, base::IntToString(i));
return false;
}
@@ -1391,7 +1401,7 @@
std::string permission_str;
if (!permissions->GetString(i, &permission_str)) {
*error = ExtensionErrorUtils::FormatErrorMessage(
- errors::kInvalidPermission, IntToString(i));
+ errors::kInvalidPermission, base::IntToString(i));
return false;
}
@@ -1407,13 +1417,13 @@
URLPattern::SCHEME_CHROMEUI);
if (!pattern.Parse(permission_str)) {
*error = ExtensionErrorUtils::FormatErrorMessage(
- errors::kInvalidPermission, IntToString(i));
+ errors::kInvalidPermission, base::IntToString(i));
return false;
}
if (!CanAccessURL(pattern)) {
*error = ExtensionErrorUtils::FormatErrorMessage(
- errors::kInvalidPermissionScheme, IntToString(i));
+ errors::kInvalidPermissionScheme, base::IntToString(i));
return false;
}
@@ -1579,7 +1589,8 @@
}
static std::string SizeToString(const gfx::Size& max_size) {
- return IntToString(max_size.width()) + "x" + IntToString(max_size.height());
+ return base::IntToString(max_size.width()) + "x" +
+ base::IntToString(max_size.height());
}
void Extension::SetCachedImage(const ExtensionResource& source,
« no previous file with comments | « chrome/common/child_process_logging_win.cc ('k') | chrome/common/extensions/update_manifest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698