| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/printing/print_job_worker.h" | 5 #include "chrome/browser/printing/print_job_worker.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 } | 37 } |
| 38 | 38 |
| 39 class PrintingContextDelegate : public PrintingContext::Delegate { | 39 class PrintingContextDelegate : public PrintingContext::Delegate { |
| 40 public: | 40 public: |
| 41 PrintingContextDelegate(int render_process_id, int render_view_id); | 41 PrintingContextDelegate(int render_process_id, int render_view_id); |
| 42 ~PrintingContextDelegate() override; | 42 ~PrintingContextDelegate() override; |
| 43 | 43 |
| 44 gfx::NativeView GetParentView() override; | 44 gfx::NativeView GetParentView() override; |
| 45 std::string GetAppLocale() override; | 45 std::string GetAppLocale() override; |
| 46 | 46 |
| 47 // Not exposed to PrintingContext::Delegate because of dependency issues. |
| 48 content::WebContents* GetWebContents(); |
| 49 |
| 47 private: | 50 private: |
| 48 int render_process_id_; | 51 int render_process_id_; |
| 49 int render_view_id_; | 52 int render_view_id_; |
| 50 }; | 53 }; |
| 51 | 54 |
| 52 PrintingContextDelegate::PrintingContextDelegate(int render_process_id, | 55 PrintingContextDelegate::PrintingContextDelegate(int render_process_id, |
| 53 int render_view_id) | 56 int render_view_id) |
| 54 : render_process_id_(render_process_id), | 57 : render_process_id_(render_process_id), |
| 55 render_view_id_(render_view_id) { | 58 render_view_id_(render_view_id) { |
| 56 } | 59 } |
| 57 | 60 |
| 58 PrintingContextDelegate::~PrintingContextDelegate() { | 61 PrintingContextDelegate::~PrintingContextDelegate() { |
| 59 } | 62 } |
| 60 | 63 |
| 61 gfx::NativeView PrintingContextDelegate::GetParentView() { | 64 gfx::NativeView PrintingContextDelegate::GetParentView() { |
| 65 content::WebContents* wc = GetWebContents(); |
| 66 return wc ? wc->GetNativeView() : nullptr; |
| 67 } |
| 68 |
| 69 content::WebContents* PrintingContextDelegate::GetWebContents() { |
| 62 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 70 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 63 content::RenderViewHost* view = | 71 content::RenderViewHost* view = |
| 64 content::RenderViewHost::FromID(render_process_id_, render_view_id_); | 72 content::RenderViewHost::FromID(render_process_id_, render_view_id_); |
| 65 if (!view) | 73 return view ? content::WebContents::FromRenderViewHost(view) : nullptr; |
| 66 return NULL; | |
| 67 content::WebContents* wc = content::WebContents::FromRenderViewHost(view); | |
| 68 return wc ? wc->GetNativeView() : NULL; | |
| 69 } | 74 } |
| 70 | 75 |
| 71 std::string PrintingContextDelegate::GetAppLocale() { | 76 std::string PrintingContextDelegate::GetAppLocale() { |
| 72 return g_browser_process->GetApplicationLocale(); | 77 return g_browser_process->GetApplicationLocale(); |
| 73 } | 78 } |
| 74 | 79 |
| 75 void NotificationCallback(PrintJobWorkerOwner* print_job, | 80 void NotificationCallback(PrintJobWorkerOwner* print_job, |
| 76 JobEventDetails::Type detail_type, | 81 JobEventDetails::Type detail_type, |
| 77 PrintedDocument* document, | 82 PrintedDocument* document, |
| 78 PrintedPage* page) { | 83 PrintedPage* page) { |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 document_, | 408 document_, |
| 404 scoped_refptr<PrintedPage>())); | 409 scoped_refptr<PrintedPage>())); |
| 405 Cancel(); | 410 Cancel(); |
| 406 | 411 |
| 407 // Makes sure the variables are reinitialized. | 412 // Makes sure the variables are reinitialized. |
| 408 document_ = NULL; | 413 document_ = NULL; |
| 409 page_number_ = PageNumber::npos(); | 414 page_number_ = PageNumber::npos(); |
| 410 } | 415 } |
| 411 | 416 |
| 412 } // namespace printing | 417 } // namespace printing |
| OLD | NEW |