summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormaruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-28 15:27:12 +0000
committermaruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-28 15:27:12 +0000
commit378f0e82d196573004b1f0efe58ccc067774368d (patch)
treee7c6b4b13dc4a7940d2ceb4afbfe1e39450b6fe3
parent7f0f68158d4c9806ac5f093d17007b1d6cbd0db2 (diff)
downloadchromium_src-378f0e82d196573004b1f0efe58ccc067774368d.zip
chromium_src-378f0e82d196573004b1f0efe58ccc067774368d.tar.gz
chromium_src-378f0e82d196573004b1f0efe58ccc067774368d.tar.bz2
Should handle the events when no printer is detected on local
machineGetDefaultPrintSettings was returning an empty struct because no printer is installed. Checking when its empty will allow us to know that a printer is missing on that system. There is clearly no other way to do this, unless we do not do all those dchecks on dpi and other struct members.BUG=6835TEST=Tested only on windows, since linux/mac printing not even implemented. Removed all printer drivers, opened chromium, and ran a print job, popup dialog appeared stating no printer installed. Installed my printer drivers again, print dialog appeared. Patch contributed by Mohamed Mansour <m0.interactive@gmail.com> Review: http://codereview.chromium.org/100023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14731 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/app/generated_resources.grd5
-rw-r--r--chrome/common/render_messages.h6
-rw-r--r--chrome/renderer/render_view.cc9
3 files changed, 19 insertions, 1 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index ad9f703..27ca552 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -2363,10 +2363,13 @@ each locale. -->
Update server not available (error: <ph name="ERROR_NUMBER">$1<ex>1</ex></ph>)
</message>
- <!-- Print preview UI -->
+ <!-- Print -->
<message name="IDS_DEFAULT_PRINT_DOCUMENT_TITLE" desc="Default title for a print document">
Untitled Document
</message>
+ <message name="IDS_DEFAULT_PRINTER_NOT_FOUND_WARNING_TITLE" desc="Title of the warning dialog when no when no printer is available">
+ No printer found, Please install a printer.
+ </message>
<!-- Tabs -->
<message name="IDS_TAB_LOADING_TITLE" desc="The text to be displayed in the title of a tab before a title is discovered.">
diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h
index e0c6004..c689365 100644
--- a/chrome/common/render_messages.h
+++ b/chrome/common/render_messages.h
@@ -309,6 +309,12 @@ struct ViewMsg_Print_Params {
max_shrink == rhs.max_shrink &&
desired_dpi == rhs.desired_dpi;
}
+
+ // Checking if the current params is empty. Just initialized after a memset.
+ bool IsEmpty() const {
+ return !document_cookie && !desired_dpi && !max_shrink && !min_shrink &&
+ !dpi && printable_size.IsEmpty();
+ }
};
struct ViewMsg_PrintPage_Params {
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index 0f5b80e..bce6d4c 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -2340,6 +2340,15 @@ void RenderView::ScriptedPrint(WebFrame* frame) {
new ViewHostMsg_GetDefaultPrintSettings(routing_id_, &default_settings);
if (Send(msg)) {
msg = NULL;
+ // Check if the printer returned any settings, if the settings is empty, we
+ // can safely assume there are no printer drivers configured. So we safely
+ // terminate.
+ if (default_settings.IsEmpty()) {
+ RunJavaScriptAlert(frame,
+ l10n_util::GetString(IDS_DEFAULT_PRINTER_NOT_FOUND_WARNING_TITLE));
+ return;
+ }
+
// Continue only if the settings are valid.
if (default_settings.dpi && default_settings.document_cookie) {
int expected_pages_count = 0;