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
3 // found in the LICENSE file.
5 #include "printing/backend/printing_info_win.h"
7 #include "base/logging.h"
13 uint8
* GetDriverInfo(HANDLE printer
, int level
) {
15 ::GetPrinterDriver(printer
, NULL
, level
, NULL
, 0, &size
);
19 scoped_array
<uint8
> buffer(new uint8
[size
]);
20 memset(buffer
.get(), 0, size
);
21 if (!::GetPrinterDriver(printer
, NULL
, level
, buffer
.get(), size
, &size
)) {
24 return buffer
.release();
27 uint8
* GetPrinterInfo(HANDLE printer
, int level
) {
29 ::GetPrinter(printer
, level
, NULL
, 0, &size
);
31 LOG(WARNING
) << "Failed to get size of PRINTER_INFO_" << level
<<
32 ", error = " << GetLastError();
35 scoped_array
<uint8
> buffer(new uint8
[size
]);
36 memset(buffer
.get(), 0, size
);
37 if (!::GetPrinter(printer
, level
, buffer
.get(), size
, &size
)) {
38 LOG(WARNING
) << "Failed to get PRINTER_INFO_" << level
<<
39 ", error = " << GetLastError();
42 return buffer
.release();
45 } // namespace internal
47 UserDefaultDevMode::UserDefaultDevMode() : dev_mode_(NULL
) {
50 bool UserDefaultDevMode::Init(HANDLE printer
) {
51 if (info_9_
.Init(printer
))
52 dev_mode_
= info_9_
.get()->pDevMode
;
54 if (!dev_mode_
&& info_8_
.Init(printer
))
55 dev_mode_
= info_8_
.get()->pDevMode
;
57 if (!dev_mode_
&& info_2_
.Init(printer
))
58 dev_mode_
= info_2_
.get()->pDevMode
;
60 return dev_mode_
!= NULL
;
63 UserDefaultDevMode::~UserDefaultDevMode() {
66 } // namespace printing