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

Unified Diff: printing/printing_utils.cc

Issue 59903019: Moved SimplifyDocumentTitle from printing/backend (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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
« no previous file with comments | « printing/printing_utils.h ('k') | printing/printing_utils_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: printing/printing_utils.cc
diff --git a/printing/printing_utils.cc b/printing/printing_utils.cc
new file mode 100644
index 0000000000000000000000000000000000000000..3d91de1bf0bfb0cf6cfbeb65e546b4605c0b4ce6
--- /dev/null
+++ b/printing/printing_utils.cc
@@ -0,0 +1,28 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "printing/printing_utils.h"
+
+#include <algorithm>
+
+#include "third_party/icu/source/common/unicode/uchar.h"
+#include "ui/gfx/text_elider.h"
+
+namespace {
+const int kMaxDocumentTitleLength = 50;
+}
+
+namespace printing {
+
+base::string16 SimplifyDocumentTitle(const base::string16& title) {
+ base::string16 no_controls(title);
+ no_controls.erase(
+ std::remove_if(no_controls.begin(), no_controls.end(), &u_iscntrl),
+ no_controls.end());
+ base::string16 result;
+ gfx::ElideString(no_controls, kMaxDocumentTitleLength, &result);
+ return result;
+}
+
+} // namespace printing
« no previous file with comments | « printing/printing_utils.h ('k') | printing/printing_utils_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698