Skip to content

Commit

Permalink
Avoid patching for theme_service_factory.cc
Browse files Browse the repository at this point in the history
  • Loading branch information
simonhong committed Nov 24, 2020
1 parent f5540d4 commit f9bce3e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 14 deletions.
19 changes: 14 additions & 5 deletions chromium_src/chrome/browser/themes/theme_service_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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);
}
18 changes: 18 additions & 0 deletions chromium_src/chrome/browser/themes/theme_service_factory.h
Original file line number Diff line number Diff line change
@@ -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_
10 changes: 1 addition & 9 deletions patches/chrome-browser-themes-theme_service_factory.cc.patch
Original file line number Diff line number Diff line change
@@ -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() {}
Expand All @@ -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);
}

0 comments on commit f9bce3e

Please sign in to comment.