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

Side by Side Diff: chrome/browser/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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/webui/print_preview_handler.h" 5 #include "chrome/browser/webui/print_preview_handler.h"
6 6
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "chrome/browser/webui/web_ui_util.h"
arv (Not doing code reviews) 2011/02/24 23:21:03 This is no longer needed
kmadhusu 2011/03/01 01:55:50 Done.
8 #include "chrome/browser/renderer_host/render_view_host.h" 9 #include "chrome/browser/renderer_host/render_view_host.h"
9 #include "printing/backend/print_backend.h" 10 #include "printing/backend/print_backend.h"
10 11
11 PrintPreviewHandler::PrintPreviewHandler() 12 PrintPreviewHandler::PrintPreviewHandler()
12 : print_backend_(printing::PrintBackend::CreateInstance(NULL)) { 13 : print_backend_(printing::PrintBackend::CreateInstance(NULL)) {
13 } 14 }
14 15
15 PrintPreviewHandler::~PrintPreviewHandler() { 16 PrintPreviewHandler::~PrintPreviewHandler() {
16 } 17 }
17 18
(...skipping 10 matching lines...) Expand all
28 printing::PrinterList printer_list; 29 printing::PrinterList printer_list;
29 print_backend_->EnumeratePrinters(&printer_list); 30 print_backend_->EnumeratePrinters(&printer_list);
30 for (printing::PrinterList::iterator index = printer_list.begin(); 31 for (printing::PrinterList::iterator index = printer_list.begin();
31 index != printer_list.end(); ++index) { 32 index != printer_list.end(); ++index) {
32 printers.Append(new StringValue(index->printer_name)); 33 printers.Append(new StringValue(index->printer_name));
33 } 34 }
34 35
35 web_ui_->CallJavascriptFunction(L"setPrinters", printers); 36 web_ui_->CallJavascriptFunction(L"setPrinters", printers);
36 } 37 }
37 38
38 void PrintPreviewHandler::HandlePrint(const ListValue*) { 39 void PrintPreviewHandler::HandlePrint(const ListValue* args) {
39 web_ui_->GetRenderViewHost()->PrintForPrintPreview(); 40 std::string json_str;
41 CHECK(args->GetString(0, &json_str));
42 if (json_str.empty()) {
43 NOTREACHED() << "Empty print job settings";
44 return;
45 }
46 web_ui_->GetRenderViewHost()->PrintForPrintPreview(json_str);
40 } 47 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698