Home | History | Annotate | Download | only in printing
      1 // Copyright 2013 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #include "chrome/browser/printing/print_view_manager_basic.h"
      6 
      7 #if defined(OS_ANDROID)
      8 #include "base/file_descriptor_posix.h"
      9 #include "chrome/common/print_messages.h"
     10 #include "printing/printing_context_android.h"
     11 #endif
     12 
     13 DEFINE_WEB_CONTENTS_USER_DATA_KEY(printing::PrintViewManagerBasic);
     14 
     15 namespace printing {
     16 
     17 PrintViewManagerBasic::PrintViewManagerBasic(content::WebContents* web_contents)
     18     : PrintViewManagerBase(web_contents) {
     19 }
     20 
     21 PrintViewManagerBasic::~PrintViewManagerBasic() {
     22 }
     23 
     24 #if defined(OS_ANDROID)
     25 void PrintViewManagerBasic::RenderProcessGone(base::TerminationStatus status) {
     26   PrintingContextAndroid::PdfWritingDone(file_descriptor_.fd, false);
     27   file_descriptor_ = base::FileDescriptor(-1, false);
     28   PrintViewManagerBase::RenderProcessGone(status);
     29 }
     30 
     31 void PrintViewManagerBasic::OnPrintingFailed(int cookie) {
     32   PrintingContextAndroid::PdfWritingDone(file_descriptor_.fd, false);
     33   file_descriptor_ = base::FileDescriptor(-1, false);
     34   PrintViewManagerBase::OnPrintingFailed(cookie);
     35 }
     36 
     37 bool PrintViewManagerBasic::OnMessageReceived(const IPC::Message& message) {
     38   bool handled = true;
     39   IPC_BEGIN_MESSAGE_MAP(PrintViewManagerBasic, message)
     40     IPC_MESSAGE_HANDLER(PrintHostMsg_PrintingFailed, OnPrintingFailed)
     41     IPC_MESSAGE_UNHANDLED(handled = false)
     42   IPC_END_MESSAGE_MAP()
     43 
     44   return handled ? true : PrintViewManagerBase::OnMessageReceived(message);
     45 }
     46 #endif
     47 
     48 }  // namespace printing
     49