Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Side by Side Diff: chrome/browser/printing/print_view_manager_common.cc

Issue 2479593006: Move enable extensions define to a build flag. (Closed)
Patch Set: Merge Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "extensions/features/features.h"
7 #include "printing/features/features.h" 8 #include "printing/features/features.h"
8 9
9 #if defined(ENABLE_EXTENSIONS) 10 #if BUILDFLAG(ENABLE_EXTENSIONS)
10 #include "components/guest_view/browser/guest_view_manager.h" 11 #include "components/guest_view/browser/guest_view_manager.h"
11 #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_gues t.h" 12 #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_gues t.h"
12 #endif // defined(ENABLE_EXTENSIONS) 13 #endif // BUILDFLAG(ENABLE_EXTENSIONS)
13 14
14 #if BUILDFLAG(ENABLE_PRINT_PREVIEW) 15 #if BUILDFLAG(ENABLE_PRINT_PREVIEW)
15 #include "chrome/browser/printing/print_view_manager.h" 16 #include "chrome/browser/printing/print_view_manager.h"
16 #else 17 #else
17 #include "chrome/browser/printing/print_view_manager_basic.h" 18 #include "chrome/browser/printing/print_view_manager_basic.h"
18 #endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) 19 #endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
19 20
20 namespace printing { 21 namespace printing {
21 namespace { 22 namespace {
22 #if defined(ENABLE_EXTENSIONS) 23 #if BUILDFLAG(ENABLE_EXTENSIONS)
23 // Stores |guest_contents| in |result| and returns true if |guest_contents| is a 24 // Stores |guest_contents| in |result| and returns true if |guest_contents| is a
24 // full page MimeHandlerViewGuest plugin. Otherwise, returns false. 25 // full page MimeHandlerViewGuest plugin. Otherwise, returns false.
25 bool StoreFullPagePlugin(content::WebContents** result, 26 bool StoreFullPagePlugin(content::WebContents** result,
26 content::WebContents* guest_contents) { 27 content::WebContents* guest_contents) {
27 auto* guest_view = 28 auto* guest_view =
28 extensions::MimeHandlerViewGuest::FromWebContents(guest_contents); 29 extensions::MimeHandlerViewGuest::FromWebContents(guest_contents);
29 if (guest_view && guest_view->is_full_page_plugin()) { 30 if (guest_view && guest_view->is_full_page_plugin()) {
30 *result = guest_contents; 31 *result = guest_contents;
31 return true; 32 return true;
32 } 33 }
33 return false; 34 return false;
34 } 35 }
35 #endif // defined(ENABLE_EXTENSIONS) 36 #endif // BUILDFLAG(ENABLE_EXTENSIONS)
36 37
37 // If we have a single full-page embedded mime handler view guest, print the 38 // If we have a single full-page embedded mime handler view guest, print the
38 // guest's WebContents instead. 39 // guest's WebContents instead.
39 content::WebContents* GetWebContentsToUse(content::WebContents* contents) { 40 content::WebContents* GetWebContentsToUse(content::WebContents* contents) {
40 #if defined(ENABLE_EXTENSIONS) 41 #if BUILDFLAG(ENABLE_EXTENSIONS)
41 guest_view::GuestViewManager* guest_view_manager = 42 guest_view::GuestViewManager* guest_view_manager =
42 guest_view::GuestViewManager::FromBrowserContext( 43 guest_view::GuestViewManager::FromBrowserContext(
43 contents->GetBrowserContext()); 44 contents->GetBrowserContext());
44 if (guest_view_manager) { 45 if (guest_view_manager) {
45 guest_view_manager->ForEachGuest( 46 guest_view_manager->ForEachGuest(
46 contents, 47 contents,
47 base::Bind(&StoreFullPagePlugin, &contents)); 48 base::Bind(&StoreFullPagePlugin, &contents));
48 } 49 }
49 #endif // defined(ENABLE_EXTENSIONS) 50 #endif // BUILDFLAG(ENABLE_EXTENSIONS)
50 return contents; 51 return contents;
51 } 52 }
52 53
53 } // namespace 54 } // namespace
54 55
55 void StartPrint(content::WebContents* contents, 56 void StartPrint(content::WebContents* contents,
56 bool print_preview_disabled, 57 bool print_preview_disabled,
57 bool selection_only) { 58 bool selection_only) {
58 #if BUILDFLAG(ENABLE_PRINT_PREVIEW) 59 #if BUILDFLAG(ENABLE_PRINT_PREVIEW)
59 using PrintViewManagerImpl = PrintViewManager; 60 using PrintViewManagerImpl = PrintViewManager;
(...skipping 23 matching lines...) Expand all
83 PrintViewManager* print_view_manager = 84 PrintViewManager* print_view_manager =
84 PrintViewManager::FromWebContents(GetWebContentsToUse(contents)); 85 PrintViewManager::FromWebContents(GetWebContentsToUse(contents));
85 if (!print_view_manager) 86 if (!print_view_manager)
86 return; 87 return;
87 print_view_manager->BasicPrint(); 88 print_view_manager->BasicPrint();
88 #endif // ENABLE_PRINT_PREVIEW 89 #endif // ENABLE_PRINT_PREVIEW
89 } 90 }
90 #endif // ENABLE_BASIC_PRINTING 91 #endif // ENABLE_BASIC_PRINTING
91 92
92 } // namespace printing 93 } // namespace printing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698