summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorrltoscano@google.com <rltoscano@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-15 20:15:54 +0000
committerrltoscano@google.com <rltoscano@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-15 20:15:54 +0000
commit6b73f838e97375dd79cdffe968862c2e285d75f6 (patch)
tree077e5014c18ba0e72a1331d35c435e1ad0780a9f /chrome/browser
parenta2d4c3299bdb4b7b9c009f285ef78cbdcd09d8ff (diff)
downloadchromium_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')
-rw-r--r--chrome/browser/resources/print_preview/native_layer.js5
-rw-r--r--chrome/browser/resources/print_preview/print_preview.html9
-rw-r--r--chrome/browser/resources/print_preview/print_preview.js36
-rw-r--r--chrome/browser/ui/webui/print_preview/print_preview_data_source.cc6
-rw-r--r--chrome/browser/ui/webui/print_preview/print_preview_handler.cc7
-rw-r--r--chrome/browser/ui/webui/print_preview/print_preview_handler.h4
6 files changed, 55 insertions, 12 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);
}
};
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.