Index: chrome/browser/resources/print_preview/print_preview.js |
diff --git a/chrome/browser/resources/print_preview/print_preview.js b/chrome/browser/resources/print_preview/print_preview.js |
index ac3a0ab789135db2746d6fe3b522398b759867d9..330c11e90b118ba4f31b8830c460e4467c11ba4b 100644 |
--- a/chrome/browser/resources/print_preview/print_preview.js |
+++ b/chrome/browser/resources/print_preview/print_preview.js |
@@ -285,7 +285,10 @@ cr.define('print_preview', function() { |
this.nativeLayer_, |
print_preview.NativeLayer.EventType.PRIVET_PRINT_FAILED, |
this.onPrivetPrintFailed_.bind(this)); |
- |
+ this.tracker.add( |
+ this.nativeLayer_, |
+ print_preview.NativeLayer.EventType.MANIPULATE_SETTINGS, |
+ this.onManipulateSettings_.bind(this)); |
this.tracker.add( |
$('system-dialog-link'), |
@@ -691,6 +694,9 @@ cr.define('print_preview', function() { |
onPreviewGenerationDone_: function() { |
this.isPreviewGenerationInProgress_ = false; |
this.printHeader_.isPrintButtonEnabled = true; |
+ if (global['onManipulateSettings']) { |
ivandavid
2014/06/17 22:59:16
This makes it so that the chrome.send() is only us
|
+ chrome.send('UILoadedForTest'); |
Lei Zhang
2014/06/17 23:22:20
Although this is just 1 line, consider putting it
ivandavid
2014/06/18 00:25:59
Done. Made a function in native_layer.js since tha
|
+ } |
this.printIfReady_(); |
}, |
@@ -889,6 +895,72 @@ cr.define('print_preview', function() { |
localStrings.getString('couldNotPrint')); |
}, |
+ onManipulateSettings_: function(event) { |
+ if (event.messageName == 'SAVE_AS_PDF') { |
+ this.destinationStore_.selectDefaultDestination_(); |
+ } |
+ else if (event.messageName == 'LAYOUT_SETTINGS') { |
+ if (event.layoutSettings == 'LANDSCAPE') { |
+ var landscape = document.getElementsByClassName( |
+ 'layout-settings-landscape-radio')[0]; |
+ if (landscape) { |
Lei Zhang
2014/06/17 23:22:20
So if your source page is a PDF and not HTML, then
|
+ landscape.click(); |
+ } |
+ } else if (event.layoutSettings == 'PORTRAIT') { |
+ //chrome.send('UILoadedForTest'); |
Lei Zhang
2014/06/17 23:22:20
remove
|
+ var portrait = document.getElementsByClassName( |
+ 'layout-settings-portrait-radio')[0]; |
+ if (portrait) { |
+ portrait.click(); |
+ } |
+ } |
+ } |
+ else if (event.messageName == 'PAGE_NUMBERS') { |
+ if (event.pageNumbers != '') { |
+ var pageSettingsCustomInput = document.getElementsByClassName( |
+ 'page-settings-custom-input')[0]; |
+ if (pageSettingsCustomInput) { |
+ pageSettingsCustomInput.value = event.pageSettings; |
+ } |
+ } else { |
+ chrome.send('UILoadedForTest'); |
+ } |
+ } |
+ else if (event.messageName == 'HEADERS_AND_FOOTERS') { |
+ if (event.headersAndFooters == false) { |
Lei Zhang
2014/06/17 23:22:20
There's 2x2 matrix of possibilities, where the axi
|
+ var headerFooterCheckbox = document.getElementsByClassName( |
+ 'header-footer-checkbox'); |
+ if (headerFooterCheckbox) { |
+ this.otherOptionsSettings_.headerFooterCheckbox_.click(); |
+ } |
+ } else { |
+ chrome.send('UILoadedForTest'); |
+ } |
+ } |
+ else if (event.messageName == 'BACKGROUND_COLORS_AND_IMAGES') { |
+ if (event.backgroundColorsAndImages == true) { |
+ var backgroundCheckbox = document.getElementsByClassName( |
+ 'css-background-checkbox')[0]; |
+ if (backgroundCheckbox) { |
+ this.otherOptionsSettings_.cssBackgroundCheckbox_.click(); |
+ } |
+ } else { |
+ chrome.send('UILoadedForTest'); |
+ } |
+ } |
+ else if (event.messageName == 'MARGINS') { |
+ var marginSettingsSelect = |
+ document.getElementsByClassName('margin-settings-select')[0]; |
+ var index = parseInt(event.margins, 10); |
+ if (marginSettingsSelect && index != 0) { |
+ marginSettingsSelect.selectedIndex = index; |
Lei Zhang
2014/06/17 23:22:20
Is this sufficient to cause the PDF to re-render?
ivandavid
2014/06/18 00:25:59
It wasn't. I 'fired' on event which now causes the
|
+ chrome.send('UILoadedForTest'); |
Lei Zhang
2014/06/17 23:22:20
nit: If you compare this to line 959, one of the t
|
+ } else { |
+ chrome.send('UILoadedForTest'); |
+ } |
+ } |
+ }, |
+ |
/** |
* Called when the open-cloud-print-dialog link is clicked. Opens the Google |
* Cloud Print web dialog. |