| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_view_manager_common.h" | 5 #include "chrome/browser/printing/print_view_manager_common.h" |
| 6 | 6 |
| 7 #if defined(ENABLE_EXTENSIONS) | 7 #if defined(ENABLE_EXTENSIONS) |
| 8 #include "components/guest_view/browser/guest_view_manager.h" | 8 #include "components/guest_view/browser/guest_view_manager.h" |
| 9 #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_gues
t.h" | 9 #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_gues
t.h" |
| 10 #endif // defined(ENABLE_EXTENSIONS) | 10 #endif // defined(ENABLE_EXTENSIONS) |
| 11 | 11 |
| 12 #if defined(ENABLE_PRINT_PREVIEW) | 12 #if defined(ENABLE_PRINT_PREVIEW) |
| 13 #include "chrome/browser/printing/print_view_manager.h" | 13 #include "chrome/browser/printing/print_view_manager.h" |
| 14 #else | 14 #else |
| 15 #include "chrome/browser/printing/print_view_manager_basic.h" | 15 #include "chrome/browser/printing/print_view_manager_basic.h" |
| 16 #endif // defined(ENABLE_PRINT_PREVIEW) | 16 #endif // defined(ENABLE_PRINT_PREVIEW) |
| 17 | 17 |
| 18 namespace printing { | 18 namespace printing { |
| 19 namespace { | 19 namespace { |
| 20 #if defined(ENABLE_EXTENSIONS) | 20 #if defined(ENABLE_EXTENSIONS) |
| 21 // Stores |guest_contents| in |result| and returns true if |guest_contents| is a | 21 // Stores |guest_contents| in |result| and returns true if |guest_contents| is a |
| 22 // full page MimeHandlerViewGuest plugin. Otherwise, returns false. | 22 // full page MimeHandlerViewGuest plugin. Otherwise, returns false. |
| 23 bool StoreFullPagePlugin(content::WebContents** result, | 23 bool StoreFullPagePlugin(content::WebContents** result, |
| 24 content::WebContents* guest_contents) { | 24 content::WebContents* guest_contents) { |
| 25 auto guest_view = | 25 auto* guest_view = |
| 26 extensions::MimeHandlerViewGuest::FromWebContents(guest_contents); | 26 extensions::MimeHandlerViewGuest::FromWebContents(guest_contents); |
| 27 if (guest_view && guest_view->is_full_page_plugin()) { | 27 if (guest_view && guest_view->is_full_page_plugin()) { |
| 28 *result = guest_contents; | 28 *result = guest_contents; |
| 29 return true; | 29 return true; |
| 30 } | 30 } |
| 31 return false; | 31 return false; |
| 32 } | 32 } |
| 33 #endif // defined(ENABLE_EXTENSIONS) | 33 #endif // defined(ENABLE_EXTENSIONS) |
| 34 | 34 |
| 35 // If we have a single full-page embedded mime handler view guest, print the | 35 // If we have a single full-page embedded mime handler view guest, print the |
| (...skipping 16 matching lines...) Expand all Loading... |
| 52 | 52 |
| 53 void StartPrint(content::WebContents* contents, | 53 void StartPrint(content::WebContents* contents, |
| 54 bool print_preview_disabled, | 54 bool print_preview_disabled, |
| 55 bool selection_only) { | 55 bool selection_only) { |
| 56 #if defined(ENABLE_PRINT_PREVIEW) | 56 #if defined(ENABLE_PRINT_PREVIEW) |
| 57 using PrintViewManagerImpl = PrintViewManager; | 57 using PrintViewManagerImpl = PrintViewManager; |
| 58 #else | 58 #else |
| 59 using PrintViewManagerImpl = PrintViewManagerBasic; | 59 using PrintViewManagerImpl = PrintViewManagerBasic; |
| 60 #endif // defined(ENABLE_PRINT_PREVIEW) | 60 #endif // defined(ENABLE_PRINT_PREVIEW) |
| 61 | 61 |
| 62 auto print_view_manager = | 62 auto* print_view_manager = |
| 63 PrintViewManagerImpl::FromWebContents(GetWebContentsToUse(contents)); | 63 PrintViewManagerImpl::FromWebContents(GetWebContentsToUse(contents)); |
| 64 if (!print_view_manager) | 64 if (!print_view_manager) |
| 65 return; | 65 return; |
| 66 #if defined(ENABLE_PRINT_PREVIEW) | 66 #if defined(ENABLE_PRINT_PREVIEW) |
| 67 if (!print_preview_disabled) { | 67 if (!print_preview_disabled) { |
| 68 print_view_manager->PrintPreviewNow(selection_only); | 68 print_view_manager->PrintPreviewNow(selection_only); |
| 69 return; | 69 return; |
| 70 } | 70 } |
| 71 #endif // ENABLE_PRINT_PREVIEW | 71 #endif // ENABLE_PRINT_PREVIEW |
| 72 | 72 |
| 73 #if defined(ENABLE_BASIC_PRINTING) | 73 #if defined(ENABLE_BASIC_PRINTING) |
| 74 print_view_manager->PrintNow(); | 74 print_view_manager->PrintNow(); |
| 75 #endif // ENABLE_BASIC_PRINTING | 75 #endif // ENABLE_BASIC_PRINTING |
| 76 } | 76 } |
| 77 | 77 |
| 78 #if defined(ENABLE_BASIC_PRINTING) | 78 #if defined(ENABLE_BASIC_PRINTING) |
| 79 void StartBasicPrint(content::WebContents* contents) { | 79 void StartBasicPrint(content::WebContents* contents) { |
| 80 #if defined(ENABLE_PRINT_PREVIEW) | 80 #if defined(ENABLE_PRINT_PREVIEW) |
| 81 PrintViewManager* print_view_manager = | 81 PrintViewManager* print_view_manager = |
| 82 PrintViewManager::FromWebContents(GetWebContentsToUse(contents)); | 82 PrintViewManager::FromWebContents(GetWebContentsToUse(contents)); |
| 83 if (!print_view_manager) | 83 if (!print_view_manager) |
| 84 return; | 84 return; |
| 85 print_view_manager->BasicPrint(); | 85 print_view_manager->BasicPrint(); |
| 86 #endif // ENABLE_PRINT_PREVIEW | 86 #endif // ENABLE_PRINT_PREVIEW |
| 87 } | 87 } |
| 88 #endif // ENABLE_BASIC_PRINTING | 88 #endif // ENABLE_BASIC_PRINTING |
| 89 | 89 |
| 90 } // namespace printing | 90 } // namespace printing |
| OLD | NEW |