Commit 917a0cf9 authored by alekseys@chromium.org's avatar alekseys@chromium.org

In App Kiosk mode, Print Preview changes:

- do not show user sign in promo
- do not show cloud print dialog link
- do not send COOKIES-based cloud printer search requests
- do not add Save as PDF printer
Related changes:
- fix UI issues when no printer is selected
- fix destination list sizing when one of the sections is empty

BUG=370096

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@282800 0039d316-1c4b-4281-b951-d872f2087c98
parent 8709371a
...@@ -13,10 +13,13 @@ cr.define('cloudprint', function() { ...@@ -13,10 +13,13 @@ cr.define('cloudprint', function() {
* @param {!print_preview.NativeLayer} nativeLayer Native layer used to get * @param {!print_preview.NativeLayer} nativeLayer Native layer used to get
* Auth2 tokens. * Auth2 tokens.
* @param {!print_preview.UserInfo} userInfo User information repository. * @param {!print_preview.UserInfo} userInfo User information repository.
* @param {boolean} isInAppKioskMode Whether the print preview is in App
* Kiosk mode.
* @constructor * @constructor
* @extends {cr.EventTarget} * @extends {cr.EventTarget}
*/ */
function CloudPrintInterface(baseUrl, nativeLayer, userInfo) { function CloudPrintInterface(
baseUrl, nativeLayer, userInfo, isInAppKioskMode) {
/** /**
* The base URL of the Google Cloud Print API. * The base URL of the Google Cloud Print API.
* @type {string} * @type {string}
...@@ -38,6 +41,14 @@ cr.define('cloudprint', function() { ...@@ -38,6 +41,14 @@ cr.define('cloudprint', function() {
*/ */
this.userInfo_ = userInfo; this.userInfo_ = userInfo;
/**
* Whether Print Preview is in App Kiosk mode, basically, use only printers
* available for the device.
* @type {boolean}
* @private
*/
this.isInAppKioskMode_ = isInAppKioskMode;
/** /**
* Currently logged in users (identified by email) mapped to the Google * Currently logged in users (identified by email) mapped to the Google
* session index. * session index.
...@@ -179,6 +190,11 @@ cr.define('cloudprint', function() { ...@@ -179,6 +190,11 @@ cr.define('cloudprint', function() {
var account = opt_account || ''; var account = opt_account || '';
var origins = var origins =
opt_origin && [opt_origin] || CloudPrintInterface.CLOUD_ORIGINS_; opt_origin && [opt_origin] || CloudPrintInterface.CLOUD_ORIGINS_;
if (this.isInAppKioskMode_) {
origins = origins.filter(function(origin) {
return origin != print_preview.Destination.Origin.COOKIES;
});
}
this.abortSearchRequests_(origins); this.abortSearchRequests_(origins);
this.search_(true, account, origins); this.search_(true, account, origins);
this.search_(false, account, origins); this.search_(false, account, origins);
......
...@@ -83,6 +83,14 @@ cr.define('print_preview', function() { ...@@ -83,6 +83,14 @@ cr.define('print_preview', function() {
*/ */
this.tracker_ = new EventTracker(); this.tracker_ = new EventTracker();
/**
* Whether PDF printer is enabled. It's disabled, for example, in App Kiosk
* mode.
* @type {boolean}
* @private
*/
this.pdfPrinterEnabled_ = false;
/** /**
* Used to fetch cloud-based print destinations. * Used to fetch cloud-based print destinations.
* @type {print_preview.CloudPrintInterface} * @type {print_preview.CloudPrintInterface}
...@@ -246,6 +254,12 @@ cr.define('print_preview', function() { ...@@ -246,6 +254,12 @@ cr.define('print_preview', function() {
return this.selectedDestination_; return this.selectedDestination_;
}, },
/** @return {boolean} Whether destination selection is pending or not. */
get isAutoSelectDestinationInProgress() {
return this.selectedDestination_ == null &&
this.autoSelectTimeout_ != null;
},
/** /**
* @return {boolean} Whether a search for local destinations is in progress. * @return {boolean} Whether a search for local destinations is in progress.
*/ */
...@@ -267,13 +281,16 @@ cr.define('print_preview', function() { ...@@ -267,13 +281,16 @@ cr.define('print_preview', function() {
* destination. If any inserted destinations match this ID, that destination * destination. If any inserted destinations match this ID, that destination
* will be automatically selected. This method must be called after the * will be automatically selected. This method must be called after the
* print_preview.AppState has been initialized. * print_preview.AppState has been initialized.
* @private * @param {boolean} isInAppKioskMode Whether the print preview is in App
* Kiosk mode.
*/ */
init: function() { init: function(isInAppKioskMode) {
this.pdfPrinterEnabled_ = !isInAppKioskMode;
this.isInAutoSelectMode_ = true; this.isInAutoSelectMode_ = true;
this.createLocalPdfPrintDestination_();
if (!this.appState_.selectedDestinationId || if (!this.appState_.selectedDestinationId ||
!this.appState_.selectedDestinationOrigin) { !this.appState_.selectedDestinationOrigin) {
this.onAutoSelectFailed_(); this.selectDefaultDestination_();
} else { } else {
var key = this.getDestinationKey_( var key = this.getDestinationKey_(
this.appState_.selectedDestinationOrigin, this.appState_.selectedDestinationOrigin,
...@@ -319,9 +336,8 @@ cr.define('print_preview', function() { ...@@ -319,9 +336,8 @@ cr.define('print_preview', function() {
cr.dispatchSimpleEvent( cr.dispatchSimpleEvent(
this, this,
DestinationStore.EventType.CACHED_SELECTED_DESTINATION_INFO_READY); DestinationStore.EventType.CACHED_SELECTED_DESTINATION_INFO_READY);
} else { } else {
this.onAutoSelectFailed_(); this.selectDefaultDestination_();
} }
} }
}, },
...@@ -367,8 +383,12 @@ cr.define('print_preview', function() { ...@@ -367,8 +383,12 @@ cr.define('print_preview', function() {
/** @param {!print_preview.Destination} Destination to select. */ /** @param {!print_preview.Destination} Destination to select. */
selectDestination: function(destination) { selectDestination: function(destination) {
this.isInAutoSelectMode_ = false; this.isInAutoSelectMode_ = false;
this.cancelAutoSelectTimeout_(); // When auto select expires, DESTINATION_SELECT event has to be dispatched
if (destination == this.selectedDestination_) { // anyway (see isAutoSelectDestinationInProgress() logic).
if (this.autoSelectTimeout_) {
clearTimeout(this.autoSelectTimeout_);
this.autoSelectTimeout_ = null;
} else if (destination == this.selectedDestination_) {
return; return;
} }
if (destination == null) { if (destination == null) {
...@@ -434,12 +454,12 @@ cr.define('print_preview', function() { ...@@ -434,12 +454,12 @@ cr.define('print_preview', function() {
* @private * @private
*/ */
selectDefaultDestination_: function() { selectDefaultDestination_: function() {
var destination = this.destinationMap_[this.getDestinationKey_( var saveToPdfKey = this.getDestinationKey_(
print_preview.Destination.Origin.LOCAL, print_preview.Destination.Origin.LOCAL,
print_preview.Destination.GooglePromotedId.SAVE_AS_PDF, print_preview.Destination.GooglePromotedId.SAVE_AS_PDF,
'')] || null; '');
assert(destination != null, 'Save to PDF printer not found'); this.selectDestination(
this.selectDestination(destination); this.destinationMap_[saveToPdfKey] || this.destinations_[0] || null);
}, },
/** Initiates loading of local print destinations. */ /** Initiates loading of local print destinations. */
...@@ -658,13 +678,17 @@ cr.define('print_preview', function() { ...@@ -658,13 +678,17 @@ cr.define('print_preview', function() {
* @private * @private
*/ */
createLocalPdfPrintDestination_: function() { createLocalPdfPrintDestination_: function() {
return new print_preview.Destination( // TODO(alekseys): Create PDF printer in the native code and send its
print_preview.Destination.GooglePromotedId.SAVE_AS_PDF, // capabilities back with other local printers.
print_preview.Destination.Type.LOCAL, if (this.pdfPrinterEnabled_) {
print_preview.Destination.Origin.LOCAL, this.insertDestination_(new print_preview.Destination(
localStrings.getString('printToPDF'), print_preview.Destination.GooglePromotedId.SAVE_AS_PDF,
false /*isRecent*/, print_preview.Destination.Type.LOCAL,
print_preview.Destination.ConnectionStatus.ONLINE); print_preview.Destination.Origin.LOCAL,
localStrings.getString('printToPDF'),
false /*isRecent*/,
print_preview.Destination.ConnectionStatus.ONLINE));
}
}, },
/** /**
...@@ -677,32 +701,11 @@ cr.define('print_preview', function() { ...@@ -677,32 +701,11 @@ cr.define('print_preview', function() {
this.selectDestination(null); this.selectDestination(null);
this.loadedCloudOrigins_ = {}; this.loadedCloudOrigins_ = {};
this.hasLoadedAllLocalDestinations_ = false; this.hasLoadedAllLocalDestinations_ = false;
// TODO(alekseys): Create PDF printer in the native code and send its
// capabilities back with other local printers.
this.insertDestination_(this.createLocalPdfPrintDestination_());
this.resetAutoSelectTimeout_();
},
/** clearTimeout(this.autoSelectTimeout_);
* Resets destination auto selection timeout. this.autoSelectTimeout_ = setTimeout(
* @private this.selectDefaultDestination_.bind(this),
*/ DestinationStore.AUTO_SELECT_TIMEOUT_);
resetAutoSelectTimeout_: function() {
this.cancelAutoSelectTimeout_();
this.autoSelectTimeout_ =
setTimeout(this.onAutoSelectFailed_.bind(this),
DestinationStore.AUTO_SELECT_TIMEOUT_);
},
/**
* Cancels destination auto selection timeout.
* @private
*/
cancelAutoSelectTimeout_: function() {
if (this.autoSelectTimeout_ != null) {
clearTimeout(this.autoSelectTimeout_);
this.autoSelectTimeout_ = null;
}
}, },
/** /**
...@@ -876,20 +879,12 @@ cr.define('print_preview', function() { ...@@ -876,20 +879,12 @@ cr.define('print_preview', function() {
onDestinationsReload_: function() { onDestinationsReload_: function() {
this.reset_(); this.reset_();
this.isInAutoSelectMode_ = true; this.isInAutoSelectMode_ = true;
this.createLocalPdfPrintDestination_();
this.startLoadLocalDestinations(); this.startLoadLocalDestinations();
this.startLoadCloudDestinations(); this.startLoadCloudDestinations();
this.startLoadPrivetDestinations(); this.startLoadPrivetDestinations();
}, },
/**
* Called when auto-selection fails. Selects the first destination in store.
* @private
*/
onAutoSelectFailed_: function() {
this.cancelAutoSelectTimeout_();
this.selectDefaultDestination_();
},
// TODO(vitalybuka): Remove three next functions replacing Destination.id // TODO(vitalybuka): Remove three next functions replacing Destination.id
// and Destination.origin by complex ID. // and Destination.origin by complex ID.
/** /**
......
...@@ -403,6 +403,7 @@ cr.define('print_preview', function() { ...@@ -403,6 +403,7 @@ cr.define('print_preview', function() {
var nativeInitialSettings = new print_preview.NativeInitialSettings( var nativeInitialSettings = new print_preview.NativeInitialSettings(
initialSettings['printAutomaticallyInKioskMode'] || false, initialSettings['printAutomaticallyInKioskMode'] || false,
initialSettings['appKioskMode'] || false,
initialSettings['hidePrintWithSystemDialogLink'] || false, initialSettings['hidePrintWithSystemDialogLink'] || false,
numberFormatSymbols[0] || ',', numberFormatSymbols[0] || ',',
numberFormatSymbols[1] || '.', numberFormatSymbols[1] || '.',
...@@ -425,10 +426,11 @@ cr.define('print_preview', function() { ...@@ -425,10 +426,11 @@ cr.define('print_preview', function() {
* @param {string} cloudPrintURL The URL to use for cloud print servers. * @param {string} cloudPrintURL The URL to use for cloud print servers.
* @private * @private
*/ */
onSetUseCloudPrint_: function(cloudPrintURL) { onSetUseCloudPrint_: function(settings) {
var cloudPrintEnableEvent = new Event( var cloudPrintEnableEvent = new Event(
NativeLayer.EventType.CLOUD_PRINT_ENABLE); NativeLayer.EventType.CLOUD_PRINT_ENABLE);
cloudPrintEnableEvent.baseCloudPrintUrl = cloudPrintURL; cloudPrintEnableEvent.baseCloudPrintUrl = settings['cloudPrintUrl'] || '';
cloudPrintEnableEvent.appKioskMode = settings['appKioskMode'] || false;
this.dispatchEvent(cloudPrintEnableEvent); this.dispatchEvent(cloudPrintEnableEvent);
}, },
...@@ -695,6 +697,8 @@ cr.define('print_preview', function() { ...@@ -695,6 +697,8 @@ cr.define('print_preview', function() {
* Initial settings retrieved from the native layer. * Initial settings retrieved from the native layer.
* @param {boolean} isInKioskAutoPrintMode Whether the print preview should be * @param {boolean} isInKioskAutoPrintMode Whether the print preview should be
* in auto-print mode. * in auto-print mode.
* @param {boolean} isInAppKioskMode Whether the print preview is in App Kiosk
* mode.
* @param {string} thousandsDelimeter Character delimeter of thousands digits. * @param {string} thousandsDelimeter Character delimeter of thousands digits.
* @param {string} decimalDelimeter Character delimeter of the decimal point. * @param {string} decimalDelimeter Character delimeter of the decimal point.
* @param {!print_preview.MeasurementSystem.UnitType} unitType Unit type of * @param {!print_preview.MeasurementSystem.UnitType} unitType Unit type of
...@@ -713,6 +717,7 @@ cr.define('print_preview', function() { ...@@ -713,6 +717,7 @@ cr.define('print_preview', function() {
*/ */
function NativeInitialSettings( function NativeInitialSettings(
isInKioskAutoPrintMode, isInKioskAutoPrintMode,
isInAppKioskMode,
hidePrintWithSystemDialogLink, hidePrintWithSystemDialogLink,
thousandsDelimeter, thousandsDelimeter,
decimalDelimeter, decimalDelimeter,
...@@ -731,6 +736,13 @@ cr.define('print_preview', function() { ...@@ -731,6 +736,13 @@ cr.define('print_preview', function() {
*/ */
this.isInKioskAutoPrintMode_ = isInKioskAutoPrintMode; this.isInKioskAutoPrintMode_ = isInKioskAutoPrintMode;
/**
* Whether the print preview should switch to App Kiosk mode.
* @type {boolean}
* @private
*/
this.isInAppKioskMode_ = isInAppKioskMode;
/** /**
* Whether we should hide the link which shows the system print dialog. * Whether we should hide the link which shows the system print dialog.
* @type {boolean} * @type {boolean}
...@@ -810,6 +822,14 @@ cr.define('print_preview', function() { ...@@ -810,6 +822,14 @@ cr.define('print_preview', function() {
return this.isInKioskAutoPrintMode_; return this.isInKioskAutoPrintMode_;
}, },
/**
* @return {boolean} Whether the print preview should switch to App Kiosk
* mode.
*/
get isInAppKioskMode() {
return this.isInAppKioskMode_;
},
/** /**
* @return {boolean} Whether we should hide the link which shows the * @return {boolean} Whether we should hide the link which shows the
system print dialog. system print dialog.
......
...@@ -193,6 +193,14 @@ cr.define('print_preview', function() { ...@@ -193,6 +193,14 @@ cr.define('print_preview', function() {
*/ */
this.isInKioskAutoPrintMode_ = false; this.isInKioskAutoPrintMode_ = false;
/**
* Whether Print Preview is in App Kiosk mode, basically, use only printers
* available for the device.
* @type {boolean}
* @private
*/
this.isInAppKioskMode_ = false;
/** /**
* State of the print preview UI. * State of the print preview UI.
* @type {print_preview.PrintPreview.UiState_} * @type {print_preview.PrintPreview.UiState_}
...@@ -530,6 +538,7 @@ cr.define('print_preview', function() { ...@@ -530,6 +538,7 @@ cr.define('print_preview', function() {
var settings = event.initialSettings; var settings = event.initialSettings;
this.isInKioskAutoPrintMode_ = settings.isInKioskAutoPrintMode; this.isInKioskAutoPrintMode_ = settings.isInKioskAutoPrintMode;
this.isInAppKioskMode_ = settings.isInAppKioskMode;
// The following components must be initialized in this order. // The following components must be initialized in this order.
this.appState_.init( this.appState_.init(
...@@ -544,12 +553,13 @@ cr.define('print_preview', function() { ...@@ -544,12 +553,13 @@ cr.define('print_preview', function() {
settings.decimalDelimeter, settings.decimalDelimeter,
settings.unitType, settings.unitType,
settings.selectionOnly); settings.selectionOnly);
this.destinationStore_.init(); this.destinationStore_.init(settings.isInAppKioskMode);
this.appState_.setInitialized(); this.appState_.setInitialized();
$('document-title').innerText = settings.documentTitle; $('document-title').innerText = settings.documentTitle;
setIsVisible($('system-dialog-link'), setIsVisible($('system-dialog-link'),
!settings.hidePrintWithSystemDialogLink); !settings.hidePrintWithSystemDialogLink);
setIsVisible($('cloud-print-dialog-link'), !settings.isInAppKioskMode);
}, },
/** /**
...@@ -563,7 +573,8 @@ cr.define('print_preview', function() { ...@@ -563,7 +573,8 @@ cr.define('print_preview', function() {
this.cloudPrintInterface_ = new cloudprint.CloudPrintInterface( this.cloudPrintInterface_ = new cloudprint.CloudPrintInterface(
event.baseCloudPrintUrl, event.baseCloudPrintUrl,
this.nativeLayer_, this.nativeLayer_,
this.userInfo_); this.userInfo_,
event.appKioskMode);
this.tracker.add( this.tracker.add(
this.cloudPrintInterface_, this.cloudPrintInterface_,
cloudprint.CloudPrintInterface.EventType.SUBMIT_DONE, cloudprint.CloudPrintInterface.EventType.SUBMIT_DONE,
...@@ -662,7 +673,9 @@ cr.define('print_preview', function() { ...@@ -662,7 +673,9 @@ cr.define('print_preview', function() {
*/ */
onCloudPrintError_: function(event) { onCloudPrintError_: function(event) {
if (event.status == 403) { if (event.status == 403) {
this.destinationSearch_.showCloudPrintPromo(); if (!this.isInAppKioskMode_) {
this.destinationSearch_.showCloudPrintPromo();
}
} else if (event.status == 0) { } else if (event.status == 0) {
return; // Ignore, the system does not have internet connectivity. return; // Ignore, the system does not have internet connectivity.
} else { } else {
......
...@@ -128,7 +128,10 @@ cr.define('print_preview', function() { ...@@ -128,7 +128,10 @@ cr.define('print_preview', function() {
numItems = Math.min(numItems, this.destinations_.length); numItems = Math.min(numItems, this.destinations_.length);
var headerHeight = var headerHeight =
this.getChildElement('.destination-list > header').offsetHeight; this.getChildElement('.destination-list > header').offsetHeight;
return headerHeight + numItems * DestinationList.HEIGHT_OF_ITEM_; return headerHeight + (numItems > 0 ?
numItems * DestinationList.HEIGHT_OF_ITEM_ :
// To account for "No destinations found" message.
DestinationList.HEIGHT_OF_ITEM_);
}, },
/** @param {boolean} isVisible Whether the throbber is visible. */ /** @param {boolean} isVisible Whether the throbber is visible. */
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#destination-settings .throbber { #destination-settings .throbber {
display: block; display: block;
margin-bottom: 14px; margin-bottom: 4px;
margin-top: 8px; margin-top: 8px;
} }
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
-webkit-box-align: center; -webkit-box-align: center;
display: -webkit-box; display: -webkit-box;
height: 28px; height: 28px;
margin-bottom: 10px;
} }
.destination-settings-box.stale { .destination-settings-box.stale {
...@@ -25,7 +24,7 @@ ...@@ -25,7 +24,7 @@
} }
#destination-settings .destination-settings-change-button { #destination-settings .destination-settings-change-button {
margin-bottom: 10px; margin: 10px 0;
} }
.destination-settings-icon { .destination-settings-icon {
......
...@@ -140,8 +140,9 @@ cr.define('print_preview', function() { ...@@ -140,8 +140,9 @@ cr.define('print_preview', function() {
} }
setIsVisible( setIsVisible(
this.getChildElement('.throbber-container'), destination == null); this.getChildElement('.throbber-container'),
setIsVisible(destinationSettingsBoxEl, destination != null); this.destinationStore_.isAutoSelectDestinationInProgress);
setIsVisible(destinationSettingsBoxEl, !!destination);
}, },
onSelectedDestinationNameSet_: function() { onSelectedDestinationNameSet_: function() {
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "base/threading/thread.h" #include "base/threading/thread.h"
#include "base/threading/thread_restrictions.h" #include "base/threading/thread_restrictions.h"
#include "base/values.h" #include "base/values.h"
#include "chrome/browser/app_mode/app_mode_utils.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/platform_util.h" #include "chrome/browser/platform_util.h"
#include "chrome/browser/printing/print_dialog_cloud.h" #include "chrome/browser/printing/print_dialog_cloud.h"
...@@ -182,6 +183,11 @@ const char kNumberFormat[] = "numberFormat"; ...@@ -182,6 +183,11 @@ const char kNumberFormat[] = "numberFormat";
// Name of a dictionary field specifying whether to print automatically in // Name of a dictionary field specifying whether to print automatically in
// kiosk mode. See http://crbug.com/31395. // kiosk mode. See http://crbug.com/31395.
const char kPrintAutomaticallyInKioskMode[] = "printAutomaticallyInKioskMode"; const char kPrintAutomaticallyInKioskMode[] = "printAutomaticallyInKioskMode";
// Dictionary field to indicate whether Chrome is running in forced app (app
// kiosk) mode. It's not the same as desktop Chrome kiosk (the one above).
const char kAppKioskMode[] = "appKioskMode";
// Dictionary field to store Cloud Print base URL.
const char kCloudPrintUrl[] = "cloudPrintUrl";
#if defined(OS_WIN) #if defined(OS_WIN)
const char kHidePrintWithSystemDialogLink[] = "hidePrintWithSystemDialogLink"; const char kHidePrintWithSystemDialogLink[] = "hidePrintWithSystemDialogLink";
#endif #endif
...@@ -1195,6 +1201,8 @@ void PrintPreviewHandler::SendInitialSettings( ...@@ -1195,6 +1201,8 @@ void PrintPreviewHandler::SendInitialSettings(
base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess();
initial_settings.SetBoolean(kPrintAutomaticallyInKioskMode, initial_settings.SetBoolean(kPrintAutomaticallyInKioskMode,
cmdline->HasSwitch(switches::kKioskModePrinting)); cmdline->HasSwitch(switches::kKioskModePrinting));
initial_settings.SetBoolean(kAppKioskMode,
chrome::IsRunningInForcedAppMode());
#if defined(OS_WIN) #if defined(OS_WIN)
// In Win8 metro, the system print dialog can only open on the desktop. Doing // In Win8 metro, the system print dialog can only open on the desktop. Doing
// so will cause the browser to appear hung, so we don't show the link in // so will cause the browser to appear hung, so we don't show the link in
...@@ -1251,9 +1259,11 @@ void PrintPreviewHandler::SendCloudPrintEnabled() { ...@@ -1251,9 +1259,11 @@ void PrintPreviewHandler::SendCloudPrintEnabled() {
preview_web_contents()->GetBrowserContext()); preview_web_contents()->GetBrowserContext());
PrefService* prefs = profile->GetPrefs(); PrefService* prefs = profile->GetPrefs();
if (prefs->GetBoolean(prefs::kCloudPrintSubmitEnabled)) { if (prefs->GetBoolean(prefs::kCloudPrintSubmitEnabled)) {
GURL gcp_url(cloud_devices::GetCloudPrintURL()); base::DictionaryValue settings;
base::StringValue gcp_url_value(gcp_url.spec()); settings.SetString(kCloudPrintUrl,
web_ui()->CallJavascriptFunction("setUseCloudPrint", gcp_url_value); GURL(cloud_devices::GetCloudPrintURL()).spec());
settings.SetBoolean(kAppKioskMode, chrome::IsRunningInForcedAppMode());
web_ui()->CallJavascriptFunction("setUseCloudPrint", settings);
} }
} }
......
...@@ -115,6 +115,7 @@ PrintPreviewWebUITest.prototype = { ...@@ -115,6 +115,7 @@ PrintPreviewWebUITest.prototype = {
this.initialSettings_ = new print_preview.NativeInitialSettings( this.initialSettings_ = new print_preview.NativeInitialSettings(
false /*isInKioskAutoPrintMode*/, false /*isInKioskAutoPrintMode*/,
false /*isInAppKioskMode*/,
false /*hidePrintWithSystemDialogLink*/, false /*hidePrintWithSystemDialogLink*/,
',' /*thousandsDelimeter*/, ',' /*thousandsDelimeter*/,
'.' /*decimalDelimeter*/, '.' /*decimalDelimeter*/,
...@@ -475,9 +476,8 @@ TEST_F('PrintPreviewWebUITest', 'CustomMarginsControlsCheck', function() { ...@@ -475,9 +476,8 @@ TEST_F('PrintPreviewWebUITest', 'CustomMarginsControlsCheck', function() {
}); });
// Page layout has zero margins. Hide header and footer option. // Page layout has zero margins. Hide header and footer option.
TEST_F('PrintPreviewWebUITest', TEST_F('PrintPreviewWebUITest', 'PageLayoutHasNoMarginsHideHeaderFooter',
'PageLayoutHasNoMarginsHideHeaderFooter', function() {
function() {
var initialSettingsSetEvent = var initialSettingsSetEvent =
new Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET); new Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET);
initialSettingsSetEvent.initialSettings = this.initialSettings_; initialSettingsSetEvent.initialSettings = this.initialSettings_;
...@@ -508,9 +508,8 @@ TEST_F('PrintPreviewWebUITest', ...@@ -508,9 +508,8 @@ TEST_F('PrintPreviewWebUITest',
}); });
// Page layout has half-inch margins. Show header and footer option. // Page layout has half-inch margins. Show header and footer option.
TEST_F('PrintPreviewWebUITest', TEST_F('PrintPreviewWebUITest', 'PageLayoutHasMarginsShowHeaderFooter',
'PageLayoutHasMarginsShowHeaderFooter', function() {
function() {
var initialSettingsSetEvent = var initialSettingsSetEvent =
new Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET); new Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET);
initialSettingsSetEvent.initialSettings = this.initialSettings_; initialSettingsSetEvent.initialSettings = this.initialSettings_;
...@@ -649,12 +648,12 @@ TEST_F('PrintPreviewWebUITest', 'TestColorSettingsColor', function() { ...@@ -649,12 +648,12 @@ TEST_F('PrintPreviewWebUITest', 'TestColorSettingsColor', function() {
this.setUpPreview(); this.setUpPreview();
var capsSetEvent = var capsSetEvent =
new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET);
capsSetEvent.settingsInfo = getCddTemplate("FooDevice"); capsSetEvent.settingsInfo = getCddTemplate("FooDevice");
capsSetEvent.settingsInfo.capabilities.printer.color = { capsSetEvent.settingsInfo.capabilities.printer.color = {
"option": [ "option": [
{"is_default": true, "type": "STANDARD_COLOR"} {"is_default": true, "type": "STANDARD_COLOR"}
] ]
}; };
this.nativeLayer_.dispatchEvent(capsSetEvent); this.nativeLayer_.dispatchEvent(capsSetEvent);
...@@ -669,9 +668,9 @@ TEST_F('PrintPreviewWebUITest', 'TestColorSettingsCustomColor', function() { ...@@ -669,9 +668,9 @@ TEST_F('PrintPreviewWebUITest', 'TestColorSettingsCustomColor', function() {
new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET);
capsSetEvent.settingsInfo = getCddTemplate("FooDevice"); capsSetEvent.settingsInfo = getCddTemplate("FooDevice");
capsSetEvent.settingsInfo.capabilities.printer.color = { capsSetEvent.settingsInfo.capabilities.printer.color = {
"option": [ "option": [
{"is_default": true, "type": "CUSTOM_COLOR", "vendor_id": "42"} {"is_default": true, "type": "CUSTOM_COLOR", "vendor_id": "42"}
] ]
}; };
this.nativeLayer_.dispatchEvent(capsSetEvent); this.nativeLayer_.dispatchEvent(capsSetEvent);
...@@ -709,10 +708,10 @@ TEST_F('PrintPreviewWebUITest', ...@@ -709,10 +708,10 @@ TEST_F('PrintPreviewWebUITest',
new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET);
capsSetEvent.settingsInfo = getCddTemplate("FooDevice"); capsSetEvent.settingsInfo = getCddTemplate("FooDevice");
capsSetEvent.settingsInfo.capabilities.printer.color = { capsSetEvent.settingsInfo.capabilities.printer.color = {
"option": [ "option": [
{"is_default": true, "type": "STANDARD_MONOCHROME"}, {"is_default": true, "type": "STANDARD_MONOCHROME"},
{"type": "STANDARD_COLOR"} {"type": "STANDARD_COLOR"}
] ]
}; };
this.nativeLayer_.dispatchEvent(capsSetEvent); this.nativeLayer_.dispatchEvent(capsSetEvent);
...@@ -727,13 +726,13 @@ TEST_F('PrintPreviewWebUITest', ...@@ -727,13 +726,13 @@ TEST_F('PrintPreviewWebUITest',
this.setUpPreview(); this.setUpPreview();
var capsSetEvent = var capsSetEvent =
new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET);
capsSetEvent.settingsInfo = getCddTemplate("FooDevice"); capsSetEvent.settingsInfo = getCddTemplate("FooDevice");
capsSetEvent.settingsInfo.capabilities.printer.color = { capsSetEvent.settingsInfo.capabilities.printer.color = {
"option": [ "option": [
{"type": "CUSTOM_MONOCHROME", "vendor_id": "42"}, {"type": "CUSTOM_MONOCHROME", "vendor_id": "42"},
{"is_default": true, "type": "CUSTOM_COLOR", "vendor_id": "43"} {"is_default": true, "type": "CUSTOM_COLOR", "vendor_id": "43"}
] ]
}; };
this.nativeLayer_.dispatchEvent(capsSetEvent); this.nativeLayer_.dispatchEvent(capsSetEvent);
......
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