Chromium Code Reviews| 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_preview_message_handler.h" | 5 #include "chrome/browser/printing/print_preview_message_handler.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/ref_counted_memory.h" | 11 #include "base/memory/ref_counted_memory.h" |
| 12 #include "base/shared_memory.h" | 12 #include "base/shared_memory.h" |
| 13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
| 14 #include "chrome/browser/printing/print_job_manager.h" | 14 #include "chrome/browser/printing/print_job_manager.h" |
| 15 #include "chrome/browser/printing/print_preview_tab_controller.h" | 15 #include "chrome/browser/printing/print_preview_tab_controller.h" |
| 16 #include "chrome/browser/printing/print_view_manager.h" | 16 #include "chrome/browser/printing/print_view_manager.h" |
| 17 #include "chrome/browser/printing/printer_query.h" | 17 #include "chrome/browser/printing/printer_query.h" |
| 18 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 18 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 19 #include "chrome/browser/ui/webui/print_preview/print_preview_ui.h" | 19 #include "chrome/browser/ui/webui/print_preview/print_preview_ui.h" |
| 20 #include "chrome/common/print_messages.h" | 20 #include "chrome/common/print_messages.h" |
| 21 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
| 22 #include "content/public/browser/render_view_host.h" | 22 #include "content/public/browser/render_view_host.h" |
| 23 #include "content/public/browser/web_contents.h" | 23 #include "content/public/browser/web_contents.h" |
| 24 #include "content/public/browser/web_ui.h" | 24 #include "content/public/browser/web_ui.h" |
| 25 #include "printing/page_size_margins.h" | 25 #include "printing/page_size_margins.h" |
| 26 #include "printing/print_job_constants.h" | 26 #include "printing/print_job_constants.h" |
| 27 | 27 |
|
vandebo (ex-Chrome)
2012/03/19 17:11:30
#include "ui/gfx/rect.h"
kmadhusu
2012/03/19 18:45:31
(repeating our conversation) Header file inclusion
| |
| 28 using content::BrowserThread; | 28 using content::BrowserThread; |
| 29 using content::NavigationController; | 29 using content::NavigationController; |
| 30 using content::WebContents; | 30 using content::WebContents; |
| 31 | 31 |
| 32 namespace { | 32 namespace { |
| 33 | 33 |
| 34 void StopWorker(int document_cookie) { | 34 void StopWorker(int document_cookie) { |
| 35 if (document_cookie <= 0) | 35 if (document_cookie <= 0) |
| 36 return; | 36 return; |
| 37 | 37 |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 184 StopWorker(document_cookie); | 184 StopWorker(document_cookie); |
| 185 | 185 |
| 186 PrintPreviewUI* print_preview_ui = GetPrintPreviewUI(); | 186 PrintPreviewUI* print_preview_ui = GetPrintPreviewUI(); |
| 187 if (!print_preview_ui) | 187 if (!print_preview_ui) |
| 188 return; | 188 return; |
| 189 print_preview_ui->OnPrintPreviewFailed(); | 189 print_preview_ui->OnPrintPreviewFailed(); |
| 190 } | 190 } |
| 191 | 191 |
| 192 void PrintPreviewMessageHandler::OnDidGetDefaultPageLayout( | 192 void PrintPreviewMessageHandler::OnDidGetDefaultPageLayout( |
| 193 const PageSizeMargins& page_layout_in_points, | 193 const PageSizeMargins& page_layout_in_points, |
| 194 const gfx::Rect& printable_area_in_points, | |
| 194 bool has_custom_page_size_style) { | 195 bool has_custom_page_size_style) { |
| 195 PrintPreviewUI* print_preview_ui = GetPrintPreviewUI(); | 196 PrintPreviewUI* print_preview_ui = GetPrintPreviewUI(); |
| 196 if (!print_preview_ui) | 197 if (!print_preview_ui) |
| 197 return; | 198 return; |
| 198 print_preview_ui->OnDidGetDefaultPageLayout(page_layout_in_points, | 199 print_preview_ui->OnDidGetDefaultPageLayout(page_layout_in_points, |
| 200 printable_area_in_points, | |
| 199 has_custom_page_size_style); | 201 has_custom_page_size_style); |
| 200 } | 202 } |
| 201 | 203 |
| 202 void PrintPreviewMessageHandler::OnPrintPreviewCancelled(int document_cookie) { | 204 void PrintPreviewMessageHandler::OnPrintPreviewCancelled(int document_cookie) { |
| 203 // Always need to stop the worker. | 205 // Always need to stop the worker. |
| 204 StopWorker(document_cookie); | 206 StopWorker(document_cookie); |
| 205 } | 207 } |
| 206 | 208 |
| 207 void PrintPreviewMessageHandler::OnInvalidPrinterSettings(int document_cookie) { | 209 void PrintPreviewMessageHandler::OnInvalidPrinterSettings(int document_cookie) { |
| 208 StopWorker(document_cookie); | 210 StopWorker(document_cookie); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 249 return; | 251 return; |
| 250 } | 252 } |
| 251 // If |tab| is navigating and it has a print preview tab, notify |tab| to | 253 // If |tab| is navigating and it has a print preview tab, notify |tab| to |
| 252 // consider print preview done so it unfreezes the renderer in the case of | 254 // consider print preview done so it unfreezes the renderer in the case of |
| 253 // window.print(). | 255 // window.print(). |
| 254 if (preview_tab) | 256 if (preview_tab) |
| 255 tab->print_view_manager()->PrintPreviewDone(); | 257 tab->print_view_manager()->PrintPreviewDone(); |
| 256 } | 258 } |
| 257 | 259 |
| 258 } // namespace printing | 260 } // namespace printing |
| OLD | NEW |