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

Unified Diff: printing/backend/print_backend.cc

Issue 10941025: Simplify document title for Windows printing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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: printing/backend/print_backend.cc
diff --git a/printing/backend/print_backend.cc b/printing/backend/print_backend.cc
index b993bfc2212a55cedfb31a31443deac1f27c21f8..71f917d44bf394cbce0e30fc5db363f61adcb36b 100644
--- a/printing/backend/print_backend.cc
+++ b/printing/backend/print_backend.cc
@@ -4,6 +4,18 @@
#include "printing/backend/print_backend.h"
+#include <algorithm>
+
+#include "third_party/icu/public/common/unicode/uchar.h"
+#include "ui/base/text/text_elider.h"
+
+namespace {
+
+const wchar_t kDefaultDocumentTitle[] = L"Untitled Document";
+const int kMaxDocumentTitleLength = 25;
Albert Bodenhamer 2012/09/20 00:25:20 Is 25 long enough? We can start with this for now
+
+} // namespace
+
namespace printing {
PrinterBasicInfo::PrinterBasicInfo()
@@ -26,4 +38,14 @@ PrinterCapsAndDefaults::~PrinterCapsAndDefaults() {}
PrintBackend::~PrintBackend() {}
+string16 PrintBackend::SimplifyDocumentTitle(const string16& title) {
+ string16 no_controls(title);
+ no_controls.erase(
+ std::remove_if(no_controls.begin(), no_controls.end(), &u_iscntrl),
+ no_controls.end());
+ string16 result;
+ ui::ElideString(no_controls, kMaxDocumentTitleLength, &result);
+ return result;
+}
+
} // namespace printing

Powered by Google App Engine
This is Rietveld 408576698