| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/renderer_host/render_view_host.h" | 5 #include "chrome/browser/renderer_host/render_view_host.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 1967 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1978 if (tab_controller) | 1978 if (tab_controller) |
| 1979 return tab_controller->GetOrCreatePreviewTab( | 1979 return tab_controller->GetOrCreatePreviewTab( |
| 1980 initiator_tab, delegate_->GetBrowserWindowID()); | 1980 initiator_tab, delegate_->GetBrowserWindowID()); |
| 1981 } | 1981 } |
| 1982 return NULL; | 1982 return NULL; |
| 1983 } | 1983 } |
| 1984 | 1984 |
| 1985 void RenderViewHost::OnPagesReadyForPreview( | 1985 void RenderViewHost::OnPagesReadyForPreview( |
| 1986 const ViewHostMsg_DidPreviewDocument_Params& params) { | 1986 const ViewHostMsg_DidPreviewDocument_Params& params) { |
| 1987 #if defined(OS_MACOSX) | 1987 #if defined(OS_MACOSX) |
| 1988 base::SharedMemory shared_buf(params.metafile_data_handle, true); | 1988 base::SharedMemory* shared_buf = |
| 1989 if (!shared_buf.Map(params.data_size)) { | 1989 new base::SharedMemory(params.metafile_data_handle, true); |
| 1990 if (!shared_buf->Map(params.data_size)) { |
| 1990 NOTREACHED(); | 1991 NOTREACHED(); |
| 1991 return; | 1992 return; |
| 1992 } | 1993 } |
| 1993 scoped_ptr<printing::NativeMetafile> metafile(new printing::NativeMetafile()); | |
| 1994 if (!metafile->Init(shared_buf.memory(), params.data_size)) { | |
| 1995 NOTREACHED(); | |
| 1996 return; | |
| 1997 } | |
| 1998 | |
| 1999 // TODO(kmadhusu): Add more functionality for the preview tab to access this | |
| 2000 // |metafile| data. | |
| 2001 #endif | 1994 #endif |
| 2002 | 1995 |
| 2003 // Get/Create print preview tab. | 1996 // Get/Create print preview tab. |
| 2004 TabContents* print_preview_tab = GetOrCreatePrintPreviewTab(); | 1997 TabContents* print_preview_tab = GetOrCreatePrintPreviewTab(); |
| 2005 DCHECK(print_preview_tab); | 1998 DCHECK(print_preview_tab); |
| 1999 #if defined(OS_MACOSX) |
| 2000 printing::PrintPreviewTabController* tab_controller = |
| 2001 printing::PrintPreviewTabController::GetInstance(); |
| 2002 DCHECK(tab_controller); |
| 2003 tab_controller->SetPrintPreviewData( |
| 2004 print_preview_tab, std::make_pair(shared_buf, params.data_size)); |
| 2005 #endif |
| 2006 | 2006 |
| 2007 scoped_refptr<printing::PrinterQuery> printer_query; | 2007 scoped_refptr<printing::PrinterQuery> printer_query; |
| 2008 g_browser_process->print_job_manager()->PopPrinterQuery( | 2008 g_browser_process->print_job_manager()->PopPrinterQuery( |
| 2009 params.document_cookie, &printer_query); | 2009 params.document_cookie, &printer_query); |
| 2010 if (printer_query.get()) { | 2010 if (printer_query.get()) { |
| 2011 BrowserThread::PostTask( | 2011 BrowserThread::PostTask( |
| 2012 BrowserThread::IO, FROM_HERE, | 2012 BrowserThread::IO, FROM_HERE, |
| 2013 NewRunnableMethod(printer_query.get(), | 2013 NewRunnableMethod(printer_query.get(), |
| 2014 &printing::PrinterQuery::StopWorker)); | 2014 &printing::PrinterQuery::StopWorker)); |
| 2015 } | 2015 } |
| 2016 | 2016 |
| 2017 // Send the printingDone msg for now. | 2017 // Send the printingDone msg for now. |
| 2018 Send(new ViewMsg_PrintingDone(routing_id(), params.document_cookie, true)); | 2018 Send(new ViewMsg_PrintingDone(routing_id(), params.document_cookie, true)); |
| 2019 } | 2019 } |
| OLD | NEW |