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 | |
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')
7 files changed, 58 insertions, 12 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index f990f4e..cd93f25 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -7255,6 +7255,9 @@ The following plug-in is unresponsive: <ph name="PLUGIN_NAME">$1 <message name="IDS_PRINT_PREVIEW_CLOUD_DIALOG_OPTION" desc="Option allowing the user to access advanced printer settings using the cloud print dialog instead of printing through the print preview mechanism."> Print using <ph name="CLOUD_PRINT_NAME">$1<ex>Google Cloud Print</ex></ph> dialog... <ph name="SHORTCUT_KEY">$2<ex>(Shift+Ctrl+P)</ex></ph> </message> + <message name="IDS_PRINT_PREVIEW_CLOUD_DIALOG_OPTION_NO_SHORTCUT" desc="Option allowing the user to access advanced printer settings using the cloud print dialog instead of printing through the print preview mechanism without a shortcut key."> + Print using <ph name="CLOUD_PRINT_NAME">$1<ex>Google Cloud Print</ex></ph> dialog... + </message> <message name="IDS_PRINT_PREVIEW_PAGE_RANGE_INSTRUCTION" desc="Instruction shown when the user enters an invalid page range."> Invalid page range, use <ph name="EXAMPLE_PAGE_RANGE">$1<ex>e.g. 1-5, 8, 11-13</ex></ph> </message> 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); } }; diff --git a/chrome/browser/ui/webui/print_preview/print_preview_data_source.cc b/chrome/browser/ui/webui/print_preview/print_preview_data_source.cc index 5d41df8..1f2c74f 100644 --- a/chrome/browser/ui/webui/print_preview/print_preview_data_source.cc +++ b/chrome/browser/ui/webui/print_preview/print_preview_data_source.cc @@ -93,7 +93,7 @@ void PrintPreviewDataSource::Init() { IDS_PRINT_PREVIEW_PAGE_LABEL_PLURAL); const string16 shortcut_text(UTF8ToUTF16(kAdvancedPrintShortcut)); #if defined(OS_CHROMEOS) - AddString("cloudPrintDialogOption", l10n_util::GetStringFUTF16( + AddString("systemDialogOption", l10n_util::GetStringFUTF16( IDS_PRINT_PREVIEW_CLOUD_DIALOG_OPTION, l10n_util::GetStringUTF16(IDS_GOOGLE_CLOUD_PRINT), shortcut_text)); @@ -102,6 +102,10 @@ void PrintPreviewDataSource::Init() { IDS_PRINT_PREVIEW_SYSTEM_DIALOG_OPTION, shortcut_text)); #endif + AddString("cloudPrintDialogOption", + l10n_util::GetStringFUTF16( + IDS_PRINT_PREVIEW_CLOUD_DIALOG_OPTION_NO_SHORTCUT, + l10n_util::GetStringUTF16(IDS_GOOGLE_CLOUD_PRINT))); #if defined(OS_MACOSX) AddLocalizedString("openPdfInPreviewOption", IDS_PRINT_PREVIEW_OPEN_PDF_IN_PREVIEW_APP); diff --git a/chrome/browser/ui/webui/print_preview/print_preview_handler.cc b/chrome/browser/ui/webui/print_preview/print_preview_handler.cc index b421fb2..7276389 100644 --- a/chrome/browser/ui/webui/print_preview/print_preview_handler.cc +++ b/chrome/browser/ui/webui/print_preview/print_preview_handler.cc @@ -279,6 +279,9 @@ void PrintPreviewHandler::RegisterMessages() { web_ui()->RegisterMessageCallback("reportDestinationEvent", base::Bind(&PrintPreviewHandler::HandleReportDestinationEvent, base::Unretained(this))); + web_ui()->RegisterMessageCallback("printWithCloudPrint", + base::Bind(&PrintPreviewHandler::HandlePrintWithCloudPrint, + base::Unretained(this))); } TabContents* PrintPreviewHandler::preview_tab_contents() const { @@ -420,7 +423,7 @@ void PrintPreviewHandler::HandlePrint(const ListValue* args) { } else if (print_to_pdf) { HandlePrintToPdf(*settings); } else if (is_cloud_dialog) { - HandlePrintWithCloudPrint(); + HandlePrintWithCloudPrint(NULL); } else { ReportPrintSettingsStats(*settings); ReportUserActionHistogram(PRINT_TO_PRINTER); @@ -550,7 +553,7 @@ void PrintPreviewHandler::HandleSignin(const ListValue* /*args*/) { base::Bind(&PrintPreviewHandler::OnSigninComplete, AsWeakPtr())); } -void PrintPreviewHandler::HandlePrintWithCloudPrint() { +void PrintPreviewHandler::HandlePrintWithCloudPrint(const ListValue* /*args*/) { // Record the number of times the user asks to print via cloud print // instead of the print preview dialog. ReportStats(); diff --git a/chrome/browser/ui/webui/print_preview/print_preview_handler.h b/chrome/browser/ui/webui/print_preview/print_preview_handler.h index b9d4a8d..71cdf9d 100644 --- a/chrome/browser/ui/webui/print_preview/print_preview_handler.h +++ b/chrome/browser/ui/webui/print_preview/print_preview_handler.h @@ -138,8 +138,8 @@ class PrintPreviewHandler : public content::WebUIMessageHandler, // |args| is unused. void HandleManagePrinters(const base::ListValue* args); - // Asks the browser to show the cloud print dialog. - void HandlePrintWithCloudPrint(); + // Asks the browser to show the cloud print dialog. |args| is unused. + void HandlePrintWithCloudPrint(const base::ListValue* args); // Asks the browser for several settings that are needed before the first // preview is displayed. |