diff options
author | rltoscano@google.com <rltoscano@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-15 20:15:54 +0000 |
---|---|---|
committer | rltoscano@google.com <rltoscano@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-15 20:15:54 +0000 |
commit | 6b73f838e97375dd79cdffe968862c2e285d75f6 (patch) | |
tree | 077e5014c18ba0e72a1331d35c435e1ad0780a9f /chrome/browser/resources/print_preview | |
parent | a2d4c3299bdb4b7b9c009f285ef78cbdcd09d8ff (diff) | |
download | chromium_src-6b73f838e97375dd79cdffe968862c2e285d75f6.zip chromium_src-6b73f838e97375dd79cdffe968862c2e285d75f6.tar.gz chromium_src-6b73f838e97375dd79cdffe968862c2e285d75f6.tar.bz2 |
Adds a 'Print with Cloud Print' link when cloud printers are selected.
BUG=132899
TEST=Make sure the "Print with Google Cloud Print" link appears when a cloud printer is selected. This link should be permanently visible on ChromeOS.
Review URL: https://chromiumcodereview.appspot.com/10543169
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@142462 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/resources/print_preview')
3 files changed, 43 insertions, 7 deletions
diff --git a/chrome/browser/resources/print_preview/native_layer.js b/chrome/browser/resources/print_preview/native_layer.js index b1151e6..712bf42 100644 --- a/chrome/browser/resources/print_preview/native_layer.js +++ b/chrome/browser/resources/print_preview/native_layer.js @@ -279,6 +279,11 @@ cr.define('print_preview', function() { chrome.send('showSystemDialog'); }, + /** Shows Google Cloud Print's web-based print dialog. */ + startShowCloudPrintDialog: function() { + chrome.send('printWithCloudPrint'); + }, + /** Closes the print preview dialog. */ startCloseDialog: function() { chrome.send('closePrintPreviewTab'); diff --git a/chrome/browser/resources/print_preview/print_preview.html b/chrome/browser/resources/print_preview/print_preview.html index 34a49b2..739932e 100644 --- a/chrome/browser/resources/print_preview/print_preview.html +++ b/chrome/browser/resources/print_preview/print_preview.html @@ -51,17 +51,20 @@ </div> <div id="link-container"> <div> - <button id="cloud-print-dialog-link" class="link-button navbar-link" - hidden i18n-content="cloudPrintDialogOption"></button> <button id="system-dialog-link" class="link-button navbar-link" hidden i18n-content="systemDialogOption"></button> - <div id="dialog-throbber" hidden class="throbber"></div> + <div id="system-dialog-throbber" hidden class="throbber"></div> </div> <div> <button id="open-pdf-in-preview-link" class="link-button navbar-link" hidden i18n-content="openPdfInPreviewOption"></button> <div id="open-preview-app-throbber" hidden class="throbber"></div> </div> + <div> + <button id="cloud-print-dialog-link" class="link-button navbar-link" + hidden i18n-content="cloudPrintDialogOption"></button> + <div id="cloud-print-dialog-throbber" hidden class="throbber"></div> + </div> </div> </div> <include src="search/destination_search.html"/> diff --git a/chrome/browser/resources/print_preview/print_preview.js b/chrome/browser/resources/print_preview/print_preview.js index b0b3655..b3a7218 100644 --- a/chrome/browser/resources/print_preview/print_preview.js +++ b/chrome/browser/resources/print_preview/print_preview.js @@ -247,7 +247,7 @@ cr.define('print_preview', function() { this.tracker.add( $('cloud-print-dialog-link'), 'click', - this.openSystemPrintDialog_.bind(this)); + this.onCloudPrintDialogLinkClick_.bind(this)); this.tracker.add( $('open-pdf-in-preview-link'), 'click', @@ -275,6 +275,10 @@ cr.define('print_preview', function() { print_preview.DestinationStore.EventType. SELECTED_DESTINATION_CAPABILITIES_READY, this.printIfReady_.bind(this)); + this.tracker.add( + this.destinationStore_, + print_preview.DestinationStore.EventType.DESTINATION_SELECT, + this.onDestinationSelect_.bind(this)); this.tracker.add( this.printHeader_, @@ -319,8 +323,6 @@ cr.define('print_preview', function() { this.otherOptionsSettings_.decorate($('other-options-settings')); this.previewArea_.decorate($('preview-area')); - setIsVisible($('cloud-print-dialog-link'), cr.isChromeOS); - setIsVisible($('system-dialog-link'), !cr.isChromeOS); setIsVisible($('open-pdf-in-preview-link'), cr.isMac); }, @@ -419,7 +421,7 @@ cr.define('print_preview', function() { openSystemPrintDialog_: function() { assert(this.uiState_ == PrintPreview.UiState_.READY, 'Opening system dialog when not in ready state: ' + this.uiState_); - setIsVisible($('dialog-throbber'), true); + setIsVisible($('system-dialog-throbber'), true); this.setIsEnabled_(false); this.uiState_ = PrintPreview.UiState_.OPENING_NATIVE_PRINT_DIALOG; this.nativeLayer_.startShowSystemDialog(); @@ -704,6 +706,32 @@ cr.define('print_preview', function() { */ onDisableScaling_: function() { this.printTicketStore_.updateFitToPage(false); + }, + + /** + * Called when the open-cloud-print-dialog link is clicked. Opens the Google + * Cloud Print web dialog. + * @private + */ + onCloudPrintDialogLinkClick_: function() { + assert(this.uiState_ == PrintPreview.UiState_.READY, + 'Opening Google Cloud Print dialog when not in ready state: ' + + this.uiState_); + setIsVisible($('cloud-print-dialog-throbber'), true); + this.setIsEnabled_(false); + this.uiState_ = PrintPreview.UiState_.OPENING_NATIVE_PRINT_DIALOG; + this.nativeLayer_.startShowCloudPrintDialog(); + }, + + /** + * Called when a print destination is selected. Shows/hides the "Print with + * Cloud Print" link in the navbar. + * @private + */ + onDestinationSelect_: function() { + var selectedDest = this.destinationStore_.selectedDestination; + setIsVisible($('cloud-print-dialog-link'), + !cr.isChromeOS && !selectedDest.isLocal); } }; |