diff options
41 files changed, 531 insertions, 480 deletions
diff --git a/base/containers/hash_tables.h b/base/containers/hash_tables.h index 2a2b52f..365b586 100644 --- a/base/containers/hash_tables.h +++ b/base/containers/hash_tables.h @@ -103,7 +103,7 @@ DEFINE_TRIVIAL_HASH(unsigned long long); } DEFINE_STRING_HASH(std::string); -DEFINE_STRING_HASH(string16); +DEFINE_STRING_HASH(base::string16); #undef DEFINE_STRING_HASH diff --git a/base/file_version_info.h b/base/file_version_info.h index 59cd45d..e18ba13 100644 --- a/base/file_version_info.h +++ b/base/file_version_info.h @@ -66,21 +66,21 @@ class FileVersionInfo { // Accessors to the different version properties. // Returns an empty string if the property is not found. - virtual string16 company_name() = 0; - virtual string16 company_short_name() = 0; - virtual string16 product_name() = 0; - virtual string16 product_short_name() = 0; - virtual string16 internal_name() = 0; - virtual string16 product_version() = 0; - virtual string16 private_build() = 0; - virtual string16 special_build() = 0; - virtual string16 comments() = 0; - virtual string16 original_filename() = 0; - virtual string16 file_description() = 0; - virtual string16 file_version() = 0; - virtual string16 legal_copyright() = 0; - virtual string16 legal_trademarks() = 0; - virtual string16 last_change() = 0; + virtual base::string16 company_name() = 0; + virtual base::string16 company_short_name() = 0; + virtual base::string16 product_name() = 0; + virtual base::string16 product_short_name() = 0; + virtual base::string16 internal_name() = 0; + virtual base::string16 product_version() = 0; + virtual base::string16 private_build() = 0; + virtual base::string16 special_build() = 0; + virtual base::string16 comments() = 0; + virtual base::string16 original_filename() = 0; + virtual base::string16 file_description() = 0; + virtual base::string16 file_version() = 0; + virtual base::string16 legal_copyright() = 0; + virtual base::string16 legal_trademarks() = 0; + virtual base::string16 last_change() = 0; virtual bool is_official_build() = 0; }; diff --git a/base/i18n/case_conversion_unittest.cc b/base/i18n/case_conversion_unittest.cc index 2139bbe..38e2c68 100644 --- a/base/i18n/case_conversion_unittest.cc +++ b/base/i18n/case_conversion_unittest.cc @@ -6,6 +6,7 @@ #include "base/strings/utf_string_conversions.h" #include "testing/gtest/include/gtest/gtest.h" +namespace base { namespace { // Test upper and lower case string conversion. @@ -24,3 +25,4 @@ TEST(CaseConversionTest, UpperLower) { // TODO(jshin): More tests are needed, especially with non-ASCII characters. } // namespace +} // namespace base diff --git a/base/i18n/file_util_icu.cc b/base/i18n/file_util_icu.cc index 4b2ca3a..9b05250 100644 --- a/base/i18n/file_util_icu.cc +++ b/base/i18n/file_util_icu.cc @@ -19,6 +19,8 @@ #include "third_party/icu/source/common/unicode/uniset.h" #include "third_party/icu/source/i18n/unicode/coll.h" +using base::string16; + namespace { class IllegalCharacters { diff --git a/base/i18n/file_util_icu.h b/base/i18n/file_util_icu.h index 7f246c7..15526c3 100644 --- a/base/i18n/file_util_icu.h +++ b/base/i18n/file_util_icu.h @@ -15,7 +15,7 @@ namespace file_util { // Returns true if file_name does not have any illegal character. The input // param has the same restriction as that for ReplaceIllegalCharacters. -BASE_I18N_EXPORT bool IsFilenameLegal(const string16& file_name); +BASE_I18N_EXPORT bool IsFilenameLegal(const base::string16& file_name); // Replaces characters in 'file_name' that are illegal for file names with // 'replace_char'. 'file_name' must not be a full or relative path, but just the diff --git a/base/i18n/time_formatting.cc b/base/i18n/time_formatting.cc index 3973dd2..917ba43 100644 --- a/base/i18n/time_formatting.cc +++ b/base/i18n/time_formatting.cc @@ -12,8 +12,7 @@ #include "third_party/icu/source/i18n/unicode/dtptngen.h" #include "third_party/icu/source/i18n/unicode/smpdtfmt.h" -using base::Time; - +namespace base { namespace { string16 TimeFormat(const icu::DateFormat* formatter, @@ -48,8 +47,6 @@ string16 TimeFormatWithoutAmPm(const icu::DateFormat* formatter, } // namespace -namespace base { - string16 TimeFormatTimeOfDay(const Time& time) { // We can omit the locale parameter because the default should match // Chrome's application locale. diff --git a/base/pickle.cc b/base/pickle.cc index 796fbc3..12a3237 100644 --- a/base/pickle.cc +++ b/base/pickle.cc @@ -10,6 +10,9 @@ //------------------------------------------------------------------------------ +using base::char16; +using base::string16; + // static const int Pickle::kPayloadUnit = 64; diff --git a/base/pickle.h b/base/pickle.h index 3254837..dd34f54 100644 --- a/base/pickle.h +++ b/base/pickle.h @@ -37,7 +37,7 @@ class BASE_EXPORT PickleIterator { bool ReadFloat(float* result) WARN_UNUSED_RESULT; bool ReadString(std::string* result) WARN_UNUSED_RESULT; bool ReadWString(std::wstring* result) WARN_UNUSED_RESULT; - bool ReadString16(string16* result) WARN_UNUSED_RESULT; + bool ReadString16(base::string16* result) WARN_UNUSED_RESULT; bool ReadData(const char** data, int* length) WARN_UNUSED_RESULT; bool ReadBytes(const char** data, int length) WARN_UNUSED_RESULT; @@ -179,7 +179,7 @@ class BASE_EXPORT Pickle { return iter->ReadWString(result); } bool ReadString16(PickleIterator* iter, - string16* result) const WARN_UNUSED_RESULT { + base::string16* result) const WARN_UNUSED_RESULT { return iter->ReadString16(result); } // A pointer to the data will be placed in *data, and the length will be @@ -243,7 +243,7 @@ class BASE_EXPORT Pickle { } bool WriteString(const std::string& value); bool WriteWString(const std::wstring& value); - bool WriteString16(const string16& value); + bool WriteString16(const base::string16& value); // "Data" is a blob with a length. When you read it out you will be given the // length. See also WriteBytes. bool WriteData(const char* data, int length); diff --git a/base/pickle_unittest.cc b/base/pickle_unittest.cc index 6e9d41d..b1c5925 100644 --- a/base/pickle_unittest.cc +++ b/base/pickle_unittest.cc @@ -10,6 +10,9 @@ #include "base/strings/string16.h" #include "testing/gtest/include/gtest/gtest.h" +// Remove when this file is in the base namespace. +using base::string16; + namespace { const int testint = 2093847192; diff --git a/base/strings/string16.cc b/base/strings/string16.cc index c802eef..f4c8cf7 100644 --- a/base/strings/string16.cc +++ b/base/strings/string16.cc @@ -77,6 +77,6 @@ void PrintTo(const string16& str, std::ostream* out) { } // namespace base -template class std::basic_string<char16, base::string16_char_traits>; +template class std::basic_string<base::char16, base::string16_char_traits>; #endif // WCHAR_T_IS_UTF32 diff --git a/base/strings/string16_unittest.cc b/base/strings/string16_unittest.cc index d98b2a9..4e58218 100644 --- a/base/strings/string16_unittest.cc +++ b/base/strings/string16_unittest.cc @@ -9,6 +9,8 @@ #include "base/strings/utf_string_conversions.h" #include "testing/gtest/include/gtest/gtest.h" +namespace base { + #if defined(WCHAR_T_IS_UTF32) // We define a custom operator<< for string16 so we can use it with logging. @@ -52,3 +54,5 @@ TEST(String16Test, OutputStream) { } #endif + +} // namespace base diff --git a/base/strings/string_util.cc b/base/strings/string_util.cc index 4fa3f3f..1d85de8 100644 --- a/base/strings/string_util.cc +++ b/base/strings/string_util.cc @@ -26,6 +26,10 @@ #include "base/third_party/icu/icu_utf.h" #include "build/build_config.h" +// Remove when this entire file is in the base namespace. +using base::char16; +using base::string16; + namespace { // Force the singleton used by Empty[W]String[16] to be a unique type. This diff --git a/base/strings/string_util.h b/base/strings/string_util.h index a6ee815..442db8e 100644 --- a/base/strings/string_util.h +++ b/base/strings/string_util.h @@ -161,9 +161,9 @@ BASE_EXPORT extern const char kUtf8ByteOrderMark[]; // Removes characters in |remove_chars| from anywhere in |input|. Returns true // if any characters were removed. |remove_chars| must be null-terminated. // NOTE: Safe to use the same variable for both |input| and |output|. -BASE_EXPORT bool RemoveChars(const string16& input, - const char16 remove_chars[], - string16* output); +BASE_EXPORT bool RemoveChars(const base::string16& input, + const base::char16 remove_chars[], + base::string16* output); BASE_EXPORT bool RemoveChars(const std::string& input, const char remove_chars[], std::string* output); @@ -173,10 +173,10 @@ BASE_EXPORT bool RemoveChars(const std::string& input, // the |replace_with| string. Returns true if any characters were replaced. // |replace_chars| must be null-terminated. // NOTE: Safe to use the same variable for both |input| and |output|. -BASE_EXPORT bool ReplaceChars(const string16& input, - const char16 replace_chars[], - const string16& replace_with, - string16* output); +BASE_EXPORT bool ReplaceChars(const base::string16& input, + const base::char16 replace_chars[], + const base::string16& replace_with, + base::string16* output); BASE_EXPORT bool ReplaceChars(const std::string& input, const char replace_chars[], const std::string& replace_with, @@ -185,9 +185,9 @@ BASE_EXPORT bool ReplaceChars(const std::string& input, // Removes characters in |trim_chars| from the beginning and end of |input|. // |trim_chars| must be null-terminated. // NOTE: Safe to use the same variable for both |input| and |output|. -BASE_EXPORT bool TrimString(const string16& input, - const char16 trim_chars[], - string16* output); +BASE_EXPORT bool TrimString(const base::string16& input, + const base::char16 trim_chars[], + base::string16* output); BASE_EXPORT bool TrimString(const std::string& input, const char trim_chars[], std::string* output); @@ -211,9 +211,9 @@ enum TrimPositions { TRIM_TRAILING = 1 << 1, TRIM_ALL = TRIM_LEADING | TRIM_TRAILING, }; -BASE_EXPORT TrimPositions TrimWhitespace(const string16& input, +BASE_EXPORT TrimPositions TrimWhitespace(const base::string16& input, TrimPositions positions, - string16* output); + base::string16* output); BASE_EXPORT TrimPositions TrimWhitespaceASCII(const std::string& input, TrimPositions positions, std::string* output); @@ -232,8 +232,8 @@ BASE_EXPORT TrimPositions TrimWhitespace(const std::string& input, // (2) If |trim_sequences_with_line_breaks| is true, any other whitespace // sequences containing a CR or LF are trimmed. // (3) All other whitespace sequences are converted to single spaces. -BASE_EXPORT string16 CollapseWhitespace( - const string16& text, +BASE_EXPORT base::string16 CollapseWhitespace( + const base::string16& text, bool trim_sequences_with_line_breaks); BASE_EXPORT std::string CollapseWhitespaceASCII( const std::string& text, @@ -242,19 +242,19 @@ BASE_EXPORT std::string CollapseWhitespaceASCII( // Returns true if the passed string is empty or contains only white-space // characters. BASE_EXPORT bool ContainsOnlyWhitespaceASCII(const std::string& str); -BASE_EXPORT bool ContainsOnlyWhitespace(const string16& str); +BASE_EXPORT bool ContainsOnlyWhitespace(const base::string16& str); // Returns true if |input| is empty or contains only characters found in // |characters|. -BASE_EXPORT bool ContainsOnlyChars(const string16& input, - const string16& characters); +BASE_EXPORT bool ContainsOnlyChars(const base::string16& input, + const base::string16& characters); BASE_EXPORT bool ContainsOnlyChars(const std::string& input, const std::string& characters); // Converts to 7-bit ASCII by truncating. The result must be known to be ASCII // beforehand. BASE_EXPORT std::string WideToASCII(const std::wstring& wide); -BASE_EXPORT std::string UTF16ToASCII(const string16& utf16); +BASE_EXPORT std::string UTF16ToASCII(const base::string16& utf16); // 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 @@ -269,7 +269,7 @@ BASE_EXPORT std::string UTF16ToASCII(const string16& utf16); // 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 string16& str); +BASE_EXPORT bool IsStringASCII(const base::string16& str); // Converts the elements of the given string. This version uses a pointer to // clearly differentiate it from the non-pointer variant. @@ -304,40 +304,40 @@ template <class str> inline str StringToUpperASCII(const str& s) { // token, and it is optimized to avoid intermediate string copies. This API is // borrowed from the equivalent APIs in Mozilla. BASE_EXPORT bool LowerCaseEqualsASCII(const std::string& a, const char* b); -BASE_EXPORT bool LowerCaseEqualsASCII(const string16& a, const char* b); +BASE_EXPORT bool LowerCaseEqualsASCII(const base::string16& a, const char* b); // Same thing, but with string iterators instead. BASE_EXPORT bool LowerCaseEqualsASCII(std::string::const_iterator a_begin, std::string::const_iterator a_end, const char* b); -BASE_EXPORT bool LowerCaseEqualsASCII(string16::const_iterator a_begin, - string16::const_iterator a_end, +BASE_EXPORT bool LowerCaseEqualsASCII(base::string16::const_iterator a_begin, + base::string16::const_iterator a_end, const char* b); BASE_EXPORT bool LowerCaseEqualsASCII(const char* a_begin, const char* a_end, const char* b); -BASE_EXPORT bool LowerCaseEqualsASCII(const char16* a_begin, - const char16* a_end, +BASE_EXPORT bool LowerCaseEqualsASCII(const base::char16* a_begin, + const base::char16* a_end, const char* b); // Performs a case-sensitive string compare. The behavior is undefined if both // strings are not ASCII. -BASE_EXPORT bool EqualsASCII(const string16& a, const base::StringPiece& b); +BASE_EXPORT bool EqualsASCII(const base::string16& a, const base::StringPiece& b); // Returns true if str starts with search, or false otherwise. BASE_EXPORT bool StartsWithASCII(const std::string& str, const std::string& search, bool case_sensitive); -BASE_EXPORT bool StartsWith(const string16& str, - const string16& search, +BASE_EXPORT bool StartsWith(const base::string16& str, + const base::string16& search, bool case_sensitive); // Returns true if str ends with search, or false otherwise. BASE_EXPORT bool EndsWith(const std::string& str, const std::string& search, bool case_sensitive); -BASE_EXPORT bool EndsWith(const string16& str, - const string16& search, +BASE_EXPORT bool EndsWith(const base::string16& str, + const base::string16& search, bool case_sensitive); @@ -384,15 +384,15 @@ inline bool IsWhitespace(wchar_t c) { // appropriate for use in any UI; use of FormatBytes and friends in ui/base is // highly recommended instead. TODO(avi): Figure out how to get callers to use // FormatBytes instead; remove this. -BASE_EXPORT string16 FormatBytesUnlocalized(int64 bytes); +BASE_EXPORT base::string16 FormatBytesUnlocalized(int64 bytes); // Starting at |start_offset| (usually 0), replace the first instance of // |find_this| with |replace_with|. BASE_EXPORT void ReplaceFirstSubstringAfterOffset( - string16* str, - string16::size_type start_offset, - const string16& find_this, - const string16& replace_with); + base::string16* str, + base::string16::size_type start_offset, + const base::string16& find_this, + const base::string16& replace_with); BASE_EXPORT void ReplaceFirstSubstringAfterOffset( std::string* str, std::string::size_type start_offset, @@ -406,10 +406,10 @@ BASE_EXPORT void ReplaceFirstSubstringAfterOffset( // characters, for example: // std::replace(str.begin(), str.end(), 'a', 'b'); BASE_EXPORT void ReplaceSubstringsAfterOffset( - string16* str, - string16::size_type start_offset, - const string16& find_this, - const string16& replace_with); + base::string16* str, + base::string16::size_type start_offset, + const base::string16& find_this, + const base::string16& replace_with); BASE_EXPORT void ReplaceSubstringsAfterOffset( std::string* str, std::string::size_type start_offset, @@ -450,9 +450,9 @@ inline typename string_type::value_type* WriteInto(string_type* str, // Splits a string into its fields delimited by any of the characters in // |delimiters|. Each field is added to the |tokens| vector. Returns the // number of tokens found. -BASE_EXPORT size_t Tokenize(const string16& str, - const string16& delimiters, - std::vector<string16>* tokens); +BASE_EXPORT size_t Tokenize(const base::string16& str, + const base::string16& delimiters, + std::vector<base::string16>* tokens); BASE_EXPORT size_t Tokenize(const std::string& str, const std::string& delimiters, std::vector<std::string>* tokens); @@ -461,7 +461,8 @@ BASE_EXPORT size_t Tokenize(const base::StringPiece& str, std::vector<base::StringPiece>* tokens); // Does the opposite of SplitString(). -BASE_EXPORT string16 JoinString(const std::vector<string16>& parts, char16 s); +BASE_EXPORT base::string16 JoinString(const std::vector<base::string16>& parts, + base::char16 s); BASE_EXPORT std::string JoinString( const std::vector<std::string>& parts, char s); @@ -469,17 +470,17 @@ BASE_EXPORT std::string JoinString( BASE_EXPORT std::string JoinString( const std::vector<std::string>& parts, const std::string& separator); -BASE_EXPORT string16 JoinString( - const std::vector<string16>& parts, - const string16& separator); +BASE_EXPORT base::string16 JoinString( + const std::vector<base::string16>& parts, + const base::string16& separator); // Replace $1-$2-$3..$9 in the format string with |a|-|b|-|c|..|i| respectively. // Additionally, any number of consecutive '$' characters is replaced by that // number less one. Eg $$->$, $$$->$$, etc. The offsets parameter here can be // NULL. This only allows you to use up to nine replacements. -BASE_EXPORT string16 ReplaceStringPlaceholders( - const string16& format_string, - const std::vector<string16>& subst, +BASE_EXPORT base::string16 ReplaceStringPlaceholders( + const base::string16& format_string, + const std::vector<base::string16>& subst, std::vector<size_t>* offsets); BASE_EXPORT std::string ReplaceStringPlaceholders( @@ -488,9 +489,10 @@ BASE_EXPORT std::string ReplaceStringPlaceholders( std::vector<size_t>* offsets); // Single-string shortcut for ReplaceStringHolders. |offset| may be NULL. -BASE_EXPORT string16 ReplaceStringPlaceholders(const string16& format_string, - const string16& a, - size_t* offset); +BASE_EXPORT base::string16 ReplaceStringPlaceholders( + const base::string16& format_string, + const base::string16& a, + size_t* offset); // Returns true if the string passed in matches the pattern. The pattern // string can contain wildcards like * and ? @@ -499,7 +501,8 @@ BASE_EXPORT string16 ReplaceStringPlaceholders(const string16& format_string, // ? matches 0 or 1 character, while * matches 0 or more characters. BASE_EXPORT bool MatchPattern(const base::StringPiece& string, const base::StringPiece& pattern); -BASE_EXPORT bool MatchPattern(const string16& string, const string16& pattern); +BASE_EXPORT bool MatchPattern(const base::string16& string, + const base::string16& pattern); // Hack to convert any char-like type to its unsigned counterpart. // For example, it will convert char, signed char and unsigned char to unsigned diff --git a/ipc/ipc_message_utils.cc b/ipc/ipc_message_utils.cc index c5ace24..0390648 100644 --- a/ipc/ipc_message_utils.cc +++ b/ipc/ipc_message_utils.cc @@ -344,7 +344,7 @@ void ParamTraits<std::wstring>::Log(const param_type& p, std::string* l) { } #if !defined(WCHAR_T_IS_UTF16) -void ParamTraits<string16>::Log(const param_type& p, std::string* l) { +void ParamTraits<base::string16>::Log(const param_type& p, std::string* l) { l->append(UTF16ToUTF8(p)); } #endif @@ -536,7 +536,7 @@ void ParamTraits<base::NullableString16>::Write(Message* m, bool ParamTraits<base::NullableString16>::Read(const Message* m, PickleIterator* iter, param_type* r) { - string16 string; + base::string16 string; if (!ReadParam(m, iter, &string)) return false; bool is_null; diff --git a/ipc/ipc_message_utils.h b/ipc/ipc_message_utils.h index e9c0ba0b0..24b38af 100644 --- a/ipc/ipc_message_utils.h +++ b/ipc/ipc_message_utils.h @@ -265,8 +265,8 @@ struct ParamTraits<std::wstring> { // need this trait. #if !defined(WCHAR_T_IS_UTF16) template <> -struct ParamTraits<string16> { - typedef string16 param_type; +struct ParamTraits<base::string16> { + typedef base::string16 param_type; static void Write(Message* m, const param_type& p) { m->WriteString16(p); } diff --git a/net/ftp/ftp_util.cc b/net/ftp/ftp_util.cc index 472275a..e639c46 100644 --- a/net/ftp/ftp_util.cc +++ b/net/ftp/ftp_util.cc @@ -251,7 +251,7 @@ bool FtpUtil::LsDateListingToTime(const base::string16& month, return false; size_t colon_pos = rest.find(':'); - if (colon_pos == string16::npos) + if (colon_pos == base::string16::npos) return false; if (colon_pos > 2) return false; diff --git a/third_party/zlib/google/zip_reader.cc b/third_party/zlib/google/zip_reader.cc index d29082c..862e29a 100644 --- a/third_party/zlib/google/zip_reader.cc +++ b/third_party/zlib/google/zip_reader.cc @@ -39,7 +39,7 @@ ZipReader::EntryInfo::EntryInfo(const std::string& file_name_in_zip, is_unsafe_ = file_name_in_zip.find("..") != std::string::npos; // We also consider that the file name is unsafe, if it's invalid UTF-8. - string16 file_name_utf16; + base::string16 file_name_utf16; if (!UTF8ToUTF16(file_name_in_zip.data(), file_name_in_zip.size(), &file_name_utf16)) { is_unsafe_ = true; diff --git a/ui/base/clipboard/clipboard.h b/ui/base/clipboard/clipboard.h index 27d005a..7229041 100644 --- a/ui/base/clipboard/clipboard.h +++ b/ui/base/clipboard/clipboard.h @@ -230,11 +230,11 @@ class UI_EXPORT Clipboard : NON_EXPORTED_BASE(public base::ThreadChecker) { void Clear(ClipboardType type); void ReadAvailableTypes(ClipboardType type, - std::vector<string16>* types, + std::vector<base::string16>* types, bool* contains_filenames) const; // Reads UNICODE text from the clipboard, if available. - void ReadText(ClipboardType type, string16* result) const; + void ReadText(ClipboardType type, base::string16* result) const; // Reads ASCII text from the clipboard, if available. void ReadAsciiText(ClipboardType type, std::string* result) const; @@ -244,7 +244,7 @@ class UI_EXPORT Clipboard : NON_EXPORTED_BASE(public base::ThreadChecker) { // markup indicating the beginning and end of the actual fragment. Otherwise, // they will contain 0 and markup->size(). void ReadHTML(ClipboardType type, - string16* markup, + base::string16* markup, std::string* src_url, uint32* fragment_start, uint32* fragment_end) const; @@ -257,11 +257,11 @@ class UI_EXPORT Clipboard : NON_EXPORTED_BASE(public base::ThreadChecker) { SkBitmap ReadImage(ClipboardType type) const; void ReadCustomData(ClipboardType clipboard_type, - const string16& type, - string16* result) const; + const base::string16& type, + base::string16* result) const; // Reads a bookmark from the clipboard, if available. - void ReadBookmark(string16* title, std::string* url) const; + void ReadBookmark(base::string16* title, std::string* url) const; // Reads raw data from the clipboard with the given format type. Stores result // as a byte vector. @@ -346,8 +346,8 @@ class UI_EXPORT Clipboard : NON_EXPORTED_BASE(public base::ThreadChecker) { // Safely write to system clipboard. Free |handle| on failure. void WriteToClipboard(unsigned int format, HANDLE handle); - static void ParseBookmarkClipboardFormat(const string16& bookmark, - string16* title, + static void ParseBookmarkClipboardFormat(const base::string16& bookmark, + base::string16* title, std::string* url); // Free a handle depending on its type (as intuited from format) diff --git a/ui/base/clipboard/clipboard_gtk.cc b/ui/base/clipboard/clipboard_gtk.cc index 59e2bc4..eebcc5e 100644 --- a/ui/base/clipboard/clipboard_gtk.cc +++ b/ui/base/clipboard/clipboard_gtk.cc @@ -317,8 +317,8 @@ void Clipboard::WriteBitmap(const SkBitmap& bitmap) { void Clipboard::WriteBookmark(const char* title_data, size_t title_len, const char* url_data, size_t url_len) { // Write as a mozilla url (UTF16: URL, newline, title). - string16 url = UTF8ToUTF16(std::string(url_data, url_len) + "\n"); - string16 title = UTF8ToUTF16(std::string(title_data, title_len)); + base::string16 url = UTF8ToUTF16(std::string(url_data, url_len) + "\n"); + base::string16 title = UTF8ToUTF16(std::string(title_data, title_len)); if (title.length() >= std::numeric_limits<size_t>::max() / 4 || url.length() >= std::numeric_limits<size_t>::max() / 4) return; @@ -407,7 +407,7 @@ void Clipboard::Clear(ClipboardType type) { } void Clipboard::ReadAvailableTypes(ClipboardType type, - std::vector<string16>* types, + std::vector<base::string16>* types, bool* contains_filenames) const { DCHECK(CalledOnValidThread()); if (!types || !contains_filenames) { @@ -441,7 +441,7 @@ void Clipboard::ReadAvailableTypes(ClipboardType type, } -void Clipboard::ReadText(ClipboardType type, string16* result) const { +void Clipboard::ReadText(ClipboardType type, base::string16* result) const { DCHECK(CalledOnValidThread()); GtkClipboard* clipboard = LookupBackingClipboard(type); if (clipboard == NULL) @@ -478,7 +478,7 @@ void Clipboard::ReadAsciiText(ClipboardType type, // TODO(estade): handle different charsets. // TODO(port): set *src_url. void Clipboard::ReadHTML(ClipboardType type, - string16* markup, + base::string16* markup, std::string* src_url, uint32* fragment_start, uint32* fragment_end) const { @@ -547,8 +547,8 @@ SkBitmap Clipboard::ReadImage(ClipboardType type) const { } void Clipboard::ReadCustomData(ClipboardType clipboard_type, - const string16& type, - string16* result) const { + const base::string16& type, + base::string16* result) const { DCHECK(CalledOnValidThread()); GtkClipboard* clipboard = LookupBackingClipboard(clipboard_type); if (!clipboard) @@ -564,7 +564,7 @@ void Clipboard::ReadCustomData(ClipboardType clipboard_type, gtk_selection_data_free(data); } -void Clipboard::ReadBookmark(string16* title, std::string* url) const { +void Clipboard::ReadBookmark(base::string16* title, std::string* url) const { // TODO(estade): implement this. NOTIMPLEMENTED(); } diff --git a/ui/base/clipboard/custom_data_helper.cc b/ui/base/clipboard/custom_data_helper.cc index 0907361..f0b3aa3 100644 --- a/ui/base/clipboard/custom_data_helper.cc +++ b/ui/base/clipboard/custom_data_helper.cc @@ -32,14 +32,14 @@ bool SkippablePickle::SkipString16(PickleIterator* iter) { int len; if (!ReadLength(iter, &len)) return false; - return iter->SkipBytes(len * sizeof(char16)); + return iter->SkipBytes(len * sizeof(base::char16)); } } // namespace void ReadCustomDataTypes(const void* data, size_t data_length, - std::vector<string16>* types) { + std::vector<base::string16>* types) { SkippablePickle pickle(data, data_length); PickleIterator iter(pickle); @@ -53,7 +53,7 @@ void ReadCustomDataTypes(const void* data, uint64 original_size = types->size(); for (uint64 i = 0; i < size; ++i) { - types->push_back(string16()); + types->push_back(base::string16()); if (!pickle.ReadString16(&iter, &types->back()) || !pickle.SkipString16(&iter)) { types->resize(original_size); @@ -64,8 +64,8 @@ void ReadCustomDataTypes(const void* data, void ReadCustomDataForType(const void* data, size_t data_length, - const string16& type, - string16* result) { + const base::string16& type, + base::string16* result) { SkippablePickle pickle(data, data_length); PickleIterator iter(pickle); @@ -74,7 +74,7 @@ void ReadCustomDataForType(const void* data, return; for (uint64 i = 0; i < size; ++i) { - string16 deserialized_type; + base::string16 deserialized_type; if (!pickle.ReadString16(&iter, &deserialized_type)) return; if (deserialized_type == type) { @@ -88,7 +88,7 @@ void ReadCustomDataForType(const void* data, void ReadCustomDataIntoMap(const void* data, size_t data_length, - std::map<string16, string16>* result) { + std::map<base::string16, base::string16>* result) { Pickle pickle(reinterpret_cast<const char*>(data), data_length); PickleIterator iter(pickle); @@ -97,14 +97,14 @@ void ReadCustomDataIntoMap(const void* data, return; for (uint64 i = 0; i < size; ++i) { - string16 type; + base::string16 type; if (!pickle.ReadString16(&iter, &type)) { // Data is corrupt, return an empty map. result->clear(); return; } - std::pair<std::map<string16, string16>::iterator, bool> insert_result = - result->insert(std::make_pair(type, string16())); + std::pair<std::map<base::string16, base::string16>::iterator, bool> + insert_result = result->insert(std::make_pair(type, base::string16())); if (!pickle.ReadString16(&iter, &insert_result.first->second)) { // Data is corrupt, return an empty map. result->clear(); @@ -113,10 +113,12 @@ void ReadCustomDataIntoMap(const void* data, } } -void WriteCustomDataToPickle(const std::map<string16, string16>& data, - Pickle* pickle) { +void WriteCustomDataToPickle( + const std::map<base::string16, base::string16>& data, + Pickle* pickle) { pickle->WriteUInt64(data.size()); - for (std::map<string16, string16>::const_iterator it = data.begin(); + for (std::map<base::string16, base::string16>::const_iterator it = + data.begin(); it != data.end(); ++it) { pickle->WriteString16(it->first); diff --git a/ui/base/clipboard/custom_data_helper.h b/ui/base/clipboard/custom_data_helper.h index 57e1772..55e7dce 100644 --- a/ui/base/clipboard/custom_data_helper.h +++ b/ui/base/clipboard/custom_data_helper.h @@ -36,17 +36,19 @@ UI_EXPORT extern const char kMimeTypeWebCustomData[]; UI_EXPORT void ReadCustomDataTypes(const void* data, size_t data_length, - std::vector<string16>* types); + std::vector<base::string16>* types); UI_EXPORT void ReadCustomDataForType(const void* data, size_t data_length, - const string16& type, - string16* result); -UI_EXPORT void ReadCustomDataIntoMap(const void* data, - size_t data_length, - std::map<string16, string16>* result); - -UI_EXPORT void WriteCustomDataToPickle(const std::map<string16, string16>& data, - Pickle* pickle); + const base::string16& type, + base::string16* result); +UI_EXPORT void ReadCustomDataIntoMap( + const void* data, + size_t data_length, + std::map<base::string16, base::string16>* result); + +UI_EXPORT void WriteCustomDataToPickle( + const std::map<base::string16, base::string16>& data, + Pickle* pickle); } // namespace ui diff --git a/ui/base/clipboard/scoped_clipboard_writer.cc b/ui/base/clipboard/scoped_clipboard_writer.cc index 8e46955..120832f 100644 --- a/ui/base/clipboard/scoped_clipboard_writer.cc +++ b/ui/base/clipboard/scoped_clipboard_writer.cc @@ -26,15 +26,15 @@ ScopedClipboardWriter::~ScopedClipboardWriter() { clipboard_->WriteObjects(type_, objects_); } -void ScopedClipboardWriter::WriteText(const string16& text) { +void ScopedClipboardWriter::WriteText(const base::string16& text) { WriteTextOrURL(text, false); } -void ScopedClipboardWriter::WriteURL(const string16& text) { +void ScopedClipboardWriter::WriteURL(const base::string16& text) { WriteTextOrURL(text, true); } -void ScopedClipboardWriter::WriteHTML(const string16& markup, +void ScopedClipboardWriter::WriteHTML(const base::string16& markup, const std::string& source_url) { std::string utf8_markup = UTF16ToUTF8(markup); @@ -57,7 +57,7 @@ void ScopedClipboardWriter::WriteRTF(const std::string& rtf_data) { objects_[Clipboard::CBF_RTF] = parameters; } -void ScopedClipboardWriter::WriteBookmark(const string16& bookmark_title, +void ScopedClipboardWriter::WriteBookmark(const base::string16& bookmark_title, const std::string& url) { if (bookmark_title.empty() || url.empty()) return; @@ -71,7 +71,7 @@ void ScopedClipboardWriter::WriteBookmark(const string16& bookmark_title, objects_[Clipboard::CBF_BOOKMARK] = parameters; } -void ScopedClipboardWriter::WriteHyperlink(const string16& anchor_text, +void ScopedClipboardWriter::WriteHyperlink(const base::string16& anchor_text, const std::string& url) { if (anchor_text.empty() || url.empty()) return; @@ -111,7 +111,8 @@ void ScopedClipboardWriter::Reset() { objects_.clear(); } -void ScopedClipboardWriter::WriteTextOrURL(const string16& text, bool is_url) { +void ScopedClipboardWriter::WriteTextOrURL(const base::string16& text, + bool is_url) { std::string utf8_text = UTF16ToUTF8(text); Clipboard::ObjectMapParams parameters; diff --git a/ui/base/clipboard/scoped_clipboard_writer.h b/ui/base/clipboard/scoped_clipboard_writer.h index 73ff53b..8c7bb1a 100644 --- a/ui/base/clipboard/scoped_clipboard_writer.h +++ b/ui/base/clipboard/scoped_clipboard_writer.h @@ -33,26 +33,27 @@ class UI_EXPORT ScopedClipboardWriter { ~ScopedClipboardWriter(); // Converts |text| to UTF-8 and adds it to the clipboard. - void WriteText(const string16& text); + void WriteText(const base::string16& text); // Converts the text of the URL to UTF-8 and adds it to the clipboard, then // notifies the Clipboard that we just wrote a URL. - void WriteURL(const string16& text); + void WriteURL(const base::string16& text); // Adds HTML to the clipboard. The url parameter is optional, but especially // useful if the HTML fragment contains relative links. - void WriteHTML(const string16& markup, const std::string& source_url); + void WriteHTML(const base::string16& markup, const std::string& source_url); // Adds RTF to the clipboard. void WriteRTF(const std::string& rtf_data); // Adds a bookmark to the clipboard. - void WriteBookmark(const string16& bookmark_title, + void WriteBookmark(const base::string16& bookmark_title, const std::string& url); // Adds an html hyperlink (<a href>) to the clipboard. |anchor_text| and // |url| will be escaped as needed. - void WriteHyperlink(const string16& anchor_text, const std::string& url); + void WriteHyperlink(const base::string16& anchor_text, + const std::string& url); // Used by WebKit to determine whether WebKit wrote the clipboard last void WriteWebSmartPaste(); @@ -67,7 +68,7 @@ class UI_EXPORT ScopedClipboardWriter { protected: // Converts |text| to UTF-8 and adds it to the clipboard. If it's a URL, we // also notify the clipboard of that fact. - void WriteTextOrURL(const string16& text, bool is_url); + void WriteTextOrURL(const base::string16& text, bool is_url); // We accumulate the data passed to the various targets in the |objects_| // vector, and pass it to Clipboard::WriteObjects() during object destruction. diff --git a/ui/base/ime/composition_text.h b/ui/base/ime/composition_text.h index 5beaffc0..7d72863 100644 --- a/ui/base/ime/composition_text.h +++ b/ui/base/ime/composition_text.h @@ -36,7 +36,7 @@ struct UI_EXPORT CompositionText { void Clear(); // Content of the composition text. - string16 text; + base::string16 text; // Underline information of the composition text. // They must be sorted in ascending order by their start_offset and cannot be diff --git a/ui/base/ime/text_input_client.h b/ui/base/ime/text_input_client.h index 35a6884..8623064f 100644 --- a/ui/base/ime/text_input_client.h +++ b/ui/base/ime/text_input_client.h @@ -43,7 +43,7 @@ class UI_EXPORT TextInputClient { // Inserts a given text at the insertion point. Current composition text or // selection will be removed. This method should never be called when the // current text input type is TEXT_INPUT_TYPE_NONE. - virtual void InsertText(const string16& text) = 0; + virtual void InsertText(const base::string16& text) = 0; // Inserts a single char at the insertion point. Unlike above InsertText() // method, this method has an extra |flags| parameter indicating the modifier @@ -53,7 +53,7 @@ class UI_EXPORT TextInputClient { // preceding key press event should not be a VKEY_PROCESSKEY. // This method will be called whenever a char is generated by the keyboard, // even if the current text input type is TEXT_INPUT_TYPE_NONE. - virtual void InsertChar(char16 ch, int flags) = 0; + virtual void InsertChar(base::char16 ch, int flags) = 0; // Input context information ------------------------------------------------- @@ -121,8 +121,8 @@ class UI_EXPORT TextInputClient { // The result will be stored into |*text|. // Returns false if the operation is not supported or the specified range // is out of the text range returned by GetTextRange(). - virtual bool GetTextFromRange( - const gfx::Range& range, string16* text) const = 0; + virtual bool GetTextFromRange(const gfx::Range& range, + base::string16* text) const = 0; // Miscellaneous ------------------------------------------------------------ diff --git a/ui/base/l10n/l10n_util.cc b/ui/base/l10n/l10n_util.cc index 3757d2f..b610e96 100644 --- a/ui/base/l10n/l10n_util.cc +++ b/ui/base/l10n/l10n_util.cc @@ -253,11 +253,12 @@ bool IsLocaleAvailable(const std::string& locale) { // means text such as "Google Chrome foo bar..." will be layed out LTR even // if "foo bar" is RTL. So this function prepends the necessary RLM in such // cases. -void AdjustParagraphDirectionality(string16* paragraph) { +void AdjustParagraphDirectionality(base::string16* paragraph) { #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) if (base::i18n::IsRTL() && base::i18n::StringContainsStrongRTLChars(*paragraph)) { - paragraph->insert(0, 1, static_cast<char16>(base::i18n::kRightToLeftMark)); + paragraph->insert(0, 1, + static_cast<base::char16>(base::i18n::kRightToLeftMark)); } #endif } @@ -498,7 +499,7 @@ std::string GetApplicationLocale(const std::string& pref_locale) { bool IsLocaleNameTranslated(const char* locale, const std::string& display_locale) { - string16 display_name = + base::string16 display_name = l10n_util::GetDisplayNameForLocale(locale, display_locale, false); // Because ICU sets the error code to U_USING_DEFAULT_WARNING whether or not // uloc_getDisplayName returns the actual translation or the default @@ -509,9 +510,9 @@ bool IsLocaleNameTranslated(const char* locale, return !IsStringASCII(display_name) || UTF16ToASCII(display_name) != locale; } -string16 GetDisplayNameForLocale(const std::string& locale, - const std::string& display_locale, - bool is_for_ui) { +base::string16 GetDisplayNameForLocale(const std::string& locale, + const std::string& display_locale, + bool is_for_ui) { std::string locale_code = locale; // Internally, we use the language code of zh-CN and zh-TW, but we want the // display names to be Chinese (Simplified) and Chinese (Traditional) instead @@ -534,7 +535,7 @@ string16 GetDisplayNameForLocale(const std::string& locale, else if (locale_code == "zh-TW") locale_code = "zh-Hant"; - string16 display_name; + base::string16 display_name; #if defined(OS_ANDROID) // Use Java API to get locale display name so that we can remove most of // the lang data from icu data to reduce binary size, except for zh-Hans and @@ -562,8 +563,8 @@ string16 GetDisplayNameForLocale(const std::string& locale, return display_name; } -string16 GetDisplayNameForCountry(const std::string& country_code, - const std::string& display_locale) { +base::string16 GetDisplayNameForCountry(const std::string& country_code, + const std::string& display_locale) { return GetDisplayNameForLocale("_" + country_code, display_locale, false); } @@ -663,23 +664,23 @@ std::string GetStringUTF8(int message_id) { return UTF16ToUTF8(GetStringUTF16(message_id)); } -string16 GetStringUTF16(int message_id) { +base::string16 GetStringUTF16(int message_id) { ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - string16 str = rb.GetLocalizedString(message_id); + base::string16 str = rb.GetLocalizedString(message_id); AdjustParagraphDirectionality(&str); return str; } -string16 GetStringFUTF16(int message_id, - const std::vector<string16>& replacements, - std::vector<size_t>* offsets) { +base::string16 GetStringFUTF16(int message_id, + const std::vector<base::string16>& replacements, + std::vector<size_t>* offsets) { // TODO(tc): We could save a string copy if we got the raw string as // a StringPiece and were able to call ReplaceStringPlaceholders with - // a StringPiece format string and string16 substitution strings. In + // a StringPiece format string and base::string16 substitution strings. In // practice, the strings should be relatively short. ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - const string16& format_string = rb.GetLocalizedString(message_id); + const base::string16& format_string = rb.GetLocalizedString(message_id); #ifndef NDEBUG // Make sure every replacement string is being used, so we don't just @@ -709,69 +710,69 @@ string16 GetStringFUTF16(int message_id, } #endif - string16 formatted = ReplaceStringPlaceholders(format_string, replacements, - offsets); + base::string16 formatted = ReplaceStringPlaceholders( + format_string, replacements, offsets); AdjustParagraphDirectionality(&formatted); return formatted; } std::string GetStringFUTF8(int message_id, - const string16& a) { + const base::string16& a) { return UTF16ToUTF8(GetStringFUTF16(message_id, a)); } std::string GetStringFUTF8(int message_id, - const string16& a, - const string16& b) { + const base::string16& a, + const base::string16& b) { return UTF16ToUTF8(GetStringFUTF16(message_id, a, b)); } std::string GetStringFUTF8(int message_id, - const string16& a, - const string16& b, - const string16& c) { + const base::string16& a, + const base::string16& b, + const base::string16& c) { return UTF16ToUTF8(GetStringFUTF16(message_id, a, b, c)); } std::string GetStringFUTF8(int message_id, - const string16& a, - const string16& b, - const string16& c, - const string16& d) { + const base::string16& a, + const base::string16& b, + const base::string16& c, + const base::string16& d) { return UTF16ToUTF8(GetStringFUTF16(message_id, a, b, c, d)); } -string16 GetStringFUTF16(int message_id, - const string16& a) { - std::vector<string16> replacements; +base::string16 GetStringFUTF16(int message_id, + const base::string16& a) { + std::vector<base::string16> replacements; replacements.push_back(a); return GetStringFUTF16(message_id, replacements, NULL); } -string16 GetStringFUTF16(int message_id, - const string16& a, - const string16& b) { +base::string16 GetStringFUTF16(int message_id, + const base::string16& a, + const base::string16& b) { return GetStringFUTF16(message_id, a, b, NULL); } -string16 GetStringFUTF16(int message_id, - const string16& a, - const string16& b, - const string16& c) { - std::vector<string16> replacements; +base::string16 GetStringFUTF16(int message_id, + const base::string16& a, + const base::string16& b, + const base::string16& c) { + std::vector<base::string16> replacements; replacements.push_back(a); replacements.push_back(b); replacements.push_back(c); return GetStringFUTF16(message_id, replacements, NULL); } -string16 GetStringFUTF16(int message_id, - const string16& a, - const string16& b, - const string16& c, - const string16& d) { - std::vector<string16> replacements; +base::string16 GetStringFUTF16(int message_id, + const base::string16& a, + const base::string16& b, + const base::string16& c, + const base::string16& d) { + std::vector<base::string16> replacements; replacements.push_back(a); replacements.push_back(b); replacements.push_back(c); @@ -779,13 +780,13 @@ string16 GetStringFUTF16(int message_id, return GetStringFUTF16(message_id, replacements, NULL); } -string16 GetStringFUTF16(int message_id, - const string16& a, - const string16& b, - const string16& c, - const string16& d, - const string16& e) { - std::vector<string16> replacements; +base::string16 GetStringFUTF16(int message_id, + const base::string16& a, + const base::string16& b, + const base::string16& c, + const base::string16& d, + const base::string16& e) { + std::vector<base::string16> replacements; replacements.push_back(a); replacements.push_back(b); replacements.push_back(c); @@ -794,39 +795,41 @@ string16 GetStringFUTF16(int message_id, return GetStringFUTF16(message_id, replacements, NULL); } -string16 GetStringFUTF16(int message_id, const string16& a, size_t* offset) { +base::string16 GetStringFUTF16(int message_id, + const base::string16& a, + size_t* offset) { DCHECK(offset); std::vector<size_t> offsets; - std::vector<string16> replacements; + std::vector<base::string16> replacements; replacements.push_back(a); - string16 result = GetStringFUTF16(message_id, replacements, &offsets); + base::string16 result = GetStringFUTF16(message_id, replacements, &offsets); DCHECK(offsets.size() == 1); *offset = offsets[0]; return result; } -string16 GetStringFUTF16(int message_id, - const string16& a, - const string16& b, - std::vector<size_t>* offsets) { - std::vector<string16> replacements; +base::string16 GetStringFUTF16(int message_id, + const base::string16& a, + const base::string16& b, + std::vector<size_t>* offsets) { + std::vector<base::string16> replacements; replacements.push_back(a); replacements.push_back(b); return GetStringFUTF16(message_id, replacements, offsets); } -string16 GetStringFUTF16Int(int message_id, int a) { +base::string16 GetStringFUTF16Int(int message_id, int a) { return GetStringFUTF16(message_id, UTF8ToUTF16(base::IntToString(a))); } -string16 GetStringFUTF16Int(int message_id, int64 a) { +base::string16 GetStringFUTF16Int(int message_id, int64 a) { return GetStringFUTF16(message_id, UTF8ToUTF16(base::Int64ToString(a))); } -// Specialization of operator() method for string16 version. +// Specialization of operator() method for base::string16 version. template <> -bool StringComparator<string16>::operator()(const string16& lhs, - const string16& rhs) { +bool StringComparator<base::string16>::operator()(const base::string16& lhs, + const base::string16& rhs) { // If we can not get collator instance for specified locale, just do simple // string compare. if (!collator_) @@ -835,7 +838,7 @@ bool StringComparator<string16>::operator()(const string16& lhs, UCOL_LESS; }; -string16 GetPluralStringFUTF16(const std::vector<int>& message_ids, +base::string16 GetPluralStringFUTF16(const std::vector<int>& message_ids, int number) { scoped_ptr<icu::PluralFormat> format = BuildPluralFormat(message_ids); DCHECK(format); @@ -844,7 +847,7 @@ string16 GetPluralStringFUTF16(const std::vector<int>& message_ids, icu::UnicodeString result_files_string = format->format(number, err); int capacity = result_files_string.length() + 1; DCHECK_GT(capacity, 1); - string16 result; + base::string16 result; result_files_string.extract( static_cast<UChar*>(WriteInto(&result, capacity)), capacity, err); DCHECK(U_SUCCESS(err)); @@ -857,7 +860,7 @@ std::string GetPluralStringFUTF8(const std::vector<int>& message_ids, } void SortStrings16(const std::string& locale, - std::vector<string16>* strings) { + std::vector<base::string16>* strings) { SortVectorWithStringKey(locale, strings, false); } diff --git a/ui/base/l10n/l10n_util.h b/ui/base/l10n/l10n_util.h index 2207e6d..2d254fa 100644 --- a/ui/base/l10n/l10n_util.h +++ b/ui/base/l10n/l10n_util.h @@ -55,13 +55,15 @@ bool IsLocaleSupportedByOS(const std::string& locale); // in the UI thread. // If |is_for_ui| is true, U+200F is appended so that it can be // rendered properly in a RTL Chrome. -UI_EXPORT string16 GetDisplayNameForLocale(const std::string& locale, - const std::string& display_locale, - bool is_for_ui); +UI_EXPORT base::string16 GetDisplayNameForLocale( + const std::string& locale, + const std::string& display_locale, + bool is_for_ui); // Returns the display name of the |country_code| in |display_locale|. -UI_EXPORT string16 GetDisplayNameForCountry(const std::string& country_code, - const std::string& display_locale); +UI_EXPORT base::string16 GetDisplayNameForCountry( + const std::string& country_code, + const std::string& display_locale); // Converts all - into _, to be consistent with ICU and file system names. UI_EXPORT std::string NormalizeLocale(const std::string& locale); @@ -88,79 +90,81 @@ UI_EXPORT bool IsValidLocaleSyntax(const std::string& locale); // Pulls resource string from the string bundle and returns it. UI_EXPORT std::string GetStringUTF8(int message_id); -UI_EXPORT string16 GetStringUTF16(int message_id); +UI_EXPORT base::string16 GetStringUTF16(int message_id); // Get a resource string and replace $i with replacements[i] for all // i < replacements.size(). Additionally, $$ is replaced by $. // If non-NULL |offsets| will be replaced with the start points of the replaced // strings. -UI_EXPORT string16 GetStringFUTF16(int message_id, - const std::vector<string16>& replacements, - std::vector<size_t>* offsets); +UI_EXPORT base::string16 GetStringFUTF16( + int message_id, + const std::vector<base::string16>& replacements, + std::vector<size_t>* offsets); // Convenience wrappers for the above. -UI_EXPORT string16 GetStringFUTF16(int message_id, - const string16& a); -UI_EXPORT string16 GetStringFUTF16(int message_id, - const string16& a, - const string16& b); -UI_EXPORT string16 GetStringFUTF16(int message_id, - const string16& a, - const string16& b, - const string16& c); -UI_EXPORT string16 GetStringFUTF16(int message_id, - const string16& a, - const string16& b, - const string16& c, - const string16& d); -UI_EXPORT string16 GetStringFUTF16(int message_id, - const string16& a, - const string16& b, - const string16& c, - const string16& d, - const string16& e); +UI_EXPORT base::string16 GetStringFUTF16(int message_id, + const base::string16& a); +UI_EXPORT base::string16 GetStringFUTF16(int message_id, + const base::string16& a, + const base::string16& b); +UI_EXPORT base::string16 GetStringFUTF16(int message_id, + const base::string16& a, + const base::string16& b, + const base::string16& c); +UI_EXPORT base::string16 GetStringFUTF16(int message_id, + const base::string16& a, + const base::string16& b, + const base::string16& c, + const base::string16& d); +UI_EXPORT base::string16 GetStringFUTF16(int message_id, + const base::string16& a, + const base::string16& b, + const base::string16& c, + const base::string16& d, + const base::string16& e); UI_EXPORT std::string GetStringFUTF8(int message_id, - const string16& a); + const base::string16& a); UI_EXPORT std::string GetStringFUTF8(int message_id, - const string16& a, - const string16& b); + const base::string16& a, + const base::string16& b); UI_EXPORT std::string GetStringFUTF8(int message_id, - const string16& a, - const string16& b, - const string16& c); + const base::string16& a, + const base::string16& b, + const base::string16& c); UI_EXPORT std::string GetStringFUTF8(int message_id, - const string16& a, - const string16& b, - const string16& c, - const string16& d); + const base::string16& a, + const base::string16& b, + const base::string16& c, + const base::string16& d); // Variants that return the offset(s) of the replaced parameters. The // vector based version returns offsets ordered by parameter. For example if // invoked with a and b offsets[0] gives the offset for a and offsets[1] the // offset of b regardless of where the parameters end up in the string. -UI_EXPORT string16 GetStringFUTF16(int message_id, - const string16& a, - size_t* offset); -UI_EXPORT string16 GetStringFUTF16(int message_id, - const string16& a, - const string16& b, - std::vector<size_t>* offsets); +UI_EXPORT base::string16 GetStringFUTF16(int message_id, + const base::string16& a, + size_t* offset); +UI_EXPORT base::string16 GetStringFUTF16(int message_id, + const base::string16& a, + const base::string16& b, + std::vector<size_t>* offsets); // Convenience functions to get a string with a single number as a parameter. -UI_EXPORT string16 GetStringFUTF16Int(int message_id, int a); -string16 GetStringFUTF16Int(int message_id, int64 a); +UI_EXPORT base::string16 GetStringFUTF16Int(int message_id, int a); +base::string16 GetStringFUTF16Int(int message_id, int64 a); // Get a resource string using |number| to decide which of |message_ids| should // be used. |message_ids| must be size 6 and in order: default, singular, zero, // two, few, many. -UI_EXPORT string16 GetPluralStringFUTF16(const std::vector<int>& message_ids, - int number); +UI_EXPORT base::string16 GetPluralStringFUTF16( + const std::vector<int>& message_ids, + int number); UI_EXPORT std::string GetPluralStringFUTF8(const std::vector<int>& message_ids, int number); -// In place sorting of string16 strings using collation rules for |locale|. +// In place sorting of base::string16 strings using collation rules for |locale|. UI_EXPORT void SortStrings16(const std::string& locale, - std::vector<string16>* strings); + std::vector<base::string16>* strings); // Returns a vector of available locale codes. E.g., a vector containing // en-US, es, fr, fi, pt-PT, pt-BR, etc. diff --git a/ui/base/l10n/l10n_util_collator.h b/ui/base/l10n/l10n_util_collator.h index b91b804..a0bfb92 100644 --- a/ui/base/l10n/l10n_util_collator.h +++ b/ui/base/l10n/l10n_util_collator.h @@ -21,8 +21,8 @@ namespace l10n_util { // operator (), comparing the string results using a collator. template <class T, class Method> class StringMethodComparatorWithCollator - : public std::binary_function<const string16&, - const string16&, + : public std::binary_function<const base::string16&, + const base::string16&, bool> { public: StringMethodComparatorWithCollator(icu::Collator* collator, Method method) @@ -43,9 +43,10 @@ class StringMethodComparatorWithCollator // Used by SortStringsUsingMethod. Invokes a method on the objects passed to // operator (), comparing the string results using <. template <class T, class Method> -class StringMethodComparator : public std::binary_function<const string16&, - const string16&, - bool> { +class StringMethodComparator + : public std::binary_function<const base::string16&, + const base::string16&, + bool> { public: explicit StringMethodComparator(Method method) : method_(method) { } @@ -93,10 +94,10 @@ class StringComparator : public std::binary_function<const Element&, // Returns true if lhs precedes rhs. bool operator()(const Element& lhs, const Element& rhs) { - const string16& lhs_string_key = lhs.GetStringKey(); - const string16& rhs_string_key = rhs.GetStringKey(); + const base::string16& lhs_string_key = lhs.GetStringKey(); + const base::string16& rhs_string_key = rhs.GetStringKey(); - return StringComparator<string16>(collator_)(lhs_string_key, + return StringComparator<base::string16>(collator_)(lhs_string_key, rhs_string_key); } @@ -106,8 +107,8 @@ class StringComparator : public std::binary_function<const Element&, // Specialization of operator() method for string16 version. template <> UI_EXPORT -bool StringComparator<string16>::operator()(const string16& lhs, - const string16& rhs); +bool StringComparator<base::string16>::operator()(const base::string16& lhs, + const base::string16& rhs); // In place sorting of |elements| of a vector according to the string key of // each element in the vector by using collation rules for |locale|. diff --git a/ui/base/l10n/time_format.cc b/ui/base/l10n/time_format.cc index aaa35a9..f3b16a3 100644 --- a/ui/base/l10n/time_format.cc +++ b/ui/base/l10n/time_format.cc @@ -281,10 +281,10 @@ icu::PluralFormat* TimeFormatter::createFallbackFormat( return format; } -string16 FormatTimeImpl(const TimeDelta& delta, FormatType format_type) { +base::string16 FormatTimeImpl(const TimeDelta& delta, FormatType format_type) { if (delta.ToInternalValue() < 0) { NOTREACHED() << "Negative duration"; - return string16(); + return base::string16(); } int number; @@ -323,7 +323,7 @@ string16 FormatTimeImpl(const TimeDelta& delta, FormatType format_type) { DCHECK(U_SUCCESS(error)); int capacity = time_string.length() + 1; DCHECK_GT(capacity, 1); - string16 result; + base::string16 result; time_string.extract(static_cast<UChar*>(WriteInto(&result, capacity)), capacity, error); DCHECK(U_SUCCESS(error)); @@ -335,32 +335,32 @@ string16 FormatTimeImpl(const TimeDelta& delta, FormatType format_type) { namespace ui { // static -string16 TimeFormat::TimeElapsed(const TimeDelta& delta) { +base::string16 TimeFormat::TimeElapsed(const TimeDelta& delta) { return FormatTimeImpl(delta, FORMAT_ELAPSED); } // static -string16 TimeFormat::TimeRemaining(const TimeDelta& delta) { +base::string16 TimeFormat::TimeRemaining(const TimeDelta& delta) { return FormatTimeImpl(delta, FORMAT_REMAINING); } // static -string16 TimeFormat::TimeRemainingLong(const TimeDelta& delta) { +base::string16 TimeFormat::TimeRemainingLong(const TimeDelta& delta) { return FormatTimeImpl(delta, FORMAT_REMAINING_LONG); } // static -string16 TimeFormat::TimeRemainingShort(const TimeDelta& delta) { +base::string16 TimeFormat::TimeRemainingShort(const TimeDelta& delta) { return FormatTimeImpl(delta, FORMAT_SHORT); } // static -string16 TimeFormat::TimeDurationLong(const TimeDelta& delta) { +base::string16 TimeFormat::TimeDurationLong(const TimeDelta& delta) { return FormatTimeImpl(delta, FORMAT_DURATION_LONG); } // static -string16 TimeFormat::RelativeDate( +base::string16 TimeFormat::RelativeDate( const Time& time, const Time* optional_midnight_today) { Time midnight_today = optional_midnight_today ? *optional_midnight_today : @@ -369,12 +369,12 @@ string16 TimeFormat::RelativeDate( Time tomorrow = midnight_today + day; Time yesterday = midnight_today - day; if (time >= tomorrow) - return string16(); + return base::string16(); else if (time >= midnight_today) return l10n_util::GetStringUTF16(IDS_PAST_TIME_TODAY); else if (time >= yesterday) return l10n_util::GetStringUTF16(IDS_PAST_TIME_YESTERDAY); - return string16(); + return base::string16(); } } // namespace ui diff --git a/ui/base/l10n/time_format.h b/ui/base/l10n/time_format.h index 075b698..0b3a1be 100644 --- a/ui/base/l10n/time_format.h +++ b/ui/base/l10n/time_format.h @@ -25,21 +25,21 @@ class UI_EXPORT TimeFormat { // in-progress operations and users have different expectations of units. // Returns times in elapsed-format: "3 mins ago", "2 days ago". - static string16 TimeElapsed(const base::TimeDelta& delta); + static base::string16 TimeElapsed(const base::TimeDelta& delta); // Returns times in remaining-format: "3 mins left", "2 days left". - static string16 TimeRemaining(const base::TimeDelta& delta); + static base::string16 TimeRemaining(const base::TimeDelta& delta); // Returns times in remaining-long-format: "3 minutes left", "2 days left". // Currently, this only affects the minutes in long format, the rest // of the time units are formatted the same as TimeRemaining does. - static string16 TimeRemainingLong(const base::TimeDelta& delta); + static base::string16 TimeRemainingLong(const base::TimeDelta& delta); // Returns times in short-format: "3 mins", "2 days". - static string16 TimeRemainingShort(const base::TimeDelta& delta); + static base::string16 TimeRemainingShort(const base::TimeDelta& delta); // Return times in long-format: "2 hours", "25 minutes". - static string16 TimeDurationLong(const base::TimeDelta& delta); + static base::string16 TimeDurationLong(const base::TimeDelta& delta); // For displaying a relative time in the past. This method returns either // "Today", "Yesterday", or an empty string if it's older than that. Returns @@ -55,8 +55,8 @@ class UI_EXPORT TimeFormat { // If NULL, the current day's midnight will be retrieved, which can be // slow. If many items are being processed, it is best to get the current // time once at the beginning and pass it for each computation. - static string16 RelativeDate(const base::Time& time, - const base::Time* optional_midnight_today); + static base::string16 RelativeDate(const base::Time& time, + const base::Time* optional_midnight_today); private: DISALLOW_IMPLICIT_CONSTRUCTORS(TimeFormat); diff --git a/ui/base/resource/resource_bundle.cc b/ui/base/resource/resource_bundle.cc index 8b622cc..b5f8f61 100644 --- a/ui/base/resource/resource_bundle.cc +++ b/ui/base/resource/resource_bundle.cc @@ -442,8 +442,8 @@ base::StringPiece ResourceBundle::GetRawDataResourceForScale( return base::StringPiece(); } -string16 ResourceBundle::GetLocalizedString(int message_id) { - string16 string; +base::string16 ResourceBundle::GetLocalizedString(int message_id) { + base::string16 string; if (delegate_ && delegate_->GetLocalizedString(message_id, &string)) return string; @@ -455,7 +455,7 @@ string16 ResourceBundle::GetLocalizedString(int message_id) { // string (better than crashing). if (!locale_resources_data_.get()) { LOG(WARNING) << "locale resources are not loaded"; - return string16(); + return base::string16(); } base::StringPiece data; @@ -465,7 +465,7 @@ string16 ResourceBundle::GetLocalizedString(int message_id) { data = GetRawDataResource(message_id); if (data.empty()) { NOTREACHED() << "unable to find resource: " << message_id; - return string16(); + return base::string16(); } } @@ -476,10 +476,10 @@ string16 ResourceBundle::GetLocalizedString(int message_id) { << "requested localized string from binary pack file"; // Data pack encodes strings as either UTF8 or UTF16. - string16 msg; + base::string16 msg; if (encoding == ResourceHandle::UTF16) { - msg = string16(reinterpret_cast<const char16*>(data.data()), - data.length() / 2); + msg = base::string16(reinterpret_cast<const base::char16*>(data.data()), + data.length() / 2); } else if (encoding == ResourceHandle::UTF8) { msg = UTF8ToUTF16(data); } diff --git a/ui/base/resource/resource_bundle.h b/ui/base/resource/resource_bundle.h index bea12c1..272c5b3 100644 --- a/ui/base/resource/resource_bundle.h +++ b/ui/base/resource/resource_bundle.h @@ -105,7 +105,7 @@ class UI_EXPORT ResourceBundle { // Retrieve a localized string. Return true if a string was provided or // false to attempt retrieval of the default string. - virtual bool GetLocalizedString(int message_id, string16* value) = 0; + virtual bool GetLocalizedString(int message_id, base::string16* value) = 0; // Returns a font or NULL to attempt retrieval of the default resource. virtual scoped_ptr<gfx::Font> GetFont(FontStyle style) = 0; @@ -230,7 +230,7 @@ class UI_EXPORT ResourceBundle { // Get a localized string given a message id. Returns an empty // string if the message_id is not found. - string16 GetLocalizedString(int message_id); + base::string16 GetLocalizedString(int message_id); // Returns the font list for the specified style. const gfx::FontList& GetFontList(FontStyle style); diff --git a/ui/base/text/bytes_formatting.cc b/ui/base/text/bytes_formatting.cc index db353728..02bf55c 100644 --- a/ui/base/text/bytes_formatting.cc +++ b/ui/base/text/bytes_formatting.cc @@ -34,14 +34,14 @@ const int kSpeedStrings[] = { IDS_APP_PEBIBYTES_PER_SECOND }; -string16 FormatBytesInternal(int64 bytes, - DataUnits units, - bool show_units, - const int* const suffix) { +base::string16 FormatBytesInternal(int64 bytes, + DataUnits units, + bool show_units, + const int* const suffix) { DCHECK(units >= DATA_UNITS_BYTE && units <= DATA_UNITS_PEBIBYTE); if (bytes < 0) { NOTREACHED() << "Negative bytes value"; - return string16(); + return base::string16(); } // Put the quantity in the right units. @@ -53,7 +53,7 @@ string16 FormatBytesInternal(int64 bytes, if (bytes != 0 && units != DATA_UNITS_BYTE && unit_amount < 100) fractional_digits = 1; - string16 result = base::FormatDouble(unit_amount, fractional_digits); + base::string16 result = base::FormatDouble(unit_amount, fractional_digits); if (show_units) result = l10n_util::GetStringFUTF16(suffix[units], result); @@ -91,19 +91,23 @@ DataUnits GetByteDisplayUnits(int64 bytes) { return DataUnits(unit_index); } -string16 FormatBytesWithUnits(int64 bytes, DataUnits units, bool show_units) { +base::string16 FormatBytesWithUnits(int64 bytes, + DataUnits units, + bool show_units) { return FormatBytesInternal(bytes, units, show_units, kByteStrings); } -string16 FormatSpeedWithUnits(int64 bytes, DataUnits units, bool show_units) { +base::string16 FormatSpeedWithUnits(int64 bytes, + DataUnits units, + bool show_units) { return FormatBytesInternal(bytes, units, show_units, kSpeedStrings); } -string16 FormatBytes(int64 bytes) { +base::string16 FormatBytes(int64 bytes) { return FormatBytesWithUnits(bytes, GetByteDisplayUnits(bytes), true); } -string16 FormatSpeed(int64 bytes) { +base::string16 FormatSpeed(int64 bytes) { return FormatSpeedWithUnits(bytes, GetByteDisplayUnits(bytes), true); } diff --git a/ui/base/text/bytes_formatting.h b/ui/base/text/bytes_formatting.h index 2b0f517..0e81818 100644 --- a/ui/base/text/bytes_formatting.h +++ b/ui/base/text/bytes_formatting.h @@ -16,12 +16,12 @@ namespace ui { // Simple call to return a byte quantity as a string in human-readable format. // Ex: FormatBytes(512) => "512 B" // Ex: FormatBytes(101479) => "99.1 kB" -UI_EXPORT string16 FormatBytes(int64 bytes); +UI_EXPORT base::string16 FormatBytes(int64 bytes); // Simple call to return a speed as a string in human-readable format. // Ex: FormatSpeed(512) => "512 B/s" // Ex: FormatSpeed(101479) => "99.1 kB/s" -UI_EXPORT string16 FormatSpeed(int64 bytes); +UI_EXPORT base::string16 FormatSpeed(int64 bytes); // Less-Simple API ------------------------------------------------------------- @@ -43,13 +43,16 @@ UI_EXPORT DataUnits GetByteDisplayUnits(int64 bytes); // unit suffix. Specify in the |units| argument the units to be used. // Ex: FormatBytes(512, DATA_UNITS_KIBIBYTE, true) => "0.5 kB" // Ex: FormatBytes(10*1024, DATA_UNITS_MEBIBYTE, false) => "0.1" -UI_EXPORT string16 FormatBytesWithUnits(int64 bytes, DataUnits units, - bool show_units); +UI_EXPORT base::string16 FormatBytesWithUnits(int64 bytes, + DataUnits units, + bool show_units); // As above, but with "/s" units for speed values. // Ex: FormatSpeed(512, DATA_UNITS_KIBIBYTE, true) => "0.5 kB/s" // Ex: FormatSpeed(10*1024, DATA_UNITS_MEBIBYTE, false) => "0.1" -string16 FormatSpeedWithUnits(int64 bytes, DataUnits units, bool show_units); +base::string16 FormatSpeedWithUnits(int64 bytes, + DataUnits units, + bool show_units); } // namespace ui diff --git a/ui/events/keycodes/keyboard_code_conversion_x.cc b/ui/events/keycodes/keyboard_code_conversion_x.cc index 7485494..60714f2 100644 --- a/ui/events/keycodes/keyboard_code_conversion_x.cc +++ b/ui/events/keycodes/keyboard_code_conversion_x.cc @@ -448,7 +448,7 @@ uint16 GetCharacterFromXEvent(XEvent* xev) { int bytes_written = XLookupString(&xev->xkey, buf, 6, NULL, NULL); DCHECK_LE(bytes_written, 6); - string16 result; + base::string16 result; return (bytes_written > 0 && UTF8ToUTF16(buf, bytes_written, &result) && result.length() == 1) ? result[0] : 0; } diff --git a/ui/gfx/pango_util.cc b/ui/gfx/pango_util.cc index c6f0b62..1f8ac26 100644 --- a/ui/gfx/pango_util.cc +++ b/ui/gfx/pango_util.cc @@ -226,7 +226,8 @@ static void SetupPangoLayoutWithoutFont( if (flags & Canvas::HIDE_PREFIX) { DCHECK_EQ(1, g_unichar_to_utf8(kAcceleratorChar, NULL)); base::string16 accelerator_removed = - RemoveAcceleratorChar(text, static_cast<char16>(kAcceleratorChar), + RemoveAcceleratorChar(text, + static_cast<base::char16>(kAcceleratorChar), NULL, NULL); utf8 = UTF16ToUTF8(accelerator_removed); } else { diff --git a/ui/gfx/render_text.cc b/ui/gfx/render_text.cc index 8061e34..e8e3436 100644 --- a/ui/gfx/render_text.cc +++ b/ui/gfx/render_text.cc @@ -28,7 +28,7 @@ namespace { // All chars are replaced by this char when the password style is set. // TODO(benrg): GTK uses the first of U+25CF, U+2022, U+2731, U+273A, '*' // that's available in the font (find_invisible_char() in gtkentry.c). -const char16 kPasswordReplacementChar = '*'; +const base::char16 kPasswordReplacementChar = '*'; // Default color used for the text and cursor. const SkColor kDefaultColor = SK_ColorBLACK; @@ -879,7 +879,7 @@ const BreakList<size_t>& RenderText::GetLineBreaks() { if (line_breaks_.max() != 0) return line_breaks_; - const string16& layout_text = GetLayoutText(); + const base::string16& layout_text = GetLayoutText(); const size_t text_length = layout_text.length(); line_breaks_.SetValue(0); line_breaks_.SetMax(text_length); diff --git a/ui/gfx/text_elider.cc b/ui/gfx/text_elider.cc index 8396b0f..5b94696 100644 --- a/ui/gfx/text_elider.cc +++ b/ui/gfx/text_elider.cc @@ -34,16 +34,16 @@ namespace gfx { // U+2026 in utf8 const char kEllipsis[] = "\xE2\x80\xA6"; -const char16 kEllipsisUTF16[] = { 0x2026, 0 }; -const char16 kForwardSlash = '/'; +const base::char16 kEllipsisUTF16[] = { 0x2026, 0 }; +const base::char16 kForwardSlash = '/'; namespace { // Helper class to split + elide text, while respecting UTF16 surrogate pairs. class StringSlicer { public: - StringSlicer(const string16& text, - const string16& ellipsis, + StringSlicer(const base::string16& text, + const base::string16& ellipsis, bool elide_in_middle) : text_(text), ellipsis_(ellipsis), @@ -55,8 +55,9 @@ class StringSlicer { // beginning and end of the string; otherwise, the end of the string is // removed and only the beginning remains. If |insert_ellipsis| is true, // then an ellipsis character will be inserted at the cut point. - string16 CutString(size_t length, bool insert_ellipsis) { - const string16 ellipsis_text = insert_ellipsis ? ellipsis_ : string16(); + base::string16 CutString(size_t length, bool insert_ellipsis) { + const base::string16 ellipsis_text = insert_ellipsis ? ellipsis_ + : base::string16(); if (!elide_in_middle_) return text_.substr(0, FindValidBoundaryBefore(length)) + ellipsis_text; @@ -90,10 +91,10 @@ class StringSlicer { } // The text to be sliced. - const string16& text_; + const base::string16& text_; // Ellipsis string to use. - const string16& ellipsis_; + const base::string16& ellipsis_; // If true, the middle of the string will be elided. bool elide_in_middle_; @@ -103,12 +104,13 @@ class StringSlicer { // Build a path from the first |num_components| elements in |path_elements|. // Prepends |path_prefix|, appends |filename|, inserts ellipsis if appropriate. -string16 BuildPathFromComponents(const string16& path_prefix, - const std::vector<string16>& path_elements, - const string16& filename, - size_t num_components) { +base::string16 BuildPathFromComponents( + const base::string16& path_prefix, + const std::vector<base::string16>& path_elements, + const base::string16& filename, + size_t num_components) { // Add the initial elements of the path. - string16 path = path_prefix; + base::string16 path = path_prefix; // Build path from first |num_components| elements. for (size_t j = 0; j < num_components; ++j) @@ -116,7 +118,7 @@ string16 BuildPathFromComponents(const string16& path_prefix, // Add |filename|, ellipsis if necessary. if (num_components != (path_elements.size() - 1)) - path += string16(kEllipsisUTF16) + kForwardSlash; + path += base::string16(kEllipsisUTF16) + kForwardSlash; path += filename; return path; @@ -125,31 +127,32 @@ string16 BuildPathFromComponents(const string16& path_prefix, // Takes a prefix (Domain, or Domain+subdomain) and a collection of path // components and elides if possible. Returns a string containing the longest // possible elided path, or an empty string if elision is not possible. -string16 ElideComponentizedPath(const string16& url_path_prefix, - const std::vector<string16>& url_path_elements, - const string16& url_filename, - const string16& url_query, - const FontList& font_list, - float available_pixel_width) { +base::string16 ElideComponentizedPath( + const base::string16& url_path_prefix, + const std::vector<base::string16>& url_path_elements, + const base::string16& url_filename, + const base::string16& url_query, + const FontList& font_list, + float available_pixel_width) { const size_t url_path_number_of_elements = url_path_elements.size(); CHECK(url_path_number_of_elements); for (size_t i = url_path_number_of_elements - 1; i > 0; --i) { - string16 elided_path = BuildPathFromComponents(url_path_prefix, + base::string16 elided_path = BuildPathFromComponents(url_path_prefix, url_path_elements, url_filename, i); if (available_pixel_width >= GetStringWidthF(elided_path, font_list)) return ElideText(elided_path + url_query, font_list, available_pixel_width, ELIDE_AT_END); } - return string16(); + return base::string16(); } } // namespace -string16 ElideEmail(const string16& email, - const FontList& font_list, - float available_pixel_width) { +base::string16 ElideEmail(const base::string16& email, + const FontList& font_list, + float available_pixel_width) { if (GetStringWidthF(email, font_list) <= available_pixel_width) return email; @@ -159,14 +162,14 @@ string16 ElideEmail(const string16& email, // symbol in the domain part of the email however so splitting at the last @ // symbol is safe. const size_t split_index = email.find_last_of('@'); - DCHECK_NE(split_index, string16::npos); - string16 username = email.substr(0, split_index); - string16 domain = email.substr(split_index + 1); + DCHECK_NE(split_index, base::string16::npos); + base::string16 username = email.substr(0, split_index); + base::string16 domain = email.substr(split_index + 1); DCHECK(!username.empty()); DCHECK(!domain.empty()); // Subtract the @ symbol from the available width as it is mandatory. - const string16 kAtSignUTF16 = ASCIIToUTF16("@"); + const base::string16 kAtSignUTF16 = ASCIIToUTF16("@"); available_pixel_width -= GetStringWidthF(kAtSignUTF16, font_list); // Check whether eliding the domain is necessary: if eliding the username @@ -193,7 +196,7 @@ string16 ElideEmail(const string16& email, // Failing to elide the domain such that at least one character remains // (other than the ellipsis itself) remains: return a single ellipsis. if (domain.length() <= 1U) - return string16(kEllipsisUTF16); + return base::string16(kEllipsisUTF16); } // Fit the username in the remaining width (at this point the elided username @@ -210,13 +213,13 @@ string16 ElideEmail(const string16& email, // kerning/ligatures/etc. issues potentially wrong by assuming that the width of // a rendered string is always the sum of the widths of its substrings. Also I // suspect it could be made simpler. -string16 ElideUrl(const GURL& url, - const FontList& font_list, - float available_pixel_width, - const std::string& languages) { +base::string16 ElideUrl(const GURL& url, + const FontList& font_list, + float available_pixel_width, + const std::string& languages) { // Get a formatted string and corresponding parsing of the url. url_parse::Parsed parsed; - const string16 url_string = + const base::string16 url_string = net::FormatUrl(url, languages, net::kFormatUrlOmitAll, net::UnescapeRule::SPACES, &parsed, NULL, NULL); if (available_pixel_width <= 0) @@ -236,21 +239,21 @@ string16 ElideUrl(const GURL& url, // Get the path substring, including query and reference. const size_t path_start_index = parsed.path.begin; const size_t path_len = parsed.path.len; - string16 url_path_query_etc = url_string.substr(path_start_index); - string16 url_path = url_string.substr(path_start_index, path_len); + base::string16 url_path_query_etc = url_string.substr(path_start_index); + base::string16 url_path = url_string.substr(path_start_index, path_len); // Return general elided text if url minus the query fits. - const string16 url_minus_query = + const base::string16 url_minus_query = url_string.substr(0, path_start_index + path_len); if (available_pixel_width >= GetStringWidthF(url_minus_query, font_list)) return ElideText(url_string, font_list, available_pixel_width, ELIDE_AT_END); // Get Host. - string16 url_host = UTF8ToUTF16(url.host()); + base::string16 url_host = UTF8ToUTF16(url.host()); // Get domain and registry information from the URL. - string16 url_domain = UTF8ToUTF16( + base::string16 url_domain = UTF8ToUTF16( net::registry_controlled_domains::GetDomainAndRegistry( url, net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES)); if (url_domain.empty()) @@ -263,11 +266,11 @@ string16 ElideUrl(const GURL& url, } // Get sub domain. - string16 url_subdomain; + base::string16 url_subdomain; const size_t domain_start_index = url_host.find(url_domain); - if (domain_start_index != string16::npos) + if (domain_start_index != base::string16::npos) url_subdomain = url_host.substr(0, domain_start_index); - const string16 kWwwPrefix = UTF8ToUTF16("www."); + const base::string16 kWwwPrefix = UTF8ToUTF16("www."); if ((url_subdomain == kWwwPrefix || url_subdomain.empty() || url.SchemeIsFile())) { url_subdomain.clear(); @@ -278,14 +281,14 @@ string16 ElideUrl(const GURL& url, // domain is now C: - this is a nice hack for eliding to work pleasantly. if (url.SchemeIsFile()) { // Split the path string using ":" - std::vector<string16> file_path_split; + std::vector<base::string16> file_path_split; base::SplitString(url_path, ':', &file_path_split); if (file_path_split.size() > 1) { // File is of type "file:///C:/.." url_host.clear(); url_domain.clear(); url_subdomain.clear(); - const string16 kColon = UTF8ToUTF16(":"); + const base::string16 kColon = UTF8ToUTF16(":"); url_host = url_domain = file_path_split.at(0).substr(1) + kColon; url_path_query_etc = url_path = file_path_split.at(1); } @@ -309,9 +312,9 @@ string16 ElideUrl(const GURL& url, return url_subdomain + url_domain + url_path_query_etc; // Query element. - string16 url_query; + base::string16 url_query; const float kPixelWidthDotsTrailer = GetStringWidthF( - string16(kEllipsisUTF16), font_list); + base::string16(kEllipsisUTF16), font_list); if (parsed.query.is_nonempty()) { url_query = UTF8ToUTF16("?") + url_string.substr(parsed.query.begin); if (available_pixel_width >= @@ -323,14 +326,14 @@ string16 ElideUrl(const GURL& url, } // Parse url_path using '/'. - std::vector<string16> url_path_elements; + std::vector<base::string16> url_path_elements; base::SplitString(url_path, kForwardSlash, &url_path_elements); // Get filename - note that for a path ending with / // such as www.google.com/intl/ads/, the file name is ads/. size_t url_path_number_of_elements = url_path_elements.size(); DCHECK(url_path_number_of_elements != 0); - string16 url_filename; + base::string16 url_filename; if ((url_path_elements.at(url_path_number_of_elements - 1)).length() > 0) { url_filename = *(url_path_elements.end() - 1); } else if (url_path_number_of_elements > 1) { // Path ends with a '/'. @@ -350,12 +353,13 @@ string16 ElideUrl(const GURL& url, } // Start eliding the path and replacing elements by ".../". - const string16 kEllipsisAndSlash = string16(kEllipsisUTF16) + kForwardSlash; + const base::string16 kEllipsisAndSlash = + base::string16(kEllipsisUTF16) + kForwardSlash; const float pixel_width_ellipsis_slash = GetStringWidthF(kEllipsisAndSlash, font_list); // Check with both subdomain and domain. - string16 elided_path = + base::string16 elided_path = ElideComponentizedPath(url_subdomain + url_domain, url_path_elements, url_filename, url_query, font_list, available_pixel_width); @@ -367,7 +371,7 @@ string16 ElideUrl(const GURL& url, // This is added only if the subdomain pixel width is larger than // the pixel width of kEllipsis. Otherwise, subdomain remains, // which means that this case has been resolved earlier. - string16 url_elided_domain = url_subdomain + url_domain; + base::string16 url_elided_domain = url_subdomain + url_domain; if (pixel_width_url_subdomain > kPixelWidthDotsTrailer) { if (!url_subdomain.empty()) url_elided_domain = kEllipsisAndSlash[0] + url_domain; @@ -383,7 +387,7 @@ string16 ElideUrl(const GURL& url, } // Return elided domain/.../filename anyway. - string16 final_elided_url_string(url_elided_domain); + base::string16 final_elided_url_string(url_elided_domain); const float url_elided_domain_width = GetStringWidthF(url_elided_domain, font_list); @@ -391,7 +395,7 @@ string16 ElideUrl(const GURL& url, if ((available_pixel_width - url_elided_domain_width) > pixel_width_ellipsis_slash + kPixelWidthDotsTrailer + GetStringWidthF(ASCIIToUTF16("UV"), font_list)) { - final_elided_url_string += BuildPathFromComponents(string16(), + final_elided_url_string += BuildPathFromComponents(base::string16(), url_path_elements, url_filename, 1); } else { final_elided_url_string += url_path; @@ -401,19 +405,19 @@ string16 ElideUrl(const GURL& url, ELIDE_AT_END); } -string16 ElideFilename(const base::FilePath& filename, - const FontList& font_list, - float available_pixel_width) { +base::string16 ElideFilename(const base::FilePath& filename, + const FontList& font_list, + float available_pixel_width) { #if defined(OS_WIN) - string16 filename_utf16 = filename.value(); - string16 extension = filename.Extension(); - string16 rootname = filename.BaseName().RemoveExtension().value(); + base::string16 filename_utf16 = filename.value(); + base::string16 extension = filename.Extension(); + base::string16 rootname = filename.BaseName().RemoveExtension().value(); #elif defined(OS_POSIX) - string16 filename_utf16 = WideToUTF16(base::SysNativeMBToWide( + base::string16 filename_utf16 = WideToUTF16(base::SysNativeMBToWide( filename.value())); - string16 extension = WideToUTF16(base::SysNativeMBToWide( + base::string16 extension = WideToUTF16(base::SysNativeMBToWide( filename.Extension())); - string16 rootname = WideToUTF16(base::SysNativeMBToWide( + base::string16 rootname = WideToUTF16(base::SysNativeMBToWide( filename.BaseName().RemoveExtension().value())); #endif @@ -422,7 +426,7 @@ string16 ElideFilename(const base::FilePath& filename, return base::i18n::GetDisplayStringInLTRDirectionality(filename_utf16); if (rootname.empty() || extension.empty()) { - const string16 elided_name = ElideText(filename_utf16, font_list, + const base::string16 elided_name = ElideText(filename_utf16, font_list, available_pixel_width, ELIDE_AT_END); return base::i18n::GetDisplayStringInLTRDirectionality(elided_name); } @@ -432,28 +436,28 @@ string16 ElideFilename(const base::FilePath& filename, // We may have trimmed the path. if (root_width + ext_width <= available_pixel_width) { - const string16 elided_name = rootname + extension; + const base::string16 elided_name = rootname + extension; return base::i18n::GetDisplayStringInLTRDirectionality(elided_name); } if (ext_width >= available_pixel_width) { - const string16 elided_name = ElideText(rootname + extension, font_list, - available_pixel_width, - ELIDE_IN_MIDDLE); + const base::string16 elided_name = ElideText( + rootname + extension, font_list, available_pixel_width, + ELIDE_IN_MIDDLE); return base::i18n::GetDisplayStringInLTRDirectionality(elided_name); } float available_root_width = available_pixel_width - ext_width; - string16 elided_name = + base::string16 elided_name = ElideText(rootname, font_list, available_root_width, ELIDE_AT_END); elided_name += extension; return base::i18n::GetDisplayStringInLTRDirectionality(elided_name); } -string16 ElideText(const string16& text, - const FontList& font_list, - float available_pixel_width, - ElideBehavior elide_behavior) { +base::string16 ElideText(const base::string16& text, + const FontList& font_list, + float available_pixel_width, + ElideBehavior elide_behavior) { if (text.empty()) return text; @@ -461,7 +465,7 @@ string16 ElideText(const string16& text, const bool elide_in_middle = (elide_behavior == ELIDE_IN_MIDDLE); const bool insert_ellipsis = (elide_behavior != TRUNCATE_AT_END); - const string16 ellipsis = string16(kEllipsisUTF16); + const base::string16 ellipsis = base::string16(kEllipsisUTF16); StringSlicer slicer(text, ellipsis, elide_in_middle); // Pango will return 0 width for absurdly long strings. Cut the string in @@ -473,7 +477,7 @@ string16 ElideText(const string16& text, // (eliding way too much from a ridiculous string is probably still // ridiculous), but we should check other widths for bogus values as well. if (current_text_pixel_width <= 0 && !text.empty()) { - const string16 cut = slicer.CutString(text.length() / 2, false); + const base::string16 cut = slicer.CutString(text.length() / 2, false); return ElideText(cut, font_list, available_pixel_width, elide_behavior); } @@ -482,7 +486,7 @@ string16 ElideText(const string16& text, if (insert_ellipsis && GetStringWidthF(ellipsis, font_list) > available_pixel_width) - return string16(); + return base::string16(); // Use binary search to compute the elided text. size_t lo = 0; @@ -491,7 +495,7 @@ string16 ElideText(const string16& text, for (guess = (lo + hi) / 2; lo <= hi; guess = (lo + hi) / 2) { // We check the length of the whole desired string at once to ensure we // handle kerning/ligatures/etc. correctly. - const string16 cut = slicer.CutString(guess, insert_ellipsis); + const base::string16 cut = slicer.CutString(guess, insert_ellipsis); const float guess_length = GetStringWidthF(cut, font_list); // Check again that we didn't hit a Pango width overflow. If so, cut the // current string in half and start over. @@ -508,17 +512,17 @@ string16 ElideText(const string16& text, return slicer.CutString(guess, insert_ellipsis); } -string16 ElideText(const string16& text, - const Font& font, - float available_pixel_width, - ElideBehavior elide_behavior) { +base::string16 ElideText(const base::string16& text, + const Font& font, + float available_pixel_width, + ElideBehavior elide_behavior) { return ElideText(text, FontList(font), available_pixel_width, elide_behavior); } SortedDisplayURL::SortedDisplayURL(const GURL& url, const std::string& languages) { net::AppendFormattedHost(url, languages, &sort_host_); - string16 host_minus_www = net::StripWWW(sort_host_); + base::string16 host_minus_www = net::StripWWW(sort_host_); url_parse::Parsed parsed; display_url_ = net::FormatUrl(url, languages, net::kFormatUrlOmitAll, @@ -550,8 +554,8 @@ int SortedDisplayURL::Compare(const SortedDisplayURL& other, return host_compare_result; // Hosts match, compare on the portion of the url after the host. - string16 path = this->AfterHost(); - string16 o_path = other.AfterHost(); + base::string16 path = this->AfterHost(); + base::string16 o_path = other.AfterHost(); compare_status = U_ZERO_ERROR; UCollationResult path_compare_result = collator->compare( static_cast<const UChar*>(path.c_str()), @@ -576,16 +580,17 @@ int SortedDisplayURL::Compare(const SortedDisplayURL& other, return display_url_compare_result; } -string16 SortedDisplayURL::AfterHost() const { +base::string16 SortedDisplayURL::AfterHost() const { const size_t slash_index = display_url_.find(sort_host_, prefix_end_); - if (slash_index == string16::npos) { + if (slash_index == base::string16::npos) { NOTREACHED(); - return string16(); + return base::string16(); } return display_url_.substr(slash_index + sort_host_.length()); } -bool ElideString(const string16& input, int max_len, string16* output) { +bool ElideString(const base::string16& input, int max_len, + base::string16* output) { DCHECK_GE(max_len, 0); if (static_cast<int>(input.length()) <= max_len) { output->assign(input); @@ -630,7 +635,7 @@ namespace { class RectangleString { public: RectangleString(size_t max_rows, size_t max_cols, - bool strict, string16 *output) + bool strict, base::string16 *output) : max_rows_(max_rows), max_cols_(max_cols), current_row_(0), @@ -647,7 +652,7 @@ class RectangleString { // AddString() may be called multiple times to concatenate together // multiple strings into the region (the current caller doesn't do // this, however). - void AddString(const string16& input); + void AddString(const base::string16& input); // Perform any deferred output processing. Must be called after the // last AddString() call has occurred. @@ -656,15 +661,15 @@ class RectangleString { private: // Add a line to the rectangular region at the current position, // either by itself or by breaking it into words. - void AddLine(const string16& line); + void AddLine(const base::string16& line); // Add a word to the rectangular region at the current position, // either by itself or by breaking it into characters. - void AddWord(const string16& word); + void AddWord(const base::string16& word); // Add text to the output string if the rectangular boundaries // have not been exceeded, advancing the current position. - void Append(const string16& string); + void Append(const base::string16& string); // Set the current position to the beginning of the next line. If // |output| is true, add a newline to the output string if the rectangular @@ -696,12 +701,12 @@ class RectangleString { bool suppressed_; // String onto which the output is accumulated. - string16* output_; + base::string16* output_; DISALLOW_COPY_AND_ASSIGN(RectangleString); }; -void RectangleString::AddString(const string16& input) { +void RectangleString::AddString(const base::string16& input) { base::i18n::BreakIterator lines(input, base::i18n::BreakIterator::BREAK_NEWLINE); if (lines.Init()) { @@ -720,7 +725,7 @@ bool RectangleString::Finalize() { return false; } -void RectangleString::AddLine(const string16& line) { +void RectangleString::AddLine(const base::string16& line) { if (line.length() < max_cols_) { Append(line); } else { @@ -738,7 +743,7 @@ void RectangleString::AddLine(const string16& line) { current_col_ = 0; } -void RectangleString::AddWord(const string16& word) { +void RectangleString::AddWord(const base::string16& word) { if (word.length() < max_cols_) { // Word can be made to fit, no need to fragment it. if (current_col_ + word.length() >= max_cols_) @@ -765,7 +770,7 @@ void RectangleString::AddWord(const string16& word) { } } -void RectangleString::Append(const string16& string) { +void RectangleString::Append(const base::string16& string) { if (current_row_ < max_rows_) output_->append(string); else @@ -793,7 +798,7 @@ class RectangleText { float available_pixel_width, int available_pixel_height, WordWrapBehavior wrap_behavior, - std::vector<string16>* lines) + std::vector<base::string16>* lines) : font_list_(font_list), line_height_(font_list.GetHeight()), available_pixel_width_(available_pixel_width), @@ -814,7 +819,7 @@ class RectangleText { // AddString() may be called multiple times to concatenate together // multiple strings into the region (the current caller doesn't do // this, however). - void AddString(const string16& input); + void AddString(const base::string16& input); // Perform any deferred output processing. Must be called after the last // AddString() call has occured. Returns a combination of @@ -825,24 +830,24 @@ class RectangleText { private: // Add a line to the rectangular region at the current position, // either by itself or by breaking it into words. - void AddLine(const string16& line); + void AddLine(const base::string16& line); // Wrap the specified word across multiple lines. - int WrapWord(const string16& word); + int WrapWord(const base::string16& word); // Add a long word - wrapping, eliding or truncating per the wrap behavior. - int AddWordOverflow(const string16& word); + int AddWordOverflow(const base::string16& word); // Add a word to the rectangluar region at the current position. - int AddWord(const string16& word); + int AddWord(const base::string16& word); // Append the specified |text| to the current output line, incrementing the // running width by the specified amount. This is an optimization over // |AddToCurrentLine()| when |text_width| is already known. - void AddToCurrentLineWithWidth(const string16& text, float text_width); + void AddToCurrentLineWithWidth(const base::string16& text, float text_width); // Append the specified |text| to the current output line. - void AddToCurrentLine(const string16& text); + void AddToCurrentLine(const base::string16& text); // Set the current position to the beginning of the next line. bool NewLine(); @@ -869,13 +874,13 @@ class RectangleText { int current_height_; // The current line of text. - string16 current_line_; + base::string16 current_line_; // Indicates whether the last line ended with \n. bool last_line_ended_in_lf_; // The output vector of lines. - std::vector<string16>* lines_; + std::vector<base::string16>* lines_; // Indicates whether a word was so long that it had to be truncated or elided // to fit the available width. @@ -887,12 +892,12 @@ class RectangleText { DISALLOW_COPY_AND_ASSIGN(RectangleText); }; -void RectangleText::AddString(const string16& input) { +void RectangleText::AddString(const base::string16& input) { base::i18n::BreakIterator lines(input, base::i18n::BreakIterator::BREAK_NEWLINE); if (lines.Init()) { while (!insufficient_height_ && lines.Advance()) { - string16 line = lines.GetString(); + base::string16 line = lines.GetString(); // The BREAK_NEWLINE iterator will keep the trailing newline character, // except in the case of the last line, which may not have one. Remove // the newline character, if it exists. @@ -915,12 +920,12 @@ int RectangleText::Finalize() { lines_->pop_back(); } if (last_line_ended_in_lf_) - lines_->push_back(string16()); + lines_->push_back(base::string16()); return (insufficient_width_ ? INSUFFICIENT_SPACE_HORIZONTAL : 0) | (insufficient_height_ ? INSUFFICIENT_SPACE_VERTICAL : 0); } -void RectangleText::AddLine(const string16& line) { +void RectangleText::AddLine(const base::string16& line) { const float line_width = GetStringWidthF(line, font_list_); if (line_width <= available_pixel_width_) { AddToCurrentLineWithWidth(line, line_width); @@ -932,7 +937,7 @@ void RectangleText::AddLine(const string16& line) { if (words.Init()) { while (words.Advance()) { const bool truncate = !current_line_.empty(); - const string16& word = words.GetString(); + const base::string16& word = words.GetString(); const int lines_added = AddWord(word); if (lines_added) { if (truncate) { @@ -955,13 +960,13 @@ void RectangleText::AddLine(const string16& line) { NewLine(); } -int RectangleText::WrapWord(const string16& word) { +int RectangleText::WrapWord(const base::string16& word) { // Word is so wide that it must be fragmented. - string16 text = word; + base::string16 text = word; int lines_added = 0; bool first_fragment = true; while (!insufficient_height_ && !text.empty()) { - string16 fragment = + base::string16 fragment = ElideText(text, font_list_, available_pixel_width_, TRUNCATE_AT_END); // At least one character has to be added at every line, even if the @@ -977,7 +982,7 @@ int RectangleText::WrapWord(const string16& word) { return lines_added; } -int RectangleText::AddWordOverflow(const string16& word) { +int RectangleText::AddWordOverflow(const base::string16& word) { int lines_added = 0; // Unless this is the very first word, put it on a new line. @@ -995,7 +1000,7 @@ int RectangleText::AddWordOverflow(const string16& word) { } else { const ElideBehavior elide_behavior = (wrap_behavior_ == ELIDE_LONG_WORDS ? ELIDE_AT_END : TRUNCATE_AT_END); - const string16 elided_word = + const base::string16 elided_word = ElideText(word, font_list_, available_pixel_width_, elide_behavior); AddToCurrentLine(elided_word); insufficient_width_ = true; @@ -1004,9 +1009,9 @@ int RectangleText::AddWordOverflow(const string16& word) { return lines_added; } -int RectangleText::AddWord(const string16& word) { +int RectangleText::AddWord(const base::string16& word) { int lines_added = 0; - string16 trimmed; + base::string16 trimmed; TrimWhitespace(word, TRIM_TRAILING, &trimmed); const float trimmed_width = GetStringWidthF(trimmed, font_list_); if (trimmed_width <= available_pixel_width_) { @@ -1022,11 +1027,11 @@ int RectangleText::AddWord(const string16& word) { return lines_added; } -void RectangleText::AddToCurrentLine(const string16& text) { +void RectangleText::AddToCurrentLine(const base::string16& text) { AddToCurrentLineWithWidth(text, GetStringWidthF(text, font_list_)); } -void RectangleText::AddToCurrentLineWithWidth(const string16& text, +void RectangleText::AddToCurrentLineWithWidth(const base::string16& text, float text_width) { if (current_height_ >= available_pixel_height_) { insufficient_height_ = true; @@ -1052,20 +1057,21 @@ bool RectangleText::NewLine() { } // namespace -bool ElideRectangleString(const string16& input, size_t max_rows, - size_t max_cols, bool strict, string16* output) { +bool ElideRectangleString(const base::string16& input, size_t max_rows, + size_t max_cols, bool strict, + base::string16* output) { RectangleString rect(max_rows, max_cols, strict, output); rect.Init(); rect.AddString(input); return rect.Finalize(); } -int ElideRectangleText(const string16& input, +int ElideRectangleText(const base::string16& input, const FontList& font_list, float available_pixel_width, int available_pixel_height, WordWrapBehavior wrap_behavior, - std::vector<string16>* lines) { + std::vector<base::string16>* lines) { RectangleText rect(font_list, available_pixel_width, available_pixel_height, @@ -1076,19 +1082,19 @@ int ElideRectangleText(const string16& input, return rect.Finalize(); } -string16 TruncateString(const string16& string, size_t length) { +base::string16 TruncateString(const base::string16& string, size_t length) { if (string.size() <= length) // String fits, return it. return string; if (length == 0) // No room for the elide string, return an empty string. - return string16(); + return base::string16(); size_t max = length - 1; // Added to the end of strings that are too big. - static const char16 kElideString[] = { 0x2026, 0 }; + static const base::char16 kElideString[] = { 0x2026, 0 }; if (max == 0) // Just enough room for the elide string. diff --git a/ui/gfx/text_elider.h b/ui/gfx/text_elider.h index 95bdeb44..4eaca82 100644 --- a/ui/gfx/text_elider.h +++ b/ui/gfx/text_elider.h @@ -27,7 +27,7 @@ class Font; class FontList; GFX_EXPORT extern const char kEllipsis[]; -GFX_EXPORT extern const char16 kEllipsisUTF16[]; +GFX_EXPORT extern const base::char16 kEllipsisUTF16[]; // Elides a well-formed email address (e.g. username@domain.com) to fit into // |available_pixel_width| using the specified |font_list|. @@ -39,9 +39,9 @@ GFX_EXPORT extern const char16 kEllipsisUTF16[]; // equally with the elided username (should the username be short enough that it // doesn't need half the available width: the elided domain will occupy that // extra width). -GFX_EXPORT string16 ElideEmail(const string16& email, - const gfx::FontList& font_list, - float available_pixel_width); +GFX_EXPORT base::string16 ElideEmail(const base::string16& email, + const gfx::FontList& font_list, + float available_pixel_width); // This function takes a GURL object and elides it. It returns a string // which composed of parts from subdomain, domain, path, filename and query. @@ -57,10 +57,10 @@ GFX_EXPORT string16 ElideEmail(const string16& email, // as an LTR string (using base::i18n::WrapStringWithLTRFormatting()) so that it // is displayed properly in an RTL context. Please refer to // http://crbug.com/6487 for more information. -GFX_EXPORT string16 ElideUrl(const GURL& url, - const gfx::FontList& font_list, - float available_pixel_width, - const std::string& languages); +GFX_EXPORT base::string16 ElideUrl(const GURL& url, + const gfx::FontList& font_list, + float available_pixel_width, + const std::string& languages); enum ElideBehavior { // Add ellipsis at the end of the string. @@ -73,15 +73,15 @@ enum ElideBehavior { // Elides |text| to fit in |available_pixel_width| according to the specified // |elide_behavior|. -GFX_EXPORT string16 ElideText(const string16& text, - const gfx::FontList& font_list, - float available_pixel_width, - ElideBehavior elide_behavior); +GFX_EXPORT base::string16 ElideText(const base::string16& text, + const gfx::FontList& font_list, + float available_pixel_width, + ElideBehavior elide_behavior); // Obsolete version. Use the above version which takes gfx::FontList. -GFX_EXPORT string16 ElideText(const string16& text, - const gfx::Font& font, - float available_pixel_width, - ElideBehavior elide_behavior); +GFX_EXPORT base::string16 ElideText(const base::string16& text, + const gfx::Font& font, + float available_pixel_width, + ElideBehavior elide_behavior); // Elide a filename to fit a given pixel width, with an emphasis on not hiding // the extension unless we have to. If filename contains a path, the path will @@ -89,9 +89,9 @@ GFX_EXPORT string16 ElideText(const string16& text, // filename is forced to have LTR directionality, which means that in RTL UI // the elided filename is wrapped with LRE (Left-To-Right Embedding) mark and // PDF (Pop Directional Formatting) mark. -GFX_EXPORT string16 ElideFilename(const base::FilePath& filename, - const gfx::FontList& font_list, - float available_pixel_width); +GFX_EXPORT base::string16 ElideFilename(const base::FilePath& filename, + const gfx::FontList& font_list, + float available_pixel_width); // SortedDisplayURL maintains a string from a URL suitable for display to the // use. SortedDisplayURL also provides a function used for comparing two @@ -110,20 +110,20 @@ class GFX_EXPORT SortedDisplayURL { int Compare(const SortedDisplayURL& other, icu::Collator* collator) const; // Returns the display string for the URL. - const string16& display_url() const { return display_url_; } + const base::string16& display_url() const { return display_url_; } private: // Returns everything after the host. This is used by Compare if the hosts // match. - string16 AfterHost() const; + base::string16 AfterHost() const; // Host name minus 'www.'. Used by Compare. - string16 sort_host_; + base::string16 sort_host_; // End of the prefix (spec and separator) in display_url_. size_t prefix_end_; - string16 display_url_; + base::string16 display_url_; DISALLOW_COPY_AND_ASSIGN(SortedDisplayURL); }; @@ -141,8 +141,8 @@ class GFX_EXPORT SortedDisplayURL { // puts "Hell...Tom" in str and returns true. // TODO(tsepez): Doesn't handle UTF-16 surrogate pairs properly. // TODO(tsepez): Doesn't handle bidi properly. -GFX_EXPORT bool ElideString(const string16& input, int max_len, - string16* output); +GFX_EXPORT bool ElideString(const base::string16& input, int max_len, + base::string16* output); // Reformat |input| into |output| so that it fits into a |max_rows| by // |max_cols| rectangle of characters. Input newlines are respected, but @@ -153,9 +153,11 @@ GFX_EXPORT bool ElideString(const string16& input, int max_len, // intra-word (respecting UTF-16 surrogate pairs) as necssary. Truncation // (indicated by an added 3 dots) occurs if the result is still too long. // Returns true if the input had to be truncated (and not just reformatted). -GFX_EXPORT bool ElideRectangleString(const string16& input, size_t max_rows, - size_t max_cols, bool strict, - string16* output); +GFX_EXPORT bool ElideRectangleString(const base::string16& input, + size_t max_rows, + size_t max_cols, + bool strict, + base::string16* output); // Specifies the word wrapping behavior of |ElideRectangleText()| when a word // would exceed the available width. @@ -193,19 +195,20 @@ enum ReformattingResultFlags { // param. Returns a combination of |ReformattingResultFlags| that indicate // whether the given rectangle had insufficient space to accommodate |texŧ|, // leading to elision or truncation (and not just reformatting). -GFX_EXPORT int ElideRectangleText(const string16& text, +GFX_EXPORT int ElideRectangleText(const base::string16& text, const gfx::FontList& font_list, float available_pixel_width, int available_pixel_height, WordWrapBehavior wrap_behavior, - std::vector<string16>* lines); + std::vector<base::string16>* lines); // Truncates the string to length characters. This breaks the string at // the first word break before length, adding the horizontal ellipsis // character (unicode character 0x2026) to render ... // The supplied string is returned if the string has length characters or // less. -GFX_EXPORT string16 TruncateString(const string16& string, size_t length); +GFX_EXPORT base::string16 TruncateString(const base::string16& string, + size_t length); } // namespace gfx diff --git a/ui/gfx/utf16_indexing.cc b/ui/gfx/utf16_indexing.cc index 6af10c1..c7f38de 100644 --- a/ui/gfx/utf16_indexing.cc +++ b/ui/gfx/utf16_indexing.cc @@ -9,12 +9,12 @@ namespace gfx { -bool IsValidCodePointIndex(const string16& s, size_t index) { +bool IsValidCodePointIndex(const base::string16& s, size_t index) { return index == 0 || index == s.length() || !(CBU16_IS_TRAIL(s[index]) && CBU16_IS_LEAD(s[index - 1])); } -ptrdiff_t UTF16IndexToOffset(const string16& s, size_t base, size_t pos) { +ptrdiff_t UTF16IndexToOffset(const base::string16& s, size_t base, size_t pos) { // The indices point between UTF-16 words (range 0 to s.length() inclusive). // In order to consistently handle indices that point to the middle of a // surrogate pair, we count the first word in that surrogate pair and not @@ -30,7 +30,9 @@ ptrdiff_t UTF16IndexToOffset(const string16& s, size_t base, size_t pos) { return delta; } -size_t UTF16OffsetToIndex(const string16& s, size_t base, ptrdiff_t offset) { +size_t UTF16OffsetToIndex(const base::string16& s, + size_t base, + ptrdiff_t offset) { DCHECK_LE(base, s.length()); // As in UTF16IndexToOffset, we count the first half of a surrogate pair, not // the second. When stepping from pos to pos+1 we check s[pos:pos+1] == s[pos] diff --git a/ui/gfx/utf16_indexing.h b/ui/gfx/utf16_indexing.h index a9eaea2..4c2b2c1 100644 --- a/ui/gfx/utf16_indexing.h +++ b/ui/gfx/utf16_indexing.h @@ -12,7 +12,7 @@ namespace gfx { // Returns false if s[index-1] is a high surrogate and s[index] is a low // surrogate, true otherwise. -GFX_EXPORT bool IsValidCodePointIndex(const string16& s, size_t index); +GFX_EXPORT bool IsValidCodePointIndex(const base::string16& s, size_t index); // |UTF16IndexToOffset| returns the number of code points between |base| and // |pos| in the given string. |UTF16OffsetToIndex| returns the index that is @@ -37,10 +37,10 @@ GFX_EXPORT bool IsValidCodePointIndex(const string16& s, size_t index); // Always, // UTF16IndexToOffset(s, base, UTF16OffsetToIndex(s, base, ofs)) == ofs // UTF16IndexToOffset(s, i, j) == -UTF16IndexToOffset(s, j, i) -GFX_EXPORT ptrdiff_t UTF16IndexToOffset(const string16& s, +GFX_EXPORT ptrdiff_t UTF16IndexToOffset(const base::string16& s, size_t base, size_t pos); -GFX_EXPORT size_t UTF16OffsetToIndex(const string16& s, +GFX_EXPORT size_t UTF16OffsetToIndex(const base::string16& s, size_t base, ptrdiff_t offset); |