summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-04 05:29:27 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-04 05:29:27 +0000
commit4c4d8d2b8aa8ae394d0f933700ddd9e682b141af (patch)
tree6e3e10e71c29bb9cc8d221d4de38d9dc603e32cd /base
parent39d74d8b3c05faf98935927b68eaebb9a23a76a4 (diff)
downloadchromium_src-4c4d8d2b8aa8ae394d0f933700ddd9e682b141af.zip
chromium_src-4c4d8d2b8aa8ae394d0f933700ddd9e682b141af.tar.gz
chromium_src-4c4d8d2b8aa8ae394d0f933700ddd9e682b141af.tar.bz2
Convert NavigationEntry title to string16. TabContents::GetTitle no longer needs
to be virtual, either. This also changes how the display URL is computed. Instead of doing it preemptively, we now do so lazily. This allows us to do the URL formatting correctly using the elider so that we can do IDN and unescaping. I changed string_util's singleton functions. I was worried that other code might make a singleton of string, which would give you this same value as a non-const string. This would mean our empty strings might no longer be empty. Review URL: http://codereview.chromium.org/39022 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10872 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/string_util.cc18
-rw-r--r--base/string_util.h1
2 files changed, 17 insertions, 2 deletions
diff --git a/base/string_util.cc b/base/string_util.cc
index a13f79f..8f9bcf9 100644
--- a/base/string_util.cc
+++ b/base/string_util.cc
@@ -27,6 +27,16 @@
namespace {
+// Force the singleton used by Empty[W]String[16] to be a unique type. This
+// prevents other code that might accidentally use Singleton<string> from
+// getting our internal one.
+struct EmptyStrings {
+ EmptyStrings() {}
+ const std::string s;
+ const std::wstring ws;
+ const string16 s16;
+};
+
// Hack to convert any char-like type to its unsigned counterpart.
// For example, it will convert char, signed char and unsigned char to unsigned
// char.
@@ -323,11 +333,15 @@ bool IsWprintfFormatPortable(const wchar_t* format) {
const std::string& EmptyString() {
- return *Singleton<std::string>::get();
+ return Singleton<EmptyStrings>::get()->s;
}
const std::wstring& EmptyWString() {
- return *Singleton<std::wstring>::get();
+ return Singleton<EmptyStrings>::get()->ws;
+}
+
+const string16& EmptyString16() {
+ return Singleton<EmptyStrings>::get()->s16;
}
const wchar_t kWhitespaceWide[] = {
diff --git a/base/string_util.h b/base/string_util.h
index 1247cd5..3f905fe 100644
--- a/base/string_util.h
+++ b/base/string_util.h
@@ -112,6 +112,7 @@ bool IsWprintfFormatPortable(const wchar_t* format);
// These functions are threadsafe.
const std::string& EmptyString();
const std::wstring& EmptyWString();
+const string16& EmptyString16();
extern const wchar_t kWhitespaceWide[];
extern const char kWhitespaceASCII[];