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

Unified Diff: printing/backend/win_helper.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
« no previous file with comments | « printing/backend/win_helper.h ('k') | printing/printing.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: printing/backend/win_helper.cc
diff --git a/printing/backend/win_helper.cc b/printing/backend/win_helper.cc
index 5980291003d952df96de217fa19aba8758875cd3..a15907a3c1c8706ef9af2d92b3d818c2edc1b4a6 100644
--- a/printing/backend/win_helper.cc
+++ b/printing/backend/win_helper.cc
@@ -13,8 +13,14 @@
#include "base/utf_string_conversions.h"
#include "printing/backend/print_backend.h"
#include "printing/backend/print_backend_consts.h"
+#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;
+
typedef HRESULT (WINAPI* PTOpenProviderProc)(PCWSTR printer_name,
DWORD version,
HPTPROVIDER* provider);
@@ -376,4 +382,18 @@ std::string GetDriverInfo(HANDLE printer) {
return driver_info;
}
+string16 SimplifyDocumentTitle(const string16& title) {
Albert Bodenhamer 2012/09/19 18:37:10 Consider moving this into PrintBackend and doing t
+ 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);
+ if (!result.empty())
+ return result;
+ // There is localized string in chrome/app/generated_resources.grd, but case
+ // is unusual and we don't want make printing depend of chrome/app.
+ return kDefaultDocumentTitle;
+}
+
} // namespace printing
« no previous file with comments | « printing/backend/win_helper.h ('k') | printing/printing.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698