OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
(...skipping 10 matching lines...) Expand all Loading... |
22 #include "chrome/browser/cross_site_request_manager.h" | 22 #include "chrome/browser/cross_site_request_manager.h" |
23 #include "chrome/browser/debugger/devtools_manager.h" | 23 #include "chrome/browser/debugger/devtools_manager.h" |
24 #include "chrome/browser/dom_operation_notification_details.h" | 24 #include "chrome/browser/dom_operation_notification_details.h" |
25 #include "chrome/browser/extensions/extension_message_service.h" | 25 #include "chrome/browser/extensions/extension_message_service.h" |
26 #include "chrome/browser/in_process_webkit/session_storage_namespace.h" | 26 #include "chrome/browser/in_process_webkit/session_storage_namespace.h" |
27 #include "chrome/browser/metrics/user_metrics.h" | 27 #include "chrome/browser/metrics/user_metrics.h" |
28 #include "chrome/browser/net/predictor_api.h" | 28 #include "chrome/browser/net/predictor_api.h" |
29 #include "chrome/browser/notifications/desktop_notification_service.h" | 29 #include "chrome/browser/notifications/desktop_notification_service.h" |
30 #include "chrome/browser/printing/printer_query.h" | 30 #include "chrome/browser/printing/printer_query.h" |
31 #include "chrome/browser/printing/print_job_manager.h" | 31 #include "chrome/browser/printing/print_job_manager.h" |
32 #include "chrome/browser/printing/print_preview_tab_controller.h" | 32 #include "chrome/browser/printing/print_preview_manager.h" |
33 #include "chrome/browser/profiles/profile.h" | 33 #include "chrome/browser/profiles/profile.h" |
34 #include "chrome/browser/renderer_host/render_process_host.h" | 34 #include "chrome/browser/renderer_host/render_process_host.h" |
35 #include "chrome/browser/renderer_host/render_view_host_delegate.h" | 35 #include "chrome/browser/renderer_host/render_view_host_delegate.h" |
36 #include "chrome/browser/renderer_host/render_widget_host.h" | 36 #include "chrome/browser/renderer_host/render_widget_host.h" |
37 #include "chrome/browser/renderer_host/render_widget_host_view.h" | 37 #include "chrome/browser/renderer_host/render_widget_host_view.h" |
38 #include "chrome/browser/renderer_host/site_instance.h" | 38 #include "chrome/browser/renderer_host/site_instance.h" |
39 #include "chrome/common/bindings_policy.h" | 39 #include "chrome/common/bindings_policy.h" |
40 #include "chrome/common/chrome_constants.h" | 40 #include "chrome/common/chrome_constants.h" |
41 #include "chrome/common/chrome_switches.h" | 41 #include "chrome/common/chrome_switches.h" |
42 #include "chrome/common/native_web_keyboard_event.h" | 42 #include "chrome/common/native_web_keyboard_event.h" |
(...skipping 1923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1966 params.popup_items, | 1966 params.popup_items, |
1967 params.right_aligned); | 1967 params.right_aligned); |
1968 } | 1968 } |
1969 } | 1969 } |
1970 #endif | 1970 #endif |
1971 | 1971 |
1972 TabContents* RenderViewHost::GetOrCreatePrintPreviewTab() { | 1972 TabContents* RenderViewHost::GetOrCreatePrintPreviewTab() { |
1973 TabContents* initiator_tab = delegate_ ? delegate_->GetAsTabContents() : NULL; | 1973 TabContents* initiator_tab = delegate_ ? delegate_->GetAsTabContents() : NULL; |
1974 if (initiator_tab) { | 1974 if (initiator_tab) { |
1975 // Get/Create preview tab for initiator tab. | 1975 // Get/Create preview tab for initiator tab. |
1976 printing::PrintPreviewTabController* tab_controller = | 1976 printing::PrintPreviewManager* print_preview_manager = |
1977 printing::PrintPreviewTabController::GetInstance(); | 1977 printing::PrintPreviewManager::GetInstance(); |
1978 if (tab_controller) | 1978 if (print_preview_manager) |
1979 return tab_controller->GetOrCreatePreviewTab( | 1979 return print_preview_manager->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::PrintPreviewManager* print_preview_manager = |
| 2001 printing::PrintPreviewManager::GetInstance(); |
| 2002 DCHECK(print_preview_manager); |
| 2003 print_preview_manager->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 |