Fix a crash that prefetch can happen while decoder job is null.
[chromium-blink-merge.git] / components / policy.gypi
blob4d899849635b12bdca554da800bfd31f4524d544
1 # Copyright 2013 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.
6   'includes': [
7     # Included to get 'mac_bundle_id' and other variables.
8     '../build/chrome_settings.gypi',
9   ],
10   'variables': {
11     'chromium_code': 1,
12     'grit_out_dir': '<(SHARED_INTERMEDIATE_DIR)/chrome',
13     'policy_out_dir': '<(SHARED_INTERMEDIATE_DIR)/policy',
14     'protoc_out_dir': '<(SHARED_INTERMEDIATE_DIR)/protoc_out',
15     'generate_policy_source_script_path':
16         'policy/tools/generate_policy_source.py',
17     'policy_constant_header_path':
18         '<(policy_out_dir)/policy/policy_constants.h',
19     'policy_constant_source_path':
20         '<(policy_out_dir)/policy/policy_constants.cc',
21     'protobuf_decoder_path':
22         '<(policy_out_dir)/policy/cloud_policy_generated.cc',
23     # This is the "full" protobuf, which defines one protobuf message per
24     # policy. It is also the format currently used by the server.
25     'chrome_settings_proto_path':
26         '<(policy_out_dir)/policy/chrome_settings.proto',
27     # This protobuf is equivalent to chrome_settings.proto but shares messages
28     # for policies of the same type, so that less classes have to be generated
29     # and compiled.
30     'cloud_policy_proto_path':
31         '<(policy_out_dir)/policy/cloud_policy.proto',
32   },
33   'targets': [
34     {
35       'target_name': 'policy_component',
36       'type': '<(component)',
37       'dependencies': [
38         '../base/base.gyp:base',
39       ],
40       'defines': [
41         'POLICY_COMPONENT_IMPLEMENTATION',
42       ],
43       'include_dirs': [
44         '..',
45       ],
46       'conditions': [
47         ['configuration_policy==1', {
48           'dependencies': [
49             '../base/base.gyp:base_prefs',
50             '../base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations',
51             '../google_apis/google_apis.gyp:google_apis',
52             '../ui/ui.gyp:ui',
53             '../url/url.gyp:url_lib',
54             'component_strings.gyp:component_strings',
55             'cloud_policy_proto',
56             'json_schema',
57             'policy',
58             'url_matcher',
59             'user_prefs',
60           ],
61           'sources': [
62             'policy/core/browser/cloud/message_util.cc',
63             'policy/core/browser/cloud/message_util.h',
64             'policy/core/browser/configuration_policy_handler.cc',
65             'policy/core/browser/configuration_policy_handler.h',
66             'policy/core/browser/configuration_policy_handler_list.cc',
67             'policy/core/browser/configuration_policy_handler_list.h',
68             'policy/core/browser/configuration_policy_pref_store.cc',
69             'policy/core/browser/configuration_policy_pref_store.h',
70             'policy/core/browser/policy_error_map.cc',
71             'policy/core/browser/policy_error_map.h',
72             'policy/core/common/cloud/cloud_external_data_manager.cc',
73             'policy/core/common/cloud/cloud_external_data_manager.h',
74             'policy/core/common/cloud/cloud_policy_client.cc',
75             'policy/core/common/cloud/cloud_policy_client.h',
76             'policy/core/common/cloud/cloud_policy_client_registration_helper.cc',
77             'policy/core/common/cloud/cloud_policy_client_registration_helper.h',
78             'policy/core/common/cloud/cloud_policy_constants.cc',
79             'policy/core/common/cloud/cloud_policy_constants.h',
80             'policy/core/common/cloud/cloud_policy_core.cc',
81             'policy/core/common/cloud/cloud_policy_core.h',
82             'policy/core/common/cloud/cloud_policy_manager.cc',
83             'policy/core/common/cloud/cloud_policy_manager.h',
84             'policy/core/common/cloud/cloud_policy_refresh_scheduler.cc',
85             'policy/core/common/cloud/cloud_policy_refresh_scheduler.h',
86             'policy/core/common/cloud/cloud_policy_service.cc',
87             'policy/core/common/cloud/cloud_policy_service.h',
88             'policy/core/common/cloud/cloud_policy_store.cc',
89             'policy/core/common/cloud/cloud_policy_store.h',
90             'policy/core/common/cloud/cloud_policy_validator.cc',
91             'policy/core/common/cloud/cloud_policy_validator.h',
92             'policy/core/common/cloud/component_cloud_policy_service.cc',
93             'policy/core/common/cloud/component_cloud_policy_service.h',
94             'policy/core/common/cloud/component_cloud_policy_store.cc',
95             'policy/core/common/cloud/component_cloud_policy_store.h',
96             'policy/core/common/cloud/component_cloud_policy_updater.cc',
97             'policy/core/common/cloud/component_cloud_policy_updater.h',
98             'policy/core/common/cloud/device_management_service.cc',
99             'policy/core/common/cloud/device_management_service.h',
100             'policy/core/common/cloud/enterprise_metrics.cc',
101             'policy/core/common/cloud/enterprise_metrics.h',
102             'policy/core/common/cloud/external_policy_data_fetcher.cc',
103             'policy/core/common/cloud/external_policy_data_fetcher.h',
104             'policy/core/common/cloud/external_policy_data_updater.cc',
105             'policy/core/common/cloud/external_policy_data_updater.h',
106             'policy/core/common/cloud/policy_header_io_helper.cc',
107             'policy/core/common/cloud/policy_header_io_helper.h',
108             'policy/core/common/cloud/policy_header_service.cc',
109             'policy/core/common/cloud/policy_header_service.h',
110             'policy/core/common/cloud/rate_limiter.cc',
111             'policy/core/common/cloud/rate_limiter.h',
112             'policy/core/common/cloud/resource_cache.cc',
113             'policy/core/common/cloud/resource_cache.h',
114             'policy/core/common/cloud/system_policy_request_context.cc',
115             'policy/core/common/cloud/system_policy_request_context.h',
116             'policy/core/common/cloud/user_cloud_policy_manager.cc',
117             'policy/core/common/cloud/user_cloud_policy_manager.h',
118             'policy/core/common/cloud/user_cloud_policy_store.cc',
119             'policy/core/common/cloud/user_cloud_policy_store.h',
120             'policy/core/common/cloud/user_cloud_policy_store_base.cc',
121             'policy/core/common/cloud/user_cloud_policy_store_base.h',
122             'policy/core/common/cloud/user_info_fetcher.cc',
123             'policy/core/common/cloud/user_info_fetcher.h',
124             'policy/core/common/cloud/user_policy_request_context.cc',
125             'policy/core/common/cloud/user_policy_request_context.h',
126             'policy/core/common/async_policy_loader.cc',
127             'policy/core/common/async_policy_loader.h',
128             'policy/core/common/async_policy_provider.cc',
129             'policy/core/common/async_policy_provider.h',
130             'policy/core/common/config_dir_policy_loader.cc',
131             'policy/core/common/config_dir_policy_loader.h',
132             'policy/core/common/configuration_policy_provider.cc',
133             'policy/core/common/configuration_policy_provider.h',
134             'policy/core/common/external_data_fetcher.cc',
135             'policy/core/common/external_data_fetcher.h',
136             'policy/core/common/external_data_manager.h',
137             'policy/core/common/forwarding_policy_provider.cc',
138             'policy/core/common/forwarding_policy_provider.h',
139             'policy/core/common/policy_bundle.cc',
140             'policy/core/common/policy_bundle.h',
141             'policy/core/common/policy_details.h',
142             'policy/core/common/policy_loader_mac.cc',
143             'policy/core/common/policy_loader_mac.h',
144             'policy/core/common/policy_loader_win.cc',
145             'policy/core/common/policy_loader_win.h',
146             'policy/core/common/policy_load_status.cc',
147             'policy/core/common/policy_load_status.h',
148             'policy/core/common/policy_map.cc',
149             'policy/core/common/policy_map.h',
150             'policy/core/common/policy_namespace.cc',
151             'policy/core/common/policy_namespace.h',
152             'policy/core/common/policy_pref_names.cc',
153             'policy/core/common/policy_pref_names.h',
154             'policy/core/common/policy_service.cc',
155             'policy/core/common/policy_service.h',
156             'policy/core/common/policy_service_impl.cc',
157             'policy/core/common/policy_service_impl.h',
158             'policy/core/common/policy_statistics_collector.cc',
159             'policy/core/common/policy_statistics_collector.h',
160             'policy/core/common/policy_switches.cc',
161             'policy/core/common/policy_switches.h',
162             'policy/core/common/policy_types.h',
163             'policy/core/common/preferences_mac.cc',
164             'policy/core/common/preferences_mac.h',
165             'policy/core/common/preg_parser_win.cc',
166             'policy/core/common/preg_parser_win.h',
167             'policy/core/common/registry_dict_win.cc',
168             'policy/core/common/registry_dict_win.h',
169             'policy/core/common/schema.cc',
170             'policy/core/common/schema.h',
171             'policy/core/common/schema_internal.h',
172             'policy/core/common/schema_map.cc',
173             'policy/core/common/schema_map.h',
174             'policy/core/common/schema_registry.cc',
175             'policy/core/common/schema_registry.h',
176             'policy/core/common/url_blacklist_manager.cc',
177             'policy/core/common/url_blacklist_manager.h',
178             'policy/policy_export.h',
179           ],
180           'conditions': [
181             ['OS=="android"', {
182               'sources': [
183                 'policy/core/common/cloud/component_cloud_policy_service_stub.cc',
184               ],
185               'sources!': [
186                 'policy/core/common/async_policy_loader.cc',
187                 'policy/core/common/async_policy_loader.h',
188                 'policy/core/common/async_policy_provider.cc',
189                 'policy/core/common/async_policy_provider.h',
190                 'policy/core/common/cloud/component_cloud_policy_service.cc',
191                 'policy/core/common/cloud/component_cloud_policy_store.cc',
192                 'policy/core/common/cloud/component_cloud_policy_store.h',
193                 'policy/core/common/cloud/component_cloud_policy_updater.cc',
194                 'policy/core/common/cloud/component_cloud_policy_updater.h',
195                 'policy/core/common/cloud/external_policy_data_fetcher.cc',
196                 'policy/core/common/cloud/external_policy_data_fetcher.h',
197                 'policy/core/common/cloud/external_policy_data_updater.cc',
198                 'policy/core/common/cloud/external_policy_data_updater.h',
199                 'policy/core/common/cloud/resource_cache.cc',
200                 'policy/core/common/cloud/resource_cache.h',
201                 'policy/core/common/config_dir_policy_loader.cc',
202                 'policy/core/common/config_dir_policy_loader.h',
203                 'policy/core/common/policy_load_status.cc',
204                 'policy/core/common/policy_load_status.h',
205               ],
206             }],
207             ['chromeos==1', {
208               'sources!': [
209                 'policy/core/common/cloud/cloud_policy_client_registration_helper.cc',
210                 'policy/core/common/cloud/cloud_policy_client_registration_helper.h',
211                 'policy/core/common/cloud/user_cloud_policy_manager.cc',
212                 'policy/core/common/cloud/user_cloud_policy_manager.h',
213                 'policy/core/common/cloud/user_cloud_policy_store.cc',
214                 'policy/core/common/cloud/user_cloud_policy_store.h',
215               ],
216             }],
217           ],
218         }, {  # configuration_policy==0
219           # Some of the policy code is always enabled, so that other parts of
220           # Chrome can always interface with the PolicyService without having
221           # to #ifdef on ENABLE_CONFIGURATION_POLICY.
222           'sources': [
223             'policy/core/common/external_data_fetcher.h',
224             'policy/core/common/external_data_fetcher.cc',
225             'policy/core/common/external_data_manager.h',
226             'policy/core/common/policy_map.cc',
227             'policy/core/common/policy_map.h',
228             'policy/core/common/policy_namespace.cc',
229             'policy/core/common/policy_namespace.h',
230             'policy/core/common/policy_service.cc',
231             'policy/core/common/policy_service.h',
232             'policy/core/common/policy_service_stub.cc',
233             'policy/core/common/policy_service_stub.h',
234             'policy/core/common/url_blacklist_manager.cc',
235             'policy/core/common/url_blacklist_manager.h',
236           ],
237         }],
238       ],
239     },
240   ],
241   'conditions': [
242     ['configuration_policy==1', {
243       'targets': [
244         {
245           'target_name': 'cloud_policy_code_generate',
246           'type': 'none',
247           'actions': [
248             {
249               'inputs': [
250                 'policy/resources/policy_templates.json',
251                 '<(generate_policy_source_script_path)',
252               ],
253               'outputs': [
254                 '<(policy_constant_header_path)',
255                 '<(policy_constant_source_path)',
256                 '<(protobuf_decoder_path)',
257                 '<(chrome_settings_proto_path)',
258                 '<(cloud_policy_proto_path)',
259               ],
260               'action_name': 'generate_policy_source',
261               'action': [
262                 'python',
263                 '<@(generate_policy_source_script_path)',
264                 '--policy-constants-header=<(policy_constant_header_path)',
265                 '--policy-constants-source=<(policy_constant_source_path)',
266                 '--chrome-settings-protobuf=<(chrome_settings_proto_path)',
267                 '--cloud-policy-protobuf=<(cloud_policy_proto_path)',
268                 '--cloud-policy-decoder=<(protobuf_decoder_path)',
269                 '<(OS)',
270                 '<(chromeos)',
271                 'policy/resources/policy_templates.json',
272               ],
273               'message': 'Generating policy source',
274             },
275           ],
276           'direct_dependent_settings': {
277             'include_dirs': [
278               '<(policy_out_dir)',
279               '<(protoc_out_dir)',
280             ],
281           },
282         },
283         {
284           'target_name': 'cloud_policy_proto_generated_compile',
285           'type': 'static_library',
286           'sources': [
287             '<(cloud_policy_proto_path)',
288           ],
289           'variables': {
290             'proto_in_dir': '<(policy_out_dir)/policy',
291             'proto_out_dir': 'policy/proto',
292           },
293           'dependencies': [
294             'cloud_policy_code_generate',
295           ],
296           'includes': [
297             '../build/protoc.gypi',
298           ],
299           # TODO(jschuh): crbug.com/167187 fix size_t to int truncations.
300           'msvs_disabled_warnings': [4267, ],
301         },
302         {
303           # This target builds the "full" protobuf, used for tests only.
304           'target_name': 'chrome_settings_proto_generated_compile',
305           'type': 'static_library',
306           'sources': [
307             '<(chrome_settings_proto_path)',
308           ],
309           'variables': {
310             'proto_in_dir': '<(policy_out_dir)/policy',
311             'proto_out_dir': 'policy/proto',
312           },
313           'dependencies': [
314             'cloud_policy_code_generate',
315             'cloud_policy_proto_generated_compile',
316           ],
317           'includes': [
318             '../build/protoc.gypi',
319           ],
320         },
321         {
322           'target_name': 'policy',
323           'type': 'static_library',
324           'hard_dependency': 1,
325           'direct_dependent_settings': {
326             'include_dirs': [
327               '<(policy_out_dir)',
328               '<(protoc_out_dir)',
329             ],
330           },
331           'sources': [
332             '<(policy_constant_header_path)',
333             '<(policy_constant_source_path)',
334             '<(protobuf_decoder_path)',
335           ],
336           'include_dirs': [
337             '<(DEPTH)',
338           ],
339           'dependencies': [
340             'cloud_policy_code_generate',
341             'cloud_policy_proto_generated_compile',
342             '<(DEPTH)/base/base.gyp:base',
343             '<(DEPTH)/third_party/protobuf/protobuf.gyp:protobuf_lite',
344           ],
345           'defines': [
346             'POLICY_COMPONENT_IMPLEMENTATION',
347           ],
348         },
349         {
350           'target_name': 'cloud_policy_proto',
351           'type': 'static_library',
352           'sources': [
353             'policy/proto/chrome_extension_policy.proto',
354             'policy/proto/device_management_backend.proto',
355             'policy/proto/device_management_local.proto',
356           ],
357           'variables': {
358             'proto_in_dir': 'policy/proto',
359             'proto_out_dir': 'policy/proto',
360           },
361           'includes': [
362             '../build/protoc.gypi',
363           ],
364           'conditions': [
365             ['OS=="android"', {
366               'sources!': [
367                 'policy/proto/chrome_extension_policy.proto',
368               ],
369             }],
370             ['chromeos==0', {
371               'sources!': [
372                 'policy/proto/device_management_local.proto',
373               ],
374             }],
375           ],
376         },
377         {
378           'target_name': 'policy_test_support',
379           'type': 'none',
380           'hard_dependency': 1,
381           'direct_dependent_settings': {
382             'include_dirs': [
383               '<(policy_out_dir)',
384               '<(protoc_out_dir)',
385             ],
386           },
387           'dependencies': [
388             'chrome_settings_proto_generated_compile',
389             'policy',
390           ],
391         },
392         {
393           'target_name': 'policy_component_test_support',
394           'type': 'static_library',
395           # This must be undefined so that POLICY_EXPORT works correctly in
396           # the static_library build.
397           'defines!': [
398             'POLICY_COMPONENT_IMPLEMENTATION',
399           ],
400           'dependencies': [
401             'cloud_policy_proto',
402             'policy_component',
403             'policy_test_support',
404             '../testing/gmock.gyp:gmock',
405             '../testing/gtest.gyp:gtest',
406           ],
407           'include_dirs': [
408             '..',
409           ],
410           'sources': [
411             'policy/core/common/cloud/mock_cloud_external_data_manager.cc',
412             'policy/core/common/cloud/mock_cloud_external_data_manager.h',
413             'policy/core/common/cloud/mock_cloud_policy_client.cc',
414             'policy/core/common/cloud/mock_cloud_policy_client.h',
415             'policy/core/common/cloud/mock_cloud_policy_store.cc',
416             'policy/core/common/cloud/mock_cloud_policy_store.h',
417             'policy/core/common/cloud/mock_device_management_service.cc',
418             'policy/core/common/cloud/mock_device_management_service.h',
419             'policy/core/common/cloud/mock_user_cloud_policy_store.cc',
420             'policy/core/common/cloud/mock_user_cloud_policy_store.h',
421             'policy/core/common/cloud/policy_builder.cc',
422             'policy/core/common/cloud/policy_builder.h',
423             'policy/core/common/configuration_policy_provider_test.cc',
424             'policy/core/common/configuration_policy_provider_test.h',
425             'policy/core/common/mock_configuration_policy_provider.cc',
426             'policy/core/common/mock_configuration_policy_provider.h',
427             'policy/core/common/mock_policy_service.cc',
428             'policy/core/common/mock_policy_service.h',
429             'policy/core/common/policy_test_utils.cc',
430             'policy/core/common/policy_test_utils.h',
431             'policy/core/common/preferences_mock_mac.cc',
432             'policy/core/common/preferences_mock_mac.h',
433           ],
434           'conditions': [
435             ['chromeos==1', {
436               'sources!': [
437                 'policy/core/common/cloud/mock_user_cloud_policy_store.cc',
438                 'policy/core/common/cloud/mock_user_cloud_policy_store.h',
439               ],
440             }],
441           ],
442         },
443       ],
444     }],
445     ['OS=="win" and target_arch=="ia32" and configuration_policy==1', {
446       'targets': [
447         {
448           'target_name': 'policy_win64',
449           'type': 'static_library',
450           'hard_dependency': 1,
451           'sources': [
452             '<(policy_constant_header_path)',
453             '<(policy_constant_source_path)',
454           ],
455           'include_dirs': [
456             '<(DEPTH)',
457           ],
458           'direct_dependent_settings':  {
459             'include_dirs': [
460               '<(policy_out_dir)'
461             ],
462           },
463           'dependencies': [
464             'cloud_policy_code_generate',
465           ],
466           'configurations': {
467             'Common_Base': {
468               'msvs_target_platform': 'x64',
469             },
470           },
471         },
472       ],
473     }],
474     ['OS=="win" or OS=="mac" or OS=="linux"', {
475       'targets': [
476         {
477           # policy_templates has different inputs and outputs, so it can't use
478           # the rules of chrome_strings
479           'target_name': 'policy_templates',
480           'type': 'none',
481           'variables': {
482             'grit_grd_file': 'policy/resources/policy_templates.grd',
483             'grit_info_cmd': [
484               'python',
485               '<(DEPTH)/tools/grit/grit_info.py',
486               '<@(grit_defines)',
487             ],
488           },
489           'includes': [
490             '../build/grit_target.gypi',
491           ],
492           'actions': [
493             {
494               'action_name': 'policy_templates',
495               'includes': [
496                 '../build/grit_action.gypi',
497               ],
498             },
499           ],
500         },
501       ],
502     }],
503     ['OS=="mac"', {
504       'targets': [
505         {
506           # This is the bundle of the manifest file of Chrome.
507           # It contains the manifest file and its string tables.
508           'target_name': 'chrome_manifest_bundle',
509           'type': 'loadable_module',
510           'mac_bundle': 1,
511           'product_extension': 'manifest',
512           'product_name': '<(mac_bundle_id)',
513           'variables': {
514             # This avoids stripping debugging symbols from the target, which
515             # would fail because there is no binary code here.
516             'mac_strip': 0,
517           },
518           'dependencies': [
519              # Provides app-Manifest.plist and its string tables:
520             'policy_templates',
521           ],
522           'actions': [
523             {
524               'action_name': 'Copy MCX manifest file to manifest bundle',
525               'inputs': [
526                 '<(grit_out_dir)/app/policy/mac/app-Manifest.plist',
527               ],
528               'outputs': [
529                 '<(INTERMEDIATE_DIR)/app_manifest/<(mac_bundle_id).manifest',
530               ],
531               'action': [
532                 # Use plutil -convert xml1 to put the plist into Apple's
533                 # canonical format. As a side effect, this ensures that the
534                 # plist is well-formed.
535                 'plutil',
536                 '-convert',
537                 'xml1',
538                 '<@(_inputs)',
539                 '-o',
540                 '<@(_outputs)',
541               ],
542               'message':
543                   'Copying the MCX policy manifest file to the manifest bundle',
544               'process_outputs_as_mac_bundle_resources': 1,
545             },
546             {
547               'action_name':
548                   'Copy Localizable.strings files to manifest bundle',
549               'variables': {
550                 'input_path': '<(grit_out_dir)/app/policy/mac/strings',
551                 # Directory to collect the Localizable.strings files before
552                 # they are copied to the bundle.
553                 'output_path': '<(INTERMEDIATE_DIR)/app_manifest',
554                 # The reason we are not enumerating all the locales is that
555                 # the translations would eat up 3.5MB disk space in the
556                 # application bundle:
557                 'available_locales': 'en',
558               },
559               'inputs': [
560                 # TODO: remove this helper when we have loops in GYP
561                 '>!@(<(apply_locales_cmd) -d \'<(input_path)/ZZLOCALE.lproj/Localizable.strings\' <(available_locales))',
562               ],
563               'outputs': [
564                 # TODO: remove this helper when we have loops in GYP
565                 '>!@(<(apply_locales_cmd) -d \'<(output_path)/ZZLOCALE.lproj/Localizable.strings\' <(available_locales))',
566               ],
567               'action': [
568                 'cp', '-R',
569                 '<(input_path)/',
570                 '<(output_path)',
571               ],
572               'message':
573                   'Copy the Localizable.strings files to the manifest bundle',
574               'process_outputs_as_mac_bundle_resources': 1,
575               'msvs_cygwin_shell': 1,
576             },
577           ],
578         },
579       ],
580     }],
581   ],