| Index: printing/print_settings_initializer_win.cc
|
| diff --git a/printing/print_settings_initializer_win.cc b/printing/print_settings_initializer_win.cc
|
| index e72033d04ffa46511978e7a2f9a8f8b538dfa54a..0776e9e5c0e5636864e8d611edbbc704ae5686d4 100644
|
| --- a/printing/print_settings_initializer_win.cc
|
| +++ b/printing/print_settings_initializer_win.cc
|
| @@ -12,26 +12,29 @@ namespace printing {
|
|
|
| namespace {
|
|
|
| -bool IsPrinterXPS(HDC hdc) {
|
| - int device_type = ::GetDeviceCaps(hdc, TECHNOLOGY);
|
| - if (device_type != DT_RASPRINTER)
|
| +bool HasEscapeSupprt(HDC hdc, DWORD escape) {
|
| + const char* ptr = reinterpret_cast<const char*>(&escape);
|
| + return ExtEscape(hdc, QUERYESCSUPPORT, sizeof(escape), ptr, 0, nullptr) > 0;
|
| +}
|
| +
|
| +bool IsTechnology(HDC hdc, const char* technology) {
|
| + if (::GetDeviceCaps(hdc, TECHNOLOGY) != DT_RASPRINTER)
|
| return false;
|
|
|
| - const DWORD escape = GETTECHNOLOGY;
|
| - const char* escape_ptr = reinterpret_cast<const char*>(&escape);
|
| - int ret =
|
| - ExtEscape(hdc, QUERYESCSUPPORT, sizeof(escape), escape_ptr, 0, nullptr);
|
| - if (ret <= 0)
|
| + if (!HasEscapeSupprt(hdc, GETTECHNOLOGY))
|
| return false;
|
|
|
| - char buffer[256];
|
| - memset(buffer, 0, sizeof(buffer));
|
| - ret = ExtEscape(hdc, GETTECHNOLOGY, 0, nullptr, sizeof(buffer) - 1, buffer);
|
| - if (ret <= 0)
|
| + char buf[256];
|
| + memset(buf, 0, sizeof(buf));
|
| + if (ExtEscape(hdc, GETTECHNOLOGY, 0, nullptr, sizeof(buf) - 1, buf) <= 0)
|
| return false;
|
| + return strcmp(buf, technology) == 0;
|
| +}
|
|
|
| - static const char kXPSDriver[] = "http://schemas.microsoft.com/xps/2005/06";
|
| - return strcmp(buffer, kXPSDriver) == 0;
|
| +bool IsPrinterXPS(HDC hdc) {
|
| + static constexpr char kXPSDriver[] =
|
| + "http://schemas.microsoft.com/xps/2005/06";
|
| + return IsTechnology(hdc, kXPSDriver);
|
| }
|
|
|
| } // namespace
|
|
|