Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / extensions / common / error_utils.cc
blob14ca2a96c2f8aca36f5885c7e27845bbf4aa8aca
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "extensions/common/error_utils.h"
7 #include "base/strings/string_util.h"
8 #include "base/strings/utf_string_conversions.h"
10 namespace extensions {
12 std::string ErrorUtils::FormatErrorMessage(const std::string& format,
13 const std::string& s1) {
14 std::string ret_val = format;
15 base::ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s1);
16 return ret_val;
19 std::string ErrorUtils::FormatErrorMessage(const std::string& format,
20 const std::string& s1,
21 const std::string& s2) {
22 std::string ret_val = format;
23 base::ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s1);
24 base::ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s2);
25 return ret_val;
28 std::string ErrorUtils::FormatErrorMessage(const std::string& format,
29 const std::string& s1,
30 const std::string& s2,
31 const std::string& s3) {
32 std::string ret_val = format;
33 base::ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s1);
34 base::ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s2);
35 base::ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s3);
36 return ret_val;
39 base::string16 ErrorUtils::FormatErrorMessageUTF16(const std::string& format,
40 const std::string& s1) {
41 return base::UTF8ToUTF16(FormatErrorMessage(format, s1));
44 base::string16 ErrorUtils::FormatErrorMessageUTF16(const std::string& format,
45 const std::string& s1,
46 const std::string& s2) {
47 return base::UTF8ToUTF16(FormatErrorMessage(format, s1, s2));
50 base::string16 ErrorUtils::FormatErrorMessageUTF16(const std::string& format,
51 const std::string& s1,
52 const std::string& s2,
53 const std::string& s3) {
54 return base::UTF8ToUTF16(FormatErrorMessage(format, s1, s2, s3));
57 } // namespace extensions