diff --git a/chromium_src/chrome/browser/profiles/profile_io_data.cc b/chromium_src/chrome/browser/profiles/profile_io_data.cc index 816e9d05886f..6c7ada50feac 100644 --- a/chromium_src/chrome/browser/profiles/profile_io_data.cc +++ b/chromium_src/chrome/browser/profiles/profile_io_data.cc @@ -3,6 +3,29 @@ * 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/profiles/profile_io_data.h" #include "brave/common/url_constants.h" +#define IsHandledProtocol IsHandledProtocol_ChromiumImpl +#define IsHandledURL IsHandledURL_ChromiumImpl #include "../../../../../chrome/browser/profiles/profile_io_data.cc" +#undef IsHandledURL +#undef IsHandledProtocol + +bool ProfileIOData::IsHandledProtocol(const std::string& scheme) { + if (scheme == kBraveUIScheme) + return true; + return IsHandledProtocol_ChromiumImpl(scheme); +} + +// We need to provide our own version of IsHandledURL() as well to make sure +// that we get our own version of IsHandledProtocol() called when invoked via +// IsHandledURL(). Otherwise the old version will still be called since the +// renaming of IsHandledProtocol above does also modify the call point. +bool ProfileIOData::IsHandledURL(const GURL& url) { + if (!url.is_valid()) { + // We handle error cases. + return true; + } + return IsHandledProtocol(url.scheme()); +} diff --git a/chromium_src/chrome/browser/profiles/profile_io_data.h b/chromium_src/chrome/browser/profiles/profile_io_data.h new file mode 100644 index 000000000000..de9d9f8cac28 --- /dev/null +++ b/chromium_src/chrome/browser/profiles/profile_io_data.h @@ -0,0 +1,25 @@ +/* Copyright (c) 2021 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_PROFILES_PROFILE_IO_DATA_H_ +#define BRAVE_CHROMIUM_SRC_CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_ + +#include +#include "url/gurl.h" + +#define IsHandledProtocol \ + IsHandledProtocol_ChromiumImpl(const std::string& scheme); \ + static bool IsHandledProtocol + +#define IsHandledURL \ + IsHandledURL_ChromiumImpl(const GURL& url); \ + static bool IsHandledURL + +#include "../../../../../chrome/browser/profiles/profile_io_data.h" + +#undef IsHandledURL +#undef IsHandledProtocol + +#endif // BRAVE_CHROMIUM_SRC_CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_ diff --git a/patches/chrome-browser-profiles-profile_io_data.cc.patch b/patches/chrome-browser-profiles-profile_io_data.cc.patch deleted file mode 100644 index a2792530f73a..000000000000 --- a/patches/chrome-browser-profiles-profile_io_data.cc.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff --git a/chrome/browser/profiles/profile_io_data.cc b/chrome/browser/profiles/profile_io_data.cc -index 2f5ed4b15589ffa5bae18d7f06e6776f705f5229..a4bd6ab7ef01d4740211eff1de086fe1493f2129 100644 ---- a/chrome/browser/profiles/profile_io_data.cc -+++ b/chrome/browser/profiles/profile_io_data.cc -@@ -248,6 +248,7 @@ bool ProfileIOData::IsHandledProtocol(const std::string& scheme) { - #endif - content::kChromeUIScheme, - content::kChromeUIUntrustedScheme, -+ kBraveUIScheme, - url::kDataScheme, - #if BUILDFLAG(IS_CHROMEOS_ASH) - content::kExternalFileScheme,