Update from https://crrev.com/320931
- Add IsFlat() definition to ui/gfx/transform
- Change sky's uses of skia's FilterLevel to FilterQuality
- Update cc_strip_video.patch

R=jamesr@chromium.org

Review URL: https://codereview.chromium.org/1013463003
diff --git a/build/all.gyp b/build/all.gyp
index 4108962..2813ca2 100644
--- a/build/all.gyp
+++ b/build/all.gyp
@@ -163,6 +163,7 @@
         ['OS=="mac"', {
           'dependencies': [
             '../sandbox/sandbox.gyp:*',
+            '../third_party/crashpad/crashpad/crashpad.gyp:*',
             '../third_party/ocmock/ocmock.gyp:*',
           ],
         }],
diff --git a/build/android/gyp/javac.py b/build/android/gyp/javac.py
index 3738062..a0fcda8 100755
--- a/build/android/gyp/javac.py
+++ b/build/android/gyp/javac.py
@@ -80,7 +80,8 @@
       '-classpath', ':'.join(classpath),
       '-d', classes_dir]
   if chromium_code:
-    javac_args.extend(['-Xlint:unchecked', '-Xlint:deprecation'])
+    # TODO(aurimas): re-enable '-Xlint:deprecation' checks once they are fixed.
+    javac_args.extend(['-Xlint:unchecked'])
   else:
     # XDignore.symbol.file makes javac compile against rt.jar instead of
     # ct.sym. This means that using a java internal package/class will not
diff --git a/build/android/gyp/package_resources.py b/build/android/gyp/package_resources.py
index 9b6ec68..2251de0 100755
--- a/build/android/gyp/package_resources.py
+++ b/build/android/gyp/package_resources.py
@@ -100,11 +100,11 @@
   multiple targets. If it is multiple targets merged into one, the actual
   resource directories will be contained in the subdirectories 0, 1, 2, ...
   """
-  res_dirs = []
   subdirs = [os.path.join(d, s) for s in os.listdir(d)]
-  subdirs = sorted([s for s in subdirs if os.path.isdir(s)])
-  if subdirs and os.path.basename(subdirs[0]) == '0':
-    res_dirs = subdirs
+  subdirs = [s for s in subdirs if os.path.isdir(s)]
+  is_multi = '0' in [os.path.basename(s) for s in subdirs]
+  if is_multi:
+    res_dirs = sorted(subdirs, key=lambda p : int(os.path.basename(p)))
   else:
     res_dirs = [d]
   package_command = []
diff --git a/build/android/gyp/write_build_config.py b/build/android/gyp/write_build_config.py
index bf887e3..5fc8955 100755
--- a/build/android/gyp/write_build_config.py
+++ b/build/android/gyp/write_build_config.py
@@ -139,6 +139,9 @@
 
   direct_resources_deps = DepsOfType('android_resources', direct_deps_configs)
   all_resources_deps = DepsOfType('android_resources', all_deps_configs)
+  # Resources should be ordered with the highest-level dependency first so that
+  # overrides are done correctly.
+  all_resources_deps.reverse()
 
   # Initialize some common config.
   config = {
diff --git a/build/android/pylib/constants.py b/build/android/pylib/constants.py
index b849a8d..34dbf19 100644
--- a/build/android/pylib/constants.py
+++ b/build/android/pylib/constants.py
@@ -167,9 +167,10 @@
   KITKAT = 19
   KITKAT_WATCH = 20
   LOLLIPOP = 21
+  LOLLIPOP_MR1 = 22
 
-ANDROID_SDK_VERSION = ANDROID_SDK_VERSION_CODES.LOLLIPOP
-ANDROID_SDK_BUILD_TOOLS_VERSION = '21.0.1'
+ANDROID_SDK_VERSION = ANDROID_SDK_VERSION_CODES.LOLLIPOP_MR1
+ANDROID_SDK_BUILD_TOOLS_VERSION = '22.0.0'
 ANDROID_SDK_ROOT = os.path.join(DIR_SOURCE_ROOT,
                                 'third_party/android_tools/sdk')
 ANDROID_SDK_TOOLS = os.path.join(ANDROID_SDK_ROOT,
diff --git a/build/android/pylib/device/device_utils.py b/build/android/pylib/device/device_utils.py
index b6fd732..292752a 100644
--- a/build/android/pylib/device/device_utils.py
+++ b/build/android/pylib/device/device_utils.py
@@ -13,7 +13,9 @@
 import logging
 import multiprocessing
 import os
+import posixpath
 import re
+import shutil
 import sys
 import tempfile
 import time
@@ -129,6 +131,7 @@
 class DeviceUtils(object):
 
   _MAX_ADB_COMMAND_LENGTH = 512
+  _MAX_ADB_OUTPUT_LENGTH = 32768
   _VALID_SHELL_VARIABLE = re.compile('^[a-zA-Z_][a-zA-Z0-9_]*$')
 
   # Property in /data/local.prop that controls Java assertions.
@@ -937,6 +940,21 @@
       os.makedirs(dirname)
     self.adb.Pull(device_path, host_path)
 
+  def _ReadFileWithPull(self, device_path):
+    try:
+      d = tempfile.mkdtemp()
+      host_temp_path = os.path.join(d, 'tmp_ReadFileWithPull')
+      self.adb.Pull(device_path, host_temp_path)
+      with open(host_temp_path, 'r') as host_temp:
+        return host_temp.read()
+    finally:
+      if os.path.exists(d):
+        shutil.rmtree(d)
+
+  _LS_RE = re.compile(
+      r'(?P<perms>\S+) +(?P<owner>\S+) +(?P<group>\S+) +(?:(?P<size>\d+) +)?'
+      + r'(?P<date>\S+) +(?P<time>\S+) +(?P<name>.+)$')
+
   @decorators.WithTimeoutAndRetriesFromInstance()
   def ReadFile(self, device_path, as_root=False,
                timeout=None, retries=None):
@@ -960,8 +978,29 @@
       CommandTimeoutError on timeout.
       DeviceUnreachableError on missing device.
     """
-    return _JoinLines(self.RunShellCommand(
-        ['cat', device_path], as_root=as_root, check_return=True))
+    # TODO(jbudorick): Implement a generic version of Stat() that handles
+    # as_root=True, then switch this implementation to use that.
+    size = None
+    ls_out = self.RunShellCommand(['ls', '-l', device_path], as_root=as_root,
+                                  check_return=True)
+    for line in ls_out:
+      m = self._LS_RE.match(line)
+      if m and m.group('name') == posixpath.basename(device_path):
+        size = int(m.group('size'))
+        break
+    else:
+      logging.warning('Could not determine size of %s.', device_path)
+
+    if size is None or size <= self._MAX_ADB_OUTPUT_LENGTH:
+      return _JoinLines(self.RunShellCommand(
+          ['cat', device_path], as_root=as_root, check_return=True))
+    elif as_root and self.NeedsSU():
+      with device_temp_file.DeviceTempFile(self.adb) as device_temp:
+        self.RunShellCommand(['cp', device_path, device_temp.name],
+                             as_root=True, check_return=True)
+        return self._ReadFileWithPull(device_temp.name)
+    else:
+      return self._ReadFileWithPull(device_path)
 
   def _WriteFileWithPush(self, device_path, contents):
     with tempfile.NamedTemporaryFile() as host_temp:
diff --git a/build/android/pylib/device/device_utils_test.py b/build/android/pylib/device/device_utils_test.py
index b7e807e..7c20f0d 100755
--- a/build/android/pylib/device/device_utils_test.py
+++ b/build/android/pylib/device/device_utils_test.py
@@ -1046,31 +1046,100 @@
 
 class DeviceUtilsReadFileTest(DeviceUtilsTest):
 
+  def testReadFileWithPull_success(self):
+    tmp_host_dir = '/tmp/dir/on.host/'
+    tmp_host = MockTempFile('/tmp/dir/on.host/tmp_ReadFileWithPull')
+    tmp_host.file.read.return_value = 'some interesting contents'
+    with self.assertCalls(
+        (mock.call.tempfile.mkdtemp(), tmp_host_dir),
+        (self.call.adb.Pull('/path/to/device/file', mock.ANY)),
+        (mock.call.__builtin__.open(mock.ANY, 'r'), tmp_host),
+        (mock.call.os.path.exists(tmp_host_dir), True),
+        (mock.call.shutil.rmtree(tmp_host_dir), None)):
+      self.assertEquals('some interesting contents',
+                        self.device._ReadFileWithPull('/path/to/device/file'))
+    tmp_host.file.read.assert_called_once_with()
+
+  def testReadFileWithPull_rejected(self):
+    tmp_host_dir = '/tmp/dir/on.host/'
+    with self.assertCalls(
+        (mock.call.tempfile.mkdtemp(), tmp_host_dir),
+        (self.call.adb.Pull('/path/to/device/file', mock.ANY),
+         self.CommandError()),
+        (mock.call.os.path.exists(tmp_host_dir), True),
+        (mock.call.shutil.rmtree(tmp_host_dir), None)):
+      with self.assertRaises(device_errors.CommandFailedError):
+        self.device._ReadFileWithPull('/path/to/device/file')
+
   def testReadFile_exists(self):
-    with self.assertCall(
-        self.call.adb.Shell('cat /read/this/test/file'),
-        'this is a test file\r\n'):
+    with self.assertCalls(
+        (self.call.device.RunShellCommand(
+            ['ls', '-l', '/read/this/test/file'],
+            as_root=False, check_return=True),
+         ['-rw-rw---- root foo 256 1970-01-01 00:00 file']),
+        (self.call.device.RunShellCommand(
+            ['cat', '/read/this/test/file'], as_root=False, check_return=True),
+         ['this is a test file'])):
       self.assertEqual('this is a test file\n',
                        self.device.ReadFile('/read/this/test/file'))
 
   def testReadFile_doesNotExist(self):
     with self.assertCall(
-        self.call.adb.Shell('cat /this/file/does.not.exist'),
-        self.ShellError('/system/bin/sh: cat: /this/file/does.not.exist: '
-                        'No such file or directory')):
-      with self.assertRaises(device_errors.AdbCommandFailedError):
+        self.call.device.RunShellCommand(
+            ['ls', '-l', '/this/file/does.not.exist'],
+            as_root=False, check_return=True),
+        self.CommandError('File does not exist')):
+      with self.assertRaises(device_errors.CommandFailedError):
         self.device.ReadFile('/this/file/does.not.exist')
 
   def testReadFile_withSU(self):
     with self.assertCalls(
-      (self.call.device.NeedsSU(), True),
-      (self.call.adb.Shell("su -c sh -c 'cat /this/file/can.be.read.with.su'"),
-       'this is a test file\nread with su')):
+        (self.call.device.RunShellCommand(
+            ['ls', '-l', '/this/file/can.be.read.with.su'],
+            as_root=True, check_return=True),
+         ['-rw------- root root 256 1970-01-01 00:00 can.be.read.with.su']),
+        (self.call.device.RunShellCommand(
+            ['cat', '/this/file/can.be.read.with.su'],
+            as_root=True, check_return=True),
+         ['this is a test file', 'read with su'])):
       self.assertEqual(
           'this is a test file\nread with su\n',
           self.device.ReadFile('/this/file/can.be.read.with.su',
                                as_root=True))
 
+  def testReadFile_withPull(self):
+    contents = 'a' * 123456
+    with self.assertCalls(
+        (self.call.device.RunShellCommand(
+            ['ls', '-l', '/read/this/big/test/file'],
+            as_root=False, check_return=True),
+         ['-rw-rw---- root foo 123456 1970-01-01 00:00 file']),
+        (self.call.device._ReadFileWithPull('/read/this/big/test/file'),
+         contents)):
+      self.assertEqual(
+          contents, self.device.ReadFile('/read/this/big/test/file'))
+
+  def testReadFile_withPullAndSU(self):
+    contents = 'b' * 123456
+    with self.assertCalls(
+        (self.call.device.RunShellCommand(
+            ['ls', '-l', '/this/big/file/can.be.read.with.su'],
+            as_root=True, check_return=True),
+         ['-rw------- root root 123456 1970-01-01 00:00 can.be.read.with.su']),
+        (self.call.device.NeedsSU(), True),
+        (mock.call.pylib.utils.device_temp_file.DeviceTempFile(self.adb),
+         MockTempFile('/sdcard/tmp/on.device')),
+        self.call.device.RunShellCommand(
+            ['cp', '/this/big/file/can.be.read.with.su',
+             '/sdcard/tmp/on.device'],
+            as_root=True, check_return=True),
+        (self.call.device._ReadFileWithPull('/sdcard/tmp/on.device'),
+         contents)):
+      self.assertEqual(
+          contents,
+          self.device.ReadFile('/this/big/file/can.be.read.with.su',
+                               as_root=True))
+
 
 class DeviceUtilsWriteFileTest(DeviceUtilsTest):
 
diff --git a/build/android/tombstones.py b/build/android/tombstones.py
index 7449a73..9b8a8b2 100755
--- a/build/android/tombstones.py
+++ b/build/android/tombstones.py
@@ -18,9 +18,12 @@
 import optparse
 
 from pylib import android_commands
+from pylib.device import device_errors
 from pylib.device import device_utils
 
 
+_TZ_UTC = {'TZ': 'UTC'}
+
 def _ListTombstones(device):
   """List the tombstone files on the device.
 
@@ -30,7 +33,9 @@
   Yields:
     Tuples of (tombstone filename, date time of file on device).
   """
-  lines = device.RunShellCommand('TZ=UTC su -c ls -a -l /data/tombstones')
+  lines = device.RunShellCommand(
+      ['ls', '-a', '-l', '/data/tombstones'],
+      as_root=True, check_return=True, env=_TZ_UTC, timeout=60)
   for line in lines:
     if 'tombstone' in line and not 'No such file or directory' in line:
       details = line.split()
@@ -48,7 +53,8 @@
   Returns:
     A datetime instance.
   """
-  device_now_string = device.RunShellCommand('TZ=UTC date')
+  device_now_string = device.RunShellCommand(
+      ['date'], check_return=True, env=_TZ_UTC)
   return datetime.datetime.strptime(
       device_now_string[0], '%a %b %d %H:%M:%S %Z %Y')
 
@@ -75,7 +81,8 @@
     tombstone_file: the tombstone to delete.
   """
   return device.RunShellCommand(
-      'rm /data/tombstones/' + tombstone_file, as_root=True)
+      ['rm', '/data/tombstones/' + tombstone_file],
+      as_root=True, check_return=True)
 
 
 def _DeviceAbiToArch(device_abi):
@@ -172,14 +179,21 @@
   tombstones = all_tombstones if options.all_tombstones else [all_tombstones[0]]
 
   device_now = _GetDeviceDateTime(device)
-  for tombstone_file, tombstone_time in tombstones:
-    ret += [{'serial': str(device),
-             'device_abi': device.product_cpu_abi,
-             'device_now': device_now,
-             'time': tombstone_time,
-             'file': tombstone_file,
-             'stack': options.stack,
-             'data': _GetTombstoneData(device, tombstone_file)}]
+  try:
+    for tombstone_file, tombstone_time in tombstones:
+      ret += [{'serial': str(device),
+               'device_abi': device.product_cpu_abi,
+               'device_now': device_now,
+               'time': tombstone_time,
+               'file': tombstone_file,
+               'stack': options.stack,
+               'data': _GetTombstoneData(device, tombstone_file)}]
+  except device_errors.CommandFailedError:
+    for line in device.RunShellCommand(
+        ['ls', '-a', '-l', '/data/tombstones'],
+        as_root=True, check_return=True, env=_TZ_UTC, timeout=60):
+      print '%s: %s' % (str(device), line)
+    raise
 
   # Erase all the tombstones if desired.
   if options.wipe_tombstones:
diff --git a/build/common.gypi b/build/common.gypi
index 043dd92..61224ba 100644
--- a/build/common.gypi
+++ b/build/common.gypi
@@ -581,7 +581,7 @@
       # Use experimental lld linker instead of the platform's default linker.
       'use_lld%': 0,
 
-      # Enable plug-in installation by default.
+      # Enable plugin installation by default.
       'enable_plugin_installation%': 1,
 
       # Specifies whether to use canvas_skia.cc in place of platform
@@ -603,9 +603,6 @@
       # Supervised users are enabled by default.
       'enable_supervised_users%': 1,
 
-      # Platform natively supports discardable memory.
-      'native_discardable_memory%': 0,
-
       # Platform sends memory pressure signals natively.
       'native_memory_pressure_signals%': 0,
 
@@ -760,7 +757,6 @@
           'remoting%': 0,
           'arm_neon%': 0,
           'arm_neon_optional%': 1,
-          'native_discardable_memory%': 1,
           'native_memory_pressure_signals%': 1,
           'enable_basic_printing%': 1,
           'enable_print_preview%': 0,
@@ -1201,7 +1197,6 @@
     'google_default_client_id%': '<(google_default_client_id)',
     'google_default_client_secret%': '<(google_default_client_secret)',
     'enable_supervised_users%': '<(enable_supervised_users)',
-    'native_discardable_memory%': '<(native_discardable_memory)',
     'native_memory_pressure_signals%': '<(native_memory_pressure_signals)',
     'spdy_proxy_auth_property%': '<(spdy_proxy_auth_property)',
     'spdy_proxy_auth_value%': '<(spdy_proxy_auth_value)',
@@ -1502,6 +1497,7 @@
     # Ozone platforms to include in the build.
     'ozone_platform_caca%': 0,
     'ozone_platform_dri%': 0,
+    'ozone_platform_drm%': 0,
     'ozone_platform_egltest%': 0,
     'ozone_platform_gbm%': 0,
     'ozone_platform_ozonex%': 0,
@@ -1523,7 +1519,7 @@
         'dont_embed_build_metadata%': 0,
       }],
       # Enable the Syzygy optimization step for the official builds.
-      ['OS=="win" and buildtype=="Official" and syzyasan!=1', {
+      ['OS=="win" and buildtype=="Official" and syzyasan!=1 and clang!=1', {
         'syzygy_optimize%': 1,
       }, {
         'syzygy_optimize%': 0,
@@ -1686,8 +1682,8 @@
             'android_ndk_absolute_root%': '<!(cd <(DEPTH) && pwd -P)/third_party/android_tools/ndk/',
             'android_host_arch%': '<!(uname -m)',
             # Android API-level of the SDK used for compilation.
-            'android_sdk_version%': '21',
-            'android_sdk_build_tools_version%': '21.0.1',
+            'android_sdk_version%': '22',
+            'android_sdk_build_tools_version%': '22.0.0',
             'host_os%': "<!(uname -s | sed -e 's/Linux/linux/;s/Darwin/mac/')",
           },
           # Copy conditionally-set variables out one scope.
@@ -1955,7 +1951,9 @@
             'win_use_allocator_shim%': 0,
           }],
           ['syzyasan==1', {
-            'kasko%': 1,
+            # Uncomment the following line to enable Kasko for
+            # SyzyASAN-instrumented releases.
+            # 'kasko%': 1,
           }],
           ['component=="shared_library" and "<(GENERATOR)"=="ninja"', {
             # Only enabled by default for ninja because it's buggy in VS.
@@ -2350,6 +2348,7 @@
         # Build all platforms whose deps are in install-build-deps.sh.
         # Only these platforms will be compile tested by buildbots.
         'ozone_platform_dri%': 1,
+        'ozone_platform_drm%': 1,
         'ozone_platform_test%': 1,
         'ozone_platform_egltest%': 1,
       }],
@@ -2719,9 +2718,6 @@
       ['enable_hidpi==1', {
         'defines': ['ENABLE_HIDPI=1'],
       }],
-      ['native_discardable_memory==1', {
-        'defines': ['DISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY'],
-      }],
       ['native_memory_pressure_signals==1', {
         'defines': ['SYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE'],
       }],
diff --git a/build/config/android/config.gni b/build/config/android/config.gni
index cebf4de..5a27e78 100644
--- a/build/config/android/config.gni
+++ b/build/config/android/config.gni
@@ -16,8 +16,8 @@
 
   if (!defined(default_android_sdk_root)) {
     default_android_sdk_root = "//third_party/android_tools/sdk"
-    default_android_sdk_version = "21"
-    default_android_sdk_build_tools_version = "21.0.1"
+    default_android_sdk_version = "22"
+    default_android_sdk_build_tools_version = "22.0.0"
   }
 
   if (!defined(google_play_services_library)) {
diff --git a/build/config/android/rules.gni b/build/config/android/rules.gni
index 28608cb..a056997 100644
--- a/build/config/android/rules.gni
+++ b/build/config/android/rules.gni
@@ -1216,6 +1216,11 @@
         invoker.enable_relocation_packing) {
       _enable_relocation_packing = true
     }
+
+    _native_lib_version_name = ""
+    if (defined(invoker.native_lib_version_name)) {
+      _native_lib_version_name = invoker.native_lib_version_name
+    }
   }
 
   _rebased_build_config = rebase_path(_build_config, root_build_dir)
@@ -1252,8 +1257,6 @@
       _enable_chromium_linker_tests = invoker.enable_chromium_linker_tests
     }
 
-    _native_lib_version_name = ""
-
     java_cpp_template("${_template_name}__native_libraries_java") {
       package_name = "org/chromium/base/library_loader"
       sources = [
diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn
index f75ad06..42dc584 100644
--- a/build/config/compiler/BUILD.gn
+++ b/build/config/compiler/BUILD.gn
@@ -726,6 +726,7 @@
   if (is_win) {
     cflags = [
       "/WX",  # Treat warnings as errors.
+
       # Warnings permanently disabled:
 
       # TODO(GYP) The GYP build doesn't have this globally enabled but disabled
@@ -780,6 +781,7 @@
       # have to turn off this warning (and be careful about how object
       # destruction happens in such cases).
       "/wd4611",
+
       # Warnings to evaluate and possibly fix/reenable later:
 
       "/wd4100",  # Unreferenced formal function parameter.
@@ -923,6 +925,8 @@
 #
 # Note that this can be applied regardless of platform and architecture to
 # clean up the call sites. This will only apply the flag when necessary.
+#
+# TODO(jschuh): crbug.com/167187 fix this and delete this config.
 config("no_size_t_to_int_warning") {
   if (is_win && current_cpu == "x64") {
     cflags = [ "/wd4267" ]
diff --git a/build/config/features.gni b/build/config/features.gni
index ee61da5..783e32d 100644
--- a/build/config/features.gni
+++ b/build/config/features.gni
@@ -72,6 +72,8 @@
   enable_google_now = !is_ios && !is_android
 
   enable_one_click_signin = is_win || is_mac || (is_linux && !is_chromeos)
+
+  enable_remoting = !is_ios && !is_android
 }
 
 # Additional dependent variables -----------------------------------------------
@@ -158,8 +160,6 @@
 # Image loader extension is enabled on ChromeOS only.
 enable_image_loader_extension = is_chromeos
 
-enable_remoting = !is_ios && !is_android
-
 # Chrome OS: whether to also build the upcoming version of
 # ChromeVox, which can then be enabled via a command-line switch.
 enable_chromevox_next = false
diff --git a/build/config/linux/BUILD.gn b/build/config/linux/BUILD.gn
index 202fd73..3d65937 100644
--- a/build/config/linux/BUILD.gn
+++ b/build/config/linux/BUILD.gn
@@ -35,6 +35,25 @@
   }
 }
 
+pkg_config("atk") {
+  packages = [ "atk" ]
+  atk_lib_dir = exec_script(pkg_config_script,
+                            [
+                              "--libdir",
+                              "atk",
+                            ],
+                            "string")
+  defines = [ "ATK_LIB_DIR=\"$atk_lib_dir\"" ]
+}
+
+# gn orders flags on a target before flags from configs. The default config
+# adds -Wall, and these flags have to be after -Wall -- so they need to come
+# from a config and can't be on the target directly.
+config("atk_warnings") {
+  # glib uses the pre-c++11 typedef-as-static_assert hack.
+  cflags = [ "-Wno-unused-local-typedef" ]
+}
+
 config("fontconfig") {
   libs = [ "fontconfig" ]
 }
diff --git a/build/config/linux/pkg-config.py b/build/config/linux/pkg-config.py
index a4f4703..fadcc0b 100644
--- a/build/config/linux/pkg-config.py
+++ b/build/config/linux/pkg-config.py
@@ -112,6 +112,7 @@
 parser.add_option('-a', action='store', dest='arch', type='string')
 parser.add_option('--atleast-version', action='store',
                   dest='atleast_version', type='string')
+parser.add_option('--libdir', action='store_true', dest='libdir')
 (options, args) = parser.parse_args()
 
 # Make a list of regular expressions to strip out.
@@ -138,6 +139,18 @@
     print "false"
   sys.exit(0)
 
+if options.libdir:
+  try:
+    libdir = subprocess.check_output([options.pkg_config,
+                                      "--variable=libdir"] +
+                                     args,
+                                     env=os.environ)
+  except:
+    print "Error from pkg-config."
+    sys.exit(1)
+  sys.stdout.write(libdir.strip())
+  sys.exit(0)
+
 try:
   flag_string = subprocess.check_output(
       [ options.pkg_config, "--cflags", "--libs-only-l", "--libs-only-L" ] +
diff --git a/build/filename_rules.gypi b/build/filename_rules.gypi
index bc657d8..48c8027 100644
--- a/build/filename_rules.gypi
+++ b/build/filename_rules.gypi
@@ -106,11 +106,6 @@
                     ['exclude', '(^|/)evdev/'],
       ]
     }],
-    ['<(ozone_platform_dri)==0 or >(nacl_untrusted_build)==1', {
-      'sources/': [ ['exclude', '_dri(_browsertest|_unittest)?\\.(h|cc)$'],
-                    ['exclude', '(^|/)dri/'],
-      ]
-    }],
     ['<(use_pango)==0', {
       'sources/': [ ['exclude', '(^|_)pango(_util|_browsertest|_unittest)?\\.(h|cc)$'], ],
     }],
diff --git a/build/gn_migration.gypi b/build/gn_migration.gypi
index 92c050f..8413002 100644
--- a/build/gn_migration.gypi
+++ b/build/gn_migration.gypi
@@ -112,6 +112,10 @@
         '../net/net.gyp:dump_cache',
         '../net/net.gyp:gdig',
         '../net/net.gyp:get_server_time',
+        '../net/net.gyp:hpack_example_generator',
+        '../net/net.gyp:hpack_fuzz_mutator',
+        '../net/net.gyp:hpack_fuzz_wrapper',
+        '../net/net.gyp:net_perftests',
         '../net/net.gyp:net_unittests',
         '../net/net.gyp:net_watcher',  # TODO(GYP): This should be conditional on use_v8_in_net
         '../net/net.gyp:run_testserver',
@@ -227,7 +231,7 @@
         }],
         ['OS=="android"', {
           'dependencies': [
-            '../base/base.gyp:chromium_android_linker', 
+            '../base/base.gyp:chromium_android_linker',
             '../breakpad/breakpad.gyp:dump_syms',
             '../build/android/rezip.gyp:rezip_apk_jar',
             '../chrome/chrome.gyp:chrome_shell_apk',
@@ -235,7 +239,7 @@
             #"//clank" TODO(GYP) - conditional somehow?
             '../tools/imagediff/image_diff.gyp:image_diff#host',
             '../tools/telemetry/telemetry.gyp:bitmaptools#host',
-      
+
             # TODO(GYP): Remove these when the components_unittests work.
             #"//components/history/core/test:test",
             #"//components/policy:policy_component_test_support",
@@ -247,7 +251,7 @@
             #"//components/wallpaper",
 
             '../content/content_shell_and_tests.gyp:content_shell_apk',
-      
+
             # TODO(GYP): Are these needed, or will they be pulled in automatically?
             #"//third_party/android_tools:android_gcm_java",
             #"//third_party/android_tools:uiautomator_java",
@@ -408,7 +412,6 @@
             '../device/device_tests.gyp:device_unittests',
             '../gin/gin.gyp:gin_v8_snapshot_fingerprint',
             '../gin/gin.gyp:gin_shell',
-            '../google_apis/gcm/gcm.gyp:mcs_probe',
             '../gpu/gpu.gyp:gl_tests',
             '../gpu/gles2_conform_support/gles2_conform_support.gyp:gles2_conform_support',
             '../gpu/gles2_conform_support/gles2_conform_test.gyp:gles2_conform_test',
@@ -418,10 +421,6 @@
             '../media/cast/cast.gyp:generate_timecode_audio',
             '../media/cast/cast.gyp:tap_proxy',
             '../mojo/mojo_base.gyp:mojo_application_chromium',
-            '../net/net.gyp:hpack_example_generator',
-            '../net/net.gyp:hpack_fuzz_mutator',
-            '../net/net.gyp:hpack_fuzz_wrapper',
-            '../net/net.gyp:net_perftests',
             '../ppapi/ppapi_internal.gyp:ppapi_unittests',
             '../ppapi/tools/ppapi_tools.gyp:pepper_hash_for_uma',
             '../sandbox/sandbox.gyp:sandbox_linux_jni_unittests',
diff --git a/build/gyp_helper.py b/build/gyp_helper.py
index a2cc7e1..9be2b9e 100644
--- a/build/gyp_helper.py
+++ b/build/gyp_helper.py
@@ -44,11 +44,17 @@
       if var in os.environ:
         behavior = 'replaces'
         if var == 'GYP_DEFINES':
-          os.environ[var] = file_val + ' ' + os.environ[var]
-          behavior = 'overrides'
+          result = file_val + ' ' + os.environ[var]
+          behavior = 'merges with, and individual components override,'
+        else:
+          result = os.environ[var]
         print 'INFO: Environment value for "%s" %s value in %s' % (
             var, behavior, os.path.abspath(file_path)
         )
+        string_padding = max(len(var), len(file_path), len('result'))
+        print '      %s: %s' % (var.rjust(string_padding), os.environ[var])
+        print '      %s: %s' % (file_path.rjust(string_padding), file_val)
+        os.environ[var] = result
       else:
         os.environ[var] = file_val
 
diff --git a/build/install-build-deps.sh b/build/install-build-deps.sh
index 43b5545..32dd744 100755
--- a/build/install-build-deps.sh
+++ b/build/install-build-deps.sh
@@ -102,16 +102,15 @@
           language-pack-fr language-pack-he language-pack-zh-hant
           libapache2-mod-php5 libasound2-dev libbrlapi-dev libav-tools
           libbz2-dev libcairo2-dev libcap-dev libcups2-dev libcurl4-gnutls-dev
-          libdrm-dev libelf-dev libexif-dev libgconf2-dev libgl1-mesa-dev
-          libglib2.0-dev libglu1-mesa-dev libgnome-keyring-dev libgtk2.0-dev
-          libkrb5-dev libnspr4-dev libnss3-dev libpam0g-dev libpci-dev
-          libpulse-dev libsctp-dev libspeechd-dev libsqlite3-dev libssl-dev
-          libudev-dev libwww-perl libxslt1-dev libxss-dev libxt-dev libxtst-dev
-          mesa-common-dev openbox patch perl php5-cgi pkg-config python
-          python-cherrypy3 python-crypto python-dev python-numpy python-opencv
-          python-openssl python-psutil rpm ruby subversion ttf-dejavu-core
-          ttf-indic-fonts ttf-kochi-gothic ttf-kochi-mincho wdiff xfonts-mathml
-          zip $chromeos_dev_list"
+          libdrm-dev libelf-dev libexif-dev libgconf2-dev libglib2.0-dev
+          libglu1-mesa-dev libgnome-keyring-dev libgtk2.0-dev libkrb5-dev
+          libnspr4-dev libnss3-dev libpam0g-dev libpci-dev libpulse-dev
+          libsctp-dev libspeechd-dev libsqlite3-dev libssl-dev libudev-dev
+          libwww-perl libxslt1-dev libxss-dev libxt-dev libxtst-dev openbox
+          patch perl php5-cgi pkg-config python python-cherrypy3 python-crypto
+          python-dev python-numpy python-opencv python-openssl python-psutil
+          rpm ruby subversion ttf-dejavu-core ttf-indic-fonts ttf-kochi-gothic
+          ttf-kochi-mincho wdiff xfonts-mathml zip $chromeos_dev_list"
 
 # 64-bit systems need a minimum set of 32-bit compat packages for the pre-built
 # NaCl binaries.
@@ -164,14 +163,16 @@
 # it depends on mesa, and only one version of mesa can exists on the system.
 # Hence we must match the same version or this entire script will fail.
 mesa_variant=""
-for variant in "-lts-quantal" "-lts-raring" "-lts-saucy" "-lts-trusty"; do
+for variant in "-lts-quantal" "-lts-raring" "-lts-saucy" "-lts-trusty" \
+               "-lts-utopic"; do
   if $(dpkg-query -Wf'${Status}' libgl1-mesa-glx${variant} 2>/dev/null | \
        grep -q " ok installed"); then
     mesa_variant="${variant}"
   fi
 done
 dev_list="${dev_list} libgbm-dev${mesa_variant}
-          libgles2-mesa-dev${mesa_variant}"
+          libgles2-mesa-dev${mesa_variant} libgl1-mesa-dev${mesa_variant}
+          mesa-common-dev${mesa_variant}"
 nacl_list="${nacl_list} libgl1-mesa-glx${mesa_variant}:i386"
 
 # Some package names have changed over time
diff --git a/build/ios/grit_whitelist.txt b/build/ios/grit_whitelist.txt
index 0d19361..28407eb 100644
--- a/build/ios/grit_whitelist.txt
+++ b/build/ios/grit_whitelist.txt
@@ -273,7 +273,6 @@
 IDS_CRASHES_NO_CRASHES_MESSAGE
 IDS_CRASHES_TITLE
 IDS_CRASHES_UPLOAD_MESSAGE
-IDS_CREDIT_CARD_NUMBER_PREVIEW_FORMAT
 IDS_DATA_REDUCTION_PROXY_BACK_BUTTON
 IDS_DATA_REDUCTION_PROXY_CANNOT_PROXY_HEADING
 IDS_DATA_REDUCTION_PROXY_CANNOT_PROXY_PRIMARY_PARAGRAPH
diff --git a/build/linux/system.gyp b/build/linux/system.gyp
index a71a5c5..5333798 100644
--- a/build/linux/system.gyp
+++ b/build/linux/system.gyp
@@ -91,6 +91,30 @@
       # added back to Chrome OS and Ozone. Don't try to use GTK on Chrome OS and Ozone.
       'targets': [
         {
+          'target_name': 'atk',
+          'type': 'none',
+          'conditions': [
+            ['_toolset=="target"', {
+              'direct_dependent_settings': {
+                'cflags': [
+                  '<!@(<(pkg-config) --cflags atk)',
+                ],
+                'defines': [
+                  'ATK_LIB_DIR="<!@(<(pkg-config) --variable=libdir atk)"',
+                ],
+              },
+              'link_settings': {
+                'ldflags': [
+                  '<!@(<(pkg-config) --libs-only-L --libs-only-other atk)',
+                ],
+                'libraries': [
+                  '<!@(<(pkg-config) --libs-only-l atk)',
+                ],
+              },
+            }],
+          ],
+        },
+        {
           'target_name': 'gdk',
           'type': 'none',
           'conditions': [
@@ -508,7 +532,7 @@
         },
       ],
     }],
-    ['ozone_platform_dri==1 or ozone_platform_gbm==1', {
+    ['ozone_platform_dri==1 or ozone_platform_drm==1 or ozone_platform_gbm==1', {
       'targets': [
         {
           'target_name': 'libdrm',
diff --git a/build/secondary/tools/grit/grit_rule.gni b/build/secondary/tools/grit/grit_rule.gni
index 626fd74..777c3dc 100644
--- a/build/secondary/tools/grit/grit_rule.gni
+++ b/build/secondary/tools/grit/grit_rule.gni
@@ -364,8 +364,21 @@
   action(grit_custom_target) {
     script = "//tools/grit/grit.py"
     inputs = grit_inputs
-    outputs = grit_outputs
-    depfile = "$output_dir/${grit_output_name}.d"
+
+    # TODO(knn): Remove this once grit has rolled to recognize the flag.
+    depend_on_stamp =
+        defined(invoker.depend_on_stamp) && invoker.depend_on_stamp
+    if (depend_on_stamp) {
+      # Need this for migrating existing targets without clobbering.
+      depfile = "$output_dir/${grit_output_name}_stamp.d"
+      outputs = [
+        "${depfile}.stamp",
+      ]
+    } else {
+      depfile = "$output_dir/${grit_output_name}.d"
+      outputs = []
+    }
+    outputs += grit_outputs
 
     args = [
       "-i",
@@ -379,14 +392,18 @@
       ]
     }
     args += [
-              "-o",
-              rebased_output_dir,
-              "--depdir",
-              ".",
-              "--depfile",
-              rebase_path(depfile, root_build_dir),
-              "--write-only-new=1",
-            ] + grit_defines
+      "-o",
+      rebased_output_dir,
+      "--depdir",
+      ".",
+      "--depfile",
+      rebase_path(depfile, root_build_dir),
+      "--write-only-new=1",
+    ]
+    if (depend_on_stamp) {
+      args += [ "--depend-on-stamp" ]
+    }
+    args += grit_defines
 
     # Add extra defines with -D flags.
     if (defined(invoker.defines)) {
diff --git a/build/whitespace_file.txt b/build/whitespace_file.txt
index 7191150..ea82f4e 100644
--- a/build/whitespace_file.txt
+++ b/build/whitespace_file.txt
@@ -152,3 +152,5 @@
 
 In the BUILD we trust.
 ^_^
+
+In the masters we don't.