Skip to content

Commit

Permalink
Move StringToLowerASCII to base namespace
Browse files Browse the repository at this point in the history
TBR=sky

Review URL: https://codereview.chromium.org/448853002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@288085 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
brettw@chromium.org committed Aug 7, 2014
1 parent b7a95ad commit cb1f4ac
Show file tree
Hide file tree
Showing 145 changed files with 286 additions and 258 deletions.
2 changes: 1 addition & 1 deletion android_webview/browser/aw_content_browser_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ std::string AwContentBrowserClient::GetAcceptLangsImpl() {

// If we're not en-US, add in en-US which will be
// used with a lower q-value.
if (StringToLowerASCII(langs) != "en-us") {
if (base::StringToLowerASCII(langs) != "en-us") {
langs += ",en-US";
}
return langs;
Expand Down
4 changes: 2 additions & 2 deletions ash/system/chromeos/network/network_connect.cc
Original file line number Diff line number Diff line change
Expand Up @@ -567,8 +567,8 @@ base::string16 ErrorString(const std::string& error,
IDS_CHROMEOS_NETWORK_ERROR_PPP_AUTH_FAILED);
}

if (StringToLowerASCII(error) ==
StringToLowerASCII(std::string(shill::kUnknownString))) {
if (base::StringToLowerASCII(error) ==
base::StringToLowerASCII(std::string(shill::kUnknownString))) {
return l10n_util::GetStringUTF16(IDS_CHROMEOS_NETWORK_ERROR_UNKNOWN);
}
return l10n_util::GetStringFUTF16(IDS_NETWORK_UNRECOGNIZED_ERROR,
Expand Down
2 changes: 1 addition & 1 deletion base/command_line.cc
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void AppendSwitchesAndArguments(CommandLine& command_line,
// Lowercase switches for backwards compatiblity *on Windows*.
std::string LowerASCIIOnWindows(const std::string& string) {
#if defined(OS_WIN)
return StringToLowerASCII(string);
return base::StringToLowerASCII(string);
#elif defined(OS_POSIX)
return string;
#endif
Expand Down
2 changes: 1 addition & 1 deletion base/environment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class EnvironmentImpl : public base::Environment {
if (first_char >= 'a' && first_char <= 'z')
alternate_case_var = StringToUpperASCII(std::string(variable_name));
else if (first_char >= 'A' && first_char <= 'Z')
alternate_case_var = StringToLowerASCII(std::string(variable_name));
alternate_case_var = base::StringToLowerASCII(std::string(variable_name));
else
return false;
return GetVarImpl(alternate_case_var.c_str(), result);
Expand Down
2 changes: 1 addition & 1 deletion base/i18n/rtl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ std::string GetLocaleString(const icu::Locale& locale) {

if (variant != NULL && *variant != '\0') {
std::string variant_str(variant);
StringToLowerASCII(&variant_str);
base::StringToLowerASCII(&variant_str);
result += '@' + variant_str;
}

Expand Down
22 changes: 11 additions & 11 deletions base/strings/string_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,21 +249,11 @@ BASE_EXPORT bool IsStringUTF8(const std::string& str);
BASE_EXPORT bool IsStringASCII(const StringPiece& str);
BASE_EXPORT bool IsStringASCII(const string16& str);

} // namespace base

#if defined(OS_WIN)
#include "base/strings/string_util_win.h"
#elif defined(OS_POSIX)
#include "base/strings/string_util_posix.h"
#else
#error Define string operations appropriately for your platform
#endif

// Converts the elements of the given string. This version uses a pointer to
// clearly differentiate it from the non-pointer variant.
template <class str> inline void StringToLowerASCII(str* s) {
for (typename str::iterator i = s->begin(); i != s->end(); ++i)
*i = base::ToLowerASCII(*i);
*i = ToLowerASCII(*i);
}

template <class str> inline str StringToLowerASCII(const str& s) {
Expand All @@ -273,6 +263,16 @@ template <class str> inline str StringToLowerASCII(const str& s) {
return output;
}

} // namespace base

#if defined(OS_WIN)
#include "base/strings/string_util_win.h"
#elif defined(OS_POSIX)
#include "base/strings/string_util_posix.h"
#else
#error Define string operations appropriately for your platform
#endif

// Converts the elements of the given string. This version uses a pointer to
// clearly differentiate it from the non-pointer variant.
template <class str> inline void StringToUpperASCII(str* s) {
Expand Down
2 changes: 1 addition & 1 deletion chrome/app/chrome_main_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ bool HasDeprecatedArguments(const std::wstring& command_line) {
const wchar_t kChromeHtml[] = L"chromehtml:";
std::wstring command_line_lower = command_line;
// We are only searching for ASCII characters so this is OK.
StringToLowerASCII(&command_line_lower);
base::StringToLowerASCII(&command_line_lower);
std::wstring::size_type pos = command_line_lower.find(kChromeHtml);
return (pos != std::wstring::npos);
}
Expand Down
3 changes: 2 additions & 1 deletion chrome/app/signature_validator_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ bool ExtractPublicKeyHash(const CERT_CONTEXT* cert_context,
crypt_blob.pbData), crypt_blob.cbData);
crypto::SHA256HashString(key_bytes, hash, crypto::kSHA256Length);

*public_key_hash = StringToLowerASCII(base::HexEncode(hash, arraysize(hash)));
*public_key_hash =
base::StringToLowerASCII(base::HexEncode(hash, arraysize(hash)));
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion chrome/app/signature_validator_win_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class SignatureValidatorTest : public testing::Test {
crypto::SHA256HashString(key_bytes, hash, crypto::kSHA256Length);

std::string public_key_hash =
StringToLowerASCII(base::HexEncode(hash, arraysize(hash)));
base::StringToLowerASCII(base::HexEncode(hash, arraysize(hash)));
expected_hashes_.push_back(public_key_hash);
}

Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/chromeos/customization_document.cc
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ void ServicesCustomizationDocument::StartFetching() {
&customization_id) &&
!customization_id.empty()) {
url_ = GURL(base::StringPrintf(
kManifestUrl, StringToLowerASCII(customization_id).c_str()));
kManifestUrl, base::StringToLowerASCII(customization_id).c_str()));
} else {
// Remember that there is no customization ID in VPD.
OnCustomizationNotFound();
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/chromeos/file_manager/file_tasks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ void UpdateDefaultTask(PrefService* pref_service,
iter != suffixes.end(); ++iter) {
base::StringValue* value = new base::StringValue(task_id);
// Suffixes are case insensitive.
std::string lower_suffix = StringToLowerASCII(*iter);
std::string lower_suffix = base::StringToLowerASCII(*iter);
mime_type_pref->SetWithoutPathExpansion(lower_suffix, value);
}
}
Expand Down Expand Up @@ -215,7 +215,7 @@ std::string GetDefaultTaskIdFromPrefs(const PrefService& pref_service,
pref_service.GetDictionary(prefs::kDefaultTasksBySuffix);
DCHECK(suffix_task_prefs);
LOG_IF(ERROR, !suffix_task_prefs) << "Unable to open suffix prefs";
std::string lower_suffix = StringToLowerASCII(suffix);
std::string lower_suffix = base::StringToLowerASCII(suffix);
if (suffix_task_prefs)
suffix_task_prefs->GetStringWithoutPathExpansion(lower_suffix, &task_id);
VLOG_IF(1, !task_id.empty()) << "Found suffix default handler: " << task_id;
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/chromeos/login/existing_user_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1137,7 +1137,7 @@ void ExistingUserController::InitializeStartUrls() const {
const char* url = kChromeVoxTutorialURLPattern;
PrefService* prefs = g_browser_process->local_state();
const std::string current_locale =
StringToLowerASCII(prefs->GetString(prefs::kApplicationLocale));
base::StringToLowerASCII(prefs->GetString(prefs::kApplicationLocale));
std::string vox_url = base::StringPrintf(url, current_locale.c_str());
start_urls.push_back(vox_url);
can_show_getstarted_guide = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const int kMasterKeySize = 32;
std::string CreateSalt() {
char result[kSaltSize];
crypto::RandBytes(&result, sizeof(result));
return StringToLowerASCII(base::HexEncode(
return base::StringToLowerASCII(base::HexEncode(
reinterpret_cast<const void*>(result),
sizeof(result)));
}
Expand Down Expand Up @@ -163,7 +163,7 @@ bool SupervisedUserAuthentication::FillDataForNewUser(
std::string SupervisedUserAuthentication::GenerateMasterKey() {
char master_key_bytes[kMasterKeySize];
crypto::RandBytes(&master_key_bytes, sizeof(master_key_bytes));
return StringToLowerASCII(
return base::StringToLowerASCII(
base::HexEncode(reinterpret_cast<const void*>(master_key_bytes),
sizeof(master_key_bytes)));
}
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/chromeos/power/peripheral_battery_observer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ std::string ExtractBluetoothAddress(const std::string& path) {
if (key_len <= 0)
return std::string();
std::string reverse_address = path.substr(header_size, key_len);
StringToLowerASCII(&reverse_address);
base::StringToLowerASCII(&reverse_address);
std::vector<std::string> result;
base::SplitString(reverse_address, ':', &result);
std::reverse(result.begin(), result.end());
Expand Down Expand Up @@ -187,7 +187,7 @@ void PeripheralBatteryObserver::InitializeOnBluetoothReady(
void PeripheralBatteryObserver::RemoveBattery(const std::string& address) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
std::string address_lowercase = address;
StringToLowerASCII(&address_lowercase);
base::StringToLowerASCII(&address_lowercase);
std::map<std::string, BatteryInfo>::iterator it =
batteries_.find(address_lowercase);
if (it != batteries_.end()) {
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/chromeos/settings/token_encryptor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ std::string CryptohomeTokenEncryptor::EncryptTokenWithKey(
return std::string();
}

return StringToLowerASCII(base::HexEncode(
return base::StringToLowerASCII(base::HexEncode(
reinterpret_cast<const void*>(encoded_token.data()),
encoded_token.size()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ std::string HexStringToID(const std::string& hexstr) {
}

std::string GetCrxComponentID(const CrxComponent& component) {
return HexStringToID(StringToLowerASCII(
return HexStringToID(base::StringToLowerASCII(
base::HexEncode(&component.pk_hash[0], component.pk_hash.size() / 2)));
}

Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/enumerate_modules_model_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ static void GenerateHash(const std::string& input, std::string* output) {

uint8 hash[4];
crypto::SHA256HashString(input, hash, sizeof(hash));
*output = StringToLowerASCII(base::HexEncode(hash, sizeof(hash)));
*output = base::StringToLowerASCII(base::HexEncode(hash, sizeof(hash)));
}

// -----------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/extensions/api/file_system/file_system_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ bool GetFileTypesFromAcceptOption(
iter != list->end(); ++iter) {
std::vector<base::FilePath::StringType> inner;
std::string accept_type = *iter;
StringToLowerASCII(&accept_type);
base::StringToLowerASCII(&accept_type);
net::GetExtensionsForMimeType(accept_type, &inner);
if (inner.empty())
continue;
Expand All @@ -127,7 +127,7 @@ bool GetFileTypesFromAcceptOption(
for (std::vector<std::string>::const_iterator iter = list->begin();
iter != list->end(); ++iter) {
std::string extension = *iter;
StringToLowerASCII(&extension);
base::StringToLowerASCII(&extension);
#if defined(OS_WIN)
extension_set.insert(base::UTF8ToWide(*iter));
#else
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/extensions/api/gcm/gcm_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const char* GcmResultToError(gcm::GCMClient::Result result) {
}

bool IsMessageKeyValid(const std::string& key) {
std::string lower = StringToLowerASCII(key);
std::string lower = base::StringToLowerASCII(key);
return !key.empty() &&
key.compare(0, arraysize(kCollapseKey) - 1, kCollapseKey) != 0 &&
lower.compare(0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ bool ComputeHmacSha256(const std::string& key,
bool result = hmac.Init(key) &&
hmac.Sign(text, &digest[0], digest.size());
if (result) {
*signature_return = StringToLowerASCII(base::HexEncode(digest.data(),
digest.size()));
*signature_return = base::StringToLowerASCII(
base::HexEncode(digest.data(), digest.size()));
}
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class MacAddressProcessor {

// Got one!
found_mac_address_ =
StringToLowerASCII(base::HexEncode(mac_address, MAC_LENGTH));
base::StringToLowerASCII(base::HexEncode(mac_address, MAC_LENGTH));
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ class MacAddressProcessor {
if (!is_valid_mac_address_.Run(mac_address, mac_address_size))
return keep_going;

std::string mac_address_string =
StringToLowerASCII(base::HexEncode(mac_address, mac_address_size));
std::string mac_address_string = base::StringToLowerASCII(base::HexEncode(
mac_address, mac_address_size));

base::ScopedCFTypeRef<CFStringRef> provider_class(
static_cast<CFStringRef>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class MacAddressProcessor {
if (!is_valid_mac_address_.Run(bytes, size))
return;

found_mac_address_ = StringToLowerASCII(base::HexEncode(bytes, size));
found_mac_address_ = base::StringToLowerASCII(base::HexEncode(bytes, size));
found_index_ = index;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ EventResponseDelta* CalculateOnHeadersReceivedDelta(
std::string value;
while (old_response_headers->EnumerateHeaderLines(&iter, &name, &value)) {
std::string name_lowercase(name);
StringToLowerASCII(&name_lowercase);
base::StringToLowerASCII(&name_lowercase);

bool header_found = false;
for (ResponseHeaders::const_iterator i = new_response_headers->begin();
Expand Down Expand Up @@ -1017,7 +1017,7 @@ void MergeCookiesInOnHeadersReceivedResponses(
// Converts the key of the (key, value) pair to lower case.
static ResponseHeader ToLowerCase(const ResponseHeader& header) {
std::string lower_key(header.first);
StringToLowerASCII(&lower_key);
base::StringToLowerASCII(&lower_key);
return ResponseHeader(lower_key, header.second);
}

Expand All @@ -1026,13 +1026,13 @@ static ResponseHeader ToLowerCase(const ResponseHeader& header) {
static std::string FindRemoveResponseHeader(
const EventResponseDeltas& deltas,
const std::string& key) {
std::string lower_key = StringToLowerASCII(key);
std::string lower_key = base::StringToLowerASCII(key);
EventResponseDeltas::const_iterator delta;
for (delta = deltas.begin(); delta != deltas.end(); ++delta) {
ResponseHeaders::const_iterator i;
for (i = (*delta)->deleted_response_headers.begin();
i != (*delta)->deleted_response_headers.end(); ++i) {
if (StringToLowerASCII(i->first) == lower_key)
if (base::StringToLowerASCII(i->first) == lower_key)
return (*delta)->extension_id;
}
}
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/extensions/extension_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1925,7 +1925,7 @@ void ExtensionService::TerminateExtension(const std::string& extension_id) {
}

void ExtensionService::UntrackTerminatedExtension(const std::string& id) {
std::string lowercase_id = StringToLowerASCII(id);
std::string lowercase_id = base::StringToLowerASCII(id);
const Extension* extension =
registry_->terminated_extensions().GetByID(lowercase_id);
registry_->RemoveTerminated(lowercase_id);
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/extensions/external_registry_loader_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void ExternalRegistryLoader::LoadOnFileThread() {
}

std::string id = base::UTF16ToASCII(*it);
StringToLowerASCII(&id);
base::StringToLowerASCII(&id);
if (!Extension::IdIsValid(id)) {
LOG(ERROR) << "Invalid id value " << id
<< " for key " << key_path << ".";
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/extensions/updater/local_extension_cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ void LocalExtensionCache::BackendCheckCacheContentsInternal(
}

// Enforce a lower-case id.
id = StringToLowerASCII(id);
id = base::StringToLowerASCII(id);
if (!extensions::Extension::IdIsValid(id)) {
LOG(ERROR) << "Bad extension id in cache: " << id;
id.clear();
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/file_select_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ bool FileSelectHelper::IsAcceptTypeValid(const std::string& accept_type) {
// of an extension or a "/" in the case of a MIME type).
std::string unused;
if (accept_type.length() <= 1 ||
StringToLowerASCII(accept_type) != accept_type ||
base::StringToLowerASCII(accept_type) != accept_type ||
base::TrimWhitespaceASCII(accept_type, base::TRIM_ALL, &unused) !=
base::TRIM_NONE) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/icon_loader_chromeos.cc
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ int IconSizeToDIPSize(IconLoader::IconSize size) {
// static
IconGroupID IconLoader::ReadGroupIDFromFilepath(
const base::FilePath& filepath) {
return StringToLowerASCII(filepath.Extension());
return base::StringToLowerASCII(filepath.Extension());
}

// static
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/importer/in_process_importer_bridge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class FirefoxURLParameterFilter : public TemplateURLParser::ParameterFilter {
// TemplateURLParser::ParameterFilter method.
virtual bool KeepParameter(const std::string& key,
const std::string& value) OVERRIDE {
std::string low_value = StringToLowerASCII(value);
std::string low_value = base::StringToLowerASCII(value);
if (low_value.find("mozilla") != std::string::npos ||
low_value.find("firefox") != std::string::npos ||
low_value.find("moz:") != std::string::npos) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "chrome/browser/install_verification/win/module_list.h"

std::string CalculateModuleNameDigest(const base::string16& module_name) {
return base::MD5String(StringToLowerASCII(base::UTF16ToUTF8(
return base::MD5String(base::StringToLowerASCII(base::UTF16ToUTF8(
base::FilePath(module_name).BaseName().value())));
}

Expand Down
3 changes: 2 additions & 1 deletion chrome/browser/media_galleries/fileapi/media_path_filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ bool MediaPathFilter::Match(const base::FilePath& path) {
MediaGalleryScanFileType MediaPathFilter::GetType(const base::FilePath& path) {
EnsureInitialized();
MediaFileExtensionMap::const_iterator it =
media_file_extensions_map_.find(StringToLowerASCII(path.Extension()));
media_file_extensions_map_.find(
base::StringToLowerASCII(path.Extension()));
if (it == media_file_extensions_map_.end())
return MEDIA_GALLERY_SCAN_FILE_TYPE_UNKNOWN;
return static_cast<MediaGalleryScanFileType>(it->second);
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/prefs/pref_hash_calculator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ std::string GenerateDeviceIdLikePrefMetricsServiceDid(
const std::string& original_device_id) {
if (original_device_id.empty())
return std::string();
return StringToLowerASCII(
return base::StringToLowerASCII(
GetDigestString(original_device_id, "PrefMetricsService"));
}

Expand Down
Loading

0 comments on commit cb1f4ac

Please sign in to comment.