summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/printing/print_preview_tab_controller.cc6
-rw-r--r--chrome/browser/resources/print_preview.html18
-rw-r--r--chrome/browser/resources/print_preview.js15
-rw-r--r--chrome/browser/ui/webui/print_preview_ui.cc4
-rw-r--r--chrome/browser/ui/webui/print_preview_ui.h4
5 files changed, 41 insertions, 6 deletions
diff --git a/chrome/browser/printing/print_preview_tab_controller.cc b/chrome/browser/printing/print_preview_tab_controller.cc
index 24c4313..4c6352e 100644
--- a/chrome/browser/printing/print_preview_tab_controller.cc
+++ b/chrome/browser/printing/print_preview_tab_controller.cc
@@ -10,6 +10,7 @@
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_navigator.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
+#include "chrome/browser/ui/webui/print_preview_ui.h"
#include "chrome/common/url_constants.h"
#include "content/browser/tab_contents/tab_contents.h"
#include "content/common/notification_details.h"
@@ -139,6 +140,11 @@ void PrintPreviewTabController::Observe(NotificationType type,
// Erase the map entry.
preview_tab_map_.erase(source_tab);
} else {
+ // Initiator tab is closed. Disable the controls in preview tab.
+ PrintPreviewUI* print_preview_ui =
+ static_cast<PrintPreviewUI*>(preview_tab->web_ui());
+ print_preview_ui->DisablePrintPreviewSettings();
+
// |source_tab| is an initiator tab, update the map entry.
preview_tab_map_[preview_tab] = NULL;
}
diff --git a/chrome/browser/resources/print_preview.html b/chrome/browser/resources/print_preview.html
index ab7066b..05b6b7d 100644
--- a/chrome/browser/resources/print_preview.html
+++ b/chrome/browser/resources/print_preview.html
@@ -35,8 +35,10 @@
<h3 i18n-content="pagesLabel"></h3>
<div class="options-block">
<div>
- <input name="pages" checked type="radio" id="all-pages">
- <label for="all-pages" i18n-content="optionAllPages"></label>
+ <input name="pages" checked type="radio" id="all-pages"
+ label="all-pages-label">
+ <label for="all-pages" id="all-pages-label"
+ i18n-content="optionAllPages"></label>
</div>
<div>
<input name="pages" type="radio" id="print-pages">
@@ -89,12 +91,16 @@
<h3 i18n-content="layoutLabel"></h3>
<div class="options-block">
<div>
- <input type="radio" name="layout" checked id="portrait">
- <label for="portrait" i18n-content="optionPortrait"></label>
+ <input type="radio" name="layout" checked id="portrait"
+ label="portrait-label">
+ <label for="portrait" id="portrait-label"
+ i18n-content="optionPortrait"></label>
</div>
<div>
- <input type="radio" name="layout" id="landscape">
- <label for="landscape" i18n-content="optionLandscape"></label>
+ <input type="radio" name="layout" id="landscape"
+ label="landscape-label">
+ <label for="landscape" id="landscape-label"
+ i18n-content="optionLandscape"></label>
</div>
</div>
</div>
diff --git a/chrome/browser/resources/print_preview.js b/chrome/browser/resources/print_preview.js
index 395af97..1ea1d5b 100644
--- a/chrome/browser/resources/print_preview.js
+++ b/chrome/browser/resources/print_preview.js
@@ -61,6 +61,18 @@ function onLoad() {
}
/**
+ * Disables the controls which need the initiator tab to generate preview
+ * data. This function is called when the initiator tab is closed.
+ */
+function disablePreviewControls() {
+ var controlIDs = ['landscape', 'portrait', 'all-pages', 'print-pages',
+ 'individual-pages'];
+ var controlCount = controlIDs.length;
+ for (var i = 0; i < controlCount; i++)
+ setControlAndLabelDisabled($(controlIDs[i]), true);
+}
+
+/**
* Gets the selected printer capabilities and updates the controls accordingly.
*/
function updateControlsWithSelectedPrinterCapabilities() {
@@ -110,6 +122,9 @@ function updateWithPrinterCapabilities(settingInfo) {
function setControlAndLabelDisabled(controlElm, disable) {
controlElm.disabled = disable;
var label = $(controlElm.getAttribute('label'));
+ if (label == undefined)
+ return;
+
if (disable)
label.classList.add('disabled-label-text');
else
diff --git a/chrome/browser/ui/webui/print_preview_ui.cc b/chrome/browser/ui/webui/print_preview_ui.cc
index 3224f63..232c11c 100644
--- a/chrome/browser/ui/webui/print_preview_ui.cc
+++ b/chrome/browser/ui/webui/print_preview_ui.cc
@@ -29,6 +29,10 @@ PrintPreviewUIHTMLSource* PrintPreviewUI::html_source() {
return html_source_.get();
}
+void PrintPreviewUI::DisablePrintPreviewSettings() {
+ CallJavascriptFunction("disablePreviewControls");
+}
+
void PrintPreviewUI::PreviewDataIsAvailable(int expected_pages_count,
const string16& job_title) {
FundamentalValue pages_count(expected_pages_count);
diff --git a/chrome/browser/ui/webui/print_preview_ui.h b/chrome/browser/ui/webui/print_preview_ui.h
index 6f63c8f..eb23e68 100644
--- a/chrome/browser/ui/webui/print_preview_ui.h
+++ b/chrome/browser/ui/webui/print_preview_ui.h
@@ -24,6 +24,10 @@ class PrintPreviewUI : public WebUI {
void PreviewDataIsAvailable(int expected_pages_count,
const string16& job_title);
+ // Notify the Web UI that initiator tab is closed, so we can disable all
+ // the controls that needs initiator tab for generating the preview data.
+ void DisablePrintPreviewSettings();
+
private:
scoped_refptr<PrintPreviewUIHTMLSource> html_source_;