Enables to build chrome for ChromeOS on GN.

BUG=None
[email protected], [email protected]
[email protected], [email protected]
TEST=manually

Review URL: https://codereview.chromium.org/653273002

Cr-Commit-Position: refs/heads/master@{#299641}
diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn
index eaeffc9..b0109bb7 100644
--- a/chrome/browser/BUILD.gn
+++ b/chrome/browser/BUILD.gn
@@ -350,7 +350,7 @@
     sources += rebase_path(gypi_values.chrome_browser_chromeos_sources,
                            ".", "//chrome")
     deps += [
-      #"browser_chromeos",  TODO(GYP)
+      "//chrome/browser/chromeos",
     ]
   } else {
     # Non-ChromeOS.
@@ -358,6 +358,13 @@
                            ".", "//chrome")
   }
 
+  if (is_chromeos || is_ios) {
+    sources -= [
+      "metrics/signin_status_metrics_provider.cc",
+      "metrics/signin_status_metrics_provider.h",
+    ]
+  }
+
   if (use_cups) {
     configs += [ "//printing:cups" ]
   }
@@ -404,6 +411,9 @@
   if (use_nss_certs) {
     sources += rebase_path(gypi_values.chrome_browser_nss_sources,
                            ".", "//chrome")
+    if (is_chromeos) {
+      sources -= [ "net/nss_context_linux.cc" ]
+    }
   }
   if (enable_notifications) {
     sources += rebase_path(gypi_values.chrome_browser_notifications_sources,
diff --git a/chrome/browser/chromeos/BUILD.gn b/chrome/browser/chromeos/BUILD.gn
new file mode 100644
index 0000000..58dab2a2
--- /dev/null
+++ b/chrome/browser/chromeos/BUILD.gn
@@ -0,0 +1,172 @@
+# Copyright 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//build/config/features.gni")
+import("//build/config/ui.gni")
+import("//components/nacl/nacl_defines.gni")
+import("//media/media_options.gni")
+import("//third_party/protobuf/proto_library.gni")
+
+gypi_values = exec_script(
+    "//build/gypi_to_gn.py",
+    [ rebase_path("../../chrome_browser_chromeos.gypi") ],
+    "scope",
+    [ "chrome_browser_chromeos.gypi" ])
+
+source_set("chromeos") {
+  assert(enable_extensions, "ChromeOS Chrome has to be built with extensions")
+
+  configs += [
+    "//build/config/compiler:wexit_time_destructors",
+    "//build/config/linux:fontconfig",
+  ]
+
+  public_deps = [
+    "//ash/resources",
+    "//ash/strings",
+    "//chrome/app/resources:platform_locale_settings",
+    "//chrome/app/theme:theme_resources",
+    "//chrome:extra_resources",
+    "//chrome:resources",
+    "//chrome:strings",
+    "//content/app/resources",
+    "//ui/chromeos/resources",
+    "//ui/chromeos/strings",
+    "//ui/resources",
+    "//ui/strings",
+  ]
+
+  deps = [
+    # TODO(tbarzic): Cleanup this list.
+    "//ash",
+    "//ash:ash_with_content",
+    "//breakpad:client",
+    "//components/session_manager/core",
+    "//components/user_manager",
+    "//chrome/browser/devtools",
+    "//chrome/browser/extensions",
+    "//chrome/browser/history:in_memory_url_index_cache_proto",
+    "//chrome/browser/net:cert_logger_proto",
+    "//chrome/browser/safe_browsing:chunk_proto",
+    "//chrome/browser/safe_browsing:metadata_proto",
+    "//chrome/browser/safe_browsing:report_proto",
+    "//chrome/common",
+    "//chrome/common/extensions/api",
+    "//chrome/common/extensions/api:api_registration",
+    "//chrome/common/net",
+    "//chrome/installer/util",
+    "//chromeos",
+    "//chromeos/ime:gencode",
+    "//chromeos:cryptohome_proto",
+    "//chromeos:cryptohome_signkey_proto",
+    "//chromeos:power_manager_proto",
+    "//components/onc",
+    "//components/ownership",
+    "//components/pairing",
+    "//components/policy",
+    # This depends directly on the variations target, rather than just
+    # transitively via the common target because the proto sources need to
+    # be generated before code in this target can start building.
+    "//components/strings",
+    "//components/variations",
+    "//content/public/browser",
+    "//content/public/common",
+    "//crypto",
+    "//dbus",
+    "//device/bluetooth",
+    "//device/hid",
+    "//media",
+    "//net",
+    "//ppapi:ppapi_ipc",  # For PpapiMsg_LoadPlugin
+    "//printing", # TODO: care about enable_printing
+    "//skia",
+    "//storage/browser",
+    "//storage/common",
+    "//sync",
+    "//third_party/adobe/flash:flapper_version_h",
+    "//third_party/cacheinvalidation",
+    "//third_party/expat",
+    "//third_party/hunspell",
+    "//third_party/icu",
+    "//third_party/leveldatabase",
+    "//third_party/libevent",
+    "//third_party/libjingle",
+    "//third_party/libusb",
+    "//third_party/libxml",
+    "//third_party/npapi",
+    "//third_party/protobuf:protobuf_lite",
+    "//third_party/protobuf:protoc($host_toolchain)",
+    "//third_party/re2",
+    "//third_party/zlib",
+    "//ui/app_list",
+    "//ui/aura",
+    "//ui/base",
+    "//ui/compositor",
+    "//ui/display",
+    "//ui/events/platform",
+    "//ui/events:dom4_keycode_converter",
+    "//ui/file_manager",
+    "//ui/message_center",
+    "//ui/surface",
+    "//ui/views",
+    "//ui/views/controls/webview",
+    "//ui/web_dialogs",
+    "//url",
+    "//v8",
+    ":attestation_proto",
+    ":device_policy_proto",
+    ":drive_proto",
+  ]
+
+  defines = nacl_defines
+
+  sources = rebase_path(gypi_values.browser_chromeos_sources,
+                        ".", "//chrome") +
+            rebase_path(gypi_values.browser_chromeos_extension_sources,
+                        ".", "//chrome")
+  if (use_athena) {
+    defines += ["USE_ATHENA=1"]
+  }
+
+  if (use_x11) {
+    configs += [ "//build/config/linux:x11" ]
+  } else {
+    assert(use_ozone, "Either use_x11 or use_ozone has to be specified.")
+    deps += [ "//ui/ozone" ]
+    sources -= [
+      "device_uma.cc",
+      "device_uma.h",
+      "events/system_key_event_listener.cc",
+      "events/system_key_event_listener.h",
+      "events/xinput_hierarchy_changed_event_listener.cc",
+      "events/xinput_hierarchy_changed_event_listener.h",
+    ]
+  }
+
+  if (use_cras) {
+    defines += [ "USE_CRAS" ]
+  }
+
+  if (ui_compositor_image_transport) {
+    deps += [ "//ui/gl" ]
+  }
+}
+
+proto_library("drive_proto") {
+  sources = [ "drive/drive.proto" ]
+}
+
+proto_library("device_policy_proto") {
+  sources = [
+    "policy/proto/chrome_device_policy.proto",
+    "policy/proto/install_attributes.proto",
+  ]
+}
+
+proto_library("attestation_proto") {
+  sources = [
+    "attestation/attestation_key_payload.proto",
+    "attestation/attestation_signed_data.proto",
+  ]
+}
diff --git a/chrome/browser/extensions/BUILD.gn b/chrome/browser/extensions/BUILD.gn
index 3caec7d0..41c800ac 100644
--- a/chrome/browser/extensions/BUILD.gn
+++ b/chrome/browser/extensions/BUILD.gn
@@ -86,7 +86,7 @@
     deps += [
       "//third_party/libevent",
       "//third_party/protobuf:protobuf_lite",
-      #'../chromeos/ime/input_method.gyp:gencode',  TODO(GYP)
+      "//chromeos/ime:gencode",
     ]
   } else {
     sources += [
diff --git a/chrome/browser/ui/BUILD.gn b/chrome/browser/ui/BUILD.gn
index 426ab912..6ed8165 100644
--- a/chrome/browser/ui/BUILD.gn
+++ b/chrome/browser/ui/BUILD.gn
@@ -167,7 +167,7 @@
     sources += rebase_path(gypi_values.chrome_browser_ui_chromeos_sources,
                            ".", "//chrome")
     deps += [
-      #"browser_chromeos",  TODO(GYP)
+      "//chrome/browser/chromeos",
     ]
   } else {
     sources += rebase_path(gypi_values.chrome_browser_ui_non_chromeos_sources,
diff --git a/chrome/chrome_browser_chromeos.gypi b/chrome/chrome_browser_chromeos.gypi
index 44b9a18..7542219 100644
--- a/chrome/chrome_browser_chromeos.gypi
+++ b/chrome/chrome_browser_chromeos.gypi
@@ -4,129 +4,9 @@
 # found in the LICENSE file.
 
 {
-  'targets': [
-    {
-      'target_name': 'browser_chromeos',
-      'type': 'static_library',
-      'variables': {
-        'conditions': [
-          ['sysroot!=""', {
-            'pkg-config': '../build/linux/pkg-config-wrapper "<(sysroot)" "<(target_arch)" "<(system_libdir)"',
-          }, {
-            'pkg-config': 'pkg-config'
-          }],
-        ],
-        # Override to dynamically link the cras (ChromeOS audio) library.
-        'use_cras%': 0,
-        'enable_wexit_time_destructors': 1,
-      },
-      'dependencies': [
-        # TODO(tbarzic): Cleanup this list.
-        'attestation_proto',
-        'browser/extensions/api/api_registration.gyp:chrome_api_registration',
-        'browser_extensions',
-        'cert_logger_proto',
-        'chrome_resources.gyp:chrome_extra_resources',
-        'chrome_resources.gyp:chrome_resources',
-        'chrome_resources.gyp:platform_locale_settings',
-        'chrome_resources.gyp:theme_resources',
-        'common',
-        'common/extensions/api/api.gyp:chrome_api',
-        'common_net',
-        'debugger',
-        'device_policy_proto',
-        'drive_proto',
-        'in_memory_url_index_cache_proto',
-        'installer_util',
-        'safe_browsing_chunk_proto',
-        'safe_browsing_proto',
-        'safe_browsing_report_proto',
-        '../breakpad/breakpad.gyp:breakpad_client',
-        '../build/linux/system.gyp:dbus',
-        '../chromeos/chromeos.gyp:chromeos',
-        '../chromeos/chromeos.gyp:cryptohome_proto',
-        # browser_chromeos #includes signed_secret.pb.h directly.
-        '../chromeos/chromeos.gyp:cryptohome_signkey_proto',
-        # browser_chromeos #includes power_supply_properties.pb.h directly.
-        '../chromeos/chromeos.gyp:power_manager_proto',
-        '../chromeos/ime/input_method.gyp:gencode',
-        '../components/components.gyp:cloud_policy_proto',
-        '../components/components.gyp:onc_component',
-        '../components/components.gyp:ownership',
-        '../components/components.gyp:pairing',
-        '../components/components.gyp:policy',
-        # This depends directly on the variations target, rather than just
-        # transitively via the common target because the proto sources need to
-        # be generated before code in this target can start building.
-        '../components/components.gyp:variations',
-        '../components/components.gyp:variations_http_provider',
-        '../components/components_strings.gyp:components_strings',
-        '../content/app/resources/content_resources.gyp:content_resources',
-        '../content/content.gyp:content_browser',
-        '../content/content.gyp:content_common',
-        '../crypto/crypto.gyp:crypto',
-        '../dbus/dbus.gyp:dbus',
-        '../device/bluetooth/bluetooth.gyp:device_bluetooth',
-        '../device/hid/hid.gyp:device_hid',
-        '../media/media.gyp:media',
-        '../net/net.gyp:net',
-        '../ppapi/ppapi_internal.gyp:ppapi_ipc',  # For PpapiMsg_LoadPlugin
-        '../skia/skia.gyp:skia',
-        '../storage/storage_browser.gyp:storage',
-        '../storage/storage_common.gyp:storage_common',
-        '../sync/sync.gyp:sync',
-        '../third_party/adobe/flash/flash_player.gyp:flapper_version_h',
-        '../third_party/cacheinvalidation/cacheinvalidation.gyp:cacheinvalidation',
-        '../third_party/cacheinvalidation/cacheinvalidation.gyp:cacheinvalidation_proto_cpp',
-        '../third_party/expat/expat.gyp:expat',
-        '../third_party/hunspell/hunspell.gyp:hunspell',
-        '../third_party/icu/icu.gyp:icui18n',
-        '../third_party/icu/icu.gyp:icuuc',
-        '../third_party/leveldatabase/leveldatabase.gyp:leveldatabase',
-        '../third_party/libevent/libevent.gyp:libevent',
-        '../third_party/libjingle/libjingle.gyp:libjingle',
-        '../third_party/libusb/libusb.gyp:libusb',
-        '../third_party/libxml/libxml.gyp:libxml',
-        '../third_party/npapi/npapi.gyp:npapi',
-        '../third_party/protobuf/protobuf.gyp:protobuf_lite',
-        '../third_party/protobuf/protobuf.gyp:protoc#host',
-        '../third_party/re2/re2.gyp:re2',
-        '../third_party/zlib/zlib.gyp:zlib',
-        '../ui/base/ui_base.gyp:ui_base',
-        '../ui/display/display.gyp:display',
-        '../ui/events/events.gyp:dom4_keycode_converter',
-        '../ui/events/platform/events_platform.gyp:events_platform',
-        '../ui/chromeos/ui_chromeos.gyp:ui_chromeos_resources',
-        '../ui/chromeos/ui_chromeos.gyp:ui_chromeos_strings',
-        '../ui/resources/ui_resources.gyp:ui_resources',
-        '../ui/strings/ui_strings.gyp:ui_strings',
-        '../ui/surface/surface.gyp:surface',
-        '../ui/views/controls/webview/webview.gyp:webview',
-        '../ui/views/controls/webview/webview.gyp:webview',
-        '../ui/web_dialogs/web_dialogs.gyp:web_dialogs',
-        '../url/url.gyp:url_lib',
-        '../v8/tools/gyp/v8.gyp:v8',
-        'chrome_resources.gyp:chrome_strings',
-      ],
-      'defines': [
-        '<@(nacl_defines)',
-      ],
-      'direct_dependent_settings': {
-        'defines': [
-          '<@(nacl_defines)',
-        ],
-      },
-      'export_dependent_settings': [
-        'browser/extensions/api/api_registration.gyp:chrome_api_registration',
-        'common/extensions/api/api.gyp:chrome_api',
-        '../sync/sync.gyp:sync',
-      ],
-      'include_dirs': [
-        # breakpad_linux.cc uses generated file_version_info_linux.h.
-        '<(SHARED_INTERMEDIATE_DIR)',
-        '../breakpad/src',
-      ],
-      'sources': [
+  'variables': {
+    # These files lists are shared with the GN build.
+    'browser_chromeos_sources': [
         # All .cc, .h, .m, and .mm files under browser/chromeos, except for tests
         # and mocks.
         'browser/chromeos/accessibility/accessibility_manager.cc',
@@ -1063,16 +943,9 @@
         'browser/supervised_user/chromeos/supervised_user_password_service.h',
         'browser/supervised_user/chromeos/supervised_user_password_service_factory.cc',
         'browser/supervised_user/chromeos/supervised_user_password_service_factory.h',
-      ],
-      'conditions': [
-        ['use_athena==1', {
-          'defines': ['USE_ATHENA=1'],
-        }],
-        ['enable_extensions==1', {
-          'dependencies': [
-            '../ui/file_manager/file_manager.gyp:file_manager',
-          ],
-          'sources': [
+    ],
+    # These files lists are shared with the GN build.
+    'browser_chromeos_extension_sources': [
             # Only extension API implementations should go here.
             'browser/chromeos/extensions/echo_private_api.cc',
             'browser/chromeos/extensions/echo_private_api.h',
@@ -1121,7 +994,141 @@
             'browser/chromeos/extensions/wallpaper_function_base.cc',
             'browser/chromeos/extensions/wallpaper_private_api.cc',
             'browser/chromeos/extensions/wallpaper_private_api.h',
+    ],
+  },
+  'targets': [
+    {
+      # GN version: //chrome/browser/chromeos
+      'target_name': 'browser_chromeos',
+      'type': 'static_library',
+      'variables': {
+        'conditions': [
+          ['sysroot!=""', {
+            'pkg-config': '../build/linux/pkg-config-wrapper "<(sysroot)" "<(target_arch)" "<(system_libdir)"',
+          }, {
+            'pkg-config': 'pkg-config'
+          }],
+        ],
+        # Override to dynamically link the cras (ChromeOS audio) library.
+        'use_cras%': 0,
+        'enable_wexit_time_destructors': 1,
+      },
+      'dependencies': [
+        # TODO(tbarzic): Cleanup this list.
+        'attestation_proto',
+        'browser/extensions/api/api_registration.gyp:chrome_api_registration',
+        'browser_extensions',
+        'cert_logger_proto',
+        'chrome_resources.gyp:chrome_extra_resources',
+        'chrome_resources.gyp:chrome_resources',
+        'chrome_resources.gyp:platform_locale_settings',
+        'chrome_resources.gyp:theme_resources',
+        'common',
+        'common/extensions/api/api.gyp:chrome_api',
+        'common_net',
+        'debugger',
+        'device_policy_proto',
+        'drive_proto',
+        'in_memory_url_index_cache_proto',
+        'installer_util',
+        'safe_browsing_chunk_proto',
+        'safe_browsing_proto',
+        'safe_browsing_report_proto',
+        '../breakpad/breakpad.gyp:breakpad_client',
+        '../build/linux/system.gyp:dbus',
+        '../chromeos/chromeos.gyp:chromeos',
+        '../chromeos/chromeos.gyp:cryptohome_proto',
+        # browser_chromeos #includes signed_secret.pb.h directly.
+        '../chromeos/chromeos.gyp:cryptohome_signkey_proto',
+        # browser_chromeos #includes power_supply_properties.pb.h directly.
+        '../chromeos/chromeos.gyp:power_manager_proto',
+        '../chromeos/ime/input_method.gyp:gencode',
+        '../components/components.gyp:cloud_policy_proto',
+        '../components/components.gyp:onc_component',
+        '../components/components.gyp:ownership',
+        '../components/components.gyp:pairing',
+        '../components/components.gyp:policy',
+        # This depends directly on the variations target, rather than just
+        # transitively via the common target because the proto sources need to
+        # be generated before code in this target can start building.
+        '../components/components.gyp:variations',
+        '../components/components.gyp:variations_http_provider',
+        '../components/components_strings.gyp:components_strings',
+        '../content/app/resources/content_resources.gyp:content_resources',
+        '../content/content.gyp:content_browser',
+        '../content/content.gyp:content_common',
+        '../crypto/crypto.gyp:crypto',
+        '../dbus/dbus.gyp:dbus',
+        '../device/bluetooth/bluetooth.gyp:device_bluetooth',
+        '../device/hid/hid.gyp:device_hid',
+        '../media/media.gyp:media',
+        '../net/net.gyp:net',
+        '../ppapi/ppapi_internal.gyp:ppapi_ipc',  # For PpapiMsg_LoadPlugin
+        '../skia/skia.gyp:skia',
+        '../storage/storage_browser.gyp:storage',
+        '../storage/storage_common.gyp:storage_common',
+        '../sync/sync.gyp:sync',
+        '../third_party/adobe/flash/flash_player.gyp:flapper_version_h',
+        '../third_party/cacheinvalidation/cacheinvalidation.gyp:cacheinvalidation',
+        '../third_party/cacheinvalidation/cacheinvalidation.gyp:cacheinvalidation_proto_cpp',
+        '../third_party/expat/expat.gyp:expat',
+        '../third_party/hunspell/hunspell.gyp:hunspell',
+        '../third_party/icu/icu.gyp:icui18n',
+        '../third_party/icu/icu.gyp:icuuc',
+        '../third_party/leveldatabase/leveldatabase.gyp:leveldatabase',
+        '../third_party/libevent/libevent.gyp:libevent',
+        '../third_party/libjingle/libjingle.gyp:libjingle',
+        '../third_party/libusb/libusb.gyp:libusb',
+        '../third_party/libxml/libxml.gyp:libxml',
+        '../third_party/npapi/npapi.gyp:npapi',
+        '../third_party/protobuf/protobuf.gyp:protobuf_lite',
+        '../third_party/protobuf/protobuf.gyp:protoc#host',
+        '../third_party/re2/re2.gyp:re2',
+        '../third_party/zlib/zlib.gyp:zlib',
+        '../ui/base/ui_base.gyp:ui_base',
+        '../ui/display/display.gyp:display',
+        '../ui/events/events.gyp:dom4_keycode_converter',
+        '../ui/events/platform/events_platform.gyp:events_platform',
+        '../ui/chromeos/ui_chromeos.gyp:ui_chromeos_resources',
+        '../ui/chromeos/ui_chromeos.gyp:ui_chromeos_strings',
+        '../ui/resources/ui_resources.gyp:ui_resources',
+        '../ui/strings/ui_strings.gyp:ui_strings',
+        '../ui/surface/surface.gyp:surface',
+        '../ui/views/controls/webview/webview.gyp:webview',
+        '../ui/views/controls/webview/webview.gyp:webview',
+        '../ui/web_dialogs/web_dialogs.gyp:web_dialogs',
+        '../url/url.gyp:url_lib',
+        '../v8/tools/gyp/v8.gyp:v8',
+        'chrome_resources.gyp:chrome_strings',
+      ],
+      'defines': [
+        '<@(nacl_defines)',
+      ],
+      'direct_dependent_settings': {
+        'defines': [
+          '<@(nacl_defines)',
+        ],
+      },
+      'export_dependent_settings': [
+        'browser/extensions/api/api_registration.gyp:chrome_api_registration',
+        'common/extensions/api/api.gyp:chrome_api',
+        '../sync/sync.gyp:sync',
+      ],
+      'include_dirs': [
+        # breakpad_linux.cc uses generated file_version_info_linux.h.
+        '<(SHARED_INTERMEDIATE_DIR)',
+        '../breakpad/src',
+      ],
+      'sources': [ '<@(browser_chromeos_sources)' ],
+      'conditions': [
+        ['use_athena==1', {
+          'defines': ['USE_ATHENA=1'],
+        }],
+        ['enable_extensions==1', {
+          'dependencies': [
+            '../ui/file_manager/file_manager.gyp:file_manager',
           ],
+          'sources': [ '<@(browser_chromeos_extension_sources)' ],
         }],
         ['use_x11==0', {
           'sources!': [
@@ -1198,6 +1205,7 @@
       ],
     },
     {
+      # GN version: //chrome/browser/chromeos:drive_proto
       # Protobuf compiler / generator for the Drive protocol buffer.
       'target_name': 'drive_proto',
       'type': 'static_library',
@@ -1209,6 +1217,7 @@
       'includes': [ '../build/protoc.gypi' ]
     },
     {
+      # GN version: //chrome/browser/chromeos:device_policy_proto
       # Protobuf compiler / generator for device settings protocol buffers.
       'target_name': 'device_policy_proto',
       'type': 'static_library',
@@ -1223,6 +1232,7 @@
       'includes': [ '../build/protoc.gypi' ]
     },
     {
+      # GN version: //chrome/browser/chromeos:attestation_proto
       # Protobuf compiler / generator for attestation protocol buffers.
       'target_name': 'attestation_proto',
       'type': 'static_library',