diff options
Diffstat (limited to 'ui/base')
-rw-r--r-- | ui/base/clipboard/clipboard.h | 16 | ||||
-rw-r--r-- | ui/base/clipboard/clipboard_gtk.cc | 16 | ||||
-rw-r--r-- | ui/base/clipboard/custom_data_helper.cc | 28 | ||||
-rw-r--r-- | ui/base/clipboard/custom_data_helper.h | 20 | ||||
-rw-r--r-- | ui/base/clipboard/scoped_clipboard_writer.cc | 13 | ||||
-rw-r--r-- | ui/base/clipboard/scoped_clipboard_writer.h | 13 | ||||
-rw-r--r-- | ui/base/ime/composition_text.h | 2 | ||||
-rw-r--r-- | ui/base/ime/text_input_client.h | 8 | ||||
-rw-r--r-- | ui/base/l10n/l10n_util.cc | 139 | ||||
-rw-r--r-- | ui/base/l10n/l10n_util.h | 108 | ||||
-rw-r--r-- | ui/base/l10n/l10n_util_collator.h | 21 | ||||
-rw-r--r-- | ui/base/l10n/time_format.cc | 22 | ||||
-rw-r--r-- | ui/base/l10n/time_format.h | 14 | ||||
-rw-r--r-- | ui/base/resource/resource_bundle.cc | 14 | ||||
-rw-r--r-- | ui/base/resource/resource_bundle.h | 4 | ||||
-rw-r--r-- | ui/base/text/bytes_formatting.cc | 24 | ||||
-rw-r--r-- | ui/base/text/bytes_formatting.h | 13 |
17 files changed, 248 insertions, 227 deletions
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 |