From 921f7b8fae34cc989b4dcf3b819ad2f5a8906047 Mon Sep 17 00:00:00 2001 From: Eric Hameleers Date: Thu, 15 Sep 2016 07:07:16 +0000 Subject: Initial revision --- .../patches/chromium_no_gzippable_bindata.patch | 791 +++++++++++++++++++++ 1 file changed, 791 insertions(+) create mode 100644 chromium/build/patches/chromium_no_gzippable_bindata.patch diff --git a/chromium/build/patches/chromium_no_gzippable_bindata.patch b/chromium/build/patches/chromium_no_gzippable_bindata.patch new file mode 100644 index 00000000..56c7c69d --- /dev/null +++ b/chromium/build/patches/chromium_no_gzippable_bindata.patch @@ -0,0 +1,791 @@ +# Original patch was taken from below Review URL, +# and then rebased for chromium 53.0.2785.92. + +commit e87c66cbfe6ca12f2f422b07cdc318d48c6c1cbd +author xdai Thu Jun 02 21:15:25 2016 +committer xdai Thu Jun 02 21:19:57 2016 +tree fc0c283e8c801fef64e0767efecf8375d61a5efd +parent bfdd352db3b3b9a3185d639e27061e5eb7df69ac +[Merge to 2756] Revert "Compress .pak resources with new option: "type=GZIPPABLE_BINDATA"" + +This reverts commit e3a06a21aa1a7adfaef988488cdbcccbfa9a2ef6. + +This CL breaks all PFQ at the BuildPackages stage. See the infomational builder https://uberchromegw.corp.google.com/i/chromeos.chrome/builders/lumpy-tot-chrome-pfq-informational/builds/19533 as an example. + +TBR=smaier@chromium.org +BUG=616798 +CQ_INCLUDE_TRYBOTS=tryserver.chromium.linux:closure_compilation + +Review URL: https://codereview.chromium.org/2034473004 . + +Cr-Commit-Position: refs/heads/master@{#397455} +(cherry picked from commit 49624437b555e0020e0addf2b3c8499b9574e376) + + +diff -uarN chromium-53.0.2785.92.orig/chrome/browser/browser_resources.grd chromium-53.0.2785.92/chrome/browser/browser_resources.grd +--- chromium-53.0.2785.92.orig/chrome/browser/browser_resources.grd 2016-09-02 21:02:03.000000000 +0200 ++++ chromium-53.0.2785.92/chrome/browser/browser_resources.grd 2016-09-14 10:01:45.331455651 +0200 +@@ -109,9 +109,9 @@ + + + +- +- +- ++ ++ ++ + + + +@@ -185,16 +185,16 @@ + + + +- +- +- +- +- +- ++ ++ ++ ++ ++ ++ + +- +- +- ++ ++ ++ + + + +diff -uarN chromium-53.0.2785.92.orig/chrome/browser/resources/net_internals_resources.grd chromium-53.0.2785.92/chrome/browser/resources/net_internals_resources.grd +--- chromium-53.0.2785.92.orig/chrome/browser/resources/net_internals_resources.grd 2016-09-02 21:02:04.000000000 +0200 ++++ chromium-53.0.2785.92/chrome/browser/resources/net_internals_resources.grd 2016-09-14 09:59:54.449773068 +0200 +@@ -10,8 +10,8 @@ + + + +- +- ++ ++ + + + +diff -uarN chromium-53.0.2785.92.orig/chrome/browser/resources/password_manager_internals_resources.grd chromium-53.0.2785.92/chrome/browser/resources/password_manager_internals_resources.grd +--- chromium-53.0.2785.92.orig/chrome/browser/resources/password_manager_internals_resources.grd 2016-09-02 21:02:04.000000000 +0200 ++++ chromium-53.0.2785.92/chrome/browser/resources/password_manager_internals_resources.grd 2016-09-14 09:59:54.455773970 +0200 +@@ -8,9 +8,9 @@ + + + +- +- +- ++ ++ ++ + + + +diff -uarN chromium-53.0.2785.92.orig/chrome/browser/resources/translate_internals_resources.grd chromium-53.0.2785.92/chrome/browser/resources/translate_internals_resources.grd +--- chromium-53.0.2785.92.orig/chrome/browser/resources/translate_internals_resources.grd 2016-09-02 21:02:04.000000000 +0200 ++++ chromium-53.0.2785.92/chrome/browser/resources/translate_internals_resources.grd 2016-09-14 09:59:54.467775775 +0200 +@@ -8,8 +8,8 @@ + + + +- +- ++ ++ + + + +diff -uarN chromium-53.0.2785.92.orig/components/resources/gcm_driver_resources.grdp chromium-53.0.2785.92/components/resources/gcm_driver_resources.grdp +--- chromium-53.0.2785.92.orig/components/resources/gcm_driver_resources.grdp 2016-09-02 21:02:07.000000000 +0200 ++++ chromium-53.0.2785.92/components/resources/gcm_driver_resources.grdp 2016-09-14 09:59:54.489779087 +0200 +@@ -1,6 +1,6 @@ + + +- +- +- ++ ++ ++ + +diff -uarN chromium-53.0.2785.92.orig/components/resources/signin_resources.grdp chromium-53.0.2785.92/components/resources/signin_resources.grdp +--- chromium-53.0.2785.92.orig/components/resources/signin_resources.grdp 2016-09-02 21:02:07.000000000 +0200 ++++ chromium-53.0.2785.92/components/resources/signin_resources.grdp 2016-09-14 09:59:54.498780440 +0200 +@@ -2,9 +2,8 @@ + + ++ flattenhtml="true" allowexternalscript="true" type="BINDATA" /> + ++ type="BINDATA" /> + +diff -uarN chromium-53.0.2785.92.orig/content/content_resources.grd chromium-53.0.2785.92/content/content_resources.grd +--- chromium-53.0.2785.92.orig/content/content_resources.grd 2016-09-02 21:02:08.000000000 +0200 ++++ chromium-53.0.2785.92/content/content_resources.grd 2016-09-14 09:59:54.514782848 +0200 +@@ -13,20 +13,20 @@ + + + +- +- +- ++ ++ ++ + + + + +- +- +- +- +- +- +- ++ ++ ++ ++ ++ ++ ++ + + + +@@ -36,11 +36,11 @@ + + + +- +- +- +- +- ++ ++ ++ ++ ++ + + + +diff -uarN chromium-53.0.2785.92.orig/content/public/test/browser_test_utils.cc chromium-53.0.2785.92/content/public/test/browser_test_utils.cc +--- chromium-53.0.2785.92.orig/content/public/test/browser_test_utils.cc 2016-09-02 21:02:08.000000000 +0200 ++++ chromium-53.0.2785.92/content/public/test/browser_test_utils.cc 2016-09-14 09:59:54.531785406 +0200 +@@ -809,9 +809,8 @@ + for (std::vector::iterator iter = ids.begin(); + iter != ids.end(); + ++iter) { +- scoped_refptr resource = +- ResourceBundle::GetSharedInstance().LoadDataResourceBytes(*iter); +- script.append(resource->front_as(), resource->size()); ++ ResourceBundle::GetSharedInstance().GetRawDataResource(*iter) ++ .AppendToString(&script); + script.append("\n"); + } + if (!ExecuteScript(web_contents, script)) +diff -uarN chromium-53.0.2785.92.orig/tools/grit/grit/exception.py chromium-53.0.2785.92/tools/grit/grit/exception.py +--- chromium-53.0.2785.92.orig/tools/grit/grit/exception.py 2016-09-02 21:02:26.000000000 +0200 ++++ chromium-53.0.2785.92/tools/grit/grit/exception.py 2016-09-14 09:59:54.539786609 +0200 +@@ -48,6 +48,7 @@ + '''This element should not have content''' + pass + ++ + class MissingMandatoryAttribute(Parsing): + '''This element is missing a mandatory attribute''' + pass +@@ -135,7 +136,3 @@ + '''ID range overlap.''' + pass + +- +-class ReservedHeaderCollision(Base): +- '''Resource included with first 3 bytes matching reserved header.''' +- pass +diff -uarN chromium-53.0.2785.92.orig/tools/grit/grit/format/data_pack_unittest.py chromium-53.0.2785.92/tools/grit/grit/format/data_pack_unittest.py +--- chromium-53.0.2785.92.orig/tools/grit/grit/format/data_pack_unittest.py 2016-09-02 21:02:26.000000000 +0200 ++++ chromium-53.0.2785.92/tools/grit/grit/format/data_pack_unittest.py 2016-09-14 09:59:54.542787062 +0200 +@@ -13,7 +13,6 @@ + + import unittest + +-from grit import exception + from grit.format import data_pack + + +@@ -33,39 +32,6 @@ + output = data_pack.WriteDataPackToString(input, data_pack.UTF8) + self.failUnless(output == expected) + +- def testIncludeWithReservedHeader(self): +- from grit import util +- from grit.node import misc, include, empty +- root = misc.GritNode() +- root.StartParsing(u'grit', None) +- root.HandleAttribute(u'latest_public_release', u'0') +- root.HandleAttribute(u'current_release', u'1') +- root.HandleAttribute(u'base_dir', ur'..\resource') +- release = misc.ReleaseNode() +- release.StartParsing(u'release', root) +- release.HandleAttribute(u'seq', u'1') +- root.AddChild(release) +- includes = empty.IncludesNode() +- includes.StartParsing(u'includes', release) +- release.AddChild(includes) +- include_node = include.IncludeNode() +- include_node.StartParsing(u'include', includes) +- include_node.HandleAttribute(u'name', u'test') +- include_node.HandleAttribute(u'type', u'BINDATA') +- include_node.HandleAttribute(u'file', u'doesntmatter') +- includes.AddChild(include_node) +- include_node.EndParsing() +- root.EndParsing() +- +- ReadFile_copy = util.ReadFile +- try: +- util.ReadFile = lambda a, b: include.IncludeNode.RESERVED_HEADER +- with self.assertRaises(exception.ReservedHeaderCollision): +- data_pack.Format(root) +- +- finally: +- util.ReadFile = ReadFile_copy +- + def testRePackUnittest(self): + expected_with_whitelist = { + 1: 'Never gonna', 10: 'give you up', 20: 'Never gonna let', +diff -uarN chromium-53.0.2785.92.orig/tools/grit/grit/format/gzip_string.py chromium-53.0.2785.92/tools/grit/grit/format/gzip_string.py +--- chromium-53.0.2785.92.orig/tools/grit/grit/format/gzip_string.py 2016-09-02 21:02:26.000000000 +0200 ++++ chromium-53.0.2785.92/tools/grit/grit/format/gzip_string.py 1970-01-01 01:00:00.000000000 +0100 +@@ -1,43 +0,0 @@ +-# Copyright (c) 2016 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. +-"""Provides gzip utilities for strings. +-""" +-import cStringIO +-import gzip +-import subprocess +- +- +-def GzipStringRsyncable(data): +- # Make call to host system's gzip to get access to --rsyncable option. This +- # option makes updates much smaller - if one line is changed in the resource, +- # it won't have to push the entire compressed resource with the update. +- # Instead, --rsyncable breaks the file into small chunks, so that one doesn't +- # affect the other in compression, and then only that chunk will have to be +- # updated. +- gzip_proc = subprocess.Popen(['gzip', '--stdout', '--rsyncable', +- '--best', '--no-name'], +- stdin=subprocess.PIPE, +- stdout=subprocess.PIPE, +- stderr=subprocess.PIPE) +- data, stderr = gzip_proc.communicate(data) +- if gzip_proc.returncode != 0: +- raise subprocess.CalledProcessError(gzip_proc.returncode, 'gzip', +- stderr) +- return data +- +- +-def GzipString(data): +- # Gzipping using Python's built in gzip: Windows doesn't ship with gzip, and +- # OSX's gzip does not have an --rsyncable option built in. Although this is +- # not preferable to --rsyncable, it is an option for the systems that do +- # not have --rsyncable. If used over GzipStringRsyncable, the primary +- # difference of this function's compression will be larger updates every time +- # a compressed resource is changed. +- gzip_output = cStringIO.StringIO() +- with gzip.GzipFile(mode='wb', compresslevel=9, fileobj=gzip_output, +- mtime=0) as gzip_file: +- gzip_file.write(data) +- data = gzip_output.getvalue() +- gzip_output.close() +- return data +diff -uarN chromium-53.0.2785.92.orig/tools/grit/grit/format/gzip_string_unittest.py chromium-53.0.2785.92/tools/grit/grit/format/gzip_string_unittest.py +--- chromium-53.0.2785.92.orig/tools/grit/grit/format/gzip_string_unittest.py 2016-09-02 21:02:26.000000000 +0200 ++++ chromium-53.0.2785.92/tools/grit/grit/format/gzip_string_unittest.py 1970-01-01 01:00:00.000000000 +0100 +@@ -1,62 +0,0 @@ +-# Copyright (c) 2016 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. +- +-'''Unit tests for grit.format.gzip_string''' +- +-import gzip +-import io +-import os +-import sys +-if __name__ == '__main__': +- sys.path.append(os.path.join(os.path.dirname(__file__), '../..')) +- +-import unittest +- +-from grit.format import gzip_string +- +- +-class FormatGzipStringUnittest(unittest.TestCase): +- +- def testGzipStringRsyncable(self): +- # Can only test the rsyncable version on platforms which support rsyncable, +- # which at the moment is Linux. +- if sys.platform == 'linux2': +- header_begin = ('\x1f\x8b') # gzip first two bytes +- input = ('TEST STRING STARTING NOW' +- 'continuing' +- '' +- '') +- +- compressed = gzip_string.GzipStringRsyncable(input) +- self.failUnless(header_begin == compressed[:2]) +- +- compressed_file = io.BytesIO() +- compressed_file.write(compressed) +- compressed_file.seek(0) +- +- with gzip.GzipFile(mode='rb', fileobj=compressed_file) as f: +- output = f.read() +- self.failUnless(output == input) +- +- def testGzipString(self): +- header_begin = '\x1f\x8b' # gzip first two bytes +- input = ('TEST STRING STARTING NOW' +- 'continuing' +- '' +- '') +- +- compressed = gzip_string.GzipString(input) +- self.failUnless(header_begin == compressed[:2]) +- +- compressed_file = io.BytesIO() +- compressed_file.write(compressed) +- compressed_file.seek(0) +- +- with gzip.GzipFile(mode='rb', fileobj=compressed_file) as f: +- output = f.read() +- self.failUnless(output == input) +- +- +-if __name__ == '__main__': +- unittest.main() +diff -uarN chromium-53.0.2785.92.orig/tools/grit/grit/node/include.py chromium-53.0.2785.92/tools/grit/grit/node/include.py +--- chromium-53.0.2785.92.orig/tools/grit/grit/node/include.py 2016-09-02 21:02:26.000000000 +0200 ++++ chromium-53.0.2785.92/tools/grit/grit/node/include.py 2016-09-14 10:03:21.650947219 +0200 +@@ -7,21 +7,16 @@ + """ + + import os +-import sys + +-from grit import exception +-from grit import util +-import grit.format.gzip_string + import grit.format.html_inline +-import grit.format.rc + import grit.format.rc_header ++import grit.format.rc ++ + from grit.node import base ++from grit import util + + class IncludeNode(base.Node): + """An element.""" +- +- RESERVED_HEADER = '\xff\x1f\x8b' +- + def __init__(self): + super(IncludeNode, self).__init__() + +@@ -43,6 +38,7 @@ + preprocess_only=False, + allow_external_script=allow_external_script)) + return self._flattened_data ++ + def MandatoryAttributes(self): + return ['name', 'type', 'file'] + +@@ -52,7 +48,6 @@ + 'filenameonly': 'false', + 'mkoutput': 'false', + 'flattenhtml': 'false', +- 'compress': 'false', + 'allowexternalscript': 'false', + 'relativepath': 'false', + 'use_base_dir': 'true', +@@ -96,25 +91,6 @@ + filename = self.ToRealPath(self.GetInputPath()) + data = util.ReadFile(filename, util.BINARY) + +- if 'compress' in self.attrs and self.attrs['compress'] == 'gzip': +- # We only use rsyncable compression on Linux. +- # We exclude ChromeOS since ChromeOS bots are Linux based but do not have +- # the --rsyncable option built in for gzip. See crbug.com/617950. +- if sys.platform == 'linux2' and 'chromeos' not in self.GetRoot().defines: +- data = grit.format.gzip_string.GzipStringRsyncable(data) +- else: +- data = grit.format.gzip_string.GzipString(data) +- data = self.RESERVED_HEADER[0] + data +- elif data[:3] == self.RESERVED_HEADER: +- # We are reserving these 3 bytes as the header for gzipped files in the +- # data pack. 1f:8b is the first two bytes of a gzipped header, and ff is +- # a custom byte we throw in front of the gzip header so that we prevent +- # accidentally throwing this error on a resource we gzipped beforehand and +- # don't wish to compress again. If this exception is hit, change the first +- # byte of RESERVED_HEADER, and then mirror that update in +- # ui/base/resource/resource_bundle.h +- raise exception.ReservedHeaderCollision() +- + # Include does not care about the encoding, because it only returns binary + # data. + return id, data +diff -uarN chromium-53.0.2785.92.orig/tools/grit/grit/node/include_unittest.py chromium-53.0.2785.92/tools/grit/grit/node/include_unittest.py +--- chromium-53.0.2785.92.orig/tools/grit/grit/node/include_unittest.py 2016-09-02 21:02:26.000000000 +0200 ++++ chromium-53.0.2785.92/tools/grit/grit/node/include_unittest.py 2016-09-14 09:59:54.548787965 +0200 +@@ -11,8 +11,8 @@ + sys.path.append(os.path.join(os.path.dirname(__file__), '../..')) + + import os ++import StringIO + import unittest +-import zlib + + from grit.node import misc + from grit.node import include +@@ -69,21 +69,6 @@ + util.normpath( + os.path.join(ur'../', ur'flugel/kugel.pdf'))) + +- def testCompressGzip(self): +- root = util.ParseGrdForUnittest(''' +- +- +- ''', base_dir = util.PathFromRoot('grit/testdata')) +- inc, = root.GetChildrenOfType(include.IncludeNode) +- throwaway, compressed = inc.GetDataPackPair(lang='en', encoding=1) +- +- # compressed[1:] ensures we skip the special inserted first byte. +- decompressed_data = zlib.decompress(compressed[1:], 16 + zlib.MAX_WBITS) +- self.assertEqual(util.ReadFile(util.PathFromRoot('grit/testdata') +- + "/test_text.txt", util.BINARY), +- decompressed_data) +- + + if __name__ == '__main__': + unittest.main() +diff -uarN chromium-53.0.2785.92.orig/tools/grit/grit/test_suite_all.py chromium-53.0.2785.92/tools/grit/grit/test_suite_all.py +--- chromium-53.0.2785.92.orig/tools/grit/grit/test_suite_all.py 2016-09-02 21:02:26.000000000 +0200 ++++ chromium-53.0.2785.92/tools/grit/grit/test_suite_all.py 2016-09-14 09:59:54.549788115 +0200 +@@ -35,7 +35,6 @@ + import grit.format.c_format_unittest + import grit.format.chrome_messages_json_unittest + import grit.format.data_pack_unittest +- import grit.format.gzip_string_unittest + import grit.format.html_inline_unittest + import grit.format.js_map_format_unittest + import grit.format.rc_header_unittest +@@ -96,7 +95,6 @@ + grit.format.html_inline_unittest.HtmlInlineUnittest, + grit.format.js_map_format_unittest.JsMapFormatUnittest, + grit.format.rc_header_unittest.RcHeaderFormatterUnittest, +- grit.format.gzip_string_unittest.FormatGzipStringUnittest, + grit.format.rc_unittest.FormatRcUnittest, + grit.format.resource_map_unittest.FormatResourceMapUnittest, + grit.format.policy_templates.policy_template_generator_unittest. +diff -uarN chromium-53.0.2785.92.orig/tools/grit/grit/testdata/test_text.txt chromium-53.0.2785.92/tools/grit/grit/testdata/test_text.txt +--- chromium-53.0.2785.92.orig/tools/grit/grit/testdata/test_text.txt 2016-09-02 21:02:26.000000000 +0200 ++++ chromium-53.0.2785.92/tools/grit/grit/testdata/test_text.txt 1970-01-01 01:00:00.000000000 +0100 +@@ -1 +0,0 @@ +-This is a test! +diff -uarN chromium-53.0.2785.92.orig/ui/base/BUILD.gn chromium-53.0.2785.92/ui/base/BUILD.gn +--- chromium-53.0.2785.92.orig/ui/base/BUILD.gn 2016-09-02 21:02:26.000000000 +0200 ++++ chromium-53.0.2785.92/ui/base/BUILD.gn 2016-09-14 09:59:54.561789920 +0200 +@@ -370,7 +370,6 @@ + "//base/third_party/dynamic_annotations", + "//net", + "//third_party/icu", +- "//third_party/zlib:zlib", + "//ui/base:ui_data_pack", + "//ui/display", + "//ui/events", +diff -uarN chromium-53.0.2785.92.orig/ui/base/DEPS chromium-53.0.2785.92/ui/base/DEPS +--- chromium-53.0.2785.92.orig/ui/base/DEPS 2016-09-02 21:02:26.000000000 +0200 ++++ chromium-53.0.2785.92/ui/base/DEPS 2016-09-14 09:59:54.562790071 +0200 +@@ -3,7 +3,6 @@ + "+net", + "+skia/ext", + "+third_party/skia", +- "+third_party/zlib/zlib.h", + "+ui/display", + "+ui/events", + "+ui/gfx", +diff -uarN chromium-53.0.2785.92.orig/ui/base/resource/resource_bundle.cc chromium-53.0.2785.92/ui/base/resource/resource_bundle.cc +--- chromium-53.0.2785.92.orig/ui/base/resource/resource_bundle.cc 2016-09-02 21:02:26.000000000 +0200 ++++ chromium-53.0.2785.92/ui/base/resource/resource_bundle.cc 2016-09-14 09:59:54.577792329 +0200 +@@ -23,12 +23,10 @@ + #include "base/strings/string_piece.h" + #include "base/strings/utf_string_conversions.h" + #include "base/synchronization/lock.h" +-#include "base/sys_byteorder.h" + #include "build/build_config.h" + #include "skia/ext/image_operations.h" + #include "third_party/skia/include/core/SkBitmap.h" + #include "third_party/skia/include/core/SkColor.h" +-#include "third_party/zlib/zlib.h" + #include "ui/base/l10n/l10n_util.h" + #include "ui/base/layout.h" + #include "ui/base/material_design/material_design_controller.h" +@@ -114,39 +112,6 @@ + return bitmap; + } + +-// Decodes given gzip input via zlib. +-base::RefCountedBytes* DecodeGzipData(const unsigned char* input_buffer, +- size_t input_size) { +- z_stream inflateStream; +- memset(&inflateStream, 0, sizeof(inflateStream)); +- inflateStream.zalloc = Z_NULL; +- inflateStream.zfree = Z_NULL; +- inflateStream.opaque = Z_NULL; +- +- inflateStream.avail_in = input_size; +- inflateStream.next_in = const_cast(input_buffer); +- +- CHECK(input_size >= 4); +- // Size of output comes from footer of gzip file format, found as the last 4 +- // bytes in the compressed file, which are stored little endian. +- inflateStream.avail_out = base::ByteSwapToLE32( +- *reinterpret_cast(&input_buffer[input_size - 4])); +- +- std::vector output(inflateStream.avail_out); +- inflateStream.next_out = reinterpret_cast(&output[0]); +- +- CHECK(inflateInit2(&inflateStream, 16) == Z_OK); +- CHECK(inflate(&inflateStream, Z_FINISH) == Z_STREAM_END); +- CHECK(inflateEnd(&inflateStream) == Z_OK); +- +- // Cannot use TakeVector since it puts the RefCounted* into a scoped_refptr, +- // and callers of this function return a raw pointer (not a scoped_refptr), so +- // the memory will be deallocated upon exit of the calling function. +- base::RefCountedBytes* returnVal = new base::RefCountedBytes(); +- returnVal->data().swap(output); +- return returnVal; +-} +- + } // namespace + + // An ImageSkiaSource that loads bitmaps for the requested scale factor from +@@ -512,16 +477,9 @@ + + if (!bytes) { + base::StringPiece data = +- GetRawDataResourceForScaleImpl(resource_id, scale_factor); ++ GetRawDataResourceForScale(resource_id, scale_factor); + if (!data.empty()) { +- if (data.starts_with(CUSTOM_GZIP_HEADER)) { +- // Jump past special identification byte prepended to header +- const unsigned char* gzip_start = +- reinterpret_cast(data.data()) + 1; +- bytes = DecodeGzipData(gzip_start, data.length() - 1); +- } else { +- bytes = new base::RefCountedStaticMemory(data.data(), data.length()); +- } ++ bytes = new base::RefCountedStaticMemory(data.data(), data.length()); + } + } + +@@ -535,13 +493,31 @@ + base::StringPiece ResourceBundle::GetRawDataResourceForScale( + int resource_id, + ScaleFactor scale_factor) const { +- base::StringPiece data = +- GetRawDataResourceForScaleImpl(resource_id, scale_factor); ++ base::StringPiece data; ++ if (delegate_ && ++ delegate_->GetRawDataResource(resource_id, scale_factor, &data)) ++ return data; + +- // Do not allow this function to retrieve gzip compressed resources. +- CHECK(!data.starts_with(CUSTOM_GZIP_HEADER)); ++ if (scale_factor != ui::SCALE_FACTOR_100P) { ++ for (size_t i = 0; i < data_packs_.size(); i++) { ++ if (data_packs_[i]->GetScaleFactor() == scale_factor && ++ data_packs_[i]->GetStringPiece(static_cast(resource_id), ++ &data)) ++ return data; ++ } ++ } + +- return data; ++ for (size_t i = 0; i < data_packs_.size(); i++) { ++ if ((data_packs_[i]->GetScaleFactor() == ui::SCALE_FACTOR_100P || ++ data_packs_[i]->GetScaleFactor() == ui::SCALE_FACTOR_200P || ++ data_packs_[i]->GetScaleFactor() == ui::SCALE_FACTOR_300P || ++ data_packs_[i]->GetScaleFactor() == ui::SCALE_FACTOR_NONE) && ++ data_packs_[i]->GetStringPiece(static_cast(resource_id), ++ &data)) ++ return data; ++ } ++ ++ return base::StringPiece(); + } + + base::string16 ResourceBundle::GetLocalizedString(int message_id) { +@@ -901,36 +877,6 @@ + return false; + } + +-base::StringPiece ResourceBundle::GetRawDataResourceForScaleImpl( +- int resource_id, +- ScaleFactor scale_factor) const { +- base::StringPiece data; +- if (delegate_ && +- delegate_->GetRawDataResource(resource_id, scale_factor, &data)) +- return data; +- +- if (scale_factor != ui::SCALE_FACTOR_100P) { +- for (size_t i = 0; i < data_packs_.size(); i++) { +- if (data_packs_[i]->GetScaleFactor() == scale_factor && +- data_packs_[i]->GetStringPiece(static_cast(resource_id), +- &data)) +- return data; +- } +- } +- +- for (size_t i = 0; i < data_packs_.size(); i++) { +- if ((data_packs_[i]->GetScaleFactor() == ui::SCALE_FACTOR_100P || +- data_packs_[i]->GetScaleFactor() == ui::SCALE_FACTOR_200P || +- data_packs_[i]->GetScaleFactor() == ui::SCALE_FACTOR_300P || +- data_packs_[i]->GetScaleFactor() == ui::SCALE_FACTOR_NONE) && +- data_packs_[i]->GetStringPiece(static_cast(resource_id), +- &data)) +- return data; +- } +- +- return base::StringPiece(); +-} +- + gfx::Image& ResourceBundle::GetEmptyImage() { + base::AutoLock lock(*images_and_fonts_lock_); + +diff -uarN chromium-53.0.2785.92.orig/ui/base/resource/resource_bundle.h chromium-53.0.2785.92/ui/base/resource/resource_bundle.h +--- chromium-53.0.2785.92.orig/ui/base/resource/resource_bundle.h 2016-09-02 21:02:26.000000000 +0200 ++++ chromium-53.0.2785.92/ui/base/resource/resource_bundle.h 2016-09-14 09:59:54.587793833 +0200 +@@ -50,8 +50,6 @@ + static const int kMediumFontDelta = 3; + static const int kLargeFontDelta = 8; + +- static constexpr const char* CUSTOM_GZIP_HEADER = "\xff\x1f\x8b"; +- + // Legacy font style mappings. TODO(tapted): Phase these out in favour of + // client code providing their own constant with the desired font size delta. + enum FontStyle { +@@ -230,7 +228,7 @@ + ScaleFactor scale_factor) const; + + // Return the contents of a scale independent resource in a +- // StringPiece given the resource id. ++ // StringPiece given the resource id + base::StringPiece GetRawDataResource(int resource_id) const; + + // Return the contents of a resource in a StringPiece given the resource id +@@ -388,15 +386,6 @@ + SkBitmap* bitmap, + bool* fell_back_to_1x) const; + +- // Loads the raw bytes of a data resource nearest the scale factor +- // |scale_factor| into |bytes|, without doing any processing or +- // interpretation of the resource. Use ResourceHandle::SCALE_FACTOR_NONE +- // for scale independent image resources (such as wallpaper). +- // Returns NULL if we fail to read the resource. +- base::StringPiece GetRawDataResourceForScaleImpl( +- int resource_id, +- ScaleFactor scale_factor) const; +- + // Returns true if missing scaled resources should be visually indicated when + // drawing the fallback (e.g., by tinting the image). + static bool ShouldHighlightMissingScaledResources(); +diff -uarN chromium-53.0.2785.92.orig/ui/base/resource/resource_bundle_unittest.cc chromium-53.0.2785.92/ui/base/resource/resource_bundle_unittest.cc +--- chromium-53.0.2785.92.orig/ui/base/resource/resource_bundle_unittest.cc 2016-09-02 21:02:26.000000000 +0200 ++++ chromium-53.0.2785.92/ui/base/resource/resource_bundle_unittest.cc 2016-09-14 09:59:54.588793983 +0200 +@@ -6,7 +6,6 @@ + + #include + #include +-#include + + #include "base/base_paths.h" + #include "base/big_endian.h" +@@ -271,44 +270,6 @@ + EXPECT_EQ(static_memory, result); + } + +-TEST_F(ResourceBundleTest, LoadDataResourceBytesGzip) { +- base::ScopedTempDir dir; +- ASSERT_TRUE(dir.CreateUniqueTempDir()); +- base::FilePath data_path = dir.path().Append(FILE_PATH_LITERAL("sample.pak")); +- +- char kCompressedEntryPakContents[] = { +- 0x04u, 0x00u, 0x00u, 0x00u, // header(version +- 0x01u, 0x00u, 0x00u, 0x00u, // no. entries +- 0x01u, // encoding) +- 0x04u, 0x00u, 0x15u, 0x00u, 0x00u, 0x00u, // index entry 4 +- 0x00u, 0x00u, 0x3bu, 0x00u, 0x00u, +- 0x00u, // extra entry for the size of last +- // Entry 4 is a compressed gzip file (with custom leading byte) saying: +- // "This is compressed\n" +- ResourceBundle::CUSTOM_GZIP_HEADER[0], 0x1fu, 0x8bu, 0x08u, 0x00u, 0x00u, +- 0x00u, 0x00u, 0x00u, 0x00u, 0x03u, 0x0bu, 0xc9u, 0xc8u, 0x2cu, 0x56u, +- 0x00u, 0xa2u, 0xe4u, 0xfcu, 0xdcu, 0x82u, 0xa2u, 0xd4u, 0xe2u, 0xe2u, +- 0xd4u, 0x14u, 0x2eu, 0x00u, 0xd9u, 0xf8u, 0xc4u, 0x6fu, 0x13u, 0x00u, +- 0x00u, 0x00u}; +- +- size_t compressed_entry_pak_size = sizeof(kCompressedEntryPakContents); +- +- // Dump contents into the pak file. +- ASSERT_EQ(base::WriteFile(data_path, kCompressedEntryPakContents, +- compressed_entry_pak_size), static_cast(compressed_entry_pak_size)); +- +- ResourceBundle* resource_bundle = CreateResourceBundle(nullptr); +- resource_bundle->AddDataPackFromPath(data_path, SCALE_FACTOR_NONE); +- +- // Load the compressed resource. +- scoped_refptr result = +- resource_bundle->LoadDataResourceBytes(4); +- EXPECT_EQ( +- strncmp("This is compressed\n", +- reinterpret_cast(result->front()), result->size()), +- 0); +-} +- + TEST_F(ResourceBundleTest, DelegateGetRawDataResource) { + MockResourceBundleDelegate delegate; + ResourceBundle* resource_bundle = CreateResourceBundle(&delegate); +diff -uarN chromium-53.0.2785.92.orig/ui/base/ui_base.gyp chromium-53.0.2785.92/ui/base/ui_base.gyp +--- chromium-53.0.2785.92.orig/ui/base/ui_base.gyp 2016-09-02 21:02:26.000000000 +0200 ++++ chromium-53.0.2785.92/ui/base/ui_base.gyp 2016-09-14 09:59:54.605796544 +0200 +@@ -66,7 +66,6 @@ + '../../skia/skia.gyp:skia', + '../../third_party/icu/icu.gyp:icui18n', + '../../third_party/icu/icu.gyp:icuuc', +- '../../third_party/zlib/zlib.gyp:zlib', + '../../url/url.gyp:url_lib', + '../display/display.gyp:display', + '../events/events.gyp:events', -- cgit v1.2.3-65-gdbad