Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Unified Diff: chrome/browser/ui/omnibox/location_bar_util.cc

Issue 296593003: Make various string_util functions take StringPieces instead of char[]. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/omnibox/location_bar_util.cc
diff --git a/chrome/browser/ui/omnibox/location_bar_util.cc b/chrome/browser/ui/omnibox/location_bar_util.cc
index 93c8b5f9c6f1f4beb6789a01a1086e2e7b5c9e45..42a24f5774d29ec37705aef99027882001ac20d8 100644
--- a/chrome/browser/ui/omnibox/location_bar_util.cc
+++ b/chrome/browser/ui/omnibox/location_bar_util.cc
@@ -6,6 +6,7 @@
#include "base/i18n/rtl.h"
#include "base/strings/string_util.h"
+#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/extensions/extension_action.h"
#include "third_party/skia/include/core/SkPaint.h"
#include "third_party/skia/include/effects/SkGradientShader.h"
@@ -18,16 +19,10 @@ namespace location_bar_util {
base::string16 CalculateMinString(const base::string16& description) {
// Chop at the first '.' or whitespace.
- const size_t dot_index = description.find('.');
- const size_t ws_index = description.find_first_of(base::kWhitespaceUTF16);
- size_t chop_index = std::min(dot_index, ws_index);
- base::string16 min_string;
- if (chop_index == base::string16::npos) {
- // No dot or whitespace, truncate to at most 3 chars.
- min_string = gfx::TruncateString(description, 3);
- } else {
- min_string = description.substr(0, chop_index);
- }
+ const size_t chop_index = description.find_first_of(
+ base::kWhitespaceUTF16 + base::ASCIIToUTF16("."));
+ base::string16 min_string((chop_index == base::string16::npos) ?
+ gfx::TruncateString(description, 3) : description.substr(0, chop_index));
base::i18n::AdjustStringForLocaleDirection(&min_string);
return min_string;
}

Powered by Google App Engine
This is Rietveld 408576698