summaryrefslogtreecommitdiffstats
path: root/base/string_util.cc
diff options
context:
space:
mode:
authorstuartmorgan@google.com <stuartmorgan@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-04 19:12:37 +0000
committerstuartmorgan@google.com <stuartmorgan@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-04 19:12:37 +0000
commit996fd703fb7229e931203edc77df436aea9bc9a5 (patch)
treee52458f9e43ec4762ce58c3b15a235ad31e3d667 /base/string_util.cc
parentf62a8906648ddfcee0ffa9604939d4c7f66891aa (diff)
downloadchromium_src-996fd703fb7229e931203edc77df436aea9bc9a5.zip
chromium_src-996fd703fb7229e931203edc77df436aea9bc9a5.tar.gz
chromium_src-996fd703fb7229e931203edc77df436aea9bc9a5.tar.bz2
Strip .plugin off of Mac plugin names when showing the crash info bar.
BUG=21029 TEST=Kill a plugin process; the plugin crash info bar shouldn't have ".plugin" in the plugin name. Review URL: http://codereview.chromium.org/197018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25487 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/string_util.cc')
-rw-r--r--base/string_util.cc16
1 files changed, 16 insertions, 0 deletions
diff --git a/base/string_util.cc b/base/string_util.cc
index 1edc0d9..82b6c0b 100644
--- a/base/string_util.cc
+++ b/base/string_util.cc
@@ -773,6 +773,22 @@ bool StartsWith(const std::wstring& str,
}
}
+bool EndsWith(const std::wstring& str,
+ const std::wstring& search,
+ bool case_sensitive) {
+ std::wstring::size_type str_length = str.length();
+ std::wstring::size_type search_length = search.length();
+ if (search_length > str_length)
+ return false;
+ if (case_sensitive) {
+ return str.compare(str_length - search_length, search_length, search) == 0;
+ } else {
+ return std::equal(search.begin(), search.end(),
+ str.begin() + (str_length - search_length),
+ CaseInsensitiveCompare<wchar_t>());
+ }
+}
+
DataUnits GetByteDisplayUnits(int64 bytes) {
// The byte thresholds at which we display amounts. A byte count is displayed
// in unit U when kUnitThresholds[U] <= bytes < kUnitThresholds[U+1].