mac: Allow Chrome to hand off its active URL to other devices.
[chromium-blink-merge.git] / printing / BUILD.gn
blob6b6cb1b5e799343b0d7d831f82a2a6672e7f776b
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
3 # found in the LICENSE file.
5 import("//build/config/features.gni")
6 import("//build/config/ui.gni")
7 if (is_mac) {
8   import("//build/config/mac/mac_sdk.gni")
10 if (is_android) {
11   import("//build/config/android/rules.gni")
14 component("printing") {
15   sources = [
16     "backend/print_backend.cc",
17     "backend/print_backend.h",
18     "backend/print_backend_consts.cc",
19     "backend/print_backend_consts.h",
20     "backend/print_backend_dummy.cc",
21     "backend/printing_info_win.cc",
22     "backend/printing_info_win.h",
23     "emf_win.cc",
24     "emf_win.h",
25     "image.cc",
26     "image.h",
27     "image_android.cc",
28     "image_linux.cc",
29     "image_mac.cc",
30     "image_win.cc",
31     "metafile.cc",
32     "metafile.h",
33     "metafile_skia_wrapper.cc",
34     "metafile_skia_wrapper.h",
35     "page_number.cc",
36     "page_number.h",
37     "page_range.cc",
38     "page_range.h",
39     "page_setup.cc",
40     "page_setup.h",
41     "page_size_margins.h",
42     "pdf_metafile_cg_mac.cc",
43     "pdf_metafile_cg_mac.h",
44     "pdf_metafile_skia.cc",
45     "pdf_metafile_skia.h",
46     "print_dialog_gtk_interface.h",
47     "print_job_constants.cc",
48     "print_job_constants.h",
49     "print_settings.cc",
50     "print_settings.h",
51     "print_settings_conversion.cc",
52     "print_settings_conversion.h",
53     "print_settings_initializer_mac.cc",
54     "print_settings_initializer_mac.h",
55     "print_settings_initializer_win.cc",
56     "print_settings_initializer_win.h",
57     "printed_document.cc",
58     "printed_document.h",
59     "printed_document_linux.cc",
60     "printed_document_mac.cc",
61     "printed_document_win.cc",
62     "printed_page.cc",
63     "printed_page.h",
64     "printed_pages_source.h",
65     "printing_context.cc",
66     "printing_context.h",
67     "printing_utils.cc",
68     "printing_utils.h",
69     "units.cc",
70     "units.h",
71   ]
73   cflags = []
74   defines = [ "PRINTING_IMPLEMENTATION" ]
76   deps = [
77     "//base",
78     "//base:i18n",
79     "//base/third_party/dynamic_annotations",
80     "//skia",
81     "//third_party/icu",
82     "//ui/gfx",
83     "//ui/gfx/geometry",
84     "//url",
85   ]
87   if (use_aura) {
88     deps += [ "//ui/aura" ]
89   }
91   if (is_mac) {
92     # Mac-Aura does not support printing.
93     if (use_aura) {
94       sources -= [ "printed_document_mac.cc" ]
95     } else {
96       sources += [
97         "printing_context_mac.mm",
98         "printing_context_mac.h",
99       ]
100     }
101   }
103   if (is_win) {
104     # PRINT_BACKEND_AVAILABLE disables the default dummy implementation of the
105     # print backend and enables a custom implementation instead.
106     defines += [ "PRINT_BACKEND_AVAILABLE" ]
107     sources += [
108       "backend/win_helper.cc",
109       "backend/win_helper.h",
110       "backend/print_backend_win.cc",
111       "printing_context_win.cc",
112       "printing_context_win.h",
113     ]
114   }
116   if (is_chromeos) {
117     sources += [
118       "printing_context_no_system_dialog.cc",
119       "printing_context_no_system_dialog.h",
120     ]
121   }
123   if (use_cups) {
124     configs += [ ":cups" ]
126     if (is_linux) {
127       cups_version = exec_script("cups_config_helper.py",
128                                  [ "--api-version" ],
129                                  "trim string")
131       if (cups_version == "1.6" || cups_version == "1.7") {
132         cflags += [
133           # CUPS 1.6 deprecated the PPD APIs, but we will stay with this
134           # API for now as supported Linux and Mac OS'es are still using
135           # older versions of CUPS. More info: crbug.com/226176
136           "-Wno-deprecated-declarations",
137           # CUPS 1.7 deprecates httpConnectEncrypt(), see the mac section
138           # below.
139         ]
140       }
141     }
143     if (is_mac && mac_sdk_version == "10.9") {
144       # The 10.9 SDK includes cups 1.7, which deprecates
145       # httpConnectEncrypt() in favor of httpConnect2(). hhttpConnect2()
146       # is new in 1.7, so it doesn't exist on OS X 10.6-10.8 and we
147       # can't use it until 10.9 is our minimum system version.
148       # (cups_version isn't reliable on OS X, so key the check off of
149       # mac_sdk).
150       cflags += [ "-Wno-deprecated-declarations" ]
151     }
153     # PRINT_BACKEND_AVAILABLE disables the default dummy implementation
154     # of the print backend and enables a custom implementation instead.
155     defines += [ "PRINT_BACKEND_AVAILABLE" ]
157     sources += [
158       "backend/cups_helper.cc",
159       "backend/cups_helper.h",
160       "backend/print_backend_cups.cc",
161     ]
162   }
164   if (is_chromeos) {
165     # PRINT_BACKEND_AVAILABLE disables the default dummy implementation
166     # of the print backend and enables a custom implementation instead.
167     defines += [ "PRINT_BACKEND_AVAILABLE" ]
169     sources += [ "backend/print_backend_chromeos.cc" ]
170   } else if (is_linux) {  # Non-ChromeOS Linux.
171     sources += [
172       "printing_context_linux.cc",
173       "printing_context_linux.h",
174     ]
175   }
177   if (is_android) {
178     sources += [
179       "printing_context_android.cc",
180       "printing_context_android.h",
181     ]
183     deps += [ ":printing_jni_headers" ]
184   }
187 test("printing_unittests") {
188   sources = [
189     "emf_win_unittest.cc",
190     "page_number_unittest.cc",
191     "page_range_unittest.cc",
192     "page_setup_unittest.cc",
193     "pdf_metafile_cg_mac_unittest.cc",
194     "printed_page_unittest.cc",
195     "printing_context_win_unittest.cc",
196     "printing_test.h",
197     "printing_utils_unittest.cc",
198     "units_unittest.cc",
199   ]
201   if (use_cups) {
202     configs += [ ":cups" ]
203     sources += [ "backend/cups_helper_unittest.cc" ]
204   }
206   deps = [
207     ":printing",
208     "//base/allocator",
209     "//base/test:run_all_unittests",
210     "//base/test:test_support",
211     "//testing/gtest",
212     "//ui/base",
213     "//ui/gfx",
214     "//ui/gfx:test_support",
215     "//ui/gfx/geometry",
216   ]
219 if (use_cups) {
220   config("cups") {
221     defines = [ "USE_CUPS" ]
223     if (is_mac) {
224       ldflags = [ "$mac_sdk_path/usr/lib/libcups.dylib" ]
225     } else {
226       libs = exec_script("cups_config_helper.py", [ "--libs-for-gn" ], "value")
227     }
228   }
231 if (is_android) {
232   # GYP: //printing/printing.gyp:printing_jni_headers
233   generate_jni("printing_jni_headers") {
234     sources = [
235       "android/java/src/org/chromium/printing/PrintingContext.java",
236     ]
237     jni_package = "printing"
238   }
240   # GYP: //printing/printing.gyp:printing_java
241   android_library("printing_java") {
242     deps = [
243       "//base:base_java",
244     ]
245     DEPRECATED_java_in_dir = "android/java/src"
246   }