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..87e9fca92e73b66f9d0263e0af560bd7eb2bc13d 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,7 @@ cr.define('print_preview', function() { |
onPreviewGenerationDone_: function() { |
this.isPreviewGenerationInProgress_ = false; |
this.printHeader_.isPrintButtonEnabled = true; |
+ chrome.send('UILoaded'); |
Lei Zhang
2014/06/17 21:57:33
You may want to rename "UiLoaded" to "UiLoadedForT
ivandavid
2014/06/17 22:59:16
Done.
|
this.printIfReady_(); |
}, |
@@ -889,6 +893,67 @@ 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) { |
+ landscape.click(); |
+ } |
+ } else { |
+ chrome.send('UILoaded'); |
Lei Zhang
2014/06/17 21:57:33
Why not click the portrait button in this case? Th
ivandavid
2014/06/17 22:59:16
I didn't think it would work because its already s
|
+ } |
+ } |
+ 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('UILoaded'); |
+ } |
+ } |
+ else if (event.messageName == 'HEADERS_AND_FOOTERS') { |
+ if (event.headersAndFooters == false) { |
+ var headerFooterCheckbox = document.getElementsByClassName( |
+ 'header-footer-checkbox'); |
+ if (headerFooterCheckbox) { |
+ this.otherOptionsSettings_.headerFooterCheckbox_.click(); |
+ } |
+ } else { |
+ chrome.send('UILoaded'); |
+ } |
+ } |
+ 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('UILoaded'); |
+ } |
+ } |
+ 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; |
+ chrome.send('UILoaded'); |
+ } else { |
+ chrome.send('UILoaded'); |
+ } |
+ } |
+ }, |
+ |
/** |
* Called when the open-cloud-print-dialog link is clicked. Opens the Google |
* Cloud Print web dialog. |