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.
4
5import("//build/config/features.gni")
6import("//build/config/ui.gni")
7import("//content/browser/browser.gni")
8import("//media/media_options.gni")
9
10source_set("browser") {
11  # Only the public target should depend on this. All other targets (even
12  # internal content ones) should depend on the public one.
13  visibility = [ "//content/public/browser:browser_sources" ]
14
15  defines = []
16  libs = []
17  ldflags = []
18
19  # Shared deps. See also non-iOS deps below.
20  deps = [
21    "//base",
22    "//base:base_static",
23    "//content:resources",
24    "//content/browser/service_worker:proto",
25    "//content/browser/speech/proto",
26    "//content/public/common:common_sources",
27    "//crypto",
28    "//google_apis",
29    "//net",
30    "//skia",
31    "//sql",
32    "//third_party/npapi",
33    "//third_party/re2",
34    "//third_party/WebKit/public:blink_headers",
35    "//third_party/zlib",
36    "//third_party/zlib:zip",
37    "//ui/accessibility",
38    "//ui/accessibility:ax_gen",
39    "//ui/base",
40    "//ui/events",
41    "//ui/events:gesture_detection",
42    "//ui/gfx",
43    "//ui/gfx/geometry",
44    "//ui/gl",
45    "//ui/native_theme",
46    "//ui/resources",
47    "//ui/snapshot",
48  ]
49
50  if (is_ios) {
51    # iOS doesn't get the normal file list and only takes these whitelisted
52    # files.
53    sources = [
54      "browser_context.cc",
55      "browser_main_loop.cc",
56      "browser_main_runner.cc",
57      "browser_process_sub_thread.cc",
58      "browser_thread_impl.cc",
59      "browser_url_handler_impl.cc",
60      "cert_store_impl.cc",
61      "download/download_create_info.cc",
62      "notification_service_impl.cc",
63      "signed_certificate_timestamp_store_impl.cc",
64      "user_metrics.cc",
65      "web_contents/navigation_entry_impl.cc",
66    ]
67  } else {
68    # Normal non-iOS sources get everything.
69    sources = rebase_path(content_browser_gypi_values.private_browser_sources,
70                          ".", "//content")
71
72    # TODO(GYP) these generated files are listed as sources in content_browser.
73    # This is a bit suspicious. The GN grit template will make a source set
74    # containing the generated code so it should be sufficient to just depend
75    # on the grit rule. But maybe some of these will need to be added?
76    #
77    # Need this annoying rebase_path call to match what happened with the
78    # sources.
79    sources -= rebase_path([
80      "$root_gen_dir/webkit/grit/devtools_resources.h",
81      "$root_gen_dir/webkit/grit/devtools_resources_map.cc",
82      "$root_gen_dir/webkit/grit/devtools_resources_map.h",
83      "$root_gen_dir/content/browser/tracing/grit/tracing_resources.h",
84      "$root_gen_dir/ui/resources/grit/webui_resources_map.cc",
85      "$root_gen_dir/content/browser/devtools/devtools_protocol_constants.cc",
86      "$root_gen_dir/content/browser/devtools/devtools_protocol_constants.h",
87    ], ".")
88
89    # Non-iOS deps.
90    deps += [
91      "//cc",
92      "//cc/surfaces",
93      "//content/app/resources",
94      "//content/app/strings",
95      "//content/browser/devtools:resources",
96      "//content/common:mojo_bindings",
97      "//mojo/public/cpp/bindings",
98      "//mojo/public/interfaces/application",
99      "//mojo/public/js/bindings",
100      "//net:http_server",
101      "//storage/browser",
102      "//storage/common",
103      "//third_party/WebKit/public:resources",
104      "//third_party/angle:commit_id",
105      "//third_party/icu",
106      "//third_party/leveldatabase",
107      "//third_party/libyuv",
108      "//ui/resources",
109      "//ui/surface",
110    ]
111  }
112
113  configs += [
114    "//content:content_implementation",
115  ]
116
117  if (toolkit_views) {
118    deps += [ "//ui/events" ]
119  }
120
121  if (is_win) {
122    sources += [
123      "power_profiler/power_data_provider_ia_win.cc",
124      "power_profiler/power_data_provider_ia_win.h",
125    ]
126    deps += [ "//third_party/power_gadget" ]
127  } else {
128    sources += [ "power_profiler/power_data_provider_dummy.cc" ]
129    sources -= [ "renderer_host/web_input_event_aurawin.cc" ]
130  }
131
132  if (!is_win && !is_mac && !is_android && (!is_linux || !use_udev)) {
133    sources += [ "gamepad/gamepad_platform_data_fetcher.cc" ]
134  }
135
136  if (printing_mode != 0) {
137    deps += [ "//printing" ]
138  }
139
140# TODO(GYP)
141#   ['OS!="ios" and chrome_multiple_dll!=1', {
142#     'dependencies': [
143#       '../third_party/WebKit/public/blink.gyp:blink',
144#     ],
145#   }],
146  if (!is_mac && !is_ios) {
147    deps += [ "//sandbox" ]
148  }
149  if (!is_android && !is_ios) {
150    deps += [ "//content/browser/tracing:resources" ]
151  }
152
153  if (enable_webrtc) {
154    sources += rebase_path(content_browser_gypi_values.webrtc_browser_sources,
155                           ".", "//content")
156    deps += [ "//jingle:jingle_glue" ]
157    if (is_linux) {
158      deps += [ "//third_party/libjingle:libjingle_webrtc" ]
159    }
160    if (is_linux || is_mac || is_win) {
161      sources += [
162        "media/capture/desktop_capture_device.cc",
163        "media/capture/desktop_capture_device.h",
164        "media/capture/desktop_capture_device_uma_types.cc",
165        "media/capture/desktop_capture_device_uma_types.h",
166      ]
167      if (use_aura) {
168        sources += [
169          "media/capture/desktop_capture_device_aura.cc",
170          "media/capture/desktop_capture_device_aura.h",
171        ]
172      }
173      defines += [ "ENABLE_SCREEN_CAPTURE=1" ]
174      deps += [ "//third_party/webrtc/modules/desktop_capture" ]
175    }
176  }
177
178  if (is_win) {
179    sources -= [
180      "device_sensors/data_fetcher_shared_memory_default.cc",
181      "geolocation/empty_wifi_data_provider.cc",
182    ]
183    defines += [
184      # This prevents the inclusion of atlhost.h which paired
185      # with the windows 8 sdk it does the wrong thing.
186      "__ATLHOST_H__",
187    ]
188    deps += [
189      "//third_party/iaccessible2",
190      "//third_party/isimpledom",
191    ]
192    libs += [
193      "comctl32.lib",
194      "dinput8.lib",
195      "dwmapi.lib",
196      "dxguid.lib",
197      "sensorsapi.lib",
198      "portabledeviceguids.lib",
199    ]
200    # TODI(GYP)
201#       'msvs_settings': {
202#         'VCLinkerTool': {
203#           'DelayLoadDLLs': [
204#             'dinput8.dll',
205#             'user32.dll',
206#             'dwmapi.dll',
207#           ],
208  }
209
210  if (is_linux) {
211    deps += [ "//sandbox/linux:libc_urandom_override" ]
212  }
213
214  if (use_udev) {
215    configs += [ "//build/config/linux:udev" ]
216  } else {
217    # Remove udev-specific sources.
218    sources -= [
219      "device_monitor_udev.cc",
220      "device_monitor_udev.h",
221    ]
222    if (is_linux) {
223      # Already filtered out on non-Linux.
224      sources -= [
225        "gamepad/gamepad_platform_data_fetcher_linux.cc",
226        "udev_linux.cc",
227        "udev_linux.h",
228      ]
229    }
230  }
231
232  if (enable_plugins) {
233    sources += rebase_path(content_browser_gypi_values.plugin_browser_sources,
234                           ".", "//content")
235    deps += [
236      "//ppapi:ppapi_ipc",
237      "//ppapi:ppapi_shared",
238    ]
239    if (!use_ozone || use_pango) {
240      sources -= [ "renderer_host/pepper/pepper_truetype_font_list_ozone.cc" ]
241    }
242    if (!use_pango) {
243      sources -= [ "renderer_host/pepper/pepper_truetype_font_list_pango.cc" ]
244    }
245  }
246
247  if (is_linux && use_aura) {
248    configs += [ "//build/config/linux:fontconfig" ]
249  }
250
251  if (use_x11) {
252    configs += [ "//build/config/linux:x11" ]
253  }
254
255  # Dealing with power_save_blocker_{x11,ozone}.cc is a little complicated
256  # given the interaction between os_chromeos and the feature flags for X11 and
257  # ozone, so do it all in one spot.
258  if (is_chromeos || !use_ozone) {
259    sources -= [ "power_save_blocker_ozone.cc", ]
260  }
261  if (is_chromeos || !use_x11) {
262    sources -= [ "power_save_blocker_x11.cc", ]
263  }
264
265  # Dealing with battery_status_manager_*.cc and *wifi_data_provider_*.cc
266  # is also a bit complicated given android, chromeos, linux and use_dbus.
267  if (is_android || is_chromeos || (is_linux && use_dbus)) {
268    sources -= [ "battery_status/battery_status_manager_default.cc" ]
269  }
270  if (is_linux && !use_dbus) {
271    # This will already have gotten removed for all non-Linux cases.
272    sources -= [ "battery_status/battery_status_manager_linux.cc" ]
273  }
274
275  if (is_android) {
276    sources -= [ "geolocation/wifi_data_provider_common.cc" ]
277  }
278  if (is_chromeos || (is_linux && !use_dbus)) {
279    sources -= [ "geolocation/wifi_data_provider_linux.cc" ]
280  }
281  if (is_linux && use_dbus) {
282    sources -= [ "geolocation/empty_wifi_data_provider.cc" ]
283  }
284
285  if (use_pango) {
286    configs += [ "//build/config/linux:pangocairo" ]
287  }
288
289  if (is_android) {
290    sources += rebase_path(content_browser_gypi_values.android_browser_sources,
291                           ".", "//content")
292    sources -= [
293      "browser_ipc_logging.cc",
294      "device_sensors/data_fetcher_shared_memory_default.cc",
295      "font_list_async.cc",
296      "geolocation/network_location_provider.cc",
297      "geolocation/network_location_provider.h",
298      "geolocation/network_location_request.cc",
299      "geolocation/network_location_request.h",
300      "renderer_host/native_web_keyboard_event.cc",
301      "tracing/tracing_ui.cc",
302      "tracing/tracing_ui.h",
303
304      # Android skips most, but not all, of the speech code.
305      "speech/audio_buffer.cc",
306      "speech/audio_buffer.h",
307      "speech/audio_encoder.cc",
308      "speech/audio_encoder.h",
309      "speech/chunked_byte_buffer.cc",
310      "speech/chunked_byte_buffer.h",
311      "speech/endpointer/endpointer.cc",
312      "speech/endpointer/endpointer.h",
313      "speech/endpointer/energy_endpointer.cc",
314      "speech/endpointer/energy_endpointer.h",
315      "speech/endpointer/energy_endpointer_params.cc",
316      "speech/endpointer/energy_endpointer_params.h",
317      "speech/google_one_shot_remote_engine.cc",
318      "speech/google_one_shot_remote_engine.h",
319      "speech/google_streaming_remote_engine.cc",
320      "speech/google_streaming_remote_engine.h",
321      "speech/speech_recognition_engine.cc",
322      "speech/speech_recognition_engine.h",
323      "speech/speech_recognizer_impl.cc",
324      "speech/speech_recognizer_impl.h",
325    ]
326    deps += [
327      "//content/public/android:jni",
328      "//media",
329    ]
330    libs += [ "jnigraphics" ]
331  }
332
333  if (is_mac) {
334    sources -= [
335      "device_sensors/data_fetcher_shared_memory_default.cc",
336      "geolocation/empty_wifi_data_provider.cc",
337      "geolocation/empty_wifi_data_provider.h",
338    ]
339    libs += [ "bsm" ]
340  }
341
342  if (is_chromeos) {
343    deps += [ "//chromeos:power_manager_proto" ]
344  }
345
346  if (use_aura) {
347    deps += [
348      "//ui/aura",
349      "//ui/strings",
350      "//ui/wm",
351    ]
352  } else {  # Not aura.
353    sources -= [
354      "renderer_host/input/synthetic_gesture_target_aura.cc",
355      "renderer_host/input/synthetic_gesture_target_aura.h",
356      "renderer_host/native_web_keyboard_event_aura.cc",
357      "renderer_host/render_widget_host_view_aura.cc",
358      "renderer_host/render_widget_host_view_aura.h",
359      "renderer_host/ui_events_helper.cc",
360      "renderer_host/ui_events_helper.h",
361      "renderer_host/web_input_event_aura.cc",
362      "renderer_host/web_input_event_aura.h",
363      "web_contents/aura/gesture_nav_simple.cc",
364      "web_contents/aura/gesture_nav_simple.h",
365      "web_contents/aura/image_window_delegate.cc",
366      "web_contents/aura/image_window_delegate.h",
367      "web_contents/aura/overscroll_navigation_overlay.cc",
368      "web_contents/aura/overscroll_navigation_overlay.h",
369      "web_contents/aura/shadow_layer_delegate.cc",
370      "web_contents/aura/shadow_layer_delegate.h",
371      "web_contents/aura/window_slider.cc",
372      "web_contents/aura/window_slider.h",
373      "web_contents/touch_editable_impl_aura.cc",
374      "web_contents/touch_editable_impl_aura.h",
375      "web_contents/web_contents_view_aura.cc",
376      "web_contents/web_contents_view_aura.h",
377    ]
378  }
379
380  if (use_aura || is_mac) {
381    sources += rebase_path(
382      content_browser_gypi_values.compositor_browser_sources,
383      ".", "//content")
384    if (!use_x11) {
385      sources -= [
386        "compositor/software_output_device_x11.cc",
387        "compositor/software_output_device_x11.h",
388      ]
389    }
390
391    if (!use_ozone) {
392      sources -= [
393        "compositor/overlay_candidate_validator_ozone.cc",
394        "compositor/overlay_candidate_validator_ozone.h",
395        "compositor/software_output_device_ozone.cc",
396        "compositor/software_output_device_ozone.h",
397      ]
398    }
399    deps += [ "//ui/compositor" ]
400  }
401
402  if (enable_web_speech) {
403    deps += [
404      "//third_party/flac",
405      "//third_party/speex",
406    ]
407  }
408
409  if (is_linux && use_dbus) {
410      deps += [ "//dbus" ]
411  }
412
413  if (enable_browser_cdms) {
414    sources += [
415      "media/cdm/browser_cdm_manager.cc",
416      "media/cdm/browser_cdm_manager.h",
417      "media/media_web_contents_observer.cc",
418      "media/media_web_contents_observer.h",
419    ]
420  }
421}
422