summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorjk2021-03-12 20:54:25 -0500
committerjk2021-03-12 20:54:25 -0500
commit77998aabb19eb82d6b036685a6fce85018825659 (patch)
tree1af53fde0dd53da011c2e17b6907a0b2a1dffa18
parent92b1deaa2a5db8a9f5cc7afd3c05f62d594a858a (diff)
downloadaur-77998aabb19eb82d6b036685a6fce85018825659.tar.gz
upgpkg: ungoogled-chromium 89.0.4389.82-2
-rw-r--r--.SRCINFO41
-rw-r--r--PKGBUILD53
-rw-r--r--add-dependency-on-opus-in-webcodecs.patch43
-rw-r--r--subpixel-anti-aliasing-in-FreeType-2.8.1.patch100
-rw-r--r--use-oauth2-client-switches-as-default.patch17
-rw-r--r--x11-ozone-fix-two-edge-cases.patch135
6 files changed, 246 insertions, 143 deletions
diff --git a/.SRCINFO b/.SRCINFO
index 0518c57245a1..b964d97a7dd8 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,23 +1,20 @@
pkgbase = ungoogled-chromium
pkgdesc = A lightweight approach to removing Google web service dependency
- pkgver = 88.0.4324.182
- pkgrel = 1
+ pkgver = 89.0.4389.82
+ pkgrel = 2
url = https://github.com/Eloston/ungoogled-chromium
arch = x86_64
license = BSD
makedepends = python
- makedepends = python2
- makedepends = gperf
- makedepends = mesa
+ makedepends = gn
makedepends = ninja
- makedepends = nodejs
- makedepends = git
- makedepends = libva
- makedepends = libpipewire02
makedepends = clang
makedepends = lld
- makedepends = gn
+ makedepends = gperf
+ makedepends = nodejs
+ makedepends = pipewire
makedepends = java-runtime-headless
+ makedepends = python2
makedepends = python2-setuptools
depends = gtk3
depends = nss
@@ -31,6 +28,7 @@ pkgbase = ungoogled-chromium
depends = dbus
depends = libpulse
depends = pciutils
+ depends = libva
depends = desktop-file-utils
depends = hicolor-icon-theme
depends = fontconfig
@@ -48,29 +46,32 @@ pkgbase = ungoogled-chromium
depends = libxslt
depends = libpng
depends = freetype2
- optdepends = libpipewire02: WebRTC desktop sharing under Wayland
- optdepends = libva: hardware-accelerated video decode [experimental]
+ optdepends = pipewire: WebRTC desktop sharing under Wayland
optdepends = kdialog: needed for file dialogs in KDE
optdepends = org.freedesktop.secrets: password storage backend on GNOME / Xfce
optdepends = kwallet: for storing passwords in KWallet on KDE desktops
provides = chromium
conflicts = chromium
- source = https://commondatastorage.googleapis.com/chromium-browser-official/chromium-88.0.4324.182.tar.xz
- source = ungoogled-chromium-88.0.4324.182-1.tar.gz::https://github.com/Eloston/ungoogled-chromium/archive/88.0.4324.182-1.tar.gz
+ source = https://commondatastorage.googleapis.com/chromium-browser-official/chromium-89.0.4389.82.tar.xz
+ source = ungoogled-chromium-89.0.4389.82-1.tar.gz::https://github.com/Eloston/ungoogled-chromium/archive/89.0.4389.82-1.tar.gz
source = https://github.com/foutrelis/chromium-launcher/archive/v7/chromium-launcher-7.tar.gz
+ source = https://github.com/stha09/chromium-patches/releases/download/chromium-89-patchset-7/chromium-89-patchset-7.tar.xz
+ source = add-dependency-on-opus-in-webcodecs.patch
+ source = x11-ozone-fix-two-edge-cases.patch
source = chromium-drirc-disable-10bpc-color-configs.conf
- source = https://github.com/stha09/chromium-patches/releases/download/chromium-88-patchset-3/chromium-88-patchset-3.tar.xz
source = chromium-glibc-2.33.patch
source = wayland-egl.patch
- source = subpixel-anti-aliasing-in-FreeType-2.8.1.patch
- sha256sums = 30411fc3ec2d33df4c5cad41f21affa3823c80f7dbd394f6d68f9a1e81015b81
- sha256sums = 4b0e06af18f084c11b3fea6a084d27e13952e8192f39c066563dfa8890d6e6d8
+ source = use-oauth2-client-switches-as-default.patch
+ sha256sums = df4914407b68afdc6449cb8e3f1b08d110eb8689ac41f86490e337fa4d1be379
+ sha256sums = 2bc8d0089c1a687b146a7921fcc5946c5f5f7c1745a1fe1ea6f0e275d4338631
sha256sums = 86859c11cfc8ba106a3826479c0bc759324a62150b271dd35d1a0f96e890f52f
+ sha256sums = f8b1558f6c87b33423da854d42f0f69d47885a96d6bf6ce7f26373e93d47442f
+ sha256sums = b86b11de8db438c47f0a84c7956740f648d21035f4ee46bfbd50c3348d369121
+ sha256sums = 9e4743bdeaf5b668659ad53400e3977006916aac3a7ba045bbc750b7b4cbf274
sha256sums = babda4f5c1179825797496898d77334ac067149cac03d797ab27ac69671a7feb
- sha256sums = e5a60a4c9d0544d3321cc241b4c7bd4adb0a885f090c6c6c21581eac8e3b4ba9
sha256sums = 2fccecdcd4509d4c36af873988ca9dbcba7fdb95122894a9fdf502c33a1d7a4b
sha256sums = 34d08ea93cb4762cb33c7cffe931358008af32265fc720f2762f0179c3973574
- sha256sums = 1e2913e21c491d546e05f9b4edf5a6c7a22d89ed0b36ef692ca6272bcd5faec6
+ sha256sums = e393174d7695d0bafed69e868c5fbfecf07aa6969f3b64596d0bae8b067e1711
pkgname = ungoogled-chromium
diff --git a/PKGBUILD b/PKGBUILD
index e4bc1825390a..d27cbbc750f9 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -9,10 +9,10 @@
# Contributor: Daniel J Griffiths <ghost1227@archlinux.us>
pkgname=ungoogled-chromium
-pkgver=88.0.4324.182
-pkgrel=1
+pkgver=89.0.4389.82
+pkgrel=2
_launcher_ver=7
-_gcc_patchset=3
+_gcc_patchset=7
_pkgname=$(echo $pkgname | cut -d\- -f1-2)
_pkgver=$(echo $pkgver | cut -d\. -f1-4)
# ungoogled chromium variables
@@ -23,13 +23,11 @@ arch=('x86_64')
url="https://github.com/Eloston/ungoogled-chromium"
license=('BSD')
depends=('gtk3' 'nss' 'alsa-lib' 'xdg-utils' 'libxss' 'libcups' 'libgcrypt'
- 'ttf-liberation' 'systemd' 'dbus' 'libpulse' 'pciutils'
+ 'ttf-liberation' 'systemd' 'dbus' 'libpulse' 'pciutils' 'libva'
'desktop-file-utils' 'hicolor-icon-theme')
-makedepends=('python' 'python2' 'gperf' 'mesa' 'ninja' 'nodejs' 'git' 'libva'
- 'libpipewire02' 'clang' 'lld' 'gn' 'java-runtime-headless'
- 'python2-setuptools')
-optdepends=('libpipewire02: WebRTC desktop sharing under Wayland'
- 'libva: hardware-accelerated video decode [experimental]'
+makedepends=('python' 'gn' 'ninja' 'clang' 'lld' 'gperf' 'nodejs' 'pipewire'
+ 'java-runtime-headless' 'python2' 'python2-setuptools')
+optdepends=('pipewire: WebRTC desktop sharing under Wayland'
'kdialog: needed for file dialogs in KDE'
'org.freedesktop.secrets: password storage backend on GNOME / Xfce'
'kwallet: for storing passwords in KWallet on KDE desktops')
@@ -38,19 +36,23 @@ conflicts=('chromium')
source=(https://commondatastorage.googleapis.com/chromium-browser-official/chromium-$_pkgver.tar.xz
$_pkgname-$_uc_ver.tar.gz::https://github.com/$_uc_usr/ungoogled-chromium/archive/$_uc_ver.tar.gz
https://github.com/foutrelis/chromium-launcher/archive/v$_launcher_ver/chromium-launcher-$_launcher_ver.tar.gz
- chromium-drirc-disable-10bpc-color-configs.conf
https://github.com/stha09/chromium-patches/releases/download/chromium-${pkgver%%.*}-patchset-$_gcc_patchset/chromium-${pkgver%%.*}-patchset-$_gcc_patchset.tar.xz
+ add-dependency-on-opus-in-webcodecs.patch
+ x11-ozone-fix-two-edge-cases.patch
+ chromium-drirc-disable-10bpc-color-configs.conf
chromium-glibc-2.33.patch
wayland-egl.patch
- subpixel-anti-aliasing-in-FreeType-2.8.1.patch)
-sha256sums=('30411fc3ec2d33df4c5cad41f21affa3823c80f7dbd394f6d68f9a1e81015b81'
- '4b0e06af18f084c11b3fea6a084d27e13952e8192f39c066563dfa8890d6e6d8'
+ use-oauth2-client-switches-as-default.patch)
+sha256sums=('df4914407b68afdc6449cb8e3f1b08d110eb8689ac41f86490e337fa4d1be379'
+ '2bc8d0089c1a687b146a7921fcc5946c5f5f7c1745a1fe1ea6f0e275d4338631'
'86859c11cfc8ba106a3826479c0bc759324a62150b271dd35d1a0f96e890f52f'
+ 'f8b1558f6c87b33423da854d42f0f69d47885a96d6bf6ce7f26373e93d47442f'
+ 'b86b11de8db438c47f0a84c7956740f648d21035f4ee46bfbd50c3348d369121'
+ '9e4743bdeaf5b668659ad53400e3977006916aac3a7ba045bbc750b7b4cbf274'
'babda4f5c1179825797496898d77334ac067149cac03d797ab27ac69671a7feb'
- 'e5a60a4c9d0544d3321cc241b4c7bd4adb0a885f090c6c6c21581eac8e3b4ba9'
'2fccecdcd4509d4c36af873988ca9dbcba7fdb95122894a9fdf502c33a1d7a4b'
'34d08ea93cb4762cb33c7cffe931358008af32265fc720f2762f0179c3973574'
- '1e2913e21c491d546e05f9b4edf5a6c7a22d89ed0b36ef692ca6272bcd5faec6')
+ 'e393174d7695d0bafed69e868c5fbfecf07aa6969f3b64596d0bae8b067e1711')
# Possible replacements are listed in build/linux/unbundle/replace_gn_files.py
# Keys are the names in the above script; values are the dependencies in Arch
@@ -91,17 +93,21 @@ prepare() {
third_party/blink/renderer/core/xml/parser/xml_document_parser.cc \
third_party/libxml/chromium/*.cc
+ # Use the --oauth2-client-id= and --oauth2-client-secret= switches for
+ # setting GOOGLE_DEFAULT_CLIENT_ID and GOOGLE_DEFAULT_CLIENT_SECRET at
+ # runtime -- this allows signing into Chromium without baked-in values
+ patch -Np1 -i ../use-oauth2-client-switches-as-default.patch
+
# https://crbug.com/1164975
patch -Np1 -i ../chromium-glibc-2.33.patch
# Upstream fixes
- patch -Np1 -d third_party/skia <../subpixel-anti-aliasing-in-FreeType-2.8.1.patch
+ patch -Np1 -i ../add-dependency-on-opus-in-webcodecs.patch
+ patch -Np1 -i ../x11-ozone-fix-two-edge-cases.patch
# Fixes for building with libstdc++ instead of libc++
- patch -Np1 -i ../patches/chromium-87-openscreen-include.patch
- patch -Np1 -i ../patches/chromium-88-CompositorFrameReporter-dcheck.patch
- patch -Np1 -i ../patches/chromium-88-ideographicSpaceCharacter.patch
- patch -Np1 -i ../patches/chromium-88-AXTreeFormatter-include.patch
+ patch -Np1 -i ../patches/chromium-89-quiche-dcheck.patch
+ patch -Np1 -i ../patches/chromium-89-AXTreeSerializer-include.patch
# Wayland/EGL regression (crbug #1071528 #1071550)
patch -Np1 -i ../wayland-egl.patch
@@ -136,7 +142,7 @@ prepare() {
-delete
done
- python2 build/linux/unbundle/replace_gn_files.py \
+ ./build/linux/unbundle/replace_gn_files.py \
--system-libraries "${!_system_libs[@]}"
}
@@ -159,15 +165,16 @@ build() {
'custom_toolchain="//build/toolchain/linux/unbundle:default"'
'host_toolchain="//build/toolchain/linux/unbundle:default"'
'is_official_build=true' # implies is_cfi=true on x86_64
+ 'chrome_pgo_phase=0' # unsupported instrumentation profile format version
'ffmpeg_branding="Chrome"'
'proprietary_codecs=true'
'rtc_use_pipewire=true'
+ 'rtc_pipewire_version="0.3"' # will be the default in Chromium 90
'link_pulseaudio=true'
'use_gnome_keyring=false'
'use_sysroot=false'
'use_custom_libcxx=false'
'enable_widevine=true'
- 'use_vaapi=true'
)
if [[ -n ${_system_libs[icu]+set} ]]; then
@@ -192,7 +199,7 @@ build() {
CXXFLAGS+=' -Wno-unknown-warning-option'
msg2 'Configuring Chromium'
- gn gen out/Release --args="${_flags[*]}" --script-executable=python2
+ gn gen out/Release --args="${_flags[*]}"
msg2 'Building Chromium'
ninja -C out/Release chrome chrome_sandbox chromedriver
}
diff --git a/add-dependency-on-opus-in-webcodecs.patch b/add-dependency-on-opus-in-webcodecs.patch
new file mode 100644
index 000000000000..12e1116fafc9
--- /dev/null
+++ b/add-dependency-on-opus-in-webcodecs.patch
@@ -0,0 +1,43 @@
+From b5b80df7dafba8cafa4c6c0ba2153dfda467dfc9 Mon Sep 17 00:00:00 2001
+From: Stephan Hartmann <stha09@googlemail.com>
+Date: Wed, 27 Jan 2021 20:31:51 +0000
+Subject: [PATCH] add dependency on opus in webcodecs
+
+webcodecs uses opus, but dependency is missing. With unbundled
+opus library build fails, because include path is incomplete.
+
+Bug: 1169758
+Change-Id: I01369364327461196a81002479636cf45017669a
+Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2644623
+Reviewed-by: Dale Curtis <dalecurtis@chromium.org>
+Commit-Queue: Dale Curtis <dalecurtis@chromium.org>
+Cr-Commit-Position: refs/heads/master@{#847754}
+---
+ third_party/blink/renderer/modules/webcodecs/BUILD.gn | 1 +
+ third_party/blink/renderer/modules/webcodecs/DEPS | 1 +
+ 2 files changed, 2 insertions(+)
+
+diff --git a/third_party/blink/renderer/modules/webcodecs/BUILD.gn b/third_party/blink/renderer/modules/webcodecs/BUILD.gn
+index fdf4ca0fafc72..01a7bf809ffca 100644
+--- a/third_party/blink/renderer/modules/webcodecs/BUILD.gn
++++ b/third_party/blink/renderer/modules/webcodecs/BUILD.gn
+@@ -65,6 +65,7 @@ blink_modules_sources("webcodecs") {
+ "//media/mojo/clients",
+ "//media/mojo/mojom",
+ "//third_party/libyuv:libyuv",
++ "//third_party/opus",
+ ]
+ if (media_use_openh264) {
+ deps += [ "//third_party/openh264:encoder" ]
+diff --git a/third_party/blink/renderer/modules/webcodecs/DEPS b/third_party/blink/renderer/modules/webcodecs/DEPS
+index b8dd596da8caf..ea1919d12205a 100644
+--- a/third_party/blink/renderer/modules/webcodecs/DEPS
++++ b/third_party/blink/renderer/modules/webcodecs/DEPS
+@@ -19,6 +19,7 @@ include_rules = [
+
+ "+third_party/libyuv",
+ "+third_party/openh264",
++ "+third_party/opus",
+
+ "+ui/gfx/color_space.h",
+ "+ui/gfx/geometry/rect.h",
diff --git a/subpixel-anti-aliasing-in-FreeType-2.8.1.patch b/subpixel-anti-aliasing-in-FreeType-2.8.1.patch
deleted file mode 100644
index c11b512c16ad..000000000000
--- a/subpixel-anti-aliasing-in-FreeType-2.8.1.patch
+++ /dev/null
@@ -1,100 +0,0 @@
-From f25787b72c20e97cdeb74e037dc1ff56a88b45c6 Mon Sep 17 00:00:00 2001
-From: Ben Wagner <bungeman@google.com>
-Date: Tue, 1 Dec 2020 20:22:00 -0500
-Subject: [PATCH] Subpixel anti-aliasing in FreeType 2.8.1+
-
-FreeType 2.8.1 and later always provide some form of subpixel
-anti-aliasing.
-
-Bug: skia:10950,skia:6663
-Change-Id: I666cc942e73b73073cdabf900c25faa10d9aaf0f
-Reviewed-on: https://skia-review.googlesource.com/c/skia/+/339861
-Reviewed-by: Herb Derby <herb@google.com>
-Commit-Queue: Ben Wagner <bungeman@google.com>
----
- src/ports/SkFontHost_FreeType.cpp | 33 ++++++++++++++++++++-----------
- 1 file changed, 22 insertions(+), 11 deletions(-)
-
-diff --git a/src/ports/SkFontHost_FreeType.cpp b/src/ports/SkFontHost_FreeType.cpp
-index 990eff4f5e..c0aeb792da 100644
---- a/src/ports/SkFontHost_FreeType.cpp
-+++ b/src/ports/SkFontHost_FreeType.cpp
-@@ -32,6 +32,7 @@
- #include "src/utils/SkMatrix22.h"
-
- #include <memory>
-+#include <tuple>
-
- #include <ft2build.h>
- #include FT_ADVANCES_H
-@@ -147,13 +148,16 @@ public:
- // *reinterpret_cast<void**>(&procPtr) = dlsym(self, "proc");
- // because clang has not implemented DR573. See http://clang.llvm.org/cxx_dr_status.html .
-
-- FT_Int major, minor, patch;
-- FT_Library_Version(fLibrary, &major, &minor, &patch);
-+ using Version = std::tuple<FT_Int, FT_Int, FT_Int>;
-+ Version version;
-+ FT_Library_Version(fLibrary, &std::get<0>(version),
-+ &std::get<1>(version),
-+ &std::get<2>(version));
-
- #if SK_FREETYPE_MINIMUM_RUNTIME_VERSION >= 0x02070100
- fGetVarDesignCoordinates = FT_Get_Var_Design_Coordinates;
- #elif SK_FREETYPE_MINIMUM_RUNTIME_VERSION & SK_FREETYPE_DLOPEN
-- if (major > 2 || ((major == 2 && minor > 7) || (major == 2 && minor == 7 && patch >= 0))) {
-+ if (Version(2,7,0) <= version) {
- //The FreeType library is already loaded, so symbols are available in process.
- void* self = dlopen(nullptr, RTLD_LAZY);
- if (self) {
-@@ -166,7 +170,7 @@ public:
- #if SK_FREETYPE_MINIMUM_RUNTIME_VERSION >= 0x02070200
- FT_Set_Default_Properties(fLibrary);
- #elif SK_FREETYPE_MINIMUM_RUNTIME_VERSION & SK_FREETYPE_DLOPEN
-- if (major > 2 || ((major == 2 && minor > 7) || (major == 2 && minor == 7 && patch >= 1))) {
-+ if (Version(2,7,1) <= version) {
- //The FreeType library is already loaded, so symbols are available in process.
- void* self = dlopen(nullptr, RTLD_LAZY);
- if (self) {
-@@ -185,7 +189,7 @@ public:
- #if SK_FREETYPE_MINIMUM_RUNTIME_VERSION >= 0x02080000
- fLightHintingIsYOnly = true;
- #else
-- if (major > 2 || ((major == 2 && minor > 8) || (major == 2 && minor == 8 && patch >= 0))) {
-+ if (Version(2,8,0) <= version) {
- fLightHintingIsYOnly = true;
- }
- #endif
-@@ -194,7 +198,7 @@ public:
- #if SK_FREETYPE_MINIMUM_RUNTIME_VERSION >= 0x02080100
- fGetVarAxisFlags = FT_Get_Var_Axis_Flags;
- #elif SK_FREETYPE_MINIMUM_RUNTIME_VERSION & SK_FREETYPE_DLOPEN
-- if (major > 2 || ((major == 2 && minor > 7) || (major == 2 && minor == 7 && patch >= 0))) {
-+ if (Version(2,7,0) <= version) {
- //The FreeType library is already loaded, so symbols are available in process.
- void* self = dlopen(nullptr, RTLD_LAZY);
- if (self) {
-@@ -204,11 +208,18 @@ public:
- }
- #endif
-
-- // Setup LCD filtering. This reduces color fringes for LCD smoothed glyphs.
-- // The default has changed over time, so this doesn't mean the same thing to all users.
-- if (FT_Library_SetLcdFilter(fLibrary, FT_LCD_FILTER_DEFAULT) == 0) {
-- fIsLCDSupported = true;
-- fLCDExtra = 2; //Using a filter adds one full pixel to each side.
-+ fIsLCDSupported =
-+ // Subpixel anti-aliasing may be unfiltered until the LCD filter is set.
-+ // Newer versions may still need this, so this test with side effects must come first.
-+ // The default has changed over time, so this doesn't mean the same thing to all users.
-+ (FT_Library_SetLcdFilter(fLibrary, FT_LCD_FILTER_DEFAULT) == 0) ||
-+
-+ // In 2.8.1 and later FreeType always provides some form of subpixel anti-aliasing.
-+ ((SK_FREETYPE_MINIMUM_RUNTIME_VERSION) >= 0x02080100) ||
-+ (Version(2,8,1) <= version);
-+
-+ if (fIsLCDSupported) {
-+ fLCDExtra = 2; // Using a filter may require up to one full pixel to each side.
- }
- }
- ~FreeTypeLibrary() {
diff --git a/use-oauth2-client-switches-as-default.patch b/use-oauth2-client-switches-as-default.patch
new file mode 100644
index 000000000000..9d9c57bfb0d2
--- /dev/null
+++ b/use-oauth2-client-switches-as-default.patch
@@ -0,0 +1,17 @@
+diff -upr chromium-89.0.4389.58.orig/google_apis/google_api_keys.cc chromium-89.0.4389.58/google_apis/google_api_keys.cc
+--- chromium-89.0.4389.58.orig/google_apis/google_api_keys.cc 2021-02-24 22:37:18.494007649 +0000
++++ chromium-89.0.4389.58/google_apis/google_api_keys.cc 2021-02-24 22:35:00.865777600 +0000
+@@ -154,11 +154,11 @@ class APIKeyCache {
+
+ std::string default_client_id = CalculateKeyValue(
+ GOOGLE_DEFAULT_CLIENT_ID,
+- STRINGIZE_NO_EXPANSION(GOOGLE_DEFAULT_CLIENT_ID), nullptr,
++ STRINGIZE_NO_EXPANSION(GOOGLE_DEFAULT_CLIENT_ID), ::switches::kOAuth2ClientID,
+ std::string(), environment.get(), command_line, gaia_config);
+ std::string default_client_secret = CalculateKeyValue(
+ GOOGLE_DEFAULT_CLIENT_SECRET,
+- STRINGIZE_NO_EXPANSION(GOOGLE_DEFAULT_CLIENT_SECRET), nullptr,
++ STRINGIZE_NO_EXPANSION(GOOGLE_DEFAULT_CLIENT_SECRET), ::switches::kOAuth2ClientSecret,
+ std::string(), environment.get(), command_line, gaia_config);
+
+ // We currently only allow overriding the baked-in values for the
diff --git a/x11-ozone-fix-two-edge-cases.patch b/x11-ozone-fix-two-edge-cases.patch
new file mode 100644
index 000000000000..9c4c4755ae20
--- /dev/null
+++ b/x11-ozone-fix-two-edge-cases.patch
@@ -0,0 +1,135 @@
+From 5e3a738b1204941aab9f15c0eb3d06e20fefd96e Mon Sep 17 00:00:00 2001
+From: Scott Violet <sky@chromium.org>
+Date: Mon, 8 Mar 2021 21:07:39 +0000
+Subject: [PATCH] x11/ozone: fix two edge cases
+
+WindowTreeHost::OnHostMovedInPixels() may trigger a nested message
+loop (tab dragging), which when the stack unravels means this may
+be deleted. This adds an early out if this happens.
+
+X11WholeScreenMoveLoop has a similar issue, in so far as notifying
+the delegate may delete this.
+
+BUG=1185482
+TEST=WindowTreeHostPlatform.DeleteHostFromOnHostMovedInPixels
+
+Change-Id: Ieca1c90b3e4358da50b332abe2941fdbb50c5c25
+Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2743555
+Reviewed-by: Thomas Anderson <thomasanderson@chromium.org>
+Commit-Queue: Scott Violet <sky@chromium.org>
+Cr-Commit-Position: refs/heads/master@{#860852}
+---
+ ui/aura/window_tree_host_platform.cc | 10 ++++-
+ ui/aura/window_tree_host_platform_unittest.cc | 40 ++++++++++++++++++-
+ ui/base/x/x11_whole_screen_move_loop.cc | 4 ++
+ 3 files changed, 51 insertions(+), 3 deletions(-)
+
+diff --git a/ui/aura/window_tree_host_platform.cc b/ui/aura/window_tree_host_platform.cc
+index ce8395fe07..7589542026 100644
+--- a/ui/aura/window_tree_host_platform.cc
++++ b/ui/aura/window_tree_host_platform.cc
+@@ -214,13 +214,21 @@ void WindowTreeHostPlatform::OnBoundsChanged(const gfx::Rect& new_bounds) {
+ float current_scale = compositor()->device_scale_factor();
+ float new_scale = ui::GetScaleFactorForNativeView(window());
+ gfx::Rect old_bounds = bounds_in_pixels_;
++ auto weak_ref = GetWeakPtr();
+ bounds_in_pixels_ = new_bounds;
+- if (bounds_in_pixels_.origin() != old_bounds.origin())
++ if (bounds_in_pixels_.origin() != old_bounds.origin()) {
+ OnHostMovedInPixels(bounds_in_pixels_.origin());
++ // Changing the bounds may destroy this.
++ if (!weak_ref)
++ return;
++ }
+ if (bounds_in_pixels_.size() != old_bounds.size() ||
+ current_scale != new_scale) {
+ pending_size_ = gfx::Size();
+ OnHostResizedInPixels(bounds_in_pixels_.size());
++ // Changing the size may destroy this.
++ if (!weak_ref)
++ return;
+ }
+ DCHECK_GT(on_bounds_changed_recursion_depth_, 0);
+ if (--on_bounds_changed_recursion_depth_ == 0) {
+diff --git a/ui/aura/window_tree_host_platform_unittest.cc b/ui/aura/window_tree_host_platform_unittest.cc
+index eda14e2f0c..4de039c88a 100644
+--- a/ui/aura/window_tree_host_platform_unittest.cc
++++ b/ui/aura/window_tree_host_platform_unittest.cc
+@@ -34,7 +34,7 @@ class TestWindowTreeHost : public WindowTreeHostPlatform {
+ // OnHostWill/DidProcessBoundsChange. Additionally, this triggers a bounds
+ // change from within OnHostResized(). Such a scenario happens in production
+ // code.
+-class TestWindowTreeHostObserver : public aura::WindowTreeHostObserver {
++class TestWindowTreeHostObserver : public WindowTreeHostObserver {
+ public:
+ TestWindowTreeHostObserver(WindowTreeHostPlatform* host,
+ ui::PlatformWindow* platform_window)
+@@ -51,7 +51,7 @@ class TestWindowTreeHostObserver : public aura::WindowTreeHostObserver {
+ return on_host_will_process_bounds_change_count_;
+ }
+
+- // aura::WindowTreeHostObserver:
++ // WindowTreeHostObserver:
+ void OnHostResized(WindowTreeHost* host) override {
+ if (!should_change_bounds_in_on_resized_)
+ return;
+@@ -92,5 +92,41 @@ TEST_F(WindowTreeHostPlatformTest, HostWillProcessBoundsChangeRecursion) {
+ EXPECT_EQ(1, observer.on_host_will_process_bounds_change_count());
+ }
+
++// Deletes WindowTreeHostPlatform from OnHostMovedInPixels().
++class DeleteHostWindowTreeHostObserver : public WindowTreeHostObserver {
++ public:
++ explicit DeleteHostWindowTreeHostObserver(
++ std::unique_ptr<TestWindowTreeHost> host)
++ : host_(std::move(host)) {
++ host_->AddObserver(this);
++ }
++ ~DeleteHostWindowTreeHostObserver() override = default;
++
++ TestWindowTreeHost* host() { return host_.get(); }
++
++ // WindowTreeHostObserver:
++ void OnHostMovedInPixels(WindowTreeHost* host,
++ const gfx::Point& new_origin_in_pixels) override {
++ host_->RemoveObserver(this);
++ host_.reset();
++ }
++
++ private:
++ std::unique_ptr<TestWindowTreeHost> host_;
++
++ DISALLOW_COPY_AND_ASSIGN(DeleteHostWindowTreeHostObserver);
++};
++
++// Verifies WindowTreeHostPlatform can be safely deleted when calling
++// OnHostMovedInPixels().
++// Regression test for https://crbug.com/1185482
++TEST_F(WindowTreeHostPlatformTest, DeleteHostFromOnHostMovedInPixels) {
++ std::unique_ptr<TestWindowTreeHost> host =
++ std::make_unique<TestWindowTreeHost>();
++ DeleteHostWindowTreeHostObserver observer(std::move(host));
++ observer.host()->SetBoundsInPixels(gfx::Rect(1, 2, 3, 4));
++ EXPECT_EQ(nullptr, observer.host());
++}
++
+ } // namespace
+ } // namespace aura
+diff --git a/ui/base/x/x11_whole_screen_move_loop.cc b/ui/base/x/x11_whole_screen_move_loop.cc
+index 5ed215db66..db678799db 100644
+--- a/ui/base/x/x11_whole_screen_move_loop.cc
++++ b/ui/base/x/x11_whole_screen_move_loop.cc
+@@ -78,9 +78,13 @@ X11WholeScreenMoveLoop::~X11WholeScreenMoveLoop() {
+ void X11WholeScreenMoveLoop::DispatchMouseMovement() {
+ if (!last_motion_in_screen_)
+ return;
++ auto weak_ref = weak_factory_.GetWeakPtr();
+ delegate_->OnMouseMovement(last_motion_in_screen_->root_location(),
+ last_motion_in_screen_->flags(),
+ last_motion_in_screen_->time_stamp());
++ // The delegate may delete this during dispatch.
++ if (!weak_ref)
++ return;
+ last_motion_in_screen_.reset();
+ }
+