diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-07 14:38:26 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-07 14:38:26 +0000 |
commit | 52796541ecc14a0aa287ec0859e23350fed71278 (patch) | |
tree | 62d8cd37dc5d8eabaa87d5e62150142154465ff4 | |
parent | 70d4450270d54a051b3b5ea828814ced1c29857f (diff) | |
download | chromium_src-52796541ecc14a0aa287ec0859e23350fed71278.zip chromium_src-52796541ecc14a0aa287ec0859e23350fed71278.tar.gz chromium_src-52796541ecc14a0aa287ec0859e23350fed71278.tar.bz2 |
Move IsStringUTF8/ASCII to base namespace
TBR=sky@chromium.org
Review URL: https://codereview.chromium.org/270183002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@268754 0039d316-1c4b-4281-b951-d872f2087c98
60 files changed, 127 insertions, 124 deletions
diff --git a/base/files/file_path.cc b/base/files/file_path.cc index f5a9e5a..a8b2713 100644 --- a/base/files/file_path.cc +++ b/base/files/file_path.cc @@ -521,7 +521,7 @@ FilePath FilePath::Append(const FilePath& component) const { } FilePath FilePath::AppendASCII(const StringPiece& component) const { - DCHECK(IsStringASCII(component)); + DCHECK(base::IsStringASCII(component)); #if defined(OS_WIN) return Append(ASCIIToUTF16(component.as_string())); #elif defined(OS_POSIX) @@ -587,7 +587,7 @@ string16 FilePath::LossyDisplayName() const { } std::string FilePath::MaybeAsASCII() const { - if (IsStringASCII(path_)) + if (base::IsStringASCII(path_)) return path_; return std::string(); } @@ -632,7 +632,7 @@ string16 FilePath::LossyDisplayName() const { } std::string FilePath::MaybeAsASCII() const { - if (IsStringASCII(path_)) + if (base::IsStringASCII(path_)) return UTF16ToASCII(path_); return std::string(); } diff --git a/base/strings/string_util.cc b/base/strings/string_util.cc index e514ac1..0adb989 100644 --- a/base/strings/string_util.cc +++ b/base/strings/string_util.cc @@ -324,8 +324,6 @@ bool ContainsOnlyChars(const StringPiece16& input, return input.find_first_not_of(characters) == StringPiece16::npos; } -} // namespace base - template<class STR> static bool DoIsStringASCII(const STR& str) { for (size_t i = 0; i < str.length(); i++) { @@ -336,11 +334,11 @@ static bool DoIsStringASCII(const STR& str) { return true; } -bool IsStringASCII(const base::StringPiece& str) { +bool IsStringASCII(const StringPiece& str) { return DoIsStringASCII(str); } -bool IsStringASCII(const base::string16& str) { +bool IsStringASCII(const string16& str) { return DoIsStringASCII(str); } @@ -352,12 +350,14 @@ bool IsStringUTF8(const std::string& str) { while (char_index < src_len) { int32 code_point; CBU8_NEXT(src, char_index, src_len, code_point); - if (!base::IsValidCharacter(code_point)) + if (!IsValidCharacter(code_point)) return false; } return true; } +} // namespace base + template<typename Iter> static inline bool DoLowerCaseEqualsASCII(Iter a_begin, Iter a_end, diff --git a/base/strings/string_util.h b/base/strings/string_util.h index 473deae..9478a0c 100644 --- a/base/strings/string_util.h +++ b/base/strings/string_util.h @@ -234,16 +234,6 @@ BASE_EXPORT bool ContainsOnlyChars(const StringPiece& input, BASE_EXPORT bool ContainsOnlyChars(const StringPiece16& input, const StringPiece16& characters); -} // 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 - // Returns true if the specified string matches the criteria. How can a wide // string be 8-bit or UTF8? It contains only characters that are < 256 (in the // first case) or characters that use only 8-bits and whose 8-bit @@ -256,8 +246,18 @@ BASE_EXPORT bool ContainsOnlyChars(const StringPiece16& input, // there's a use case for just checking the structural validity, we have to // add a new function for that. BASE_EXPORT bool IsStringUTF8(const std::string& str); -BASE_EXPORT bool IsStringASCII(const base::StringPiece& str); -BASE_EXPORT bool IsStringASCII(const base::string16& 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. diff --git a/chrome/app/chrome_main_delegate.cc b/chrome/app/chrome_main_delegate.cc index 6e93a8f..2c29876 100644 --- a/chrome/app/chrome_main_delegate.cc +++ b/chrome/app/chrome_main_delegate.cc @@ -339,7 +339,7 @@ void InitializeUserDataDir() { std::string user_data_dir_string; scoped_ptr<base::Environment> environment(base::Environment::Create()); if (environment->GetVar("CHROME_USER_DATA_DIR", &user_data_dir_string) && - IsStringUTF8(user_data_dir_string)) { + base::IsStringUTF8(user_data_dir_string)) { user_data_dir = base::FilePath::FromUTF8Unsafe(user_data_dir_string); } } diff --git a/chrome/browser/bookmarks/bookmark_html_writer.cc b/chrome/browser/bookmarks/bookmark_html_writer.cc index 8d4796c..82bf59c 100644 --- a/chrome/browser/bookmarks/bookmark_html_writer.cc +++ b/chrome/browser/bookmarks/bookmark_html_writer.cc @@ -205,7 +205,7 @@ class Writer : public base::RefCountedThreadSafe<Writer> { // Writes out the text string (as UTF8). The text is escaped based on // type. bool Write(const std::string& text, TextType type) { - DCHECK(IsStringUTF8(text)); + DCHECK(base::IsStringUTF8(text)); std::string utf8_string; switch (type) { diff --git a/chrome/browser/chromeos/drive/file_system_util.cc b/chrome/browser/chromeos/drive/file_system_util.cc index 9eb52e2..5cba03b 100644 --- a/chrome/browser/chromeos/drive/file_system_util.cc +++ b/chrome/browser/chromeos/drive/file_system_util.cc @@ -299,7 +299,7 @@ std::string UnescapeCacheFileName(const std::string& filename) { } std::string NormalizeFileName(const std::string& input) { - DCHECK(IsStringUTF8(input)); + DCHECK(base::IsStringUTF8(input)); std::string output; if (!base::ConvertToUtf8AndNormalize(input, base::kCodepageUTF8, &output)) diff --git a/chrome/browser/chromeos/system/syslogs_provider.cc b/chrome/browser/chromeos/system/syslogs_provider.cc index b30212b..92feef7 100644 --- a/chrome/browser/chromeos/system/syslogs_provider.cc +++ b/chrome/browser/chromeos/system/syslogs_provider.cc @@ -158,7 +158,7 @@ LogDictionaryType* GetSystemLogs(base::FilePath* zip_file_name, base::TrimWhitespaceASCII(key, base::TRIM_ALL, &key); if (!key.empty()) { std::string value = ReadValue(&data); - if (IsStringUTF8(value)) { + if (base::IsStringUTF8(value)) { base::TrimWhitespaceASCII(value, base::TRIM_ALL, &value); if (value.empty()) (*logs)[key] = kEmptyLogEntry; diff --git a/chrome/browser/download/download_extensions.cc b/chrome/browser/download/download_extensions.cc index 4d36aa0..75ebb01 100644 --- a/chrome/browser/download/download_extensions.cc +++ b/chrome/browser/download/download_extensions.cc @@ -209,7 +209,7 @@ DownloadDangerLevel GetFileDangerLevel(const base::FilePath& path) { base::FilePath::StringType extension(path.FinalExtension()); if (extension.empty()) return NOT_DANGEROUS; - if (!IsStringASCII(extension)) + if (!base::IsStringASCII(extension)) return NOT_DANGEROUS; #if defined(OS_WIN) std::string ascii_extension = base::UTF16ToASCII(extension); diff --git a/chrome/browser/extensions/api/cookies/cookies_helpers.cc b/chrome/browser/extensions/api/cookies/cookies_helpers.cc index 750bd1e..910ebb6 100644 --- a/chrome/browser/extensions/api/cookies/cookies_helpers.cc +++ b/chrome/browser/extensions/api/cookies/cookies_helpers.cc @@ -76,8 +76,8 @@ scoped_ptr<Cookie> CreateCookie( cookie->host_only = net::cookie_util::DomainIsHostOnly( canonical_cookie.Domain()); // A non-UTF8 path is invalid, so we just replace it with an empty string. - cookie->path = IsStringUTF8(canonical_cookie.Path()) ? canonical_cookie.Path() - : std::string(); + cookie->path = base::IsStringUTF8(canonical_cookie.Path()) ? + canonical_cookie.Path() : std::string(); cookie->secure = canonical_cookie.IsSecure(); cookie->http_only = canonical_cookie.IsHttpOnly(); cookie->session = !canonical_cookie.IsPersistent(); diff --git a/chrome/browser/extensions/api/proxy/proxy_api_helpers.cc b/chrome/browser/extensions/api/proxy/proxy_api_helpers.cc index e7c1174..64a4282 100644 --- a/chrome/browser/extensions/api/proxy/proxy_api_helpers.cc +++ b/chrome/browser/extensions/api/proxy/proxy_api_helpers.cc @@ -112,7 +112,7 @@ bool GetPacUrlFromExtensionPref(const base::DictionaryValue* proxy_config, *bad_message = true; return false; } - if (!IsStringASCII(pac_url16)) { + if (!base::IsStringASCII(pac_url16)) { *error = "'pacScript.url' supports only ASCII URLs " "(encode URLs in Punycode format)."; return false; @@ -137,7 +137,7 @@ bool GetPacDataFromExtensionPref(const base::DictionaryValue* proxy_config, *bad_message = true; return false; } - if (!IsStringASCII(pac_data16)) { + if (!base::IsStringASCII(pac_data16)) { *error = "'pacScript.data' supports only ASCII code" "(encode URLs in Punycode format)."; return false; @@ -169,7 +169,7 @@ bool GetProxyServer(const base::DictionaryValue* proxy_server, *bad_message = true; return false; } - if (!IsStringASCII(host16)) { + if (!base::IsStringASCII(host16)) { *error = ErrorUtils::FormatErrorMessage( "Invalid 'rules.???.host' entry '*'. 'host' field supports only ASCII " "URLs (encode URLs in Punycode format).", @@ -272,7 +272,7 @@ bool JoinUrlList(const base::ListValue* list, *bad_message = true; return false; } - if (!IsStringASCII(entry)) { + if (!base::IsStringASCII(entry)) { *error = "'rules.bypassList' supports only ASCII URLs " "(encode URLs in Punycode format)."; return false; diff --git a/chrome/browser/extensions/api/serial/serial_connection.cc b/chrome/browser/extensions/api/serial/serial_connection.cc index 8ff045e..3671901 100644 --- a/chrome/browser/extensions/api/serial/serial_connection.cc +++ b/chrome/browser/extensions/api/serial/serial_connection.cc @@ -164,7 +164,7 @@ void SerialConnection::StartOpen() { // It's the responsibility of the API wrapper around SerialConnection to // validate the supplied path against the set of valid port names, and // it is a reasonable assumption that serial port names are ASCII. - DCHECK(IsStringASCII(port_)); + DCHECK(base::IsStringASCII(port_)); base::FilePath path( base::FilePath::FromUTF8Unsafe(MaybeFixUpPortName(port_))); int flags = base::File::FLAG_OPEN | base::File::FLAG_READ | diff --git a/chrome/browser/extensions/api/web_request/web_request_api.cc b/chrome/browser/extensions/api/web_request/web_request_api.cc index f7aae30..eef2a807 100644 --- a/chrome/browser/extensions/api/web_request/web_request_api.cc +++ b/chrome/browser/extensions/api/web_request/web_request_api.cc @@ -302,7 +302,7 @@ base::DictionaryValue* ToHeaderDictionary(const std::string& name, const std::string& value) { base::DictionaryValue* header = new base::DictionaryValue(); header->SetString(keys::kHeaderNameKey, name); - if (IsStringUTF8(value)) { + if (base::IsStringUTF8(value)) { header->SetString(keys::kHeaderValueKey, value); } else { header->Set(keys::kHeaderBinaryValueKey, diff --git a/chrome/browser/extensions/convert_user_script.cc b/chrome/browser/extensions/convert_user_script.cc index b67892c..1a7d48f 100644 --- a/chrome/browser/extensions/convert_user_script.cc +++ b/chrome/browser/extensions/convert_user_script.cc @@ -39,7 +39,7 @@ scoped_refptr<Extension> ConvertUserScriptToExtension( return NULL; } - if (!IsStringUTF8(content)) { + if (!base::IsStringUTF8(content)) { *error = base::ASCIIToUTF16("User script must be UTF8 encoded."); return NULL; } diff --git a/chrome/browser/extensions/extension_garbage_collector.cc b/chrome/browser/extensions/extension_garbage_collector.cc index df33b09..5419873 100644 --- a/chrome/browser/extensions/extension_garbage_collector.cc +++ b/chrome/browser/extensions/extension_garbage_collector.cc @@ -54,7 +54,7 @@ void CheckExtensionDirectory(const base::FilePath& path, // Parse directory name as a potential extension ID. std::string extension_id; - if (IsStringASCII(basename.value())) { + if (base::IsStringASCII(basename.value())) { extension_id = base::UTF16ToASCII(basename.LossyDisplayName()); if (!Extension::IdIsValid(extension_id)) extension_id.clear(); diff --git a/chrome/browser/extensions/url_request_util.cc b/chrome/browser/extensions/url_request_util.cc index 82dd7f7..8df596c 100644 --- a/chrome/browser/extensions/url_request_util.cc +++ b/chrome/browser/extensions/url_request_util.cc @@ -107,7 +107,7 @@ class URLRequestResourceBundleJob : public net::URLRequestSimpleJob { if (StartsWithASCII(*read_mime_type, "text/", false)) { // All of our HTML files should be UTF-8 and for other resource types // (like images), charset doesn't matter. - DCHECK(IsStringUTF8(*data)); + DCHECK(base::IsStringUTF8(*data)); *charset = "utf-8"; } int result = read_result ? net::OK : net::ERR_INVALID_URL; diff --git a/chrome/browser/internal_auth.cc b/chrome/browser/internal_auth.cc index 984c954..acdd442 100644 --- a/chrome/browser/internal_auth.cc +++ b/chrome/browser/internal_auth.cc @@ -89,7 +89,7 @@ int64 GetCurrentTick() { bool IsDomainSane(const std::string& domain) { return !domain.empty() && domain.size() <= kStringLengthLimit && - IsStringUTF8(domain) && + base::IsStringUTF8(domain) && domain.find_first_of(kItemSeparator) == std::string::npos; } @@ -109,14 +109,14 @@ bool IsVarSane(const std::string& var) { kVarValueSeparator) == kAllowedChars + arraysize(kAllowedChars)); return !var.empty() && var.size() <= kStringLengthLimit && - IsStringASCII(var) && + base::IsStringASCII(var) && var.find_first_not_of(kAllowedChars) == std::string::npos && !IsAsciiDigit(var[0]); } bool IsValueSane(const std::string& value) { return value.size() <= kStringLengthLimit && - IsStringUTF8(value) && + base::IsStringUTF8(value) && value.find_first_of(kItemSeparator) == std::string::npos; } @@ -265,7 +265,7 @@ class InternalAuthVerificationService { const std::string& domain, int64 current_tick) { if (passport.size() != kPassportSize || - !IsStringASCII(passport) || + !base::IsStringASCII(passport) || !IsDomainSane(domain) || current_tick <= dark_tick_ || current_tick > key_change_tick_ + kKeyRegenerationHardTicks || diff --git a/chrome/browser/invalidation/invalidator_storage_unittest.cc b/chrome/browser/invalidation/invalidator_storage_unittest.cc index b587997..841bead 100644 --- a/chrome/browser/invalidation/invalidator_storage_unittest.cc +++ b/chrome/browser/invalidation/invalidator_storage_unittest.cc @@ -55,7 +55,7 @@ TEST_F(InvalidatorStorageTest, SetGetNotifierClientId) { TEST_F(InvalidatorStorageTest, SetGetBootstrapData) { InvalidatorStorage storage(&pref_service_); const std::string mess("n\0tK\0\0l\344", 8); - ASSERT_FALSE(IsStringUTF8(mess)); + ASSERT_FALSE(base::IsStringUTF8(mess)); storage.SetBootstrapData(mess); EXPECT_EQ(mess, storage.GetBootstrapData()); diff --git a/chrome/browser/net/firefox_proxy_settings.cc b/chrome/browser/net/firefox_proxy_settings.cc index bc3b04f..ba7fe94 100644 --- a/chrome/browser/net/firefox_proxy_settings.cc +++ b/chrome/browser/net/firefox_proxy_settings.cc @@ -118,7 +118,7 @@ bool ParsePrefFile(const base::FilePath& pref_file, value = value.substr(1, value.size() - 2); // ValueString only accept valid UTF-8. Simply ignore that entry if it is // not UTF-8. - if (IsStringUTF8(value)) + if (base::IsStringUTF8(value)) prefs->SetString(key, value); else VLOG(1) << "Non UTF8 value for key " << key << ", ignored."; diff --git a/chrome/browser/profile_resetter/jtl_interpreter.cc b/chrome/browser/profile_resetter/jtl_interpreter.cc index a4cbd16..e258078 100644 --- a/chrome/browser/profile_resetter/jtl_interpreter.cc +++ b/chrome/browser/profile_resetter/jtl_interpreter.cc @@ -195,7 +195,7 @@ class StoreValue : public Operation { StoreValue(const std::string& hashed_name, scoped_ptr<base::Value> value) : hashed_name_(hashed_name), value_(value.Pass()) { - DCHECK(IsStringUTF8(hashed_name)); + DCHECK(base::IsStringUTF8(hashed_name)); DCHECK(value_); } virtual ~StoreValue() {} @@ -218,7 +218,7 @@ class CompareStoredValue : public Operation { : hashed_name_(hashed_name), value_(value.Pass()), default_value_(default_value.Pass()) { - DCHECK(IsStringUTF8(hashed_name)); + DCHECK(base::IsStringUTF8(hashed_name)); DCHECK(value_); DCHECK(default_value_); } @@ -244,7 +244,7 @@ class StoreNodeValue : public Operation { public: explicit StoreNodeValue(const std::string& hashed_name) : hashed_name_(hashed_name) { - DCHECK(IsStringUTF8(hashed_name)); + DCHECK(base::IsStringUTF8(hashed_name)); } virtual ~StoreNodeValue() {} virtual bool Execute(ExecutionContext* context) OVERRIDE { @@ -275,7 +275,7 @@ class StoreNodeRegisterableDomain : public Operation { public: explicit StoreNodeRegisterableDomain(const std::string& hashed_name) : hashed_name_(hashed_name) { - DCHECK(IsStringUTF8(hashed_name)); + DCHECK(base::IsStringUTF8(hashed_name)); } virtual ~StoreNodeRegisterableDomain() {} virtual bool Execute(ExecutionContext* context) OVERRIDE { @@ -488,7 +488,7 @@ class Parser { break; case jtl_foundation::STORE_BOOL: { std::string hashed_name; - if (!ReadHash(&hashed_name) || !IsStringUTF8(hashed_name)) + if (!ReadHash(&hashed_name) || !base::IsStringUTF8(hashed_name)) return false; bool value = false; if (!ReadBool(&value)) @@ -500,7 +500,7 @@ class Parser { } case jtl_foundation::COMPARE_STORED_BOOL: { std::string hashed_name; - if (!ReadHash(&hashed_name) || !IsStringUTF8(hashed_name)) + if (!ReadHash(&hashed_name) || !base::IsStringUTF8(hashed_name)) return false; bool value = false; if (!ReadBool(&value)) @@ -517,7 +517,7 @@ class Parser { } case jtl_foundation::STORE_HASH: { std::string hashed_name; - if (!ReadHash(&hashed_name) || !IsStringUTF8(hashed_name)) + if (!ReadHash(&hashed_name) || !base::IsStringUTF8(hashed_name)) return false; std::string hashed_value; if (!ReadHash(&hashed_value)) @@ -529,7 +529,7 @@ class Parser { } case jtl_foundation::COMPARE_STORED_HASH: { std::string hashed_name; - if (!ReadHash(&hashed_name) || !IsStringUTF8(hashed_name)) + if (!ReadHash(&hashed_name) || !base::IsStringUTF8(hashed_name)) return false; std::string hashed_value; if (!ReadHash(&hashed_value)) @@ -546,21 +546,21 @@ class Parser { } case jtl_foundation::STORE_NODE_BOOL: { std::string hashed_name; - if (!ReadHash(&hashed_name) || !IsStringUTF8(hashed_name)) + if (!ReadHash(&hashed_name) || !base::IsStringUTF8(hashed_name)) return false; operators.push_back(new StoreNodeValue<true>(hashed_name)); break; } case jtl_foundation::STORE_NODE_HASH: { std::string hashed_name; - if (!ReadHash(&hashed_name) || !IsStringUTF8(hashed_name)) + if (!ReadHash(&hashed_name) || !base::IsStringUTF8(hashed_name)) return false; operators.push_back(new StoreNodeValue<false>(hashed_name)); break; } case jtl_foundation::STORE_NODE_REGISTERABLE_DOMAIN_HASH: { std::string hashed_name; - if (!ReadHash(&hashed_name) || !IsStringUTF8(hashed_name)) + if (!ReadHash(&hashed_name) || !base::IsStringUTF8(hashed_name)) return false; operators.push_back(new StoreNodeRegisterableDomain(hashed_name)); break; @@ -588,14 +588,14 @@ class Parser { } case jtl_foundation::COMPARE_NODE_TO_STORED_BOOL: { std::string hashed_name; - if (!ReadHash(&hashed_name) || !IsStringUTF8(hashed_name)) + if (!ReadHash(&hashed_name) || !base::IsStringUTF8(hashed_name)) return false; operators.push_back(new CompareNodeToStored<true>(hashed_name)); break; } case jtl_foundation::COMPARE_NODE_TO_STORED_HASH: { std::string hashed_name; - if (!ReadHash(&hashed_name) || !IsStringUTF8(hashed_name)) + if (!ReadHash(&hashed_name) || !base::IsStringUTF8(hashed_name)) return false; operators.push_back(new CompareNodeToStored<false>(hashed_name)); break; diff --git a/chrome/browser/spellchecker/spellcheck_custom_dictionary.cc b/chrome/browser/spellchecker/spellcheck_custom_dictionary.cc index a34c7b6..e7b9140 100644 --- a/chrome/browser/spellchecker/spellcheck_custom_dictionary.cc +++ b/chrome/browser/spellchecker/spellcheck_custom_dictionary.cc @@ -76,7 +76,7 @@ ChecksumStatus LoadFile(const base::FilePath& file_path, WordList& words) { // Returns true for invalid words and false for valid words. bool IsInvalidWord(const std::string& word) { std::string tmp; - return !IsStringUTF8(word) || + return !base::IsStringUTF8(word) || word.length() > chrome::spellcheck_common::MAX_CUSTOM_DICTIONARY_WORD_BYTES || word.empty() || diff --git a/chrome/browser/sync_file_system/drive_backend_v1/api_util.cc b/chrome/browser/sync_file_system/drive_backend_v1/api_util.cc index d3d5835..2ec9791 100644 --- a/chrome/browser/sync_file_system/drive_backend_v1/api_util.cc +++ b/chrome/browser/sync_file_system/drive_backend_v1/api_util.cc @@ -310,7 +310,7 @@ void APIUtil::DidGetDirectory(const std::string& parent_resource_id, google_apis::GDataErrorCode error, scoped_ptr<google_apis::ResourceList> feed) { DCHECK(CalledOnValidThread()); - DCHECK(IsStringASCII(directory_name)); + DCHECK(base::IsStringASCII(directory_name)); if (error != google_apis::HTTP_SUCCESS) { DVLOG(2) << "Error on getting Drive directory: " << error; diff --git a/chrome/browser/ui/webui/net_internals/net_internals_ui.cc b/chrome/browser/ui/webui/net_internals/net_internals_ui.cc index 6ca3b5e..e3db035 100644 --- a/chrome/browser/ui/webui/net_internals/net_internals_ui.cc +++ b/chrome/browser/ui/webui/net_internals/net_internals_ui.cc @@ -1201,7 +1201,7 @@ void NetInternalsMessageHandler::IOThreadImpl::OnHSTSQuery( CHECK(list->GetString(0, &domain)); base::DictionaryValue* result = new base::DictionaryValue(); - if (!IsStringASCII(domain)) { + if (!base::IsStringASCII(domain)) { result->SetString("error", "non-ASCII domain name"); } else { net::TransportSecurityState* transport_security_state = @@ -1242,7 +1242,7 @@ void NetInternalsMessageHandler::IOThreadImpl::OnHSTSAdd( // include subdomains>, <key pins>]. std::string domain; CHECK(list->GetString(0, &domain)); - if (!IsStringASCII(domain)) { + if (!base::IsStringASCII(domain)) { // Silently fail. The user will get a helpful error if they query for the // name. return; @@ -1276,7 +1276,7 @@ void NetInternalsMessageHandler::IOThreadImpl::OnHSTSDelete( // |list| should be: [<domain to query>]. std::string domain; CHECK(list->GetString(0, &domain)); - if (!IsStringASCII(domain)) { + if (!base::IsStringASCII(domain)) { // There cannot be a unicode entry in the HSTS set. return; } diff --git a/chrome/common/extensions/manifest_handlers/content_scripts_handler.cc b/chrome/common/extensions/manifest_handlers/content_scripts_handler.cc index 2753614..9a699b2 100644 --- a/chrome/common/extensions/manifest_handlers/content_scripts_handler.cc +++ b/chrome/common/extensions/manifest_handlers/content_scripts_handler.cc @@ -304,7 +304,7 @@ static bool IsScriptValid(const base::FilePath& path, return false; } - if (!IsStringUTF8(content)) { + if (!base::IsStringUTF8(content)) { *error = l10n_util::GetStringFUTF8( IDS_EXTENSION_BAD_FILE_ENCODING, relative_path.LossyDisplayName()); diff --git a/chrome/common/net/url_fixer_upper.cc b/chrome/common/net/url_fixer_upper.cc index 34966da..9bdc5e5 100644 --- a/chrome/common/net/url_fixer_upper.cc +++ b/chrome/common/net/url_fixer_upper.cc @@ -52,7 +52,7 @@ url::Component UTF8ComponentToUTF16Component( void UTF8PartsToUTF16Parts(const std::string& text_utf8, const url::Parsed& parts_utf8, url::Parsed* parts) { - if (IsStringASCII(text_utf8)) { + if (base::IsStringASCII(text_utf8)) { *parts = parts_utf8; return; } @@ -81,7 +81,7 @@ base::TrimPositions TrimWhitespaceUTF8(const std::string& input, // This implementation is not so fast since it converts the text encoding // twice. Please feel free to file a bug if this function hurts the // performance of Chrome. - DCHECK(IsStringUTF8(input)); + DCHECK(base::IsStringUTF8(input)); base::string16 input16 = base::UTF8ToUTF16(input); base::string16 output16; base::TrimPositions result = diff --git a/chrome/installer/util/installer_state.cc b/chrome/installer/util/installer_state.cc index a5ed9d9..e6cc475 100644 --- a/chrome/installer/util/installer_state.cc +++ b/chrome/installer/util/installer_state.cc @@ -661,7 +661,7 @@ void InstallerState::GetExistingExeVersions( FileVersionInfo::CreateFileVersionInfo(chrome_exe)); if (file_version_info) { base::string16 version_string = file_version_info->file_version(); - if (!version_string.empty() && IsStringASCII(version_string)) + if (!version_string.empty() && base::IsStringASCII(version_string)) existing_versions->insert(base::UTF16ToASCII(version_string)); } } diff --git a/chromeos/network/shill_property_util.cc b/chromeos/network/shill_property_util.cc index 35e4bb1..ff3980a 100644 --- a/chromeos/network/shill_property_util.cc +++ b/chromeos/network/shill_property_util.cc @@ -88,7 +88,7 @@ std::string GetSSIDFromProperties(const base::DictionaryValue& properties, return std::string(); } - if (IsStringUTF8(ssid)) + if (base::IsStringUTF8(ssid)) return ssid; // Detect encoding and convert to UTF-8. diff --git a/components/autofill/content/browser/wallet/wallet_address.cc b/components/autofill/content/browser/wallet/wallet_address.cc index 643b283..30825c9 100644 --- a/components/autofill/content/browser/wallet/wallet_address.cc +++ b/components/autofill/content/browser/wallet/wallet_address.cc @@ -330,7 +330,7 @@ base::string16 Address::DisplayPhoneNumber() const { base::string16 Address::GetInfo(const AutofillType& type, const std::string& app_locale) const { if (type.html_type() == HTML_TYPE_COUNTRY_CODE) { - DCHECK(IsStringASCII(country_name_code())); + DCHECK(base::IsStringASCII(country_name_code())); return base::ASCIIToUTF16(country_name_code()); } diff --git a/components/autofill/core/browser/address.cc b/components/autofill/core/browser/address.cc index de651479..79cdef9 100644 --- a/components/autofill/core/browser/address.cc +++ b/components/autofill/core/browser/address.cc @@ -107,7 +107,7 @@ void Address::SetRawInfo(ServerFieldType type, const base::string16& value) { case ADDRESS_HOME_COUNTRY: DCHECK(value.empty() || - (value.length() == 2u && IsStringASCII(value))); + (value.length() == 2u && base::IsStringASCII(value))); country_code_ = base::UTF16ToASCII(value); break; @@ -144,7 +144,7 @@ bool Address::SetInfo(const AutofillType& type, const base::string16& value, const std::string& app_locale) { if (type.html_type() == HTML_TYPE_COUNTRY_CODE) { - if (!value.empty() && (value.size() != 2u || !IsStringASCII(value))) { + if (!value.empty() && (value.size() != 2u || !base::IsStringASCII(value))) { country_code_ = std::string(); return false; } diff --git a/components/autofill/core/browser/validation.cc b/components/autofill/core/browser/validation.cc index e1edf73..62509cb 100644 --- a/components/autofill/core/browser/validation.cc +++ b/components/autofill/core/browser/validation.cc @@ -182,7 +182,7 @@ bool IsSSN(const base::string16& text) { // http://www.socialsecurity.gov/employer/stateweb.htm // http://www.socialsecurity.gov/employer/ssnvhighgroup.htm - if (number_string.length() != 9 || !IsStringASCII(number_string)) + if (number_string.length() != 9 || !base::IsStringASCII(number_string)) return false; int area; diff --git a/components/bookmarks/core/browser/bookmark_codec.cc b/components/bookmarks/core/browser/bookmark_codec.cc index 77357af..bbf8aa5 100644 --- a/components/bookmarks/core/browser/bookmark_codec.cc +++ b/components/bookmarks/core/browser/bookmark_codec.cc @@ -464,7 +464,7 @@ void BookmarkCodec::UpdateChecksum(const base::string16& str) { void BookmarkCodec::UpdateChecksumWithUrlNode(const std::string& id, const base::string16& title, const std::string& url) { - DCHECK(IsStringUTF8(url)); + DCHECK(base::IsStringUTF8(url)); UpdateChecksum(id); UpdateChecksum(title); UpdateChecksum(kTypeURL); diff --git a/components/storage_monitor/portable_device_watcher_win.cc b/components/storage_monitor/portable_device_watcher_win.cc index 003553e..3d79ece 100644 --- a/components/storage_monitor/portable_device_watcher_win.cc +++ b/components/storage_monitor/portable_device_watcher_win.cc @@ -59,7 +59,7 @@ base::string16 GetPnpDeviceId(LPARAM data) { if (!dev_interface) return base::string16(); base::string16 device_id(dev_interface->dbcc_name); - DCHECK(IsStringASCII(device_id)); + DCHECK(base::IsStringASCII(device_id)); return StringToLowerASCII(device_id); } diff --git a/components/url_matcher/url_matcher_unittest.cc b/components/url_matcher/url_matcher_unittest.cc index 1278f62..b69364c 100644 --- a/components/url_matcher/url_matcher_unittest.cc +++ b/components/url_matcher/url_matcher_unittest.cc @@ -159,10 +159,10 @@ TEST(URLMatcherConditionFactoryTest, GURLCharacterSet) { // non ASCII-7 characters. We test this here, because a change to this // guarantee breaks this implementation horribly. GURL url("http://www.föö.com/föö?föö#föö"); - EXPECT_TRUE(IsStringASCII(url.host())); - EXPECT_TRUE(IsStringASCII(url.path())); - EXPECT_TRUE(IsStringASCII(url.query())); - EXPECT_FALSE(IsStringASCII(url.ref())); + EXPECT_TRUE(base::IsStringASCII(url.host())); + EXPECT_TRUE(base::IsStringASCII(url.path())); + EXPECT_TRUE(base::IsStringASCII(url.query())); + EXPECT_FALSE(base::IsStringASCII(url.ref())); } TEST(URLMatcherConditionFactoryTest, Criteria) { diff --git a/content/browser/browser_plugin/browser_plugin_guest_manager.cc b/content/browser/browser_plugin/browser_plugin_guest_manager.cc index 8e44c7f0..d36dc13 100644 --- a/content/browser/browser_plugin/browser_plugin_guest_manager.cc +++ b/content/browser/browser_plugin/browser_plugin_guest_manager.cc @@ -78,7 +78,7 @@ BrowserPluginGuest* BrowserPluginGuestManager::CreateGuest( // since we depend on this in other parts of the code, such as FilePath // creation. If the validation fails, treat it as a bad message and kill the // renderer process. - if (!IsStringUTF8(params.storage_partition_id)) { + if (!base::IsStringUTF8(params.storage_partition_id)) { content::RecordAction( base::UserMetricsAction("BadMessageTerminate_BPGM")); base::KillProcess( diff --git a/content/browser/indexed_db/indexed_db_backing_store.cc b/content/browser/indexed_db/indexed_db_backing_store.cc index 3c5aa2d..c4db964 100644 --- a/content/browser/indexed_db/indexed_db_backing_store.cc +++ b/content/browser/indexed_db/indexed_db_backing_store.cc @@ -812,7 +812,7 @@ scoped_refptr<IndexedDBBackingStore> IndexedDBBackingStore::Open( scoped_ptr<LevelDBComparator> comparator(new Comparator()); - if (!IsStringASCII(path_base.AsUTF8Unsafe())) { + if (!base::IsStringASCII(path_base.AsUTF8Unsafe())) { HistogramOpenStatus(INDEXED_DB_BACKING_STORE_OPEN_ATTEMPT_NON_ASCII, origin_url); } diff --git a/content/browser/storage_partition_impl_map.cc b/content/browser/storage_partition_impl_map.cc index 03fb312..7fe7934 100644 --- a/content/browser/storage_partition_impl_map.cc +++ b/content/browser/storage_partition_impl_map.cc @@ -159,7 +159,7 @@ const int kAllFileTypes = base::FileEnumerator::FILES | base::FilePath GetStoragePartitionDomainPath( const std::string& partition_domain) { - CHECK(IsStringUTF8(partition_domain)); + CHECK(base::IsStringUTF8(partition_domain)); return base::FilePath(kStoragePartitionDirname).Append(kExtensionsDirname) .Append(base::FilePath::FromUTF8Unsafe(partition_domain)); diff --git a/content/browser/webui/web_ui_impl.cc b/content/browser/webui/web_ui_impl.cc index 445bbeb..72261c3 100644 --- a/content/browser/webui/web_ui_impl.cc +++ b/content/browser/webui/web_ui_impl.cc @@ -139,14 +139,14 @@ void WebUIImpl::SetController(WebUIController* controller) { } void WebUIImpl::CallJavascriptFunction(const std::string& function_name) { - DCHECK(IsStringASCII(function_name)); + DCHECK(base::IsStringASCII(function_name)); base::string16 javascript = base::ASCIIToUTF16(function_name + "();"); ExecuteJavascript(javascript); } void WebUIImpl::CallJavascriptFunction(const std::string& function_name, const base::Value& arg) { - DCHECK(IsStringASCII(function_name)); + DCHECK(base::IsStringASCII(function_name)); std::vector<const base::Value*> args; args.push_back(&arg); ExecuteJavascript(GetJavascriptCall(function_name, args)); @@ -155,7 +155,7 @@ void WebUIImpl::CallJavascriptFunction(const std::string& function_name, void WebUIImpl::CallJavascriptFunction( const std::string& function_name, const base::Value& arg1, const base::Value& arg2) { - DCHECK(IsStringASCII(function_name)); + DCHECK(base::IsStringASCII(function_name)); std::vector<const base::Value*> args; args.push_back(&arg1); args.push_back(&arg2); @@ -165,7 +165,7 @@ void WebUIImpl::CallJavascriptFunction( void WebUIImpl::CallJavascriptFunction( const std::string& function_name, const base::Value& arg1, const base::Value& arg2, const base::Value& arg3) { - DCHECK(IsStringASCII(function_name)); + DCHECK(base::IsStringASCII(function_name)); std::vector<const base::Value*> args; args.push_back(&arg1); args.push_back(&arg2); @@ -179,7 +179,7 @@ void WebUIImpl::CallJavascriptFunction( const base::Value& arg2, const base::Value& arg3, const base::Value& arg4) { - DCHECK(IsStringASCII(function_name)); + DCHECK(base::IsStringASCII(function_name)); std::vector<const base::Value*> args; args.push_back(&arg1); args.push_back(&arg2); @@ -191,7 +191,7 @@ void WebUIImpl::CallJavascriptFunction( void WebUIImpl::CallJavascriptFunction( const std::string& function_name, const std::vector<const base::Value*>& args) { - DCHECK(IsStringASCII(function_name)); + DCHECK(base::IsStringASCII(function_name)); ExecuteJavascript(GetJavascriptCall(function_name, args)); } diff --git a/content/child/ftp_directory_listing_response_delegate.cc b/content/child/ftp_directory_listing_response_delegate.cc index cc700ae..e6e7feb 100644 --- a/content/child/ftp_directory_listing_response_delegate.cc +++ b/content/child/ftp_directory_listing_response_delegate.cc @@ -34,7 +34,7 @@ namespace { base::string16 ConvertPathToUTF16(const std::string& path) { // Per RFC 2640, FTP servers should use UTF-8 or its proper subset ASCII, // but many old FTP servers use legacy encodings. Try UTF-8 first. - if (IsStringUTF8(path)) + if (base::IsStringUTF8(path)) return base::UTF8ToUTF16(path); // Try detecting the encoding. The sample is rather small though, so it may diff --git a/content/child/simple_webmimeregistry_impl.cc b/content/child/simple_webmimeregistry_impl.cc index 3b3ebd6..e7416d9 100644 --- a/content/child/simple_webmimeregistry_impl.cc +++ b/content/child/simple_webmimeregistry_impl.cc @@ -18,7 +18,8 @@ namespace content { //static std::string SimpleWebMimeRegistryImpl::ToASCIIOrEmpty(const WebString& string) { - return IsStringASCII(string) ? base::UTF16ToASCII(string) : std::string(); + return base::IsStringASCII(string) ? base::UTF16ToASCII(string) + : std::string(); } WebMimeRegistry::SupportsType SimpleWebMimeRegistryImpl::supportsMIMEType( diff --git a/content/renderer/media/android/webmediaplayer_android.cc b/content/renderer/media/android/webmediaplayer_android.cc index 9946500..9c230c1 100644 --- a/content/renderer/media/android/webmediaplayer_android.cc +++ b/content/renderer/media/android/webmediaplayer_android.cc @@ -1191,7 +1191,8 @@ const gfx::RectF WebMediaPlayerAndroid::GetBoundaryRectangle() { // Convert a WebString to ASCII, falling back on an empty string in the case // of a non-ASCII string. static std::string ToASCIIOrEmpty(const blink::WebString& string) { - return IsStringASCII(string) ? base::UTF16ToASCII(string) : std::string(); + return base::IsStringASCII(string) ? base::UTF16ToASCII(string) + : std::string(); } // Helper functions to report media EME related stats to UMA. They follow the diff --git a/content/renderer/media/webcontentdecryptionmodule_impl.cc b/content/renderer/media/webcontentdecryptionmodule_impl.cc index 38fe7a0..fa64ee7 100644 --- a/content/renderer/media/webcontentdecryptionmodule_impl.cc +++ b/content/renderer/media/webcontentdecryptionmodule_impl.cc @@ -40,7 +40,7 @@ WebContentDecryptionModuleImpl* WebContentDecryptionModuleImpl::Create( // TODO(ddorwin): Guard against this in supported types check and remove this. // Chromium only supports ASCII key systems. - if (!IsStringASCII(key_system)) { + if (!base::IsStringASCII(key_system)) { NOTREACHED(); return NULL; } diff --git a/content/renderer/media/webcontentdecryptionmodulesession_impl.cc b/content/renderer/media/webcontentdecryptionmodulesession_impl.cc index 14fa798..76935ae 100644 --- a/content/renderer/media/webcontentdecryptionmodulesession_impl.cc +++ b/content/renderer/media/webcontentdecryptionmodulesession_impl.cc @@ -36,7 +36,7 @@ void WebContentDecryptionModuleSessionImpl::initializeNewSession( const uint8* init_data, size_t init_data_length) { // TODO(ddorwin): Guard against this in supported types check and remove this. // Chromium only supports ASCII MIME types. - if (!IsStringASCII(mime_type)) { + if (!base::IsStringASCII(mime_type)) { NOTREACHED(); OnSessionError(media::MediaKeys::kUnknownError, 0); return; diff --git a/content/renderer/media/webmediaplayer_impl.cc b/content/renderer/media/webmediaplayer_impl.cc index fa614a4..1612f86 100644 --- a/content/renderer/media/webmediaplayer_impl.cc +++ b/content/renderer/media/webmediaplayer_impl.cc @@ -746,7 +746,8 @@ static void ReportMediaKeyExceptionToUMA(const std::string& method, // Convert a WebString to ASCII, falling back on an empty string in the case // of a non-ASCII string. static std::string ToASCIIOrEmpty(const blink::WebString& string) { - return IsStringASCII(string) ? base::UTF16ToASCII(string) : std::string(); + return base::IsStringASCII(string) ? base::UTF16ToASCII(string) + : std::string(); } WebMediaPlayer::MediaKeyException diff --git a/content/renderer/pepper/content_renderer_pepper_host_factory.cc b/content/renderer/pepper/content_renderer_pepper_host_factory.cc index 399bdb2..3a9c6fe 100644 --- a/content/renderer/pepper/content_renderer_pepper_host_factory.cc +++ b/content/renderer/pepper/content_renderer_pepper_host_factory.cc @@ -161,7 +161,7 @@ scoped_ptr<ResourceHost> ContentRendererPepperHostFactory::CreateResourceHost( } // Check that the family name is valid UTF-8 before passing it to the // host OS. - if (IsStringUTF8(desc.family)) { + if (base::IsStringUTF8(desc.family)) { return scoped_ptr<ResourceHost>(new PepperTrueTypeFontHost( host_, instance, params.pp_resource(), desc)); } diff --git a/content/renderer/renderer_webkitplatformsupport_impl.cc b/content/renderer/renderer_webkitplatformsupport_impl.cc index b507a73..8df6722 100644 --- a/content/renderer/renderer_webkitplatformsupport_impl.cc +++ b/content/renderer/renderer_webkitplatformsupport_impl.cc @@ -413,7 +413,7 @@ RendererWebKitPlatformSupportImpl::MimeRegistry::supportsMediaMIMEType( // Check whether the key system is supported with the mime_type and codecs. // Chromium only supports ASCII parameters. - if (!IsStringASCII(key_system)) + if (!base::IsStringASCII(key_system)) return IsNotSupported; std::string key_system_ascii = @@ -474,8 +474,8 @@ RendererWebKitPlatformSupportImpl::MimeRegistry::supportsEncryptedMediaMIMEType( const WebString& mime_type, const WebString& codecs) { // Chromium only supports ASCII parameters. - if (!IsStringASCII(key_system) || !IsStringASCII(mime_type) || - !IsStringASCII(codecs)) { + if (!base::IsStringASCII(key_system) || !base::IsStringASCII(mime_type) || + !base::IsStringASCII(codecs)) { return false; } diff --git a/dbus/message.cc b/dbus/message.cc index eaf3c9b..c9219b7 100644 --- a/dbus/message.cc +++ b/dbus/message.cc @@ -507,7 +507,7 @@ void MessageWriter::AppendDouble(double value) { void MessageWriter::AppendString(const std::string& value) { // D-Bus Specification (0.19) says a string "must be valid UTF-8". - CHECK(IsStringUTF8(value)); + CHECK(base::IsStringUTF8(value)); const char* pointer = value.c_str(); AppendBasic(DBUS_TYPE_STRING, &pointer); // TODO(satorux): It may make sense to return an error here, as the diff --git a/jingle/notifier/listener/notification_defines_unittest.cc b/jingle/notifier/listener/notification_defines_unittest.cc index 389f3cc..d783239 100644 --- a/jingle/notifier/listener/notification_defines_unittest.cc +++ b/jingle/notifier/listener/notification_defines_unittest.cc @@ -17,7 +17,7 @@ class NotificationTest : public testing::Test {}; // Converting it to string shouldn't cause a crash. TEST_F(NotificationTest, BinaryData) { const char kNonUtf8Data[] = { '\xff', '\0' }; - EXPECT_FALSE(IsStringUTF8(kNonUtf8Data)); + EXPECT_FALSE(base::IsStringUTF8(kNonUtf8Data)); Notification notification; notification.data = kNonUtf8Data; EXPECT_EQ("{ channel: \"\", data: \"\\u00FF\" }", notification.ToString()); diff --git a/media/cdm/json_web_key.cc b/media/cdm/json_web_key.cc index a6aa885..4b9d822 100644 --- a/media/cdm/json_web_key.cc +++ b/media/cdm/json_web_key.cc @@ -121,7 +121,7 @@ static bool ConvertJwkToKeyPair(const base::DictionaryValue& jwk, } bool ExtractKeysFromJWKSet(const std::string& jwk_set, KeyIdAndKeyPairs* keys) { - if (!IsStringASCII(jwk_set)) + if (!base::IsStringASCII(jwk_set)) return false; scoped_ptr<base::Value> root(base::JSONReader().ReadToValue(jwk_set)); diff --git a/net/base/filename_util.cc b/net/base/filename_util.cc index ed4831d8..3c9aef8 100644 --- a/net/base/filename_util.cc +++ b/net/base/filename_util.cc @@ -72,7 +72,7 @@ std::string GetFileNameFromURL(const GURL& url, // The URL's path should be escaped UTF-8, but may not be. std::string decoded_filename = unescaped_url_filename; - if (!IsStringUTF8(decoded_filename)) { + if (!base::IsStringUTF8(decoded_filename)) { // TODO(jshin): this is probably not robust enough. To be sure, we need // encoding detection. base::string16 utf16_output; @@ -311,7 +311,7 @@ bool FileURLToFilePath(const GURL& url, base::FilePath* file_path) { UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS); #if defined(OS_WIN) - if (IsStringUTF8(path)) { + if (base::IsStringUTF8(path)) { file_path_str.assign(base::UTF8ToWide(path)); // We used to try too hard and see if |path| made up entirely of // the 1st 256 characters in the Unicode was a zero-extended UTF-16. diff --git a/net/base/mime_util.cc b/net/base/mime_util.cc index fdb16fd..f75ecf9 100644 --- a/net/base/mime_util.cc +++ b/net/base/mime_util.cc @@ -650,7 +650,7 @@ static const char* legal_top_level_types[] = { bool MimeUtil::IsMimeType(const std::string& type_string) const { // MIME types are always ASCII and case-insensitive (at least, the top-level // and secondary types we care about). - if (!IsStringASCII(type_string)) + if (!base::IsStringASCII(type_string)) return false; if (type_string == "*/*" || type_string == "*") diff --git a/net/dns/dns_config_service_win.cc b/net/dns/dns_config_service_win.cc index 192ad7a..4d837f0 100644 --- a/net/dns/dns_config_service_win.cc +++ b/net/dns/dns_config_service_win.cc @@ -139,7 +139,7 @@ bool ParseDomainASCII(const base::string16& widestr, std::string* domain) { return false; // Check if already ASCII. - if (IsStringASCII(widestr)) { + if (base::IsStringASCII(widestr)) { *domain = base::UTF16ToASCII(widestr); return true; } @@ -155,7 +155,7 @@ bool ParseDomainASCII(const base::string16& widestr, std::string* domain) { // copy. Since ASCII is a subset of UTF8 the following is equivalent). bool success = base::UTF16ToUTF8(punycode.data(), punycode.length(), domain); DCHECK(success); - DCHECK(IsStringASCII(*domain)); + DCHECK(base::IsStringASCII(*domain)); return success && !domain->empty(); } diff --git a/net/ftp/ftp_network_transaction.cc b/net/ftp/ftp_network_transaction.cc index 3455fc6..7820715 100644 --- a/net/ftp/ftp_network_transaction.cc +++ b/net/ftp/ftp_network_transaction.cc @@ -152,7 +152,7 @@ bool ExtractPortFromPASVResponse(const net::FtpCtrlResponse& response, return false; std::string line(response.lines[0]); - if (!IsStringASCII(line)) + if (!base::IsStringASCII(line)) return false; if (line.length() < 2) return false; @@ -830,7 +830,7 @@ int FtpNetworkTransaction::ProcessResponseSYST( // The response should be ASCII, which allows us to do case-insensitive // comparisons easily. If it is not ASCII, we leave the system type // as unknown. - if (IsStringASCII(line)) { + if (base::IsStringASCII(line)) { line = StringToLowerASCII(line); // Remove all whitespace, to correctly handle cases like fancy "V M S" diff --git a/net/http/http_content_disposition.cc b/net/http/http_content_disposition.cc index 83098f4..3a1dede 100644 --- a/net/http/http_content_disposition.cc +++ b/net/http/http_content_disposition.cc @@ -86,9 +86,9 @@ bool DecodeWord(const std::string& encoded_word, if (encoded_word.empty()) return true; - if (!IsStringASCII(encoded_word)) { + if (!base::IsStringASCII(encoded_word)) { // Try UTF-8, referrer_charset and the native OS default charset in turn. - if (IsStringUTF8(encoded_word)) { + if (base::IsStringUTF8(encoded_word)) { *output = encoded_word; } else { base::string16 utf16_output; @@ -191,7 +191,7 @@ bool DecodeWord(const std::string& encoded_word, if (decoded_word != encoded_word) *parse_result_flags |= net::HttpContentDisposition::HAS_PERCENT_ENCODED_STRINGS; - if (IsStringUTF8(decoded_word)) { + if (base::IsStringUTF8(decoded_word)) { output->swap(decoded_word); return true; // We can try either the OS default charset or 'origin charset' here, @@ -317,7 +317,7 @@ bool DecodeExtValue(const std::string& param_value, std::string* decoded) { return false; // RFC 5987 value should be ASCII-only. - if (!IsStringASCII(value)) { + if (!base::IsStringASCII(value)) { decoded->clear(); return true; } diff --git a/net/proxy/proxy_resolver_v8.cc b/net/proxy/proxy_resolver_v8.cc index 9011875..0c08027 100644 --- a/net/proxy/proxy_resolver_v8.cc +++ b/net/proxy/proxy_resolver_v8.cc @@ -112,7 +112,7 @@ class V8ExternalASCIILiteral : public v8::String::ExternalAsciiStringResource { // throughout this object's lifetime. V8ExternalASCIILiteral(const char* ascii, size_t length) : ascii_(ascii), length_(length) { - DCHECK(IsStringASCII(ascii)); + DCHECK(base::IsStringASCII(ascii)); } virtual const char* data() const OVERRIDE { @@ -159,7 +159,7 @@ base::string16 V8StringToUTF16(v8::Handle<v8::String> s) { // Converts an ASCII std::string to a V8 string. v8::Local<v8::String> ASCIIStringToV8String(v8::Isolate* isolate, const std::string& s) { - DCHECK(IsStringASCII(s)); + DCHECK(base::IsStringASCII(s)); return v8::String::NewFromUtf8(isolate, s.data(), v8::String::kNormalString, s.size()); } @@ -182,7 +182,7 @@ v8::Local<v8::String> ScriptDataToV8String( // Converts an ASCII string literal to a V8 string. v8::Local<v8::String> ASCIILiteralToV8String(v8::Isolate* isolate, const char* ascii) { - DCHECK(IsStringASCII(ascii)); + DCHECK(base::IsStringASCII(ascii)); size_t length = strlen(ascii); if (length <= kMaxStringBytesForCopy) return v8::String::NewFromUtf8(isolate, ascii, v8::String::kNormalString, @@ -218,7 +218,7 @@ bool GetHostnameArgument(const v8::FunctionCallbackInfo<v8::Value>& args, const base::string16 hostname_utf16 = V8StringToUTF16(args[0]->ToString()); // If the hostname is already in ASCII, simply return it as is. - if (IsStringASCII(hostname_utf16)) { + if (base::IsStringASCII(hostname_utf16)) { *hostname = base::UTF16ToASCII(hostname_utf16); return true; } @@ -238,7 +238,7 @@ bool GetHostnameArgument(const v8::FunctionCallbackInfo<v8::Value>& args, punycode_output.length(), hostname); DCHECK(success); - DCHECK(IsStringASCII(*hostname)); + DCHECK(base::IsStringASCII(*hostname)); return success; } @@ -399,7 +399,7 @@ class ProxyResolverV8::Context { base::string16 ret_str = V8StringToUTF16(ret->ToString()); - if (!IsStringASCII(ret_str)) { + if (!base::IsStringASCII(ret_str)) { // TODO(eroman): Rather than failing when a wide string is returned, we // could extend the parsing to handle IDNA hostnames by // converting them to ASCII punycode. @@ -661,7 +661,7 @@ class ProxyResolverV8::Context { } std::string ip_address_list = V8StringToUTF8(args[0]->ToString()); - if (!IsStringASCII(ip_address_list)) { + if (!base::IsStringASCII(ip_address_list)) { args.GetReturnValue().SetNull(); return; } @@ -686,12 +686,12 @@ class ProxyResolverV8::Context { } std::string ip_address = V8StringToUTF8(args[0]->ToString()); - if (!IsStringASCII(ip_address)) { + if (!base::IsStringASCII(ip_address)) { args.GetReturnValue().Set(false); return; } std::string ip_prefix = V8StringToUTF8(args[1]->ToString()); - if (!IsStringASCII(ip_prefix)) { + if (!base::IsStringASCII(ip_prefix)) { args.GetReturnValue().Set(false); return; } diff --git a/ppapi/shared_impl/dictionary_var.cc b/ppapi/shared_impl/dictionary_var.cc index 54d2010..8676c43 100644 --- a/ppapi/shared_impl/dictionary_var.cc +++ b/ppapi/shared_impl/dictionary_var.cc @@ -90,7 +90,7 @@ PP_Var DictionaryVar::GetKeys() const { bool DictionaryVar::SetWithStringKey(const std::string& utf8_key, const PP_Var& value) { - if (!IsStringUTF8(utf8_key)) + if (!base::IsStringUTF8(utf8_key)) return false; key_value_map_[utf8_key] = value; diff --git a/ppapi/shared_impl/file_ref_util.cc b/ppapi/shared_impl/file_ref_util.cc index 3be8e0a..a5523cb 100644 --- a/ppapi/shared_impl/file_ref_util.cc +++ b/ppapi/shared_impl/file_ref_util.cc @@ -36,7 +36,7 @@ bool IsValidInternalPath(const std::string& path) { // The path starts with '/' // The path must contain valid UTF-8 characters. // It must not FilePath::ReferencesParent(). - if (path.empty() || !IsStringUTF8(path) || path[0] != '/') + if (path.empty() || !base::IsStringUTF8(path) || path[0] != '/') return false; base::FilePath file_path = base::FilePath::FromUTF8Unsafe(path); if (file_path.ReferencesParent()) diff --git a/ppapi/shared_impl/var.cc b/ppapi/shared_impl/var.cc index 8f3ddb5..3020182 100644 --- a/ppapi/shared_impl/var.cc +++ b/ppapi/shared_impl/var.cc @@ -148,7 +148,7 @@ PP_Var StringVar::StringToPPVar(const std::string& var) { // static PP_Var StringVar::StringToPPVar(const char* data, uint32 len) { scoped_refptr<StringVar> str(new StringVar(data, len)); - if (!str.get() || !IsStringUTF8(str->value())) + if (!str.get() || !base::IsStringUTF8(str->value())) return PP_MakeNull(); return str->GetPPVar(); } diff --git a/remoting/protocol/me2me_host_authenticator_factory.cc b/remoting/protocol/me2me_host_authenticator_factory.cc index 7e407c8..30c6419 100644 --- a/remoting/protocol/me2me_host_authenticator_factory.cc +++ b/remoting/protocol/me2me_host_authenticator_factory.cc @@ -141,7 +141,7 @@ scoped_ptr<Authenticator> Me2MeHostAuthenticatorFactory::CreateAuthenticator( // Verify that the client's jid is an ASCII string, and then check that the // client JID has the expected prefix. Comparison is case insensitive. - if (!IsStringASCII(remote_jid) || + if (!base::IsStringASCII(remote_jid) || !StartsWithASCII(remote_jid, remote_jid_prefix + '/', false)) { LOG(ERROR) << "Rejecting incoming connection from " << remote_jid; return scoped_ptr<Authenticator>(new RejectingAuthenticator()); diff --git a/sync/util/cryptographer_unittest.cc b/sync/util/cryptographer_unittest.cc index c045064..3719db3 100644 --- a/sync/util/cryptographer_unittest.cc +++ b/sync/util/cryptographer_unittest.cc @@ -189,7 +189,7 @@ TEST_F(CryptographerTest, Bootstrap) { std::string token; EXPECT_TRUE(cryptographer_.GetBootstrapToken(&token)); - EXPECT_TRUE(IsStringUTF8(token)); + EXPECT_TRUE(base::IsStringUTF8(token)); Cryptographer other_cryptographer(&encryptor_); other_cryptographer.Bootstrap(token); diff --git a/ui/base/l10n/l10n_util.cc b/ui/base/l10n/l10n_util.cc index 70a1c20..44d8df5 100644 --- a/ui/base/l10n/l10n_util.cc +++ b/ui/base/l10n/l10n_util.cc @@ -505,7 +505,7 @@ bool IsLocaleNameTranslated(const char* locale, // the translation is available or not. If ICU doesn't have a translated // name for this locale, GetDisplayNameForLocale will just return the // locale code. - return !IsStringASCII(display_name) || + return !base::IsStringASCII(display_name) || base::UTF16ToASCII(display_name) != locale; } diff --git a/webkit/common/database/database_identifier.cc b/webkit/common/database/database_identifier.cc index 07bf3d7..c4649d2 100644 --- a/webkit/common/database/database_identifier.cc +++ b/webkit/common/database/database_identifier.cc @@ -56,7 +56,7 @@ DatabaseIdentifier DatabaseIdentifier::CreateFromOrigin(const GURL& origin) { // static DatabaseIdentifier DatabaseIdentifier::Parse(const std::string& identifier) { - if (!IsStringASCII(identifier)) + if (!base::IsStringASCII(identifier)) return DatabaseIdentifier(); size_t first_underscore = identifier.find_first_of('_'); |