Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(250)

Unified Diff: chrome/browser/ui/webui/print_preview_handler.cc

Issue 6533006: Print Preview: Hook up the print button to initiate printing without displaying a print dialog. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Addressed review comments. Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/webui/print_preview_handler.h ('k') | chrome/common/render_messages_internal.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/print_preview_handler.cc
diff --git a/chrome/browser/ui/webui/print_preview_handler.cc b/chrome/browser/ui/webui/print_preview_handler.cc
index 4526b07af86ac774a1c9675ed02ed278da44d679..2898519314ac857876042f26677d70bfe579dc2e 100644
--- a/chrome/browser/ui/webui/print_preview_handler.cc
+++ b/chrome/browser/ui/webui/print_preview_handler.cc
@@ -4,10 +4,11 @@
#include "chrome/browser/ui/webui/print_preview_handler.h"
+#include "base/json/json_reader.h"
#include "base/threading/thread.h"
#include "base/values.h"
-#include "content/browser/renderer_host/render_view_host.h"
#include "content/browser/browser_thread.h"
+#include "content/browser/renderer_host/render_view_host.h"
#include "printing/backend/print_backend.h"
class EnumeratePrintersTaskProxy
@@ -79,8 +80,29 @@ void PrintPreviewHandler::HandleGetPrinters(const ListValue*) {
&EnumeratePrintersTaskProxy::EnumeratePrinters));
}
-void PrintPreviewHandler::HandlePrint(const ListValue*) {
- web_ui_->GetRenderViewHost()->PrintForPrintPreview();
+void PrintPreviewHandler::HandlePrint(const ListValue* args) {
+ std::string json_str;
+ if (!args->GetString(0, &json_str)) {
+ NOTREACHED() << "Could not read JSON argument";
+ return;
+ }
+
+ if (json_str.empty()) {
+ NOTREACHED() << "Empty print job settings";
+ return;
+ }
+ scoped_ptr<DictionaryValue> settings(static_cast<DictionaryValue*>(
+ base::JSONReader::Read(json_str, false)));
+ if (!settings.get() || !settings->IsType(Value::TYPE_DICTIONARY)) {
+ NOTREACHED() << "Print job settings must be a dictionary.";
+ return;
+ }
+
+ if (settings->empty()) {
+ NOTREACHED() << "Print job settings dictionary is empty";
+ return;
+ }
+ web_ui_->GetRenderViewHost()->PrintForPrintPreview(*settings);
}
void PrintPreviewHandler::SendPrinterList(const ListValue& printers) {
« no previous file with comments | « chrome/browser/ui/webui/print_preview_handler.h ('k') | chrome/common/render_messages_internal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698