| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "printing/printing_context_linux.h" | 5 #include "printing/printing_context_linux.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "printing/metafile.h" | 9 #include "printing/metafile.h" |
| 10 #include "printing/print_dialog_gtk_interface.h" | 10 #include "printing/print_dialog_gtk_interface.h" |
| 11 #include "printing/print_job_constants.h" | 11 #include "printing/print_job_constants.h" |
| 12 #include "printing/units.h" | 12 #include "printing/units.h" |
| 13 | 13 |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 // Function pointer for creating print dialogs. |callback| is only used when | 16 // Function pointer for creating print dialogs. |callback| is only used when |
| 17 // |show_dialog| is true. | 17 // |show_dialog| is true. |
| 18 printing::PrintDialogGtkInterface* (*create_dialog_func_)( | 18 printing::PrintDialogGtkInterface* (*create_dialog_func_)( |
| 19 printing::PrintingContextLinux* context) = NULL; | 19 printing::PrintingContextLinux* context) = NULL; |
| 20 | 20 |
| 21 // Function pointer for determining paper size. | 21 // Function pointer for determining paper size. |
| 22 gfx::Size (*get_pdf_paper_size_)( | 22 gfx::Size (*get_pdf_paper_size_)( |
| 23 printing::PrintingContextLinux* context) = NULL; | 23 printing::PrintingContextLinux* context) = NULL; |
| 24 | 24 |
| 25 } // namespace | 25 } // namespace |
| 26 | 26 |
| 27 namespace printing { | 27 namespace printing { |
| 28 | 28 |
| 29 // static | 29 // static |
| 30 PrintingContext* PrintingContext::Create(const std::string& app_locale) { | 30 scoped_ptr<PrintingContext> PrintingContext::Create(Delegate* delegate) { |
| 31 return static_cast<PrintingContext*>(new PrintingContextLinux(app_locale)); | 31 return make_scoped_ptr<PrintingContext>(new PrintingContextLinux(delegate)); |
| 32 } | 32 } |
| 33 | 33 |
| 34 PrintingContextLinux::PrintingContextLinux(const std::string& app_locale) | 34 PrintingContextLinux::PrintingContextLinux(Delegate* delegate) |
| 35 : PrintingContext(app_locale), | 35 : PrintingContext(delegate), print_dialog_(NULL) { |
| 36 print_dialog_(NULL) { | |
| 37 } | 36 } |
| 38 | 37 |
| 39 PrintingContextLinux::~PrintingContextLinux() { | 38 PrintingContextLinux::~PrintingContextLinux() { |
| 40 ReleaseContext(); | 39 ReleaseContext(); |
| 41 | 40 |
| 42 if (print_dialog_) | 41 if (print_dialog_) |
| 43 print_dialog_->ReleaseDialog(); | 42 print_dialog_->ReleaseDialog(); |
| 44 } | 43 } |
| 45 | 44 |
| 46 // static | 45 // static |
| (...skipping 13 matching lines...) Expand all Loading... |
| 60 get_pdf_paper_size_ = get_pdf_paper_size; | 59 get_pdf_paper_size_ = get_pdf_paper_size; |
| 61 } | 60 } |
| 62 | 61 |
| 63 void PrintingContextLinux::PrintDocument(const Metafile* metafile) { | 62 void PrintingContextLinux::PrintDocument(const Metafile* metafile) { |
| 64 DCHECK(print_dialog_); | 63 DCHECK(print_dialog_); |
| 65 DCHECK(metafile); | 64 DCHECK(metafile); |
| 66 print_dialog_->PrintDocument(metafile, document_name_); | 65 print_dialog_->PrintDocument(metafile, document_name_); |
| 67 } | 66 } |
| 68 | 67 |
| 69 void PrintingContextLinux::AskUserForSettings( | 68 void PrintingContextLinux::AskUserForSettings( |
| 70 gfx::NativeView parent_view, | |
| 71 int max_pages, | 69 int max_pages, |
| 72 bool has_selection, | 70 bool has_selection, |
| 73 const PrintSettingsCallback& callback) { | 71 const PrintSettingsCallback& callback) { |
| 74 if (!print_dialog_) { | 72 if (!print_dialog_) { |
| 75 // Can only get here if the renderer is sending bad messages. | 73 // Can only get here if the renderer is sending bad messages. |
| 76 // http://crbug.com/341777 | 74 // http://crbug.com/341777 |
| 77 NOTREACHED(); | 75 NOTREACHED(); |
| 78 callback.Run(FAILED); | 76 callback.Run(FAILED); |
| 79 return; | 77 return; |
| 80 } | 78 } |
| 81 | 79 |
| 82 print_dialog_->ShowDialog(parent_view, has_selection, callback); | 80 print_dialog_->ShowDialog( |
| 81 delegate_->GetParentView(), has_selection, callback); |
| 83 } | 82 } |
| 84 | 83 |
| 85 PrintingContext::Result PrintingContextLinux::UseDefaultSettings() { | 84 PrintingContext::Result PrintingContextLinux::UseDefaultSettings() { |
| 86 DCHECK(!in_print_job_); | 85 DCHECK(!in_print_job_); |
| 87 | 86 |
| 88 ResetSettings(); | 87 ResetSettings(); |
| 89 | 88 |
| 90 if (!create_dialog_func_) | 89 if (!create_dialog_func_) |
| 91 return OK; | 90 return OK; |
| 92 | 91 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 void PrintingContextLinux::ReleaseContext() { | 180 void PrintingContextLinux::ReleaseContext() { |
| 182 // Intentional No-op. | 181 // Intentional No-op. |
| 183 } | 182 } |
| 184 | 183 |
| 185 gfx::NativeDrawingContext PrintingContextLinux::context() const { | 184 gfx::NativeDrawingContext PrintingContextLinux::context() const { |
| 186 // Intentional No-op. | 185 // Intentional No-op. |
| 187 return NULL; | 186 return NULL; |
| 188 } | 187 } |
| 189 | 188 |
| 190 } // namespace printing | 189 } // namespace printing |
| OLD | NEW |