Commit 1e477176 authored by ckocagil@chromium.org's avatar ckocagil@chromium.org

Revert of Generalize printer color model handling, get rid of CUPS specific...

Revert of Generalize printer color model handling, get rid of CUPS specific case. Enable supported paper szes… (https://codereview.chromium.org/324523002/)

Reason for revert:
Breaks Linux ASAN http://build.chromium.org/p/chromium.memory/builders/Linux%20ASan%20LSan%20Tests%20%281%29/builds/2865

Original issue's description:
> Generalize printer color model handling, get rid of CUPS specific case. Enable supported paper szes reporting for all platforms.
> 
> BUG=239879
> NOTRY=true
> 
> Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=275646
> 
> Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=275716

TBR=vitalybuka@chromium.org,jschuh@chromium.org,alekseys@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=239879

Review URL: https://codereview.chromium.org/321703002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@275739 0039d316-1c4b-4281-b951-d872f2087c98
parent 64bb94fd
......@@ -376,13 +376,19 @@ cr.define('print_preview', function() {
cjt.print.collate = {collate: this.collate.getValue()};
}
if (this.color.isCapabilityAvailable() && this.color.isUserEdited()) {
var selectedOption = this.color.getSelectedOption();
if (!selectedOption) {
var colorType = this.color.getValue() ?
'STANDARD_COLOR' : 'STANDARD_MONOCHROME';
// Find option with this colorType to read its vendor_id.
var selectedOptions = destination.capabilities.printer.color.option.
filter(function(option) {
return option.type == colorType;
});
if (selectedOptions.length == 0) {
console.error('Could not find correct color option');
} else {
cjt.print.color = {type: selectedOption.type};
if (selectedOption.hasOwnProperty('vendor_id')) {
cjt.print.color.vendor_id = selectedOption.vendor_id;
cjt.print.color = {type: colorType};
if (selectedOptions[0].hasOwnProperty('vendor_id')) {
cjt.print.color.vendor_id = selectedOptions[0].vendor_id;
}
}
}
......
......@@ -23,18 +23,6 @@ cr.define('print_preview.ticket_items', function() {
destinationStore);
};
/*
* @private {!Array.<string>} List of capability types considered color.
* @const
*/
Color.COLOR_TYPES_ = ['STANDARD_COLOR', 'CUSTOM_COLOR'];
/*
* @private {!Array.<string>} List of capability types considered monochrome.
* @const
*/
Color.MONOCHROME_TYPES_ = ['STANDARD_MONOCHROME', 'CUSTOM_MONOCHROME'];
Color.prototype = {
__proto__: print_preview.ticket_items.TicketItem.prototype,
......@@ -45,72 +33,56 @@ cr.define('print_preview.ticket_items', function() {
/** @override */
isCapabilityAvailable: function() {
var capability = this.capability;
if (!capability) {
var colorCap = this.getColorCapability_();
if (!colorCap) {
return false;
}
var hasColor = false;
var hasMonochrome = false;
capability.option.forEach(function(option) {
hasColor = hasColor || (Color.COLOR_TYPES_.indexOf(option.type) >= 0);
hasMonochrome = hasMonochrome ||
(Color.MONOCHROME_TYPES_.indexOf(option.type) >= 0);
colorCap.option.forEach(function(option) {
hasColor = hasColor || option.type == 'STANDARD_COLOR';
hasMonochrome = hasMonochrome || option.type == 'STANDARD_MONOCHROME';
});
return hasColor && hasMonochrome;
},
/** @return {Object} Color capability of the selected destination. */
get capability() {
var dest = this.getSelectedDestInternal();
return (dest &&
dest.capabilities &&
dest.capabilities.printer &&
dest.capabilities.printer.color) ||
null;
},
/** @return {Object} Color option corresponding to the current value. */
getSelectedOption: function() {
var capability = this.capability;
var options = capability ? capability.option : null;
if (options) {
var typesToLookFor =
this.getValue() ? Color.COLOR_TYPES_ : Color.MONOCHROME_TYPES_;
for (var i = 0; i < typesToLookFor.length; i++) {
var matchingOptions = options.filter(function(option) {
return option.type == typesToLookFor[i];
});
if (matchingOptions.length > 0) {
return matchingOptions[0];
}
}
}
return null;
},
/** @override */
getDefaultValueInternal: function() {
var capability = this.capability;
var defaultOption = capability ?
this.getDefaultColorOption_(capability.option) : null;
return defaultOption &&
(Color.COLOR_TYPES_.indexOf(defaultOption.type) >= 0);
var colorCap = this.getColorCapability_();
var defaultOption = this.getDefaultColorOption_(colorCap.option);
return defaultOption && defaultOption.type == 'STANDARD_COLOR';
},
/** @override */
getCapabilityNotAvailableValueInternal: function() {
var colorCap = this.getColorCapability_();
var defaultOption = colorCap ?
this.getDefaultColorOption_(colorCap.option) : null;
// TODO(rltoscano): Get rid of this check based on destination ID. These
// destinations should really update their CDDs to have only one color
// option that has type 'STANDARD_COLOR'.
var dest = this.getSelectedDestInternal();
if (dest) {
if (dest.id == print_preview.Destination.GooglePromotedId.DOCS ||
dest.id == print_preview.Destination.GooglePromotedId.FEDEX ||
dest.type == print_preview.Destination.Type.MOBILE) {
return true;
}
if (!dest) {
return false;
}
return this.getDefaultValueInternal();
return dest.id == print_preview.Destination.GooglePromotedId.DOCS ||
dest.id == print_preview.Destination.GooglePromotedId.FEDEX ||
dest.type == print_preview.Destination.Type.MOBILE ||
defaultOption && defaultOption.type == 'STANDARD_COLOR';
},
/**
* @return {Object} Color capability of the selected destination.
* @private
*/
getColorCapability_: function() {
var dest = this.getSelectedDestInternal();
return (dest &&
dest.capabilities &&
dest.capabilities.printer &&
dest.capabilities.printer.color) ||
null;
},
/**
......
......@@ -167,23 +167,6 @@ cr.define('print_preview', function() {
chrome.send('getPrinterCapabilities', [destinationId]);
},
/**
* @param {!print_preview.Destination} destination Destination to print to.
* @param {!print_preview.ticket_items.Color} color Color ticket item.
* @return {number} Native layer color model.
* @private
*/
getNativeColorModel_: function(destination, color) {
// For non-local printers native color model is ignored anyway.
var option = destination.isLocal ? color.getSelectedOption() : null;
var nativeColorModel = parseInt(option ? option.vendor_id : null);
if (isNaN(nativeColorModel)) {
return color.getValue() ?
NativeLayer.ColorMode_.COLOR : NativeLayer.ColorMode_.GRAY;
}
return nativeColorModel;
},
/**
* Requests that a preview be generated. The following events may be
* dispatched in response:
......@@ -207,7 +190,8 @@ cr.define('print_preview', function() {
'pageRange': printTicketStore.pageRange.getDocumentPageRanges(),
'mediaSize': printTicketStore.mediaSize.getValue(),
'landscape': printTicketStore.landscape.getValue(),
'color': this.getNativeColorModel_(destination, printTicketStore.color),
'color': printTicketStore.color.getValue() ?
NativeLayer.ColorMode_.COLOR : NativeLayer.ColorMode_.GRAY,
'headerFooterEnabled': printTicketStore.headerFooter.getValue(),
'marginsType': printTicketStore.marginsType.getValue(),
'isFirstRequest': requestId == 0,
......@@ -279,7 +263,8 @@ cr.define('print_preview', function() {
'pageRange': printTicketStore.pageRange.getDocumentPageRanges(),
'pageCount': printTicketStore.pageRange.getPageNumberSet().size,
'landscape': printTicketStore.landscape.getValue(),
'color': this.getNativeColorModel_(destination, printTicketStore.color),
'color': printTicketStore.color.getValue() ?
NativeLayer.ColorMode_.COLOR : NativeLayer.ColorMode_.GRAY,
'headerFooterEnabled': printTicketStore.headerFooter.getValue(),
'marginsType': printTicketStore.marginsType.getValue(),
'generateDraftData': true, // TODO(rltoscano): What should this be?
......
......@@ -22,7 +22,6 @@
#include "base/metrics/histogram.h"
#include "base/path_service.h"
#include "base/prefs/pref_service.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread.h"
#include "base/threading/thread_restrictions.h"
......@@ -191,6 +190,10 @@ const char kLocalPdfPrinterId[] = "Save as PDF";
// Additional printer capability setting keys.
const char kPrinterId[] = "printerId";
const char kPrinterCapabilities[] = "capabilities";
#if defined(USE_CUPS)
const char kCUPSsColorModel[] = "cupsColorModel";
const char kCUPSsBWModel[] = "cupsBWModel";
#endif
// Get the print job settings dictionary from |args|. The caller takes
// ownership of the returned DictionaryValue. Returns NULL on failure.
......@@ -314,11 +317,7 @@ scoped_ptr<base::DictionaryValue> GetPdfCapabilitiesOnFileThread(
orientation.SaveTo(&description);
ColorCapability color;
{
Color standard_color(STANDARD_COLOR);
standard_color.vendor_id = base::IntToString(printing::COLOR);
color.AddDefaultOption(standard_color, true);
}
color.AddDefaultOption(Color(STANDARD_COLOR), true);
color.SaveTo(&description);
static const cloud_devices::printer::MediaType kPdfMedia[] = {
......@@ -377,6 +376,11 @@ scoped_ptr<base::DictionaryValue> GetLocalPrinterCapabilitiesOnFileThread(
return scoped_ptr<base::DictionaryValue>();
}
#if defined(USE_CUPS)
// TODO(alekseys): Use CUSTOM_COLOR/MONOCHROME instead.
description->SetInteger(kCUPSsColorModel, info.color_model);
description->SetInteger(kCUPSsBWModel, info.bw_model);
#endif
return description.Pass();
}
......@@ -469,6 +473,14 @@ printing::StickySettings* GetStickySettings() {
} // namespace
#if defined(USE_CUPS)
struct PrintPreviewHandler::CUPSPrinterColorModels {
std::string printer_name;
printing::ColorModel color_model;
printing::ColorModel bw_model;
};
#endif
class PrintPreviewHandler::AccessTokenService
: public OAuth2TokenService::Consumer {
public:
......@@ -868,6 +880,11 @@ void PrintPreviewHandler::HandlePrint(const base::ListValue* args) {
// Reset selection only flag for the same reason.
settings->SetBoolean(printing::kSettingShouldPrintSelectionOnly, false);
#if defined(USE_CUPS)
if (!open_pdf_in_preview) // We can get here even for cloud printers.
ConvertColorSettingToCUPSColorModel(settings.get());
#endif
// Set ID to know whether printing is for preview.
settings->SetInteger(printing::kPreviewUIID,
print_preview_ui->GetIDForPrintPreviewUI());
......@@ -1212,6 +1229,11 @@ void PrintPreviewHandler::SendAccessToken(const std::string& type,
void PrintPreviewHandler::SendPrinterCapabilities(
const base::DictionaryValue* settings_info) {
VLOG(1) << "Get printer capabilities finished";
#if defined(USE_CUPS)
SaveCUPSColorSetting(settings_info);
#endif
web_ui()->CallJavascriptFunction("updateWithPrinterCapabilities",
*settings_info);
}
......@@ -1388,6 +1410,59 @@ bool PrintPreviewHandler::GetPreviewDataAndTitle(
return true;
}
#if defined(USE_CUPS)
void PrintPreviewHandler::SaveCUPSColorSetting(
const base::DictionaryValue* settings) {
cups_printer_color_models_.reset(new CUPSPrinterColorModels);
settings->GetString(kPrinterId, &cups_printer_color_models_->printer_name);
const base::DictionaryValue* capabilities = NULL;
if (!settings->GetDictionary(kPrinterCapabilities, &capabilities) ||
!capabilities) {
NOTREACHED();
return;
}
capabilities->GetInteger(
kCUPSsColorModel,
reinterpret_cast<int*>(&cups_printer_color_models_->color_model));
capabilities->GetInteger(
kCUPSsBWModel,
reinterpret_cast<int*>(&cups_printer_color_models_->bw_model));
}
void PrintPreviewHandler::ConvertColorSettingToCUPSColorModel(
base::DictionaryValue* settings) const {
if (!cups_printer_color_models_)
return;
// Sanity check the printer name.
std::string printer_name;
if (!settings->GetString(printing::kSettingDeviceName, &printer_name) ||
printer_name != cups_printer_color_models_->printer_name) {
NOTREACHED();
return;
}
int color;
if (!settings->GetInteger(printing::kSettingColor, &color)) {
NOTREACHED();
return;
}
if (color == printing::GRAY) {
if (cups_printer_color_models_->bw_model != printing::UNKNOWN_COLOR_MODEL) {
settings->SetInteger(printing::kSettingColor,
cups_printer_color_models_->bw_model);
}
return;
}
printing::ColorModel color_model = cups_printer_color_models_->color_model;
if (color_model != printing::UNKNOWN_COLOR_MODEL)
settings->SetInteger(printing::kSettingColor, color_model);
}
#endif // defined(USE_CUPS)
#if defined(ENABLE_SERVICE_DISCOVERY)
void PrintPreviewHandler::LocalPrinterChanged(
bool added,
......
......@@ -99,6 +99,7 @@ class PrintPreviewHandler
private:
class AccessTokenService;
struct CUPSPrinterColorModels;
static bool PrivetPrintingEnabled();
......@@ -295,6 +296,11 @@ class PrintPreviewHandler
// Holds token service to get OAuth2 access tokens.
scoped_ptr<AccessTokenService> token_service_;
#if defined(USE_CUPS)
// The color capabilities from the last printer queried.
scoped_ptr<CUPSPrinterColorModels> cups_printer_color_models_;
#endif
#if defined(ENABLE_SERVICE_DISCOVERY)
scoped_refptr<local_discovery::ServiceDiscoverySharedClient>
service_discovery_client_;
......
......@@ -48,13 +48,14 @@ IPC_STRUCT_TRAITS_BEGIN(printing::PrinterCapsAndDefaults)
IPC_STRUCT_TRAITS_MEMBER(defaults_mime_type)
IPC_STRUCT_TRAITS_END()
IPC_ENUM_TRAITS_MAX_VALUE(printing::ColorModel, printing::PROCESSCOLORMODEL_RGB)
IPC_ENUM_TRAITS_MAX_VALUE(printing::DuplexMode, printing::SHORT_EDGE)
IPC_ENUM_TRAITS(printing::DuplexMode)
#if defined(OS_WIN)
IPC_STRUCT_TRAITS_BEGIN(printing::PrinterSemanticCapsAndDefaults::Paper)
IPC_STRUCT_TRAITS_MEMBER(name)
IPC_STRUCT_TRAITS_MEMBER(size_um)
IPC_STRUCT_TRAITS_END()
#endif
IPC_STRUCT_TRAITS_BEGIN(printing::PrinterSemanticCapsAndDefaults)
IPC_STRUCT_TRAITS_MEMBER(collate_capable)
......@@ -64,12 +65,16 @@ IPC_STRUCT_TRAITS_BEGIN(printing::PrinterSemanticCapsAndDefaults)
IPC_STRUCT_TRAITS_MEMBER(duplex_default)
IPC_STRUCT_TRAITS_MEMBER(color_changeable)
IPC_STRUCT_TRAITS_MEMBER(color_default)
#if defined(USE_CUPS)
IPC_STRUCT_TRAITS_MEMBER(color_model)
IPC_STRUCT_TRAITS_MEMBER(bw_model)
#endif
#if defined(OS_WIN)
IPC_STRUCT_TRAITS_MEMBER(papers)
IPC_STRUCT_TRAITS_MEMBER(default_paper)
IPC_STRUCT_TRAITS_MEMBER(dpis)
IPC_STRUCT_TRAITS_MEMBER(default_dpi)
#endif
IPC_STRUCT_TRAITS_END()
IPC_ENUM_TRAITS(printing::PwgRasterTransformType);
......
......@@ -4,7 +4,6 @@
#include "chrome/common/cloud_print/cloud_print_cdd_conversion.h"
#include "base/strings/string_number_conversions.h"
#include "components/cloud_devices/common/printer_description.h"
#include "printing/backend/print_backend.h"
......@@ -43,14 +42,11 @@ scoped_ptr<base::DictionaryValue> PrinterSemanticCapsAndDefaultsToCdd(
ColorCapability color;
if (semantic_info.color_default || semantic_info.color_changeable) {
Color standard_color(STANDARD_COLOR);
standard_color.vendor_id = base::IntToString(semantic_info.color_model);
color.AddDefaultOption(standard_color, semantic_info.color_default);
color.AddDefaultOption(Color(STANDARD_COLOR), semantic_info.color_default);
}
if (!semantic_info.color_default || semantic_info.color_changeable) {
Color standard_monochrome(STANDARD_MONOCHROME);
standard_monochrome.vendor_id = base::IntToString(semantic_info.bw_model);
color.AddDefaultOption(standard_monochrome, !semantic_info.color_default);
color.AddDefaultOption(Color(STANDARD_MONOCHROME),
!semantic_info.color_default);
}
color.SaveTo(&description);
......
......@@ -87,18 +87,6 @@ PrintPreviewWebUITest.prototype = {
}.bind(this));
},
setUpPreview: function() {
var initialSettingsSetEvent =
new Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET);
initialSettingsSetEvent.initialSettings = this.initialSettings_;
this.nativeLayer_.dispatchEvent(initialSettingsSetEvent);
var localDestsSetEvent =
new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET);
localDestsSetEvent.destinationInfos = this.localDestinationInfos_;
this.nativeLayer_.dispatchEvent(localDestsSetEvent);
},
/**
* Generate a real C++ class; don't typedef.
* @type {?string}
......@@ -596,139 +584,59 @@ TEST_F('PrintPreviewWebUITest',
true);
});
// Test that the color settings, one option, standard monochrome.
TEST_F('PrintPreviewWebUITest', 'TestColorSettingsMonochrome', function() {
this.setUpPreview();
// Only one option, standard monochrome.
var capsSetEvent =
new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET);
capsSetEvent.settingsInfo = getCddTemplate("FooDevice");
capsSetEvent.settingsInfo.capabilities.printer.color = {
"option": [
{"is_default": true, "type": "STANDARD_MONOCHROME"}
]
};
this.nativeLayer_.dispatchEvent(capsSetEvent);
checkSectionVisible($('color-settings'), false);
});
// Test that the color settings are set according to the printer capabilities.
TEST_F('PrintPreviewWebUITest', 'TestColorSettingsTrue', function() {
var initialSettingsSetEvent =
new Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET);
initialSettingsSetEvent.initialSettings = this.initialSettings_;
this.nativeLayer_.dispatchEvent(initialSettingsSetEvent);
// Test that the color settings, one option, custom monochrome.
TEST_F('PrintPreviewWebUITest', 'TestColorSettingsCustomMonochrome',
function() {
this.setUpPreview();
var localDestsSetEvent =
new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET);
localDestsSetEvent.destinationInfos = this.localDestinationInfos_;
this.nativeLayer_.dispatchEvent(localDestsSetEvent);
// Only one option, standard monochrome.
var capsSetEvent =
new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET);
capsSetEvent.settingsInfo = getCddTemplate("FooDevice");
capsSetEvent.settingsInfo.capabilities.printer.color = {
"option": [
{"is_default": true, "type": "CUSTOM_MONOCHROME", "vendor_id": "42"}
]
};
this.nativeLayer_.dispatchEvent(capsSetEvent);
checkSectionVisible($('color-settings'), false);
});
// Test that the color settings, one option, standard color.
TEST_F('PrintPreviewWebUITest', 'TestColorSettingsColor', function() {
this.setUpPreview();
var capsSetEvent =
new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET);
capsSetEvent.settingsInfo = getCddTemplate("FooDevice");
capsSetEvent.settingsInfo.capabilities.printer.color = {
"option": [
{"is_default": true, "type": "STANDARD_COLOR"}
]
};
this.nativeLayer_.dispatchEvent(capsSetEvent);
checkSectionVisible($('color-settings'), true);
checkSectionVisible($('color-settings'), false);
var colorOption = $('color-settings').querySelector('.color-option');
var bwOption = $('color-settings').querySelector('.bw-option');
expectTrue(colorOption.checked);
expectFalse(bwOption.checked);
});
// Test that the color settings, one option, custom color.
TEST_F('PrintPreviewWebUITest', 'TestColorSettingsCustomColor', function() {
this.setUpPreview();
var capsSetEvent =
new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET);
capsSetEvent.settingsInfo = getCddTemplate("FooDevice");
capsSetEvent.settingsInfo.capabilities.printer.color = {
"option": [
{"is_default": true, "type": "CUSTOM_COLOR", "vendor_id": "42"}
]
};
this.nativeLayer_.dispatchEvent(capsSetEvent);
checkSectionVisible($('color-settings'), false);
});
//Test that the color settings are set according to the printer capabilities.
TEST_F('PrintPreviewWebUITest', 'TestColorSettingsFalse', function() {
var initialSettingsSetEvent =
new Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET);
initialSettingsSetEvent.initialSettings = this.initialSettings_;
this.nativeLayer_.dispatchEvent(initialSettingsSetEvent);
// Test that the color settings, two options, both standard, defaults to color.
TEST_F('PrintPreviewWebUITest', 'TestColorSettingsBothStandardDefaultColor',
function() {
this.setUpPreview();
var localDestsSetEvent =
new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET);
localDestsSetEvent.destinationInfos = this.localDestinationInfos_;
this.nativeLayer_.dispatchEvent(localDestsSetEvent);
var capsSetEvent =
new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET);
capsSetEvent.settingsInfo = getCddTemplate("FooDevice");
capsSetEvent.settingsInfo.capabilities.printer.color = {
"option": [
{"type": "STANDARD_MONOCHROME"},
{"is_default": true, "type": "STANDARD_COLOR"}
{"is_default": true, "type": "STANDARD_MONOCHROME"}
]
};
this.nativeLayer_.dispatchEvent(capsSetEvent);
checkSectionVisible($('color-settings'), true);
expectTrue($('color-settings').querySelector('.color-option').checked);
expectFalse($('color-settings').querySelector('.bw-option').checked);
});
// Test that the color settings, two options, both standard, defaults to
// monochrome.
TEST_F('PrintPreviewWebUITest',
'TestColorSettingsBothStandardDefaultMonochrome', function() {
this.setUpPreview();
var capsSetEvent =
new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET);
capsSetEvent.settingsInfo = getCddTemplate("FooDevice");
capsSetEvent.settingsInfo.capabilities.printer.color = {
"option": [
{"is_default": true, "type": "STANDARD_MONOCHROME"},
{"type": "STANDARD_COLOR"}
]
};
this.nativeLayer_.dispatchEvent(capsSetEvent);
checkSectionVisible($('color-settings'), true);
expectFalse($('color-settings').querySelector('.color-option').checked);
expectTrue($('color-settings').querySelector('.bw-option').checked);
});
// Test that the color settings, two options, both custom, defaults to color.
TEST_F('PrintPreviewWebUITest',
'TestColorSettingsBothCustomDefaultColor', function() {
this.setUpPreview();
var capsSetEvent =
new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET);
capsSetEvent.settingsInfo = getCddTemplate("FooDevice");
capsSetEvent.settingsInfo.capabilities.printer.color = {
"option": [
{"type": "CUSTOM_MONOCHROME", "vendor_id": "42"},
{"is_default": true, "type": "CUSTOM_COLOR", "vendor_id": "43"}
]
};
this.nativeLayer_.dispatchEvent(capsSetEvent);
checkSectionVisible($('color-settings'), false);
checkSectionVisible($('color-settings'), true);
expectTrue($('color-settings').querySelector('.color-option').checked);
expectFalse($('color-settings').querySelector('.bw-option').checked);
var colorOption = $('color-settings').querySelector('.color-option');
var bwOption = $('color-settings').querySelector('.bw-option');
expectFalse(colorOption.checked);
expectTrue(bwOption.checked);
});
// Test to verify that duplex settings are set according to the printer
......@@ -758,8 +666,8 @@ TEST_F('PrintPreviewWebUITest', 'TestDuplexSettingsTrue', function() {
expectFalse(duplexCheckbox.checked);
});
// Test to verify that duplex settings are set according to the printer
// capabilities.
//Test to verify that duplex settings are set according to the printer
//capabilities.
TEST_F('PrintPreviewWebUITest', 'TestDuplexSettingsFalse', function() {
var initialSettingsSetEvent =
new Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET);
......
......@@ -19,9 +19,12 @@ PrinterSemanticCapsAndDefaults::PrinterSemanticCapsAndDefaults()
duplex_capable(false),
duplex_default(UNKNOWN_DUPLEX_MODE),
color_changeable(false),
color_default(false),
color_default(false)
#if defined (OS_POSIX)
,
color_model(UNKNOWN_COLOR_MODEL),
bw_model(UNKNOWN_COLOR_MODEL)
#endif
{}
PrinterSemanticCapsAndDefaults::~PrinterSemanticCapsAndDefaults() {}
......
......@@ -48,18 +48,28 @@ struct PRINTING_EXPORT PrinterSemanticCapsAndDefaults {
bool color_changeable;
bool color_default;
// These are CUPS specific data, which soon be removed altogether. They are
// not defined under USE_CUPS to do not pull CUPS dependency into common code.
#if defined(OS_POSIX)
// TODO(alekseys): Resolve color model within printing context, do not expose
// it outside of the context.
ColorModel color_model;
ColorModel bw_model;
#endif
#if defined(OS_WIN)
struct Paper {
std::string name;
gfx::Size size_um;
};
std::vector<Paper> papers;
Paper default_paper;
std::vector<gfx::Size> dpis;
gfx::Size default_dpi;
#endif
};
struct PRINTING_EXPORT PrinterCapsAndDefaults {
......
......@@ -267,8 +267,6 @@ bool PrintBackendWin::GetPrinterSemanticCapsAndDefaults(
// http://msdn.microsoft.com/en-us/library/windows/desktop/dd183552(v=vs.85).aspx
caps.color_changeable =
(DeviceCapabilities(name, port, DC_COLORDEVICE, NULL, NULL) == 1);
caps.color_model = printing::COLOR;
caps.bw_model = printing::GRAY;
caps.duplex_capable =
(DeviceCapabilities(name, port, DC_DUPLEX, NULL, NULL) == 1);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment