Chromium Code Reviews| 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 |