diff --git a/chromium_src/chrome/browser/themes/theme_service_factory.cc b/chromium_src/chrome/browser/themes/theme_service_factory.cc index cf888bd7b08d..7807d8e071da 100644 --- a/chromium_src/chrome/browser/themes/theme_service_factory.cc +++ b/chromium_src/chrome/browser/themes/theme_service_factory.cc @@ -3,9 +3,12 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "chrome/browser/themes/theme_service_factory.h" - #include "brave/browser/themes/brave_theme_service.h" +// Below files are included in advance to prevent overriding GetBrowserContextToUse. +#include "chrome/browser/extensions/extension_system_factory.h" +#include "chrome/browser/themes/theme_service_factory.h" +#include "extensions/browser/extension_prefs_factory.h" +#include "extensions/browser/extension_registry_factory.h" #if !defined(OS_LINUX) #define BRAVE_THEMESERVICEFACTORY_BUILDSERVICEINSTANCEFOR \ @@ -15,9 +18,15 @@ #define BRAVE_THEMESERVICEFACTORY_BUILDSERVICEINSTANCEFOR #endif -#define BRAVE_THEMESERVICEFACTORY_GETBROWSERCONTEXTTOUSE \ - if (context->IsTor()) return context; +#define GetBrowserContextToUse GetBrowserContextToUse_ChromiumImpl #include "../../../../../chrome/browser/themes/theme_service_factory.cc" #undef BRAVE_THEMESERVICEFACTORY_BUILDSERVICEINSTANCEFOR -#undef BRAVE_THEMESERVICEFACTORY_GETBROWSERCONTEXTTOUSE +#undef GetBrowserContextToUse + +content::BrowserContext* ThemeServiceFactory::GetBrowserContextToUse( + content::BrowserContext* context) const { + if (context->IsTor()) + return context; + return ThemeServiceFactory::GetBrowserContextToUse_ChromiumImpl(context); +} diff --git a/chromium_src/chrome/browser/themes/theme_service_factory.h b/chromium_src/chrome/browser/themes/theme_service_factory.h new file mode 100644 index 000000000000..032468d77031 --- /dev/null +++ b/chromium_src/chrome/browser/themes/theme_service_factory.h @@ -0,0 +1,18 @@ +/* Copyright (c) 2020 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef BRAVE_CHROMIUM_SRC_CHROME_BROWSER_THEMES_THEME_SERVICE_FACTORY_H_ +#define BRAVE_CHROMIUM_SRC_CHROME_BROWSER_THEMES_THEME_SERVICE_FACTORY_H_ + +// Below files are included in advance to prevent overriding GetBrowserContextToUse. +#include "components/keyed_service/content/browser_context_keyed_service_factory.h" + +#define GetBrowserContextToUse GetBrowserContextToUse_ChromiumImpl(content::BrowserContext* context) const; content::BrowserContext* GetBrowserContextToUse + +#include "../../../../../chrome/browser/themes/theme_service_factory.h" + +#undef GetBrowserContextToUse + +#endif // BRAVE_CHROMIUM_SRC_CHROME_BROWSER_THEMES_THEME_SERVICE_FACTORY_H_ diff --git a/patches/chrome-browser-themes-theme_service_factory.cc.patch b/patches/chrome-browser-themes-theme_service_factory.cc.patch index 22add237f79e..8e4ff2857eaa 100644 --- a/patches/chrome-browser-themes-theme_service_factory.cc.patch +++ b/patches/chrome-browser-themes-theme_service_factory.cc.patch @@ -1,5 +1,5 @@ diff --git a/chrome/browser/themes/theme_service_factory.cc b/chrome/browser/themes/theme_service_factory.cc -index caec77bbe3ba59b030622d3a9ff4fb1edd0a476d..e6d475bc2908d5a30376535c8988d8a45db78b36 100644 +index caec77bbe3ba59b030622d3a9ff4fb1edd0a476d..b1b48ed7fb8022d6377594754ce1f300b01a8fca 100644 --- a/chrome/browser/themes/theme_service_factory.cc +++ b/chrome/browser/themes/theme_service_factory.cc @@ -77,6 +77,7 @@ ThemeServiceFactory::~ThemeServiceFactory() {} @@ -10,11 +10,3 @@ index caec77bbe3ba59b030622d3a9ff4fb1edd0a476d..e6d475bc2908d5a30376535c8988d8a4 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) using ThemeService = ThemeServiceAuraLinux; #endif -@@ -108,6 +109,7 @@ void ThemeServiceFactory::RegisterProfilePrefs( - - content::BrowserContext* ThemeServiceFactory::GetBrowserContextToUse( - content::BrowserContext* context) const { -+ BRAVE_THEMESERVICEFACTORY_GETBROWSERCONTEXTTOUSE - return chrome::GetBrowserContextRedirectedInIncognito(context); - } -