OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/chromeos/arc/arc_print_service.h" | 5 #include "chrome/browser/chromeos/arc/arc_print_service.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "ash/common/shell_delegate.h" | 9 #include "ash/common/shell_delegate.h" |
10 #include "ash/common/wm_shell.h" | 10 #include "ash/common/wm_shell.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 : ArcService(bridge_service), binding_(this) { | 60 : ArcService(bridge_service), binding_(this) { |
61 arc_bridge_service()->print()->AddObserver(this); | 61 arc_bridge_service()->print()->AddObserver(this); |
62 } | 62 } |
63 | 63 |
64 ArcPrintService::~ArcPrintService() { | 64 ArcPrintService::~ArcPrintService() { |
65 arc_bridge_service()->print()->RemoveObserver(this); | 65 arc_bridge_service()->print()->RemoveObserver(this); |
66 } | 66 } |
67 | 67 |
68 void ArcPrintService::OnInstanceReady() { | 68 void ArcPrintService::OnInstanceReady() { |
69 mojom::PrintInstance* print_instance = | 69 mojom::PrintInstance* print_instance = |
70 arc_bridge_service()->print()->instance(); | 70 arc_bridge_service()->print()->GetInstanceForMethod("Init"); |
71 if (!print_instance) { | 71 DCHECK(print_instance); |
72 LOG(ERROR) << "OnPrintInstanceReady called, but no print instance found"; | |
73 return; | |
74 } | |
75 | |
76 print_instance->Init(binding_.CreateInterfacePtrAndBind()); | 72 print_instance->Init(binding_.CreateInterfacePtrAndBind()); |
77 } | 73 } |
78 | 74 |
79 void ArcPrintService::Print(mojo::ScopedHandle pdf_data) { | 75 void ArcPrintService::Print(mojo::ScopedHandle pdf_data) { |
80 if (!pdf_data.is_valid()) { | 76 if (!pdf_data.is_valid()) { |
81 LOG(ERROR) << "handle is invalid"; | 77 LOG(ERROR) << "handle is invalid"; |
82 return; | 78 return; |
83 } | 79 } |
84 | 80 |
85 mojo::edk::ScopedPlatformHandle scoped_platform_handle; | 81 mojo::edk::ScopedPlatformHandle scoped_platform_handle; |
86 MojoResult mojo_result = mojo::edk::PassWrappedPlatformHandle( | 82 MojoResult mojo_result = mojo::edk::PassWrappedPlatformHandle( |
87 pdf_data.release().value(), &scoped_platform_handle); | 83 pdf_data.release().value(), &scoped_platform_handle); |
88 if (mojo_result != MOJO_RESULT_OK) { | 84 if (mojo_result != MOJO_RESULT_OK) { |
89 LOG(ERROR) << "PassWrappedPlatformHandle failed: " << mojo_result; | 85 LOG(ERROR) << "PassWrappedPlatformHandle failed: " << mojo_result; |
90 return; | 86 return; |
91 } | 87 } |
92 | 88 |
93 base::File file(scoped_platform_handle.release().handle); | 89 base::File file(scoped_platform_handle.release().handle); |
94 | 90 |
95 content::BrowserThread::PostTaskAndReplyWithResult( | 91 content::BrowserThread::PostTaskAndReplyWithResult( |
96 content::BrowserThread::FILE, FROM_HERE, | 92 content::BrowserThread::FILE, FROM_HERE, |
97 base::Bind(&SavePdf, base::Passed(&file)), base::Bind(&OpenPdf)); | 93 base::Bind(&SavePdf, base::Passed(&file)), base::Bind(&OpenPdf)); |
98 } | 94 } |
99 | 95 |
100 } // namespace arc | 96 } // namespace arc |
OLD | NEW |