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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « printing/backend/win_helper.h ('k') | printing/printing.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "printing/backend/win_helper.h" 5 #include "printing/backend/win_helper.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/file_version_info.h" 10 #include "base/file_version_info.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/utf_string_conversions.h" 13 #include "base/utf_string_conversions.h"
14 #include "printing/backend/print_backend.h" 14 #include "printing/backend/print_backend.h"
15 #include "printing/backend/print_backend_consts.h" 15 #include "printing/backend/print_backend_consts.h"
16 #include "third_party/icu/public/common/unicode/uchar.h"
17 #include "ui/base/text/text_elider.h"
16 18
17 namespace { 19 namespace {
20
21 const wchar_t kDefaultDocumentTitle[] = L"Untitled Document";
22 const int kMaxDocumentTitleLength = 25;
23
18 typedef HRESULT (WINAPI* PTOpenProviderProc)(PCWSTR printer_name, 24 typedef HRESULT (WINAPI* PTOpenProviderProc)(PCWSTR printer_name,
19 DWORD version, 25 DWORD version,
20 HPTPROVIDER* provider); 26 HPTPROVIDER* provider);
21 typedef HRESULT (WINAPI* PTGetPrintCapabilitiesProc)(HPTPROVIDER provider, 27 typedef HRESULT (WINAPI* PTGetPrintCapabilitiesProc)(HPTPROVIDER provider,
22 IStream* print_ticket, 28 IStream* print_ticket,
23 IStream* capabilities, 29 IStream* capabilities,
24 BSTR* error_message); 30 BSTR* error_message);
25 typedef HRESULT (WINAPI* PTConvertDevModeToPrintTicketProc)( 31 typedef HRESULT (WINAPI* PTConvertDevModeToPrintTicketProc)(
26 HPTPROVIDER provider, 32 HPTPROVIDER provider,
27 ULONG devmode_size_in_bytes, 33 ULONG devmode_size_in_bytes,
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 375
370 for (size_t i = 0; i < arraysize(info); ++i) { 376 for (size_t i = 0; i < arraysize(info); ++i) {
371 std::replace(info[i].begin(), info[i].end(), ';', ','); 377 std::replace(info[i].begin(), info[i].end(), ';', ',');
372 driver_info.append(info[i]); 378 driver_info.append(info[i]);
373 if (i < arraysize(info) - 1) 379 if (i < arraysize(info) - 1)
374 driver_info.append(";"); 380 driver_info.append(";");
375 } 381 }
376 return driver_info; 382 return driver_info;
377 } 383 }
378 384
385 string16 SimplifyDocumentTitle(const string16& title) {
Albert Bodenhamer 2012/09/19 18:37:10 Consider moving this into PrintBackend and doing t
386 string16 no_controls(title);
387 no_controls.erase(
388 std::remove_if(no_controls.begin(), no_controls.end(), &u_iscntrl),
389 no_controls.end());
390 string16 result;
391 ui::ElideString(no_controls, kMaxDocumentTitleLength, &result);
392 if (!result.empty())
393 return result;
394 // There is localized string in chrome/app/generated_resources.grd, but case
395 // is unusual and we don't want make printing depend of chrome/app.
396 return kDefaultDocumentTitle;
397 }
398
379 } // namespace printing 399 } // namespace printing
OLDNEW
« 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