diff options
73 files changed, 270 insertions, 237 deletions
diff --git a/android_webview/native/aw_media_url_interceptor.cc b/android_webview/native/aw_media_url_interceptor.cc index 96d3298..39e9b54 100644 --- a/android_webview/native/aw_media_url_interceptor.cc +++ b/android_webview/native/aw_media_url_interceptor.cc @@ -13,15 +13,16 @@ namespace android_webview { bool AwMediaUrlInterceptor::Intercept(const std::string& url, - int* fd, int64* offset, int64* size) const{ - const std::string asset_file_prefix( - std::string(url::kFileScheme) + - std::string(url::kStandardSchemeSeparator) + - android_webview::kAndroidAssetPath); + int* fd, + int64* offset, + int64* size) const{ + std::string asset_file_prefix(url::kFileScheme); + asset_file_prefix.append(url::kStandardSchemeSeparator); + asset_file_prefix.append(android_webview::kAndroidAssetPath); if (base::StartsWithASCII(url, asset_file_prefix, true)) { std::string filename(url); - ReplaceFirstSubstringAfterOffset( + base::ReplaceFirstSubstringAfterOffset( &filename, 0, asset_file_prefix, "assets/"); base::MemoryMappedFile::Region region = base::MemoryMappedFile::Region::kWholeFile; diff --git a/android_webview/renderer/aw_content_renderer_client.cc b/android_webview/renderer/aw_content_renderer_client.cc index 548d3ec..ea4b0bd 100644 --- a/android_webview/renderer/aw_content_renderer_client.cc +++ b/android_webview/renderer/aw_content_renderer_client.cc @@ -174,10 +174,10 @@ void AwContentRendererClient::GetNavigationErrorStrings( contents = AwResource::GetNoDomainPageContent(); } else { contents = AwResource::GetLoadErrorPageContent(); - ReplaceSubstringsAfterOffset(&contents, 0, "%e", err); + base::ReplaceSubstringsAfterOffset(&contents, 0, "%e", err); } - ReplaceSubstringsAfterOffset(&contents, 0, "%s", + base::ReplaceSubstringsAfterOffset(&contents, 0, "%s", net::EscapeForHTML(error_url.possibly_invalid_spec())); *error_html = contents; } diff --git a/ash/system/user/login_status.cc b/ash/system/user/login_status.cc index 0e21865..fa5103a 100644 --- a/ash/system/user/login_status.cc +++ b/ash/system/user/login_status.cc @@ -41,7 +41,8 @@ base::string16 GetLocalizedSignOutStringForStatus(LoginStatus status, // spaces are substituted. base::string16 newline = multiline ? base::ASCIIToUTF16("\n") : base::ASCIIToUTF16(" "); - ReplaceSubstringsAfterOffset(&message, 0, base::ASCIIToUTF16("\\n"), newline); + base::ReplaceSubstringsAfterOffset( + &message, 0, base::ASCIIToUTF16("\\n"), newline); return message; } diff --git a/base/strings/string_util.cc b/base/strings/string_util.cc index 5839cf2..e3dcd85 100644 --- a/base/strings/string_util.cc +++ b/base/strings/string_util.cc @@ -659,19 +659,17 @@ string16 FormatBytesUnlocalized(int64 bytes) { return ASCIIToUTF16(buf); } -} // namespace base - // Runs in O(n) time in the length of |str|. template<class StringType> void DoReplaceSubstringsAfterOffset(StringType* str, size_t offset, - const StringType& find_this, - const StringType& replace_with, + BasicStringPiece<StringType> find_this, + BasicStringPiece<StringType> replace_with, bool replace_all) { DCHECK(!find_this.empty()); // If the find string doesn't appear, there's nothing to do. - offset = str->find(find_this, offset); + offset = str->find(find_this.data(), offset, find_this.size()); if (offset == StringType::npos) return; @@ -679,7 +677,7 @@ void DoReplaceSubstringsAfterOffset(StringType* str, // complicated. size_t find_length = find_this.length(); if (!replace_all) { - str->replace(offset, find_length, replace_with); + str->replace(offset, find_length, replace_with.data(), replace_with.size()); return; } @@ -688,8 +686,10 @@ void DoReplaceSubstringsAfterOffset(StringType* str, size_t replace_length = replace_with.length(); if (find_length == replace_length) { do { - str->replace(offset, find_length, replace_with); - offset = str->find(find_this, offset + replace_length); + str->replace(offset, find_length, + replace_with.data(), replace_with.size()); + offset = str->find(find_this.data(), offset + replace_length, + find_this.size()); } while (offset != StringType::npos); return; } @@ -706,11 +706,14 @@ void DoReplaceSubstringsAfterOffset(StringType* str, size_t write_offset = offset; do { if (replace_length) { - str->replace(write_offset, replace_length, replace_with); + str->replace(write_offset, replace_length, + replace_with.data(), replace_with.size()); write_offset += replace_length; } size_t read_offset = offset + find_length; - offset = std::min(str->find(find_this, read_offset), str_length); + offset = std::min( + str->find(find_this.data(), read_offset, find_this.size()), + str_length); size_t length = offset - read_offset; if (length) { memmove(&(*str)[write_offset], &(*str)[read_offset], @@ -739,13 +742,15 @@ void DoReplaceSubstringsAfterOffset(StringType* str, // exit from the loop, |current_match| will point at the last instance of // the find string, and we won't need to find() it again immediately. current_match = offset; - offset = str->find(find_this, offset + find_length); + offset = str->find(find_this.data(), offset + find_length, + find_this.size()); } while (offset != StringType::npos); str->resize(final_length); // Now do the replacement loop, working backwards through the string. for (size_t prev_match = str_length, write_offset = final_length; ; - current_match = str->rfind(find_this, current_match - 1)) { + current_match = str->rfind(find_this.data(), current_match - 1, + find_this.size())) { size_t read_offset = current_match + find_length; size_t length = prev_match - read_offset; if (length) { @@ -754,7 +759,8 @@ void DoReplaceSubstringsAfterOffset(StringType* str, length * sizeof(typename StringType::value_type)); } write_offset -= replace_length; - str->replace(write_offset, replace_length, replace_with); + str->replace(write_offset, replace_length, + replace_with.data(), replace_with.size()); if (current_match == first_match) return; prev_match = current_match; @@ -763,36 +769,38 @@ void DoReplaceSubstringsAfterOffset(StringType* str, void ReplaceFirstSubstringAfterOffset(string16* str, size_t start_offset, - const string16& find_this, - const string16& replace_with) { - DoReplaceSubstringsAfterOffset(str, start_offset, find_this, replace_with, - false); // replace first instance + StringPiece16 find_this, + StringPiece16 replace_with) { + DoReplaceSubstringsAfterOffset<string16>( + str, start_offset, find_this, replace_with, false); // Replace first. } void ReplaceFirstSubstringAfterOffset(std::string* str, size_t start_offset, - const std::string& find_this, - const std::string& replace_with) { - DoReplaceSubstringsAfterOffset(str, start_offset, find_this, replace_with, - false); // replace first instance + StringPiece find_this, + StringPiece replace_with) { + DoReplaceSubstringsAfterOffset<std::string>( + str, start_offset, find_this, replace_with, false); // Replace first. } void ReplaceSubstringsAfterOffset(string16* str, size_t start_offset, - const string16& find_this, - const string16& replace_with) { - DoReplaceSubstringsAfterOffset(str, start_offset, find_this, replace_with, - true); // replace all instances + StringPiece16 find_this, + StringPiece16 replace_with) { + DoReplaceSubstringsAfterOffset<string16>( + str, start_offset, find_this, replace_with, true); // Replace all. } void ReplaceSubstringsAfterOffset(std::string* str, size_t start_offset, - const std::string& find_this, - const std::string& replace_with) { - DoReplaceSubstringsAfterOffset(str, start_offset, find_this, replace_with, - true); // replace all instances + StringPiece find_this, + StringPiece replace_with) { + DoReplaceSubstringsAfterOffset<std::string>( + str, start_offset, find_this, replace_with, true); // Replace all. } +} // namespace base + size_t Tokenize(const base::string16& str, const base::string16& delimiters, std::vector<base::string16>* tokens) { diff --git a/base/strings/string_util.h b/base/strings/string_util.h index 8b80868..dc3d4d7 100644 --- a/base/strings/string_util.h +++ b/base/strings/string_util.h @@ -417,28 +417,18 @@ inline bool IsUnicodeWhitespace(wchar_t c) { // FormatBytes instead; remove this. BASE_EXPORT string16 FormatBytesUnlocalized(int64 bytes); -} // 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 - // Starting at |start_offset| (usually 0), replace the first instance of // |find_this| with |replace_with|. BASE_EXPORT void ReplaceFirstSubstringAfterOffset( base::string16* str, size_t start_offset, - const base::string16& find_this, - const base::string16& replace_with); + StringPiece16 find_this, + StringPiece16 replace_with); BASE_EXPORT void ReplaceFirstSubstringAfterOffset( std::string* str, size_t start_offset, - const std::string& find_this, - const std::string& replace_with); + StringPiece find_this, + StringPiece replace_with); // Starting at |start_offset| (usually 0), look through |str| and replace all // instances of |find_this| with |replace_with|. @@ -449,12 +439,23 @@ BASE_EXPORT void ReplaceFirstSubstringAfterOffset( BASE_EXPORT void ReplaceSubstringsAfterOffset( base::string16* str, size_t start_offset, - const base::string16& find_this, - const base::string16& replace_with); -BASE_EXPORT void ReplaceSubstringsAfterOffset(std::string* str, - size_t start_offset, - const std::string& find_this, - const std::string& replace_with); + StringPiece16 find_this, + StringPiece16 replace_with); +BASE_EXPORT void ReplaceSubstringsAfterOffset( + std::string* str, + size_t start_offset, + StringPiece find_this, + StringPiece replace_with); + +} // 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 // Reserves enough memory in |str| to accommodate |length_with_null| characters, // sets the size of |str| to |length_with_null - 1| characters, and returns a diff --git a/base/trace_event/trace_event_android.cc b/base/trace_event/trace_event_android.cc index 465649d..6433185 100644 --- a/base/trace_event/trace_event_android.cc +++ b/base/trace_event/trace_event_android.cc @@ -12,6 +12,9 @@ #include "base/synchronization/waitable_event.h" #include "base/trace_event/trace_event.h" +namespace base { +namespace trace_event { + namespace { int g_atrace_fd = -1; @@ -24,28 +27,26 @@ void WriteEvent( unsigned long long id, const char** arg_names, const unsigned char* arg_types, - const base::trace_event::TraceEvent::TraceValue* arg_values, - const scoped_refptr<base::trace_event::ConvertableToTraceFormat>* - convertable_values, + const TraceEvent::TraceValue* arg_values, + const scoped_refptr<ConvertableToTraceFormat>* convertable_values, unsigned char flags) { - std::string out = base::StringPrintf("%c|%d|%s", phase, getpid(), name); + std::string out = StringPrintf("%c|%d|%s", phase, getpid(), name); if (flags & TRACE_EVENT_FLAG_HAS_ID) - base::StringAppendF(&out, "-%" PRIx64, static_cast<uint64>(id)); + StringAppendF(&out, "-%" PRIx64, static_cast<uint64>(id)); out += '|'; - for (int i = 0; i < base::trace_event::kTraceMaxNumArgs && arg_names[i]; + for (int i = 0; i < kTraceMaxNumArgs && arg_names[i]; ++i) { if (i) out += ';'; out += arg_names[i]; out += '='; std::string::size_type value_start = out.length(); - if (arg_types[i] == TRACE_VALUE_TYPE_CONVERTABLE) { + if (arg_types[i] == TRACE_VALUE_TYPE_CONVERTABLE) convertable_values[i]->AppendAsTraceFormat(&out); - } else { - base::trace_event::TraceEvent::AppendValueAsJSON(arg_types[i], - arg_values[i], &out); - } + else + TraceEvent::AppendValueAsJSON(arg_types[i], arg_values[i], &out); + // Remove the quotes which may confuse the atrace script. ReplaceSubstringsAfterOffset(&out, value_start, "\\\"", "'"); ReplaceSubstringsAfterOffset(&out, value_start, "\"", ""); @@ -59,25 +60,22 @@ void WriteEvent( write(g_atrace_fd, out.c_str(), out.size()); } -void NoOpOutputCallback(base::WaitableEvent* complete_event, - const scoped_refptr<base::RefCountedString>&, +void NoOpOutputCallback(WaitableEvent* complete_event, + const scoped_refptr<RefCountedString>&, bool has_more_events) { if (!has_more_events) complete_event->Signal(); } -void EndChromeTracing(base::trace_event::TraceLog* trace_log, - base::WaitableEvent* complete_event) { +void EndChromeTracing(TraceLog* trace_log, + WaitableEvent* complete_event) { trace_log->SetDisabled(); // Delete the buffered trace events as they have been sent to atrace. - trace_log->Flush(base::Bind(&NoOpOutputCallback, complete_event)); + trace_log->Flush(Bind(&NoOpOutputCallback, complete_event)); } } // namespace -namespace base { -namespace trace_event { - // These functions support Android systrace.py when 'webview' category is // traced. With the new adb_profile_chrome, we may have two phases: // - before WebView is ready for combined tracing, we can use adb_profile_chrome diff --git a/chrome/browser/bookmarks/bookmark_html_writer.cc b/chrome/browser/bookmarks/bookmark_html_writer.cc index aeba2a8..a7e5895 100644 --- a/chrome/browser/bookmarks/bookmark_html_writer.cc +++ b/chrome/browser/bookmarks/bookmark_html_writer.cc @@ -214,7 +214,7 @@ class Writer : public base::RefCountedThreadSafe<Writer> { case ATTRIBUTE_VALUE: // Convert " to " utf8_string = text; - ReplaceSubstringsAfterOffset(&utf8_string, 0, "\"", """); + base::ReplaceSubstringsAfterOffset(&utf8_string, 0, "\"", """); break; case CONTENT: diff --git a/chrome/browser/chromeos/app_mode/fake_cws.cc b/chrome/browser/chromeos/app_mode/fake_cws.cc index b72c1d5..401e3f2 100644 --- a/chrome/browser/chromeos/app_mode/fake_cws.cc +++ b/chrome/browser/chromeos/app_mode/fake_cws.cc @@ -141,12 +141,14 @@ void FakeCWS::SetUpdateCheckContent(const std::string& update_check_file, test_data_dir.AppendASCII(update_check_file.c_str()); ASSERT_TRUE(base::ReadFileToString(update_file, update_check_content)); - ReplaceSubstringsAfterOffset(update_check_content, 0, "$AppId", app_id); - ReplaceSubstringsAfterOffset( + base::ReplaceSubstringsAfterOffset(update_check_content, 0, "$AppId", app_id); + base::ReplaceSubstringsAfterOffset( update_check_content, 0, "$CrxDownloadUrl", crx_download_url.spec()); - ReplaceSubstringsAfterOffset(update_check_content, 0, "$FP", crx_fp); - ReplaceSubstringsAfterOffset(update_check_content, 0, "$Size", crx_size); - ReplaceSubstringsAfterOffset(update_check_content, 0, "$Version", version); + base::ReplaceSubstringsAfterOffset(update_check_content, 0, "$FP", crx_fp); + base::ReplaceSubstringsAfterOffset(update_check_content, 0, + "$Size", crx_size); + base::ReplaceSubstringsAfterOffset(update_check_content, 0, + "$Version", version); } scoped_ptr<HttpResponse> FakeCWS::HandleRequest(const HttpRequest& request) { diff --git a/chrome/browser/chromeos/login/login_browsertest.cc b/chrome/browser/chromeos/login/login_browsertest.cc index 6f707f3..5bc2a6e 100644 --- a/chrome/browser/chromeos/login/login_browsertest.cc +++ b/chrome/browser/chromeos/login/login_browsertest.cc @@ -144,8 +144,8 @@ class LoginTest : public chromeos::LoginManagerTest { "document.getElementsByName('password')[0].value = '$Password';" "document.getElementById('submit-button').click();" "})();"; - ReplaceSubstringsAfterOffset(&js, 0, "$Email", user_email); - ReplaceSubstringsAfterOffset(&js, 0, "$Password", password); + base::ReplaceSubstringsAfterOffset(&js, 0, "$Email", user_email); + base::ReplaceSubstringsAfterOffset(&js, 0, "$Password", password); ExecuteJsInGaiaAuthFrame(js); } @@ -178,7 +178,7 @@ class LoginTest : public chromeos::LoginManagerTest { "})"; ASSERT_TRUE(content::ExecuteScript(web_contents(), js)); std::string set_email = email_input + ".value = '$Email'"; - ReplaceSubstringsAfterOffset(&set_email, 0, "$Email", user_email); + base::ReplaceSubstringsAfterOffset(&set_email, 0, "$Email", user_email); ASSERT_TRUE(content::ExecuteScript(web_contents(), set_email)); ASSERT_TRUE(content::ExecuteScript(web_contents(), email_next_button + ".fire('tap')")); @@ -188,7 +188,7 @@ class LoginTest : public chromeos::LoginManagerTest { } while (message != "\"switchToPassword\""); std::string set_password = password_input + ".value = '$Password'"; - ReplaceSubstringsAfterOffset(&set_password, 0, "$Password", password); + base::ReplaceSubstringsAfterOffset(&set_password, 0, "$Password", password); ASSERT_TRUE(content::ExecuteScript(web_contents(), set_password)); ASSERT_TRUE(content::ExecuteScript(web_contents(), password_next_button + ".fire('tap')")); diff --git a/chrome/browser/chromeos/login/saml/saml_browsertest.cc b/chrome/browser/chromeos/login/saml/saml_browsertest.cc index da32076..6bc72b3 100644 --- a/chrome/browser/chromeos/login/saml/saml_browsertest.cc +++ b/chrome/browser/chromeos/login/saml/saml_browsertest.cc @@ -255,9 +255,11 @@ scoped_ptr<HttpResponse> FakeSamlIdp::BuildHTMLResponse( const std::string& relay_state, const std::string& next_path) { std::string response_html = html_template; - ReplaceSubstringsAfterOffset(&response_html, 0, "$RelayState", relay_state); - ReplaceSubstringsAfterOffset(&response_html, 0, "$Post", next_path); - ReplaceSubstringsAfterOffset( + base::ReplaceSubstringsAfterOffset( + &response_html, 0, "$RelayState", relay_state); + base::ReplaceSubstringsAfterOffset( + &response_html, 0, "$Post", next_path); + base::ReplaceSubstringsAfterOffset( &response_html, 0, "$Refresh", refresh_url_.spec()); scoped_ptr<BasicHttpResponse> http_response(new BasicHttpResponse()); @@ -375,7 +377,8 @@ class SamlTest : public OobeBaseTest, public testing::WithParamInterface<bool> { std::string js = "$('confirm-password-input').value='$Password';" "$('confirm-password').onConfirmPassword_();"; - ReplaceSubstringsAfterOffset(&js, 0, "$Password", password_to_confirm); + base::ReplaceSubstringsAfterOffset( + &js, 0, "$Password", password_to_confirm); ASSERT_TRUE(content::ExecuteScript(GetLoginUI()->GetWebContents(), js)); } @@ -422,7 +425,7 @@ IN_PROC_BROWSER_TEST_P(SamlTest, SamlUI) { JsExpect("$('gaia-signin').classList.contains('full-width')"); JsExpect("!$('saml-notice-container').hidden"); std::string js = "$('saml-notice-message').textContent.indexOf('$Host') > -1"; - ReplaceSubstringsAfterOffset(&js, 0, "$Host", kIdPHost); + base::ReplaceSubstringsAfterOffset(&js, 0, "$Host", kIdPHost); JsExpect(js); if (!use_webview()) { JsExpect("!$('cancel-add-user-button').hidden"); @@ -685,7 +688,7 @@ IN_PROC_BROWSER_TEST_P(SamlTest, NoticeUpdatedOnRedirect) { " 'authDomainChange'," " processEventsAndSendIfHostFound);" "}"; - ReplaceSubstringsAfterOffset(&js, 0, "$Host", kAdditionalIdPHost); + base::ReplaceSubstringsAfterOffset(&js, 0, "$Host", kAdditionalIdPHost); bool dummy; EXPECT_TRUE(content::ExecuteScriptAndExtractBool( GetLoginUI()->GetWebContents(), js, &dummy)); diff --git a/chrome/browser/chromeos/login/test/oobe_base_test.cc b/chrome/browser/chromeos/login/test/oobe_base_test.cc index 85a8075..379b393 100644 --- a/chrome/browser/chromeos/login/test/oobe_base_test.cc +++ b/chrome/browser/chromeos/login/test/oobe_base_test.cc @@ -283,8 +283,8 @@ void OobeBaseTest::SetSignFormField(const std::string& field_id, "var e = new Event('input');" "document.getElementById('$FieldId').dispatchEvent(e);" "})();"; - ReplaceSubstringsAfterOffset(&js, 0, "$FieldId", field_id); - ReplaceSubstringsAfterOffset(&js, 0, "$FieldValue", field_value); + base::ReplaceSubstringsAfterOffset(&js, 0, "$FieldId", field_id); + base::ReplaceSubstringsAfterOffset(&js, 0, "$FieldValue", field_value); ExecuteJsInSigninFrame(js); } diff --git a/chrome/browser/chromeos/system/timezone_util.cc b/chrome/browser/chromeos/system/timezone_util.cc index 52bc6b9..56124c0 100644 --- a/chrome/browser/chromeos/system/timezone_util.cc +++ b/chrome/browser/chromeos/system/timezone_util.cc @@ -65,7 +65,7 @@ base::string16 GetExemplarCity(const icu::TimeZone& zone) { zone_id.toUTF8String(zone_id_str); // Resource keys for timezones use ':' in place of '/'. - ReplaceSubstringsAfterOffset(&zone_id_str, 0, "/", ":"); + base::ReplaceSubstringsAfterOffset(&zone_id_str, 0, "/", ":"); scoped_ptr<UResourceBundle, UResClose> zone_item( ures_getByKey(zone_strings, zone_id_str.c_str(), NULL, &status)); icu::UnicodeString city; @@ -76,7 +76,7 @@ base::string16 GetExemplarCity(const icu::TimeZone& zone) { } // Fallback case in case of failure. - ReplaceSubstringsAfterOffset(&zone_id_str, 0, ":", "/"); + base::ReplaceSubstringsAfterOffset(&zone_id_str, 0, ":", "/"); // Take the last component of a timezone id (e.g. 'Baz' in 'Foo/Bar/Baz'). // Depending on timezones, keeping all but the 1st component // (e.g. Bar/Baz) may be better, but our current list does not have @@ -85,7 +85,7 @@ base::string16 GetExemplarCity(const icu::TimeZone& zone) { if (slash_pos != std::string::npos && slash_pos < zone_id_str.size()) zone_id_str.erase(0, slash_pos + 1); // zone id has '_' in place of ' '. - ReplaceSubstringsAfterOffset(&zone_id_str, 0, "_", " "); + base::ReplaceSubstringsAfterOffset(&zone_id_str, 0, "_", " "); return base::ASCIIToUTF16(zone_id_str); } diff --git a/chrome/browser/drive/fake_drive_service.cc b/chrome/browser/drive/fake_drive_service.cc index a524b87..9c63c9b 100644 --- a/chrome/browser/drive/fake_drive_service.cc +++ b/chrome/browser/drive/fake_drive_service.cc @@ -273,11 +273,11 @@ void FakeDriveService::AddApp(const std::string& app_id, } std::string app_json = app_json_template_; - ReplaceSubstringsAfterOffset(&app_json, 0, "$AppId", app_id); - ReplaceSubstringsAfterOffset(&app_json, 0, "$AppName", app_name); - ReplaceSubstringsAfterOffset(&app_json, 0, "$ProductId", product_id); - ReplaceSubstringsAfterOffset(&app_json, 0, "$CreateUrl", create_url); - ReplaceSubstringsAfterOffset( + base::ReplaceSubstringsAfterOffset(&app_json, 0, "$AppId", app_id); + base::ReplaceSubstringsAfterOffset(&app_json, 0, "$AppName", app_name); + base::ReplaceSubstringsAfterOffset(&app_json, 0, "$ProductId", product_id); + base::ReplaceSubstringsAfterOffset(&app_json, 0, "$CreateUrl", create_url); + base::ReplaceSubstringsAfterOffset( &app_json, 0, "$Removable", is_removable ? "true" : "false"); JSONStringValueDeserializer json(app_json); diff --git a/chrome/browser/extensions/api/commands/command_service.cc b/chrome/browser/extensions/api/commands/command_service.cc index 45be93b..0f57c60 100644 --- a/chrome/browser/extensions/api/commands/command_service.cc +++ b/chrome/browser/extensions/api/commands/command_service.cc @@ -75,8 +75,8 @@ bool IsForCurrentPlatform(const std::string& key) { std::string StripCurrentPlatform(const std::string& key) { DCHECK(IsForCurrentPlatform(key)); std::string result = key; - ReplaceFirstSubstringAfterOffset(&result, 0, Command::CommandPlatform() + ":", - ""); + base::ReplaceFirstSubstringAfterOffset( + &result, 0, Command::CommandPlatform() + ":", base::StringPiece()); return result; } diff --git a/chrome/browser/extensions/api/declarative_content/declarative_content_apitest.cc b/chrome/browser/extensions/api/declarative_content/declarative_content_apitest.cc index 810f5c8..f21802c 100644 --- a/chrome/browser/extensions/api/declarative_content/declarative_content_apitest.cc +++ b/chrome/browser/extensions/api/declarative_content/declarative_content_apitest.cc @@ -126,8 +126,9 @@ void DeclarativeContentApiTest::CheckIncognito(IncognitoMode mode, bool is_enabled_in_incognito) { std::string manifest = kDeclarativeContentManifest; if (mode == SPLIT) { - ReplaceSubstringsAfterOffset(&manifest, 0, "\"incognito\": \"spanning\"", - "\"incognito\": \"split\""); + base::ReplaceSubstringsAfterOffset( + &manifest, 0, "\"incognito\": \"spanning\"", + "\"incognito\": \"split\""); ASSERT_NE(kDeclarativeContentManifest, manifest); } ext_dir_.WriteManifest(manifest); @@ -633,7 +634,7 @@ IN_PROC_BROWSER_TEST_F(DeclarativeContentApiTest, IN_PROC_BROWSER_TEST_F(DeclarativeContentApiTest, ShowPageActionWithoutPageAction) { std::string manifest_without_page_action = kDeclarativeContentManifest; - ReplaceSubstringsAfterOffset( + base::ReplaceSubstringsAfterOffset( &manifest_without_page_action, 0, "\"page_action\": {},", ""); ASSERT_NE(kDeclarativeContentManifest, manifest_without_page_action); ext_dir_.WriteManifest(manifest_without_page_action); diff --git a/chrome/browser/extensions/api/media_galleries/media_galleries_apitest.cc b/chrome/browser/extensions/api/media_galleries/media_galleries_apitest.cc index 67740e1..6b7a947 100644 --- a/chrome/browser/extensions/api/media_galleries/media_galleries_apitest.cc +++ b/chrome/browser/extensions/api/media_galleries/media_galleries_apitest.cc @@ -365,10 +365,10 @@ class MediaGalleriesPlatformAppBrowserTest : public PlatformAppBrowserTest { base::FilePath in_both_jpg = iphoto_data_root.AppendASCII("InBoth.jpg"); ASSERT_TRUE(base::CopyFile(test_jpg_path, first_only_jpg)); ASSERT_TRUE(base::CopyFile(test_jpg_path, in_both_jpg)); - ReplaceFirstSubstringAfterOffset( - &xml_contents, 0, std::string("$path1"), first_only_jpg.value()); - ReplaceFirstSubstringAfterOffset( - &xml_contents, 0, std::string("$path2"), in_both_jpg.value()); + base::ReplaceFirstSubstringAfterOffset( + &xml_contents, 0, "$path1", first_only_jpg.value()); + base::ReplaceFirstSubstringAfterOffset( + &xml_contents, 0, "$path2", in_both_jpg.value()); base::FilePath album_xml = iphoto_data_root.AppendASCII("AlbumData.xml"); ASSERT_NE(-1, base::WriteFile(album_xml, diff --git a/chrome/browser/extensions/api/settings_overrides/settings_overrides_api.cc b/chrome/browser/extensions/api/settings_overrides/settings_overrides_api.cc index 9f697e0..c1cec39 100644 --- a/chrome/browser/extensions/api/settings_overrides/settings_overrides_api.cc +++ b/chrome/browser/extensions/api/settings_overrides/settings_overrides_api.cc @@ -35,7 +35,7 @@ using api::manifest_types::ChromeSettingsOverrides; std::string SubstituteInstallParam(std::string str, const std::string& install_parameter) { - ReplaceSubstringsAfterOffset(&str, 0, "__PARAM__", install_parameter); + base::ReplaceSubstringsAfterOffset(&str, 0, "__PARAM__", install_parameter); return str; } diff --git a/chrome/browser/extensions/api/webrtc_audio_private/webrtc_audio_private_browsertest.cc b/chrome/browser/extensions/api/webrtc_audio_private/webrtc_audio_private_browsertest.cc index 289aeec..692092a 100644 --- a/chrome/browser/extensions/api/webrtc_audio_private/webrtc_audio_private_browsertest.cc +++ b/chrome/browser/extensions/api/webrtc_audio_private/webrtc_audio_private_browsertest.cc @@ -396,7 +396,8 @@ IN_PROC_BROWSER_TEST_F(HangoutServicesBrowserTest, // The "externally connectable" extension permission doesn't seem to // like when we use 127.0.0.1 as the host, but using localhost works. std::string url_spec = url.spec(); - ReplaceFirstSubstringAfterOffset(&url_spec, 0, "127.0.0.1", "localhost"); + base::ReplaceFirstSubstringAfterOffset( + &url_spec, 0, "127.0.0.1", "localhost"); GURL localhost_url(url_spec); ui_test_utils::NavigateToURL(browser(), localhost_url); diff --git a/chrome/browser/extensions/menu_manager.cc b/chrome/browser/extensions/menu_manager.cc index 95993c9..d778ae4 100644 --- a/chrome/browser/extensions/menu_manager.cc +++ b/chrome/browser/extensions/menu_manager.cc @@ -172,7 +172,8 @@ base::string16 MenuItem::TitleWithReplacement(const base::string16& selection, base::string16 result = base::UTF8ToUTF16(title_); // TODO(asargent) - Change this to properly handle %% escaping so you can // put "%s" in titles that won't get substituted. - ReplaceSubstringsAfterOffset(&result, 0, base::ASCIIToUTF16("%s"), selection); + base::ReplaceSubstringsAfterOffset( + &result, 0, base::ASCIIToUTF16("%s"), selection); if (result.length() > max_length) result = gfx::TruncateString(result, max_length, gfx::WORD_BREAK); diff --git a/chrome/browser/jumplist_win.cc b/chrome/browser/jumplist_win.cc index bed6653d..5bd8ddc 100644 --- a/chrome/browser/jumplist_win.cc +++ b/chrome/browser/jumplist_win.cc @@ -108,7 +108,8 @@ bool UpdateTaskCategory( if (incognito_availability != IncognitoModePrefs::FORCED) { scoped_refptr<ShellLinkItem> chrome = CreateShellLink(); base::string16 chrome_title = l10n_util::GetStringUTF16(IDS_NEW_WINDOW); - ReplaceSubstringsAfterOffset(&chrome_title, 0, L"&", L""); + base::ReplaceSubstringsAfterOffset( + &chrome_title, 0, L"&", base::StringPiece16()); chrome->set_title(chrome_title); chrome->set_icon(chrome_path.value(), 0); items.push_back(chrome); @@ -122,7 +123,8 @@ bool UpdateTaskCategory( incognito->GetCommandLine()->AppendSwitch(switches::kIncognito); base::string16 incognito_title = l10n_util::GetStringUTF16(IDS_NEW_INCOGNITO_WINDOW); - ReplaceSubstringsAfterOffset(&incognito_title, 0, L"&", L""); + base::ReplaceSubstringsAfterOffset( + &incognito_title, 0, L"&", base::StringPiece16()); incognito->set_title(incognito_title); incognito->set_icon(chrome_path.value(), 0); items.push_back(incognito); diff --git a/chrome/browser/local_discovery/privetv3_session_unittest.cc b/chrome/browser/local_discovery/privetv3_session_unittest.cc index 398ce18..e2b80e7 100644 --- a/chrome/browser/local_discovery/privetv3_session_unittest.cc +++ b/chrome/browser/local_discovery/privetv3_session_unittest.cc @@ -122,7 +122,7 @@ TEST_F(PrivetV3SessionTest, InitError) { TEST_F(PrivetV3SessionTest, VersionError) { std::string response(kInfoResponse); - ReplaceFirstSubstringAfterOffset(&response, 0, "3.0", "4.1"); + base::ReplaceFirstSubstringAfterOffset(&response, 0, "3.0", "4.1"); EXPECT_CALL(*this, OnInitializedMock(Result::STATUS_SESSIONERROR, _)) .Times(1); @@ -136,7 +136,7 @@ TEST_F(PrivetV3SessionTest, VersionError) { TEST_F(PrivetV3SessionTest, ModeError) { std::string response(kInfoResponse); - ReplaceFirstSubstringAfterOffset(&response, 0, "mode", "mode_"); + base::ReplaceFirstSubstringAfterOffset(&response, 0, "mode", "mode_"); EXPECT_CALL(*this, OnInitializedMock(Result::STATUS_SESSIONERROR, _)) .Times(1); diff --git a/chrome/browser/pdf/pdf_extension_util.cc b/chrome/browser/pdf/pdf_extension_util.cc index 7446087..1987a68 100644 --- a/chrome/browser/pdf/pdf_extension_util.cc +++ b/chrome/browser/pdf/pdf_extension_util.cc @@ -38,13 +38,13 @@ std::string GetManifest() { ResourceBundle::GetSharedInstance().GetRawDataResource( IDR_PDF_MANIFEST).as_string(); DCHECK(manifest_contents.find(kNameTag) != std::string::npos); - ReplaceFirstSubstringAfterOffset( + base::ReplaceFirstSubstringAfterOffset( &manifest_contents, 0, kNameTag, ChromeContentClient::kPDFPluginName); DCHECK(manifest_contents.find(kIndexTag) != std::string::npos); std::string index = switches::PdfMaterialUIEnabled() ? kMaterialIndex : kRegularIndex; - ReplaceSubstringsAfterOffset(&manifest_contents, 0, kIndexTag, index); + base::ReplaceSubstringsAfterOffset(&manifest_contents, 0, kIndexTag, index); return manifest_contents; } diff --git a/chrome/browser/prefs/profile_pref_store_manager_unittest.cc b/chrome/browser/prefs/profile_pref_store_manager_unittest.cc index 6d4f2e1..49b94d4 100644 --- a/chrome/browser/prefs/profile_pref_store_manager_unittest.cc +++ b/chrome/browser/prefs/profile_pref_store_manager_unittest.cc @@ -238,7 +238,7 @@ class ProfilePrefStoreManagerTest : public testing::Test { // Tamper with the file's contents std::string contents; EXPECT_TRUE(base::ReadFileToString(path, &contents)); - ReplaceSubstringsAfterOffset(&contents, 0u, find, replace); + base::ReplaceSubstringsAfterOffset(&contents, 0u, find, replace); EXPECT_EQ(static_cast<int>(contents.length()), base::WriteFile(path, contents.c_str(), contents.length())); } diff --git a/chrome/browser/search/iframe_source.cc b/chrome/browser/search/iframe_source.cc index 2a86a45..c611501 100644 --- a/chrome/browser/search/iframe_source.cc +++ b/chrome/browser/search/iframe_source.cc @@ -92,6 +92,6 @@ void IframeSource::SendJSWithOrigin( base::StringPiece template_js = ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id); std::string response(template_js.as_string()); - ReplaceFirstSubstringAfterOffset(&response, 0, "{{ORIGIN}}", origin); + base::ReplaceFirstSubstringAfterOffset(&response, 0, "{{ORIGIN}}", origin); callback.Run(base::RefCountedString::TakeString(&response)); } diff --git a/chrome/browser/shell_integration_win.cc b/chrome/browser/shell_integration_win.cc index 4e0af29..d79b217 100644 --- a/chrome/browser/shell_integration_win.cc +++ b/chrome/browser/shell_integration_win.cc @@ -219,10 +219,10 @@ base::string16 GetAppForProtocolUsingRegistry(const GURL& url) { url_spec.length() - 1); base::string16 application_to_launch; if (cmd_key.ReadValue(NULL, &application_to_launch) == ERROR_SUCCESS) { - ReplaceSubstringsAfterOffset(&application_to_launch, - 0, - L"%1", - parameters); + base::ReplaceSubstringsAfterOffset(&application_to_launch, + 0, + L"%1", + parameters); return application_to_launch; } return base::string16(); diff --git a/chrome/browser/ui/pdf/adobe_reader_info_win.cc b/chrome/browser/ui/pdf/adobe_reader_info_win.cc index ded85bc..4bdf62f 100644 --- a/chrome/browser/ui/pdf/adobe_reader_info_win.cc +++ b/chrome/browser/ui/pdf/adobe_reader_info_win.cc @@ -180,7 +180,7 @@ bool IsAdobeReaderUpToDate() { for (int i = 1; i <= 9; ++i) { std::string from = base::StringPrintf(".0%d", i); std::string to = base::StringPrintf(".%d", i); - ReplaceSubstringsAfterOffset(&reader_version, 0, from, to); + base::ReplaceSubstringsAfterOffset(&reader_version, 0, from, to); } base::Version file_version(reader_version); return file_version.IsValid() && !file_version.IsOlderThan(kSecureVersion); diff --git a/chrome/browser/ui/startup/startup_browser_creator_impl.cc b/chrome/browser/ui/startup/startup_browser_creator_impl.cc index f334df7..b6a1fdd 100644 --- a/chrome/browser/ui/startup/startup_browser_creator_impl.cc +++ b/chrome/browser/ui/startup/startup_browser_creator_impl.cc @@ -490,7 +490,7 @@ bool StartupBrowserCreatorImpl::OpenApplicationWindow( return false; #if defined(OS_WIN) // Fix up Windows shortcuts. - ReplaceSubstringsAfterOffset(&url_string, 0, "\\x", "%"); + base::ReplaceSubstringsAfterOffset(&url_string, 0, "\\x", "%"); #endif GURL url(url_string); diff --git a/chrome/browser/ui/webui/chromeos/login/network_dropdown.cc b/chrome/browser/ui/webui/chromeos/login/network_dropdown.cc index 4c821d8..dd2aa82 100644 --- a/chrome/browser/ui/webui/chromeos/login/network_dropdown.cc +++ b/chrome/browser/ui/webui/chromeos/login/network_dropdown.cc @@ -89,7 +89,7 @@ base::ListValue* NetworkMenuWebUI::ConvertMenuModel(ui::MenuModel* model) { base::DictionaryValue* item = new base::DictionaryValue(); item->SetInteger("id", id); base::string16 label = model->GetLabelAt(i); - ReplaceSubstringsAfterOffset(&label, 0, base::ASCIIToUTF16("&&"), + base::ReplaceSubstringsAfterOffset(&label, 0, base::ASCIIToUTF16("&&"), base::ASCIIToUTF16("&")); item->SetString("label", label); gfx::Image icon; diff --git a/chrome/common/crash_keys.cc b/chrome/common/crash_keys.cc index ad90792..d925cf9 100644 --- a/chrome/common/crash_keys.cc +++ b/chrome/common/crash_keys.cc @@ -260,7 +260,8 @@ size_t RegisterChromeCrashKeys() { void SetMetricsClientIdFromGUID(const std::string& metrics_client_guid) { std::string stripped_guid(metrics_client_guid); // Remove all instance of '-' char from the GUID. So BCD-WXY becomes BCDWXY. - ReplaceSubstringsAfterOffset(&stripped_guid, 0, "-", ""); + base::ReplaceSubstringsAfterOffset( + &stripped_guid, 0, "-", base::StringPiece()); if (stripped_guid.empty()) return; diff --git a/chrome/common/custom_handlers/protocol_handler.cc b/chrome/common/custom_handlers/protocol_handler.cc index d484fb6..8ede72d 100644 --- a/chrome/common/custom_handlers/protocol_handler.cc +++ b/chrome/common/custom_handlers/protocol_handler.cc @@ -53,7 +53,7 @@ ProtocolHandler ProtocolHandler::CreateProtocolHandler( GURL ProtocolHandler::TranslateUrl(const GURL& url) const { std::string translatedUrlSpec(url_.spec()); - ReplaceSubstringsAfterOffset(&translatedUrlSpec, 0, "%s", + base::ReplaceSubstringsAfterOffset(&translatedUrlSpec, 0, "%s", net::EscapeQueryParamValue(url.spec(), true)); return GURL(translatedUrlSpec); } diff --git a/chrome/common/importer/firefox_importer_utils.cc b/chrome/common/importer/firefox_importer_utils.cc index f824614..2ca5c4c 100644 --- a/chrome/common/importer/firefox_importer_utils.cc +++ b/chrome/common/importer/firefox_importer_utils.cc @@ -33,7 +33,7 @@ base::FilePath GetProfilePath(const base::DictionaryValue& root, return base::FilePath(); #if defined(OS_WIN) - ReplaceSubstringsAfterOffset( + base::ReplaceSubstringsAfterOffset( &path16, 0, base::ASCIIToUTF16("/"), base::ASCIIToUTF16("\\")); #endif base::FilePath path = base::FilePath::FromUTF16Unsafe(path16); @@ -136,7 +136,7 @@ bool GetFirefoxVersionAndPathFromProfile(const base::FilePath& profile_path, profile_path.AppendASCII("compatibility.ini"); std::string content; base::ReadFileToString(compatibility_file, &content); - ReplaceSubstringsAfterOffset(&content, 0, "\r\n", "\n"); + base::ReplaceSubstringsAfterOffset(&content, 0, "\r\n", "\n"); std::vector<std::string> lines; base::SplitString(content, '\n', &lines); diff --git a/chrome/common/profiling.cc b/chrome/common/profiling.cc index 6dc28c6..06f1c7d 100644 --- a/chrome/common/profiling.cc +++ b/chrome/common/profiling.cc @@ -58,7 +58,7 @@ std::string GetProfileName() { command_line.GetSwitchValueASCII(switches::kProcessType); std::string type = process_type.empty() ? std::string("browser") : std::string(process_type); - ReplaceSubstringsAfterOffset(&profile_name, 0, "{type}", type.c_str()); + base::ReplaceSubstringsAfterOffset(&profile_name, 0, "{type}", type); } return profile_name; } diff --git a/chrome/installer/setup/setup_main.cc b/chrome/installer/setup/setup_main.cc index d50aa1e..0fc346d 100644 --- a/chrome/installer/setup/setup_main.cc +++ b/chrome/installer/setup/setup_main.cc @@ -682,7 +682,7 @@ void RepairChromeIfBroken(const InstallationState& original_state, // Replace --uninstall with --do-not-launch-chrome to cause chrome to // self-repair. - ReplaceFirstSubstringAfterOffset( + base::ReplaceFirstSubstringAfterOffset( &setup_args, 0, base::UTF8ToUTF16(installer::switches::kUninstall), base::UTF8ToUTF16(installer::switches::kDoNotLaunchChrome)); base::CommandLine setup_command(base::CommandLine::NO_PROGRAM); diff --git a/chrome/tools/convert_dict/dic_reader.cc b/chrome/tools/convert_dict/dic_reader.cc index db42bcc..affeb04f 100644 --- a/chrome/tools/convert_dict/dic_reader.cc +++ b/chrome/tools/convert_dict/dic_reader.cc @@ -35,7 +35,7 @@ void SplitDicLine(const std::string& line, std::vector<std::string>* output) { // Everything before the slash index is the first term. We also need to // convert all escaped slashes ("\/" sequences) to regular slashes. std::string word = line.substr(0, slash_index); - ReplaceSubstringsAfterOffset(&word, 0, "\\/", "/"); + base::ReplaceSubstringsAfterOffset(&word, 0, "\\/", "/"); output->push_back(word); // Everything (if anything) after the slash is the second. diff --git a/chromeos/network/onc/onc_utils.cc b/chromeos/network/onc/onc_utils.cc index 2123272..2e4d384 100644 --- a/chromeos/network/onc/onc_utils.cc +++ b/chromeos/network/onc/onc_utils.cc @@ -182,16 +182,16 @@ void ExpandField(const std::string& fieldname, std::string login_id; if (substitution.GetSubstitute(substitutes::kLoginIDField, &login_id)) { - ReplaceSubstringsAfterOffset(&user_string, 0, - substitutes::kLoginIDField, - login_id); + base::ReplaceSubstringsAfterOffset(&user_string, 0, + substitutes::kLoginIDField, + login_id); } std::string email; if (substitution.GetSubstitute(substitutes::kEmailField, &email)) { - ReplaceSubstringsAfterOffset(&user_string, 0, - substitutes::kEmailField, - email); + base::ReplaceSubstringsAfterOffset(&user_string, 0, + substitutes::kEmailField, + email); } onc_object->SetStringWithoutPathExpansion(fieldname, user_string); diff --git a/cloud_print/virtual_driver/win/port_monitor/port_monitor.cc b/cloud_print/virtual_driver/win/port_monitor/port_monitor.cc index a04ac04..e52e332 100644 --- a/cloud_print/virtual_driver/win/port_monitor/port_monitor.cc +++ b/cloud_print/virtual_driver/win/port_monitor/port_monitor.cc @@ -268,15 +268,16 @@ bool LaunchPrintCommandFromTemplate(const base::string16& command_template, const base::string16& job_title) { base::string16 command_string(command_template); // Substitude the place holder with the document path wrapped in quotes. - ReplaceFirstSubstringAfterOffset( + base::ReplaceFirstSubstringAfterOffset( &command_string, 0, kDocumentPathPlaceHolder, EscapeCommandLineArg(xps_path.value())); // Substitude the place holder with the document type wrapped in quotes. - ReplaceFirstSubstringAfterOffset(&command_string, 0, kDocumentTypePlaceHolder, - kXpsMimeType); + base::ReplaceFirstSubstringAfterOffset( + &command_string, 0, kDocumentTypePlaceHolder, kXpsMimeType); // Substitude the place holder with the job title wrapped in quotes. - ReplaceFirstSubstringAfterOffset(&command_string, 0, kJobTitlePlaceHolder, - EscapeCommandLineArg(job_title)); + base::ReplaceFirstSubstringAfterOffset( + &command_string, 0, kJobTitlePlaceHolder, + EscapeCommandLineArg(job_title)); base::CommandLine command = base::CommandLine::FromString(command_string); diff --git a/components/autofill/core/browser/data_driven_test.cc b/components/autofill/core/browser/data_driven_test.cc index e166699..c339758 100644 --- a/components/autofill/core/browser/data_driven_test.cc +++ b/components/autofill/core/browser/data_driven_test.cc @@ -18,7 +18,7 @@ bool ReadFile(const base::FilePath& file, std::string* content) { if (!base::ReadFileToString(file, content)) return false; - ReplaceSubstringsAfterOffset(content, 0, "\r\n", "\n"); + base::ReplaceSubstringsAfterOffset(content, 0, "\r\n", "\n"); return true; } diff --git a/components/invalidation/gcm_network_channel_unittest.cc b/components/invalidation/gcm_network_channel_unittest.cc index 83ac630..bec5489 100644 --- a/components/invalidation/gcm_network_channel_unittest.cc +++ b/components/invalidation/gcm_network_channel_unittest.cc @@ -234,7 +234,7 @@ void TestNetworkChannelURLFetcher::AddExtraRequestHeader( std::string echo_token; if (base::StartsWithASCII(header_line, header_name, false)) { echo_token = header_line; - ReplaceFirstSubstringAfterOffset( + base::ReplaceFirstSubstringAfterOffset( &echo_token, 0, header_name, std::string()); test_->set_last_echo_token(echo_token); } diff --git a/components/json_schema/json_schema_validator.cc b/components/json_schema/json_schema_validator.cc index 34ed95e..00a2144 100644 --- a/components/json_schema/json_schema_validator.cc +++ b/components/json_schema/json_schema_validator.cc @@ -372,7 +372,7 @@ std::string JSONSchemaValidator::GetJSONSchemaType(const base::Value* value) { std::string JSONSchemaValidator::FormatErrorMessage(const std::string& format, const std::string& s1) { std::string ret_val = format; - ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s1); + base::ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s1); return ret_val; } @@ -381,8 +381,8 @@ std::string JSONSchemaValidator::FormatErrorMessage(const std::string& format, const std::string& s1, const std::string& s2) { std::string ret_val = format; - ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s1); - ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s2); + base::ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s1); + base::ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s2); return ret_val; } diff --git a/components/password_manager/core/browser/export/csv_writer.cc b/components/password_manager/core/browser/export/csv_writer.cc index f45683f..b3ea46b 100644 --- a/components/password_manager/core/browser/export/csv_writer.cc +++ b/components/password_manager/core/browser/export/csv_writer.cc @@ -42,7 +42,7 @@ void CSVFormatter::AppendValue(const std::string& raw_value) { if (raw_value.find_first_of("\r\n\",") != std::string::npos) { output_->push_back('\"'); output_->append(raw_value); - ReplaceSubstringsAfterOffset( + base::ReplaceSubstringsAfterOffset( output_, output_->size() - raw_value.size(), "\"", "\"\""); output_->push_back('\"'); } else { diff --git a/components/password_manager/core/browser/import/csv_reader.cc b/components/password_manager/core/browser/import/csv_reader.cc index c2c641c..b2056cf 100644 --- a/components/password_manager/core/browser/import/csv_reader.cc +++ b/components/password_manager/core/browser/import/csv_reader.cc @@ -80,7 +80,7 @@ bool CSVParser::ParseNextCSVRow(std::vector<std::string>* fields) { field.remove_suffix(1); } std::string field_copy(field.as_string()); - ReplaceSubstringsAfterOffset(&field_copy, 0, "\"\"", "\""); + base::ReplaceSubstringsAfterOffset(&field_copy, 0, "\"\"", "\""); fields->push_back(field_copy); } while (!remaining_row_piece.empty()); @@ -105,7 +105,7 @@ bool ReadCSV(base::StringPiece csv, // Normalize EOL sequences so that we uniformly use a single LF character. std::string normalized_csv(csv.as_string()); - ReplaceSubstringsAfterOffset(&normalized_csv, 0, "\r\n", "\n"); + base::ReplaceSubstringsAfterOffset(&normalized_csv, 0, "\r\n", "\n"); // Read header row. CSVParser parser(normalized_csv); diff --git a/components/search_engines/template_url.cc b/components/search_engines/template_url.cc index 5c35d78..b30914c 100644 --- a/components/search_engines/template_url.cc +++ b/components/search_engines/template_url.cc @@ -352,12 +352,12 @@ base::string16 TemplateURLRef::DisplayURL( ParseIfNecessary(search_terms_data); std::string result(GetURL()); if (valid_ && !replacements_.empty()) { - ReplaceSubstringsAfterOffset(&result, 0, - kSearchTermsParameterFull, - kDisplaySearchTerms); - ReplaceSubstringsAfterOffset(&result, 0, - kGoogleUnescapedSearchTermsParameterFull, - kDisplayUnescapedSearchTerms); + base::ReplaceSubstringsAfterOffset(&result, 0, + kSearchTermsParameterFull, + kDisplaySearchTerms); + base::ReplaceSubstringsAfterOffset(&result, 0, + kGoogleUnescapedSearchTermsParameterFull, + kDisplayUnescapedSearchTerms); } return base::UTF8ToUTF16(result); } @@ -366,12 +366,12 @@ base::string16 TemplateURLRef::DisplayURL( std::string TemplateURLRef::DisplayURLToURLRef( const base::string16& display_url) { std::string result = base::UTF16ToUTF8(display_url); - ReplaceSubstringsAfterOffset(&result, 0, - kDisplaySearchTerms, - kSearchTermsParameterFull); - ReplaceSubstringsAfterOffset(&result, 0, - kDisplayUnescapedSearchTerms, - kGoogleUnescapedSearchTermsParameterFull); + base::ReplaceSubstringsAfterOffset(&result, 0, + kDisplaySearchTerms, + kSearchTermsParameterFull); + base::ReplaceSubstringsAfterOffset(&result, 0, + kDisplayUnescapedSearchTerms, + kGoogleUnescapedSearchTermsParameterFull); return result; } @@ -777,10 +777,12 @@ void TemplateURLRef::ParseIfNecessary( void TemplateURLRef::ParseHostAndSearchTermKey( const SearchTermsData& search_terms_data) const { std::string url_string(GetURL()); - ReplaceSubstringsAfterOffset(&url_string, 0, "{google:baseURL}", - search_terms_data.GoogleBaseURLValue()); - ReplaceSubstringsAfterOffset(&url_string, 0, "{google:baseSuggestURL}", - search_terms_data.GoogleBaseSuggestURLValue()); + base::ReplaceSubstringsAfterOffset( + &url_string, 0, "{google:baseURL}", + search_terms_data.GoogleBaseURLValue()); + base::ReplaceSubstringsAfterOffset( + &url_string, 0, "{google:baseSuggestURL}", + search_terms_data.GoogleBaseSuggestURLValue()); search_term_key_.clear(); search_term_position_in_path_ = std::string::npos; diff --git a/components/search_engines/template_url_unittest.cc b/components/search_engines/template_url_unittest.cc index 29f75a7..a51ab69 100644 --- a/components/search_engines/template_url_unittest.cc +++ b/components/search_engines/template_url_unittest.cc @@ -424,8 +424,9 @@ TEST_F(TemplateURLTest, ReplaceSearchTerms) { EXPECT_TRUE(url.url_ref().IsValid(search_terms_data_)); ASSERT_TRUE(url.url_ref().SupportsReplacement(search_terms_data_)); std::string expected_result = test_data[i].expected_result; - ReplaceSubstringsAfterOffset(&expected_result, 0, "{language}", - search_terms_data_.GetApplicationLocale()); + base::ReplaceSubstringsAfterOffset( + &expected_result, 0, "{language}", + search_terms_data_.GetApplicationLocale()); GURL result(url.url_ref().ReplaceSearchTerms( TemplateURLRef::SearchTermsArgs(ASCIIToUTF16("X")), search_terms_data_)); diff --git a/components/url_fixer/url_fixer_unittest.cc b/components/url_fixer/url_fixer_unittest.cc index c2b3e26..ee19289 100644 --- a/components/url_fixer/url_fixer_unittest.cc +++ b/components/url_fixer/url_fixer_unittest.cc @@ -507,7 +507,7 @@ TEST(URLFixerTest, FixupRelativeFile) { // test file in the subdir with different slashes and escaping. base::FilePath::StringType relative_file_str = sub_dir.value() + FILE_PATH_LITERAL("/") + sub_file.value(); - ReplaceSubstringsAfterOffset(&relative_file_str, 0, + base::ReplaceSubstringsAfterOffset(&relative_file_str, 0, FILE_PATH_LITERAL(" "), FILE_PATH_LITERAL("%20")); EXPECT_TRUE(IsMatchingFileURL( url_fixer::FixupRelativeFile(temp_dir_.path(), diff --git a/content/browser/android/java/java_type.cc b/content/browser/android/java/java_type.cc index 5cd9b54..3c48532 100644 --- a/content/browser/android/java/java_type.cc +++ b/content/browser/android/java/java_type.cc @@ -5,7 +5,7 @@ #include "content/browser/android/java/java_type.h" #include "base/logging.h" -#include "base/strings/string_util.h" // For ReplaceSubstringsAfterOffset +#include "base/strings/string_util.h" namespace content { namespace { @@ -53,7 +53,8 @@ scoped_ptr<JavaType> CreateFromArrayComponentTypeName( } else { result->type = JavaType::TypeObject; result->class_jni_name = type_name.substr(1, type_name.length() - 2); - ReplaceSubstringsAfterOffset(&result->class_jni_name, 0, ".", "/"); + base::ReplaceSubstringsAfterOffset( + &result->class_jni_name, 0, ".", "/"); } break; default: @@ -120,7 +121,7 @@ JavaType JavaType::CreateFromBinaryName(const std::string& binary_name) { } else { result.type = JavaType::TypeObject; result.class_jni_name = binary_name; - ReplaceSubstringsAfterOffset(&result.class_jni_name, 0, ".", "/"); + base::ReplaceSubstringsAfterOffset(&result.class_jni_name, 0, ".", "/"); } return result; } diff --git a/content/browser/geolocation/wifi_data_provider_linux.cc b/content/browser/geolocation/wifi_data_provider_linux.cc index 1909abf..5fad8c5 100644 --- a/content/browser/geolocation/wifi_data_provider_linux.cc +++ b/content/browser/geolocation/wifi_data_provider_linux.cc @@ -271,7 +271,7 @@ bool NetworkManagerWlanApi::GetAccessPointsForAdapter( continue; } - ReplaceSubstringsAfterOffset(&mac, 0U, ":", std::string()); + base::ReplaceSubstringsAfterOffset(&mac, 0U, ":", base::StringPiece()); std::vector<uint8> mac_bytes; if (!base::HexStringToBytes(mac, &mac_bytes) || mac_bytes.size() != 6) { LOG(WARNING) << "Can't parse mac address (found " << mac_bytes.size() diff --git a/content/common/appcache_interfaces.cc b/content/common/appcache_interfaces.cc index c2c6192..fc1cb2b 100644 --- a/content/common/appcache_interfaces.cc +++ b/content/common/appcache_interfaces.cc @@ -104,7 +104,7 @@ bool AppCacheNamespace::IsMatch(const GURL& url) const { // as wildcards which we don't want here, we only do '*'s. std::string pattern = namespace_url.spec(); if (namespace_url.has_query()) - ReplaceSubstringsAfterOffset(&pattern, 0, "?", "\\?"); + base::ReplaceSubstringsAfterOffset(&pattern, 0, "?", "\\?"); return MatchPattern(url.spec(), pattern); } return base::StartsWithASCII(url.spec(), namespace_url.spec(), true); diff --git a/content/public/test/test_launcher.cc b/content/public/test/test_launcher.cc index 91fe680..187de3e 100644 --- a/content/public/test/test_launcher.cc +++ b/content/public/test/test_launcher.cc @@ -64,7 +64,8 @@ ContentMainParams* g_params; std::string RemoveAnyPrePrefixes(const std::string& test_name) { std::string result(test_name); - ReplaceSubstringsAfterOffset(&result, 0, kPreTestPrefix, std::string()); + base::ReplaceSubstringsAfterOffset( + &result, 0, kPreTestPrefix, base::StringPiece()); return result; } diff --git a/content/test/net/url_request_abort_on_end_job.cc b/content/test/net/url_request_abort_on_end_job.cc index 3fd494f..f7ff5a9 100644 --- a/content/test/net/url_request_abort_on_end_job.cc +++ b/content/test/net/url_request_abort_on_end_job.cc @@ -76,7 +76,8 @@ void URLRequestAbortOnEndJob::GetResponseInfoConst( NOTREACHED(); } // ParseRawHeaders expects \0 to end each header line. - ReplaceSubstringsAfterOffset(&raw_headers, 0, "\n", std::string("\0", 1)); + base::ReplaceSubstringsAfterOffset( + &raw_headers, 0, "\n", base::StringPiece("\0", 1)); info->headers = new net::HttpResponseHeaders(raw_headers); } diff --git a/extensions/browser/user_script_loader.cc b/extensions/browser/user_script_loader.cc index 69ef590..785e7c8 100644 --- a/extensions/browser/user_script_loader.cc +++ b/extensions/browser/user_script_loader.cc @@ -87,12 +87,12 @@ bool UserScriptLoader::ParseMetadataHeader(const base::StringPiece& script_text, std::string value; if (GetDeclarationValue(line, kIncludeDeclaration, &value)) { // We escape some characters that MatchPattern() considers special. - ReplaceSubstringsAfterOffset(&value, 0, "\\", "\\\\"); - ReplaceSubstringsAfterOffset(&value, 0, "?", "\\?"); + base::ReplaceSubstringsAfterOffset(&value, 0, "\\", "\\\\"); + base::ReplaceSubstringsAfterOffset(&value, 0, "?", "\\?"); script->add_glob(value); } else if (GetDeclarationValue(line, kExcludeDeclaration, &value)) { - ReplaceSubstringsAfterOffset(&value, 0, "\\", "\\\\"); - ReplaceSubstringsAfterOffset(&value, 0, "?", "\\?"); + base::ReplaceSubstringsAfterOffset(&value, 0, "\\", "\\\\"); + base::ReplaceSubstringsAfterOffset(&value, 0, "?", "\\?"); script->add_exclude_glob(value); } else if (GetDeclarationValue(line, kNamespaceDeclaration, &value)) { script->set_name_space(value); diff --git a/extensions/browser/value_store/leveldb_value_store.cc b/extensions/browser/value_store/leveldb_value_store.cc index d29bc74..0db63a17 100644 --- a/extensions/browser/value_store/leveldb_value_store.cc +++ b/extensions/browser/value_store/leveldb_value_store.cc @@ -435,7 +435,8 @@ scoped_ptr<ValueStore::Error> LeveldbValueStore::ToValueStoreError( std::string message = status.ToString(); // The message may contain |db_path_|, which may be considered sensitive // data, and those strings are passed to the extension, so strip it out. - ReplaceSubstringsAfterOffset(&message, 0u, db_path_.AsUTF8Unsafe(), "..."); + base::ReplaceSubstringsAfterOffset( + &message, 0u, db_path_.AsUTF8Unsafe(), "..."); return Error::Create(CORRUPTION, message, key.Pass()); } diff --git a/extensions/common/error_utils.cc b/extensions/common/error_utils.cc index 2343c04..14ca2a9 100644 --- a/extensions/common/error_utils.cc +++ b/extensions/common/error_utils.cc @@ -12,7 +12,7 @@ namespace extensions { std::string ErrorUtils::FormatErrorMessage(const std::string& format, const std::string& s1) { std::string ret_val = format; - ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s1); + base::ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s1); return ret_val; } @@ -20,8 +20,8 @@ std::string ErrorUtils::FormatErrorMessage(const std::string& format, const std::string& s1, const std::string& s2) { std::string ret_val = format; - ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s1); - ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s2); + base::ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s1); + base::ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s2); return ret_val; } @@ -30,9 +30,9 @@ std::string ErrorUtils::FormatErrorMessage(const std::string& format, const std::string& s2, const std::string& s3) { std::string ret_val = format; - ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s1); - ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s2); - ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s3); + base::ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s1); + base::ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s2); + base::ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s3); return ret_val; } diff --git a/extensions/common/url_pattern.cc b/extensions/common/url_pattern.cc index 40142cf..ab24ccf 100644 --- a/extensions/common/url_pattern.cc +++ b/extensions/common/url_pattern.cc @@ -329,8 +329,8 @@ void URLPattern::SetPath(const std::string& path) { spec_.clear(); path_ = path; path_escaped_ = path_; - ReplaceSubstringsAfterOffset(&path_escaped_, 0, "\\", "\\\\"); - ReplaceSubstringsAfterOffset(&path_escaped_, 0, "?", "\\?"); + base::ReplaceSubstringsAfterOffset(&path_escaped_, 0, "\\", "\\\\"); + base::ReplaceSubstringsAfterOffset(&path_escaped_, 0, "?", "\\?"); } bool URLPattern::SetPort(const std::string& port) { diff --git a/extensions/renderer/dispatcher.cc b/extensions/renderer/dispatcher.cc index 1f31964..66cdc0b 100644 --- a/extensions/renderer/dispatcher.cc +++ b/extensions/renderer/dispatcher.cc @@ -339,9 +339,9 @@ void Dispatcher::DidCreateDocumentElement(blink::WebFrame* frame) { std::string stylesheet = ResourceBundle::GetSharedInstance() .GetRawDataResource(resource_id) .as_string(); - ReplaceFirstSubstringAfterOffset( + base::ReplaceFirstSubstringAfterOffset( &stylesheet, 0, "$FONTFAMILY", system_font_family_); - ReplaceFirstSubstringAfterOffset( + base::ReplaceFirstSubstringAfterOffset( &stylesheet, 0, "$FONTSIZE", system_font_size_); // Blink doesn't let us define an additional user agent stylesheet, so diff --git a/ios/chrome/browser/infobars/confirm_infobar_controller.mm b/ios/chrome/browser/infobars/confirm_infobar_controller.mm index 9e93848..90f53a8 100644 --- a/ios/chrome/browser/infobars/confirm_infobar_controller.mm +++ b/ios/chrome/browser/infobars/confirm_infobar_controller.mm @@ -115,7 +115,7 @@ ConfirmInfoBarDelegate::InfoBarButton UITagToButton(NSUInteger tag) { confirmInfobarDelegate_->GetLinkText()) tag:ConfirmInfoBarUITags::TITLE_LINK]); base::string16 messageText = confirmInfobarDelegate_->GetMessageText(); - ReplaceFirstSubstringAfterOffset( + base::ReplaceFirstSubstringAfterOffset( &messageText, 0, confirmInfobarDelegate_->GetLinkText(), msgLink); [view addLabel:base::SysUTF16ToNSString(messageText) diff --git a/mojo/runner/context.cc b/mojo/runner/context.cc index 6eed031..e23c2b7 100644 --- a/mojo/runner/context.cc +++ b/mojo/runner/context.cc @@ -131,7 +131,7 @@ void InitContentHandlers(shell::ApplicationManager* manager, // (to embed a comma into a string escape it using "\,") // Whatever takes 'parameters' and constructs a CommandLine is failing to // un-escape the commas, we need to move this fix to that file. - ReplaceSubstringsAfterOffset(&handlers_spec, 0, "\\,", ","); + base::ReplaceSubstringsAfterOffset(&handlers_spec, 0, "\\,", ","); #endif std::vector<std::string> parts; diff --git a/mojo/util/filename_util.cc b/mojo/util/filename_util.cc index 1a694e1..665c75e 100644 --- a/mojo/util/filename_util.cc +++ b/mojo/util/filename_util.cc @@ -38,22 +38,22 @@ GURL FilePathToFileURL(const base::FilePath& path) { // This must be the first substitution since others will introduce percents as // the escape character - ReplaceSubstringsAfterOffset(&url_string, 0, FILE_PATH_LITERAL("%"), - FILE_PATH_LITERAL("%25")); + base::ReplaceSubstringsAfterOffset(&url_string, 0, FILE_PATH_LITERAL("%"), + FILE_PATH_LITERAL("%25")); // A semicolon is supposed to be some kind of separator according to RFC 2396. - ReplaceSubstringsAfterOffset(&url_string, 0, FILE_PATH_LITERAL(";"), - FILE_PATH_LITERAL("%3B")); + base::ReplaceSubstringsAfterOffset(&url_string, 0, FILE_PATH_LITERAL(";"), + FILE_PATH_LITERAL("%3B")); - ReplaceSubstringsAfterOffset(&url_string, 0, FILE_PATH_LITERAL("#"), - FILE_PATH_LITERAL("%23")); + base::ReplaceSubstringsAfterOffset(&url_string, 0, FILE_PATH_LITERAL("#"), + FILE_PATH_LITERAL("%23")); - ReplaceSubstringsAfterOffset(&url_string, 0, FILE_PATH_LITERAL("?"), - FILE_PATH_LITERAL("%3F")); + base::ReplaceSubstringsAfterOffset(&url_string, 0, FILE_PATH_LITERAL("?"), + FILE_PATH_LITERAL("%3F")); #if defined(OS_POSIX) - ReplaceSubstringsAfterOffset(&url_string, 0, FILE_PATH_LITERAL("\\"), - FILE_PATH_LITERAL("%5C")); + base::ReplaceSubstringsAfterOffset(&url_string, 0, FILE_PATH_LITERAL("\\"), + FILE_PATH_LITERAL("%5C")); #endif return GURL(url_string); diff --git a/net/base/filename_util.cc b/net/base/filename_util.cc index c41da98..b6d668d95 100644 --- a/net/base/filename_util.cc +++ b/net/base/filename_util.cc @@ -36,21 +36,21 @@ GURL FilePathToFileURL(const base::FilePath& path) { // must be the first substitution since others will introduce percents as the // escape character - ReplaceSubstringsAfterOffset( + base::ReplaceSubstringsAfterOffset( &url_string, 0, FILE_PATH_LITERAL("%"), FILE_PATH_LITERAL("%25")); // semicolon is supposed to be some kind of separator according to RFC 2396 - ReplaceSubstringsAfterOffset( + base::ReplaceSubstringsAfterOffset( &url_string, 0, FILE_PATH_LITERAL(";"), FILE_PATH_LITERAL("%3B")); - ReplaceSubstringsAfterOffset( + base::ReplaceSubstringsAfterOffset( &url_string, 0, FILE_PATH_LITERAL("#"), FILE_PATH_LITERAL("%23")); - ReplaceSubstringsAfterOffset( + base::ReplaceSubstringsAfterOffset( &url_string, 0, FILE_PATH_LITERAL("?"), FILE_PATH_LITERAL("%3F")); #if defined(OS_POSIX) - ReplaceSubstringsAfterOffset( + base::ReplaceSubstringsAfterOffset( &url_string, 0, FILE_PATH_LITERAL("\\"), FILE_PATH_LITERAL("%5C")); #endif @@ -121,7 +121,7 @@ bool FileURLToFilePath(const GURL& url, base::FilePath* file_path) { std::string new_path; do { new_path = path; - ReplaceSubstringsAfterOffset(&new_path, 0, "//", "/"); + base::ReplaceSubstringsAfterOffset(&new_path, 0, "//", "/"); path.swap(new_path); } while (new_path != path); diff --git a/net/base/filename_util_internal.cc b/net/base/filename_util_internal.cc index 8d7509f..96376ae 100644 --- a/net/base/filename_util_internal.cc +++ b/net/base/filename_util_internal.cc @@ -41,8 +41,10 @@ void SanitizeGeneratedFileName(base::FilePath::StringType* filename, if (filename->empty()) return; // Replace any path information by changing path separators. - ReplaceSubstringsAfterOffset(filename, 0, FILE_PATH_LITERAL("/"), kReplace); - ReplaceSubstringsAfterOffset(filename, 0, FILE_PATH_LITERAL("\\"), kReplace); + base::ReplaceSubstringsAfterOffset( + filename, 0, FILE_PATH_LITERAL("/"), kReplace); + base::ReplaceSubstringsAfterOffset( + filename, 0, FILE_PATH_LITERAL("\\"), kReplace); } // Returns the filename determined from the last component of the path portion diff --git a/net/ftp/ftp_util.cc b/net/ftp/ftp_util.cc index 11956ba..a653dee 100644 --- a/net/ftp/ftp_util.cc +++ b/net/ftp/ftp_util.cc @@ -108,12 +108,13 @@ std::string FtpUtil::VMSPathToUnix(const std::string& vms_path) { std::string result(vms_path); if (vms_path[0] == '[') { // It's a relative path. - ReplaceFirstSubstringAfterOffset(&result, 0, "[.", std::string()); + base::ReplaceFirstSubstringAfterOffset( + &result, 0, "[.", base::StringPiece()); } else { // It's an absolute path. result.insert(0, "/"); - ReplaceSubstringsAfterOffset(&result, 0, ":[000000]", "/"); - ReplaceSubstringsAfterOffset(&result, 0, ":[", "/"); + base::ReplaceSubstringsAfterOffset(&result, 0, ":[000000]", "/"); + base::ReplaceSubstringsAfterOffset(&result, 0, ":[", "/"); } std::replace(result.begin(), result.end(), '.', '/'); std::replace(result.begin(), result.end(), ']', '/'); diff --git a/net/test/url_request/url_request_mock_http_job.cc b/net/test/url_request/url_request_mock_http_job.cc index 297d0ff..c4efa6a 100644 --- a/net/test/url_request/url_request_mock_http_job.cc +++ b/net/test/url_request/url_request_mock_http_job.cc @@ -189,9 +189,10 @@ void URLRequestMockHTTPJob::Start() { void URLRequestMockHTTPJob::SetHeadersAndStart(const std::string& raw_headers) { raw_headers_ = raw_headers; // Handle CRLF line-endings. - ReplaceSubstringsAfterOffset(&raw_headers_, 0, "\r\n", "\n"); + base::ReplaceSubstringsAfterOffset(&raw_headers_, 0, "\r\n", "\n"); // ParseRawHeaders expects \0 to end each header line. - ReplaceSubstringsAfterOffset(&raw_headers_, 0, "\n", std::string("\0", 1)); + base::ReplaceSubstringsAfterOffset( + &raw_headers_, 0, "\n", base::StringPiece("\0", 1)); URLRequestFileJob::Start(); } diff --git a/net/test/url_request/url_request_slow_download_job.cc b/net/test/url_request/url_request_slow_download_job.cc index 2d9049f..f344feb 100644 --- a/net/test/url_request/url_request_slow_download_job.cc +++ b/net/test/url_request/url_request_slow_download_job.cc @@ -273,7 +273,8 @@ void URLRequestSlowDownloadJob::GetResponseInfoConst( } // ParseRawHeaders expects \0 to end each header line. - ReplaceSubstringsAfterOffset(&raw_headers, 0, "\n", std::string("\0", 1)); + base::ReplaceSubstringsAfterOffset( + &raw_headers, 0, "\n", base::StringPiece("\0", 1)); info->headers = new HttpResponseHeaders(raw_headers); } diff --git a/pdf/pdfium/pdfium_engine.cc b/pdf/pdfium/pdfium_engine.cc index 2825d8c..410b29b 100644 --- a/pdf/pdfium/pdfium_engine.cc +++ b/pdf/pdfium/pdfium_engine.cc @@ -499,7 +499,7 @@ void FormatStringWithHyphens(base::string16* text) { // Adobe Reader also get rid of trailing spaces right before a CRLF. static const base::char16 kSpaceCrCn[] = {L' ', L'\r', L'\n', L'\0'}; static const base::char16 kCrCn[] = {L'\r', L'\n', L'\0'}; - ReplaceSubstringsAfterOffset(text, 0, kSpaceCrCn, kCrCn); + base::ReplaceSubstringsAfterOffset(text, 0, kSpaceCrCn, kCrCn); } // Replace CR/LF with just LF on POSIX. diff --git a/ppapi/shared_impl/var.cc b/ppapi/shared_impl/var.cc index c9aee16..98c762a 100644 --- a/ppapi/shared_impl/var.cc +++ b/ppapi/shared_impl/var.cc @@ -45,9 +45,8 @@ std::string Var::PPVarToLogString(PP_Var var) { else result = string->value(); - std::string null; - null.push_back(0); - ReplaceSubstringsAfterOffset(&result, 0, null, "\\0"); + base::ReplaceSubstringsAfterOffset( + &result, 0, base::StringPiece("\0", 1), "\\0"); return result; } case PP_VARTYPE_OBJECT: diff --git a/storage/browser/fileapi/file_system_url.cc b/storage/browser/fileapi/file_system_url.cc index d0cad1a..13baad4 100644 --- a/storage/browser/fileapi/file_system_url.cc +++ b/storage/browser/fileapi/file_system_url.cc @@ -111,7 +111,7 @@ GURL FileSystemURL::ToGURL() const { std::string escaped = net::EscapeQueryParamValue( virtual_path_.NormalizePathSeparatorsTo('/').AsUTF8Unsafe(), false /* use_plus */); - ReplaceSubstringsAfterOffset(&escaped, 0, "%2F", "/"); + base::ReplaceSubstringsAfterOffset(&escaped, 0, "%2F", "/"); url.append(escaped); // Build nested GURL. diff --git a/third_party/boringssl/boringssl_unittest.cc b/third_party/boringssl/boringssl_unittest.cc index 46c68a8..34b489e 100644 --- a/third_party/boringssl/boringssl_unittest.cc +++ b/third_party/boringssl/boringssl_unittest.cc @@ -32,7 +32,7 @@ void TestProcess(const std::string& name, std::string output; EXPECT_TRUE(base::GetAppOutput(cmd, &output)); // Account for Windows line endings. - ReplaceSubstringsAfterOffset(&output, 0, "\r\n", "\n"); + base::ReplaceSubstringsAfterOffset(&output, 0, "\r\n", "\n"); const bool ok = output.size() >= 5 && memcmp("PASS\n", &output[output.size() - 5], 5) == 0 && diff --git a/third_party/zlib/google/zip.cc b/third_party/zlib/google/zip.cc index 726df33..39e2e53 100644 --- a/third_party/zlib/google/zip.cc +++ b/third_party/zlib/google/zip.cc @@ -56,7 +56,7 @@ bool AddEntryToZip(zipFile zip_file, const base::FilePath& path, DCHECK(result); std::string str_path = relative_path.AsUTF8Unsafe(); #if defined(OS_WIN) - ReplaceSubstringsAfterOffset(&str_path, 0u, "\\", "/"); + base::ReplaceSubstringsAfterOffset(&str_path, 0u, "\\", "/"); #endif bool is_directory = base::DirectoryExists(path); diff --git a/tools/gn/command_args.cc b/tools/gn/command_args.cc index 518a1b6..a8b00976 100644 --- a/tools/gn/command_args.cc +++ b/tools/gn/command_args.cc @@ -211,7 +211,7 @@ bool RunEditor(const base::FilePath& file_to_edit) { // but quoting and escaping internal quotes should handle 99.999% of all // cases. std::string escaped_name = file_to_edit.value(); - ReplaceSubstringsAfterOffset(&escaped_name, 0, "\"", "\\\""); + base::ReplaceSubstringsAfterOffset(&escaped_name, 0, "\"", "\\\""); cmd.append(escaped_name); cmd.push_back('"'); @@ -250,7 +250,8 @@ int EditArgsFile(const std::string& build_dir) { #if defined(OS_WIN) // Use Windows lineendings for this file since it will often open in // Notepad which can't handle Unix ones. - ReplaceSubstringsAfterOffset(&argfile_default_contents, 0, "\n", "\r\n"); + base::ReplaceSubstringsAfterOffset( + &argfile_default_contents, 0, "\n", "\r\n"); #endif base::CreateDirectory(arg_file.DirName()); base::WriteFile(arg_file, argfile_default_contents.c_str(), diff --git a/tools/gn/setup.cc b/tools/gn/setup.cc index aa8e8f0..033dab4 100644 --- a/tools/gn/setup.cc +++ b/tools/gn/setup.cc @@ -370,7 +370,7 @@ bool Setup::SaveArgsToFile() { #if defined(OS_WIN) // Use Windows lineendings for this file since it will often open in // Notepad which can't handle Unix ones. - ReplaceSubstringsAfterOffset(&contents, 0, "\n", "\r\n"); + base::ReplaceSubstringsAfterOffset(&contents, 0, "\n", "\r\n"); #endif if (base::WriteFile(build_arg_file, contents.c_str(), static_cast<int>(contents.size())) == -1) { diff --git a/ui/base/webui/jstemplate_builder.cc b/ui/base/webui/jstemplate_builder.cc index 2aa80a3..3e9d411 100644 --- a/ui/base/webui/jstemplate_builder.cc +++ b/ui/base/webui/jstemplate_builder.cc @@ -27,7 +27,7 @@ void AppendJsonHtml(const base::DictionaryValue* json, std::string* output) { // </ confuses the HTML parser because it could be a </script> tag. So we // replace </ with <\/. The extra \ will be ignored by the JS engine. - ReplaceSubstringsAfterOffset(&javascript_string, 0, "</", "<\\/"); + base::ReplaceSubstringsAfterOffset(&javascript_string, 0, "</", "<\\/"); output->append("<script>"); output->append(javascript_string); diff --git a/ui/gfx/text_elider_unittest.cc b/ui/gfx/text_elider_unittest.cc index 8122c42..5eeea5c 100644 --- a/ui/gfx/text_elider_unittest.cc +++ b/ui/gfx/text_elider_unittest.cc @@ -783,7 +783,7 @@ TEST(TextEliderTest, MAYBE_ElideRectangleTextLongWords) { cases[i].wrap_behavior, &lines)); std::string expected_output(cases[i].output); - ReplaceSubstringsAfterOffset(&expected_output, 0, "...", kEllipsis); + base::ReplaceSubstringsAfterOffset(&expected_output, 0, "...", kEllipsis); const std::string result = UTF16ToUTF8(JoinString(lines, '|')); EXPECT_EQ(expected_output, result) << "Case " << i << " failed!"; } diff --git a/ui/message_center/views/bounded_label_unittest.cc b/ui/message_center/views/bounded_label_unittest.cc index 9744aee..7c3a6a6 100644 --- a/ui/message_center/views/bounded_label_unittest.cc +++ b/ui/message_center/views/bounded_label_unittest.cc @@ -38,7 +38,7 @@ class BoundedLabelTest : public testing::Test { const char kPeriods[] = "..."; const char kEllipses[] = "\xE2\x80\xA6"; std::string result = string; - ReplaceSubstringsAfterOffset(&result, 0, kPeriods, kEllipses); + base::ReplaceSubstringsAfterOffset(&result, 0, kPeriods, kEllipses); return base::UTF8ToUTF16(result); } diff --git a/ui/views/controls/menu/native_menu_win.cc b/ui/views/controls/menu/native_menu_win.cc index c29e7b5..6ca0b30 100644 --- a/ui/views/controls/menu/native_menu_win.cc +++ b/ui/views/controls/menu/native_menu_win.cc @@ -692,7 +692,7 @@ void NativeMenuWin::UpdateMenuItemInfoForString(MENUITEMINFO* mii, ui::MenuModel::ItemType type = model_->GetTypeAt(model_index); // Strip out any tabs, otherwise they get interpreted as accelerators and can // lead to weird behavior. - ReplaceSubstringsAfterOffset(&formatted, 0, L"\t", L" "); + base::ReplaceSubstringsAfterOffset(&formatted, 0, L"\t", L" "); if (type != ui::MenuModel::TYPE_SUBMENU) { // Add accelerator details to the label if provided. ui::Accelerator accelerator(ui::VKEY_UNKNOWN, ui::EF_NONE); |