From 742129bc2d0bc4bcd2d03ba59be487eae9eb6424 Mon Sep 17 00:00:00 2001 From: bridiver Date: Thu, 17 Jan 2019 20:53:55 -0700 Subject: [PATCH 1/2] use `brave://` for the virtual url and `chrome://` for the internal url to load fix https://github.com/brave/brave-browser/issues/1616 --- browser/brave_content_browser_client.cc | 51 +++++-- ...rave_content_browser_client_browsertest.cc | 134 +++++++++++++++--- .../webui/brave_web_ui_controller_factory.cc | 2 +- .../ui/webui/brave_welcome_ui_browsertest.cc | 7 +- .../chrome/browser/browser_about_handler.cc | 37 ++--- chromium_src/chrome/browser/ui/browser.cc | 3 - common/webui_url_constants.cc | 1 - common/webui_url_constants.h | 1 - .../browser/rewards_service_browsertest.cc | 2 +- components/omnibox/browser/BUILD.gn | 19 +-- .../browser/brave_location_bar_model_impl.cc | 36 ----- .../browser/brave_location_bar_model_impl.h | 18 --- .../location_bar_model_impl_unittest.cc | 47 ------ test/BUILD.gn | 1 - 14 files changed, 178 insertions(+), 181 deletions(-) delete mode 100644 components/omnibox/browser/brave_location_bar_model_impl.cc delete mode 100644 components/omnibox/browser/brave_location_bar_model_impl.h delete mode 100644 components/omnibox/browser/location_bar_model_impl_unittest.cc diff --git a/browser/brave_content_browser_client.cc b/browser/brave_content_browser_client.cc index 36585469b371..9390317ccee9 100644 --- a/browser/brave_content_browser_client.cc +++ b/browser/brave_content_browser_client.cc @@ -61,29 +61,52 @@ using extensions::ChromeContentBrowserClientExtensionsPart; namespace { -bool HandleURLRewrite(GURL* url, - content::BrowserContext* browser_context) { - if (url->SchemeIs(content::kChromeUIScheme) && - (url->host() == chrome::kChromeUIWelcomeHost || - url->host() == chrome::kChromeUIWelcomeWin10Host)) { - *url = GURL(kBraveUIWelcomeURL); +bool HandleURLOverrideRewrite(GURL* url, + content::BrowserContext* browser_context) { + // redirect sync-internals + if (url->host() == chrome::kChromeUISyncInternalsHost || + url->host() == chrome::kChromeUISyncHost) { + GURL::Replacements replacements; + replacements.SetHostStr(chrome::kChromeUISyncHost); + *url = url->ReplaceComponents(replacements); return true; } - if (url->SchemeIs(content::kChromeUIScheme) && - (url->host() == kBraveUISyncHost)) { - *url = GURL(kBraveUISyncURL); + + // no special win10 welcome page + if (url->host() == chrome::kChromeUIWelcomeWin10Host || + url->host() == chrome::kChromeUIWelcomeHost) { + *url = GURL(chrome::kChromeUIWelcomeURL); return true; } return false; } -bool HandleURLReverseRewrite(GURL* url, + +bool HandleURLReverseOverrideRewrite(GURL* url, content::BrowserContext* browser_context) { - if (url->spec() == kBraveUIWelcomeURL || - url->spec() == kBraveUISyncURL) { + if (url->host() == chrome::kChromeUIWelcomeHost || + url->host() == chrome::kChromeUISyncHost) { + GURL::Replacements replacements; + replacements.SetSchemeStr(kBraveUIScheme); + *url = url->ReplaceComponents(replacements); return true; } + + return false; +} + +bool HandleURLRewrite(GURL* url, + content::BrowserContext* browser_context) { + if (url->SchemeIs(kBraveUIScheme)) { + GURL::Replacements replacements; + replacements.SetSchemeStr(content::kChromeUIScheme); + *url = url->ReplaceComponents(replacements); + } + + if (HandleURLOverrideRewrite(url, browser_context)) + return true; + return false; } @@ -110,8 +133,10 @@ void BraveContentBrowserClient::BrowserURLHandlerCreated( handler->AddHandlerPair(&webtorrent::HandleTorrentURLRewrite, &webtorrent::HandleTorrentURLReverseRewrite); handler->AddHandlerPair(&HandleURLRewrite, - &HandleURLReverseRewrite); + &HandleURLReverseOverrideRewrite); ChromeContentBrowserClient::BrowserURLHandlerCreated(handler); + handler->AddHandlerPair(&HandleURLOverrideRewrite, + &HandleURLReverseOverrideRewrite); } bool BraveContentBrowserClient::AllowAccessCookie(const GURL& url, const GURL& first_party, diff --git a/browser/brave_content_browser_client_browsertest.cc b/browser/brave_content_browser_client_browsertest.cc index e5bdbbf1c154..3d545e1452e3 100644 --- a/browser/brave_content_browser_client_browsertest.cc +++ b/browser/brave_content_browser_client_browsertest.cc @@ -19,6 +19,7 @@ #include "chrome/browser/ui/browser_window.h" #include "chrome/common/buildflags.h" #include "chrome/common/chrome_content_client.h" +#include "chrome/common/webui_url_constants.h" #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/ui_test_utils.h" #include "components/content_settings/core/browser/host_content_settings_map.h" @@ -114,36 +115,127 @@ class BraveContentBrowserClientTest : public InProcessBrowserTest { }; IN_PROC_BROWSER_TEST_F(BraveContentBrowserClientTest, CanLoadChromeURL) { - GURL chrome_settings_url("chrome://about/"); - std::vector urls{chrome_settings_url, GURL("about:about/"), - GURL("brave://about/")}; - std::for_each(urls.begin(), urls.end(), - [this, &chrome_settings_url](const GURL& url) { - content::WebContents* contents = - browser()->tab_strip_model()->GetActiveWebContents(); - ui_test_utils::NavigateToURL(browser(), url); - ASSERT_TRUE(WaitForLoadStop(contents)); - EXPECT_STREQ(contents->GetLastCommittedURL().spec().c_str(), - chrome_settings_url.spec().c_str()); - }); + std::vector pages { + chrome::kChromeUIWelcomeHost, + }; + + std::vector schemes { + "about:", + "brave://", + "chrome://", + }; + + for (const std::string& page : pages) { + for (const std::string& scheme : schemes) { + content::WebContents* contents = + browser()->tab_strip_model()->GetActiveWebContents(); + ui_test_utils::NavigateToURL(browser(), GURL(scheme + page + "/")); + ASSERT_TRUE(WaitForLoadStop(contents)); + + EXPECT_STREQ(contents->GetController().GetLastCommittedEntry() + ->GetVirtualURL().spec().c_str(), + ("brave://" + page + "/").c_str()); + EXPECT_STREQ(contents->GetController().GetLastCommittedEntry() + ->GetURL().spec().c_str(), + ("chrome://" + page + "/").c_str()); + } + } } IN_PROC_BROWSER_TEST_F(BraveContentBrowserClientTest, CanLoadCustomBravePages) { - std::vector urls { - GURL("chrome://adblock/"), + std::vector pages { + "adblock", #if BUILDFLAG(BRAVE_REWARDS_ENABLED) - GURL("chrome://rewards/"), + "rewards", #endif - GURL("chrome://welcome/"), GURL("chrome://sync/") + chrome::kChromeUISyncHost, + }; + + std::vector schemes { + "brave://", + "chrome://", + }; + + for (const std::string& page : pages) { + for (const std::string& scheme : schemes) { + content::WebContents* contents = + browser()->tab_strip_model()->GetActiveWebContents(); + ui_test_utils::NavigateToURL(browser(), GURL(scheme + page + "/")); + ASSERT_TRUE(WaitForLoadStop(contents)); + + EXPECT_STREQ(contents->GetController().GetLastCommittedEntry() + ->GetVirtualURL().spec().c_str(), + ("brave://" + page + "/").c_str()); + EXPECT_STREQ(contents->GetController().GetLastCommittedEntry() + ->GetURL().spec().c_str(), + ("chrome://" + page + "/").c_str()); + } + } +} + +IN_PROC_BROWSER_TEST_F(BraveContentBrowserClientTest, CanLoadAboutHost) { + std::vector schemes { + "chrome://", + "brave://", }; - std::for_each(urls.begin(), urls.end(), [this](const GURL& url) { + + for (const std::string& scheme : schemes) { content::WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); - ui_test_utils::NavigateToURL(browser(), url); + ui_test_utils::NavigateToURL(browser(), GURL(scheme + "about/")); + ASSERT_TRUE(WaitForLoadStop(contents)); + + EXPECT_STREQ(contents->GetController().GetLastCommittedEntry() + ->GetVirtualURL().spec().c_str(), + "brave://about/"); + EXPECT_STREQ(contents->GetController().GetLastCommittedEntry() + ->GetURL().spec().c_str(), + "chrome://chrome-urls/"); + } +} + +IN_PROC_BROWSER_TEST_F(BraveContentBrowserClientTest, + RewriteChromeSyncInternals) { + std::vector schemes { + "brave://", + "chrome://", + }; + + for (const std::string& scheme : schemes) { + content::WebContents* contents = + browser()->tab_strip_model()->GetActiveWebContents(); + ui_test_utils::NavigateToURL(browser(), GURL(scheme + "sync-internals/")); + ASSERT_TRUE(WaitForLoadStop(contents)); + + EXPECT_STREQ(contents->GetController().GetLastCommittedEntry() + ->GetVirtualURL().spec().c_str(), + "brave://sync/"); + EXPECT_STREQ(contents->GetController().GetLastCommittedEntry() + ->GetURL().spec().c_str(), + "chrome://sync/"); + } +} + +IN_PROC_BROWSER_TEST_F(BraveContentBrowserClientTest, + RewriteChromeWelcomeWin10) { + std::vector schemes { + "brave://", + "chrome://", + }; + + for (const std::string& scheme : schemes) { + content::WebContents* contents = + browser()->tab_strip_model()->GetActiveWebContents(); + ui_test_utils::NavigateToURL(browser(), GURL(scheme + "welcome-win10/")); ASSERT_TRUE(WaitForLoadStop(contents)); - EXPECT_STREQ(contents->GetLastCommittedURL().spec().c_str(), - url.spec().c_str()); - }); + + EXPECT_STREQ(contents->GetController().GetLastCommittedEntry() + ->GetVirtualURL().spec().c_str(), + "brave://welcome/"); + EXPECT_STREQ(contents->GetController().GetLastCommittedEntry() + ->GetURL().spec().c_str(), + "chrome://welcome/"); + } } IN_PROC_BROWSER_TEST_F(BraveContentBrowserClientTest, RewriteMagnetURLURLBar) { diff --git a/browser/ui/webui/brave_web_ui_controller_factory.cc b/browser/ui/webui/brave_web_ui_controller_factory.cc index c558ab87c538..8a2ab722d1c4 100644 --- a/browser/ui/webui/brave_web_ui_controller_factory.cc +++ b/browser/ui/webui/brave_web_ui_controller_factory.cc @@ -70,7 +70,7 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui, url.host_piece() == kDonateHost || #endif url.host_piece() == kWelcomeHost || - url.host_piece() == kBraveUIWelcomeURL || + url.host_piece() == chrome::kChromeUIWelcomeURL || (url.host_piece() == kBraveUISyncHost && brave_sync::BraveSyncService::is_enabled()) || url.host_piece() == chrome::kChromeUINewTabHost || diff --git a/browser/ui/webui/brave_welcome_ui_browsertest.cc b/browser/ui/webui/brave_welcome_ui_browsertest.cc index 6e1543e3b239..6ce6eeaca29f 100644 --- a/browser/ui/webui/brave_welcome_ui_browsertest.cc +++ b/browser/ui/webui/brave_welcome_ui_browsertest.cc @@ -14,6 +14,7 @@ #include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/common/webui_url_constants.h" #include "chrome/test/base/in_process_browser_test.h" +#include "content/public/browser/navigation_entry.h" #include "content/public/test/test_navigation_observer.h" #include "content/public/test/test_utils.h" @@ -38,8 +39,10 @@ IN_PROC_BROWSER_TEST_F(BraveWelcomeUIBrowserTest, PRE_StartupURLTest) { content::WebContents* web_contents = tab_strip->GetWebContentsAt(0); content::TestNavigationObserver observer(web_contents, 1); observer.Wait(); - EXPECT_EQ(kBraveUIWelcomeURL, - tab_strip->GetWebContentsAt(0)->GetURL().possibly_invalid_spec()); + EXPECT_STREQ("brave://welcome/", + tab_strip->GetWebContentsAt(0) + ->GetController().GetLastCommittedEntry() + ->GetVirtualURL().possibly_invalid_spec().c_str()); } // Check wheter startup url is not welcome ui at second run. diff --git a/chromium_src/chrome/browser/browser_about_handler.cc b/chromium_src/chrome/browser/browser_about_handler.cc index 675c46fabf48..69818d5f0eb9 100644 --- a/chromium_src/chrome/browser/browser_about_handler.cc +++ b/chromium_src/chrome/browser/browser_about_handler.cc @@ -3,32 +3,33 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ #define FixupBrowserAboutURL FixupBrowserAboutURL_ChromiumImpl -#define WillHandleBrowserAboutURL WillHandleBrowserAboutURL_ChromiumImpl #include "../../../../chrome/browser/browser_about_handler.cc" #undef FixupBrowserAboutURL -#undef WillHandleBrowserAboutURL #include "brave/common/url_constants.h" +#include "brave/common/webui_url_constants.h" -bool FixupBrowserAboutURLBraveImpl(GURL* url, - content::BrowserContext* browser_context) { - if (url->SchemeIs(kBraveUIScheme)) { +bool FixupBrowserAboutURL(GURL* url, + content::BrowserContext* browser_context) { + bool result = FixupBrowserAboutURL_ChromiumImpl(url, browser_context); + + // no special win10 welcome page + if (url->host() == chrome::kChromeUIWelcomeWin10Host) + *url = GURL(chrome::kChromeUIWelcomeURL); + + // redirect sync-internals + if (url->host() == chrome::kChromeUISyncInternalsHost) { GURL::Replacements replacements; - replacements.SetSchemeStr(content::kChromeUIScheme); + replacements.SetHostStr(chrome::kChromeUISyncHost); *url = url->ReplaceComponents(replacements); } - return true; -} - -bool FixupBrowserAboutURL(GURL* url, - content::BrowserContext* browser_context) { - FixupBrowserAboutURLBraveImpl(url, browser_context); - return FixupBrowserAboutURL_ChromiumImpl(url, browser_context); -} + if (url->SchemeIs(content::kChromeUIScheme) && + url->host() != chrome::kChromeUINewTabHost) { + GURL::Replacements replacements; + replacements.SetSchemeStr(kBraveUIScheme); + *url = url->ReplaceComponents(replacements); + } -bool WillHandleBrowserAboutURL(GURL* url, - content::BrowserContext* browser_context) { - FixupBrowserAboutURLBraveImpl(url, browser_context); - return WillHandleBrowserAboutURL_ChromiumImpl(url, browser_context); + return result; } diff --git a/chromium_src/chrome/browser/ui/browser.cc b/chromium_src/chrome/browser/ui/browser.cc index f7f9cb96dae9..8a2594db4b37 100644 --- a/chromium_src/chrome/browser/ui/browser.cc +++ b/chromium_src/chrome/browser/ui/browser.cc @@ -6,12 +6,9 @@ #include "chrome/browser/ui/browser_content_setting_bubble_model_delegate.h" #include "brave/browser/ui/brave_browser_content_setting_bubble_model_delegate.h" #include "brave/browser/ui/brave_browser_command_controller.h" -#include "brave/components/omnibox/browser/brave_location_bar_model_impl.h" -#define LocationBarModelImpl BraveLocationBarModelImpl #define BrowserContentSettingBubbleModelDelegate BraveBrowserContentSettingBubbleModelDelegate #define BrowserCommandController BraveBrowserCommandController #include "../../../../../chrome/browser/ui/browser.cc" #undef BrowserContentSettingBubbleModelDelegate #undef BrowserCommandController -#undef LocationBarModelImpl diff --git a/common/webui_url_constants.cc b/common/webui_url_constants.cc index 4a3ddeef3c6a..cd7ba3ce7ad5 100644 --- a/common/webui_url_constants.cc +++ b/common/webui_url_constants.cc @@ -15,7 +15,6 @@ const char kDonateJS[] = "brave_donate.js"; const char kBraveNewTabJS[] = "brave_new_tab.js"; const char kBraveUISyncHost[] = "sync"; const char kBraveSyncJS[] = "brave_sync.js"; -const char kBraveUIWelcomeURL[] = "chrome://welcome/"; const char kBraveUIRewardsURL[] = "chrome://rewards/"; const char kBraveUIAdblockURL[] = "chrome://adblock/"; const char kBraveUIDonateURL[] = "chrome://donate/"; diff --git a/common/webui_url_constants.h b/common/webui_url_constants.h index 1f8b324f63a8..e8c30b0aa310 100644 --- a/common/webui_url_constants.h +++ b/common/webui_url_constants.h @@ -12,7 +12,6 @@ extern const char kDonateJS[]; extern const char kBraveNewTabJS[]; extern const char kBraveUISyncHost[]; extern const char kBraveSyncJS[]; -extern const char kBraveUIWelcomeURL[]; extern const char kBraveUIRewardsURL[]; extern const char kBraveUIAdblockURL[]; extern const char kBraveUIDonateHost[]; diff --git a/components/brave_rewards/browser/rewards_service_browsertest.cc b/components/brave_rewards/browser/rewards_service_browsertest.cc index 9821ce7f0171..c3cfbea164d6 100644 --- a/components/brave_rewards/browser/rewards_service_browsertest.cc +++ b/components/brave_rewards/browser/rewards_service_browsertest.cc @@ -162,7 +162,7 @@ class BraveRewardsBrowserTest : public InProcessBrowserTest { } GURL rewards_url() { - GURL rewards_url("chrome://rewards"); + GURL rewards_url("brave://rewards"); return rewards_url; } diff --git a/components/omnibox/browser/BUILD.gn b/components/omnibox/browser/BUILD.gn index 5906c56567f3..aebeabf19881 100644 --- a/components/omnibox/browser/BUILD.gn +++ b/components/omnibox/browser/BUILD.gn @@ -1,13 +1,11 @@ source_set("browser") { # Only //components/omnibox/browser target can depend on this target # because this target expands //components/omnibox/browser implementation. - visibility = [ "//components/omnibox/browser", ":unit_tests" ] + visibility = [ "//components/omnibox/browser" ] sources = [ "brave_autocomplete_controller.cc", "brave_autocomplete_controller.h", - "brave_location_bar_model_impl.cc", - "brave_location_bar_model_impl.h", "constants.cc", "constants.h", "topsites_provider_data.cc", @@ -22,18 +20,3 @@ source_set("browser") { "//third_party/metrics_proto", ] } - -source_set("unit_tests") { - testonly = true - sources = [ - "location_bar_model_impl_unittest.cc", - ] - - deps = [ - ":browser", - "//base", - "//components/omnibox/browser", - "//testing/gtest", - "//url", - ] -} diff --git a/components/omnibox/browser/brave_location_bar_model_impl.cc b/components/omnibox/browser/brave_location_bar_model_impl.cc deleted file mode 100644 index 85a52042cfb8..000000000000 --- a/components/omnibox/browser/brave_location_bar_model_impl.cc +++ /dev/null @@ -1,36 +0,0 @@ -// 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/. - -#include "brave/components/omnibox/browser/brave_location_bar_model_impl.h" - -#include "base/strings/string_util.h" -#include "base/strings/utf_string_conversions.h" -#include "brave/components/omnibox/browser/constants.h" -#include "components/omnibox/browser/location_bar_model_impl.h" - -using namespace brave_toolbar; - -namespace { - -const base::string16 original_scheme_part = - base::ASCIIToUTF16(kOriginalInternalUIScheme); -const base::string16 replacement_scheme_part = - base::ASCIIToUTF16(kInternalUIScheme); - -} - -base::string16 BraveLocationBarModelImpl::GetURLForDisplay() const { - base::string16 formatted_text = LocationBarModelImpl::GetURLForDisplay(); - - const GURL url(GetURL()); - // Only replace chrome:// with brave:// if scheme is "chrome" and - // it has not been stripped from the display text - if (url.SchemeIs(kOriginalInternalUIScheme) && - base::StartsWith(formatted_text, original_scheme_part, - base::CompareCase::INSENSITIVE_ASCII)) { - formatted_text.replace(0, original_scheme_part.length(), - replacement_scheme_part); - } - return formatted_text; -} diff --git a/components/omnibox/browser/brave_location_bar_model_impl.h b/components/omnibox/browser/brave_location_bar_model_impl.h deleted file mode 100644 index e403e567c9ce..000000000000 --- a/components/omnibox/browser/brave_location_bar_model_impl.h +++ /dev/null @@ -1,18 +0,0 @@ -// 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_COMPONENTS_OMNIBOX_BROWSER_BRAVE_LOCATION_BAR_MODEL_IMPL_H_ -#define BRAVE_COMPONENTS_OMNIBOX_BROWSER_BRAVE_LOCATION_BAR_MODEL_IMPL_H_ - -#include "components/omnibox/browser/location_bar_model_impl.h" - -class BraveLocationBarModelImpl : public LocationBarModelImpl { - public: - using LocationBarModelImpl::LocationBarModelImpl; - base::string16 GetURLForDisplay() const override; - private: - DISALLOW_COPY_AND_ASSIGN(BraveLocationBarModelImpl); -}; - -#endif diff --git a/components/omnibox/browser/location_bar_model_impl_unittest.cc b/components/omnibox/browser/location_bar_model_impl_unittest.cc deleted file mode 100644 index 95430d8e4f14..000000000000 --- a/components/omnibox/browser/location_bar_model_impl_unittest.cc +++ /dev/null @@ -1,47 +0,0 @@ -// 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/. - -#include "brave/components/omnibox/browser/brave_location_bar_model_impl.h" - -#include "base/strings/utf_string_conversions.h" -#include "components/omnibox/browser/location_bar_model_delegate.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "url/gurl.h" - -namespace { - -class FakeLocationBarModelImpl: public LocationBarModelDelegate { - public: - void SetURL(const GURL& url) { url_ = url; } - - // LocationBarModelDelegate: - base::string16 FormattedStringWithEquivalentMeaning( - const GURL& url, - const base::string16& formatted_url) const override { - return formatted_url; - } - - bool GetURL(GURL* url) const override { - *url = url_; - return true; - } - - private: - GURL url_; -}; - -TEST(BraveLocationBarModelImplTest, - DisplayUrlRewritesScheme) { - FakeLocationBarModelImpl delegate; - auto model = std::make_unique(&delegate, 1024); - - delegate.SetURL(GURL("chrome://page")); - - // Verify that both the full formatted URL and the display URL add the test - // suffix. - EXPECT_EQ(base::ASCIIToUTF16("brave://page"), - model->GetURLForDisplay()); -} - -} // namespace diff --git a/test/BUILD.gn b/test/BUILD.gn index a4cd4656dd19..f5004d672d52 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -137,7 +137,6 @@ test("brave_unit_tests") { "//chrome/test:test_support", "//components/prefs", "//components/prefs:test_support", - "//brave/components/omnibox/browser:unit_tests", "//components/version_info", "//content/test:test_support", "//components/signin/core/browser", From 0c92190251b5c22acd548730ccb78104def36261 Mon Sep 17 00:00:00 2001 From: bridiver Date: Tue, 22 Jan 2019 12:00:36 -0700 Subject: [PATCH 2/2] fix lint errors --- browser/brave_content_browser_client.cc | 44 ++++++++++++------- ...rave_content_browser_client_browsertest.cc | 5 ++- .../webui/brave_web_ui_controller_factory.cc | 6 ++- .../ui/webui/brave_welcome_ui_browsertest.cc | 3 +- .../chrome/browser/browser_about_handler.cc | 5 ++- chromium_src/chrome/browser/ui/browser.cc | 8 ++-- common/webui_url_constants.cc | 3 +- common/webui_url_constants.h | 5 +++ 8 files changed, 52 insertions(+), 27 deletions(-) diff --git a/browser/brave_content_browser_client.cc b/browser/brave_content_browser_client.cc index 9390317ccee9..ecb7a234d02f 100644 --- a/browser/brave_content_browser_client.cc +++ b/browser/brave_content_browser_client.cc @@ -1,9 +1,13 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public +/* Copyright (c) 2019 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/. */ #include "brave/browser/brave_content_browser_client.h" +#include +#include + #include "base/bind.h" #include "base/json/json_reader.h" #include "base/task/post_task.h" @@ -43,6 +47,7 @@ #include "ui/base/resource/resource_bundle.h" using content::BrowserThread; +using content::ContentBrowserClient; using content::RenderFrameHost; using content::WebContents; using brave_shields::BraveShieldsWebContentsObserver; @@ -112,16 +117,16 @@ bool HandleURLRewrite(GURL* url, } // namespace -BraveContentBrowserClient::BraveContentBrowserClient(ChromeFeatureListCreator* chrome_feature_list_creator) : - ChromeContentBrowserClient(chrome_feature_list_creator) -{} +BraveContentBrowserClient::BraveContentBrowserClient( + ChromeFeatureListCreator* chrome_feature_list_creator) + : ChromeContentBrowserClient(chrome_feature_list_creator) {} BraveContentBrowserClient::~BraveContentBrowserClient() {} content::BrowserMainParts* BraveContentBrowserClient::CreateBrowserMainParts( const content::MainFunctionParams& parameters) { - ChromeBrowserMainParts* main_parts = (ChromeBrowserMainParts*) - ChromeContentBrowserClient::CreateBrowserMainParts(parameters); + ChromeBrowserMainParts* main_parts = static_cast( + ChromeContentBrowserClient::CreateBrowserMainParts(parameters)); main_parts->AddParts(new BraveBrowserMainExtraParts()); return main_parts; } @@ -139,8 +144,12 @@ void BraveContentBrowserClient::BrowserURLHandlerCreated( &HandleURLReverseOverrideRewrite); } -bool BraveContentBrowserClient::AllowAccessCookie(const GURL& url, const GURL& first_party, - content::ResourceContext* context, int render_process_id, int render_frame_id) { +bool BraveContentBrowserClient::AllowAccessCookie( + const GURL& url, + const GURL& first_party, + content::ResourceContext* context, + int render_process_id, + int render_frame_id) { GURL tab_origin = BraveShieldsWebContentsObserver::GetTabURLFromRenderFrameInfo( render_process_id, render_frame_id, -1).GetOrigin(); @@ -194,7 +203,7 @@ BraveContentBrowserClient::AllowWebBluetooth( content::BrowserContext* browser_context, const url::Origin& requesting_origin, const url::Origin& embedding_origin) { - return content::ContentBrowserClient::AllowWebBluetoothResult::BLOCK_GLOBALLY_DISABLED; + return ContentBrowserClient::AllowWebBluetoothResult::BLOCK_GLOBALLY_DISABLED; } bool BraveContentBrowserClient::HandleExternalProtocol( @@ -213,7 +222,8 @@ bool BraveContentBrowserClient::HandleExternalProtocol( } return ChromeContentBrowserClient::HandleExternalProtocol( - url, web_contents_getter, child_id, navigation_data, is_main_frame, page_transition, has_user_gesture, method, headers); + url, web_contents_getter, child_id, navigation_data, is_main_frame, + page_transition, has_user_gesture, method, headers); } void BraveContentBrowserClient::RegisterOutOfProcessServices( @@ -242,7 +252,6 @@ BraveContentBrowserClient::GetNavigationUIData( TorProfileServiceFactory::SetTorNavigationUIData(profile, navigation_ui_data.get()); return std::move(navigation_ui_data); - } std::unique_ptr @@ -310,11 +319,14 @@ void BraveContentBrowserClient::MaybeHideReferrer( GURL(), CONTENT_SETTINGS_TYPE_PLUGINS, brave_shields::kBraveShields); - brave_shields::ShouldSetReferrer(allow_referrers, shields_up, - referrer->url, document_url, request_url, - request_url.GetOrigin(), - referrer->policy, - referrer); + brave_shields::ShouldSetReferrer(allow_referrers, + shields_up, + referrer->url, + document_url, + request_url, + request_url.GetOrigin(), + referrer->policy, + referrer); } GURL BraveContentBrowserClient::GetEffectiveURL( diff --git a/browser/brave_content_browser_client_browsertest.cc b/browser/brave_content_browser_client_browsertest.cc index 3d545e1452e3..2c180790a7c1 100644 --- a/browser/brave_content_browser_client_browsertest.cc +++ b/browser/brave_content_browser_client_browsertest.cc @@ -1,4 +1,5 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public +/* Copyright (c) 2019 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/. */ @@ -419,7 +420,7 @@ IN_PROC_BROWSER_TEST_F(BraveContentBrowserClientTest, class BraveContentBrowserClientReferrerTest : public BraveContentBrowserClientTest { -public: + public: HostContentSettingsMap* content_settings() { return HostContentSettingsMapFactory::GetForProfile(browser()->profile()); } diff --git a/browser/ui/webui/brave_web_ui_controller_factory.cc b/browser/ui/webui/brave_web_ui_controller_factory.cc index 8a2ab722d1c4..626ed8df28ac 100644 --- a/browser/ui/webui/brave_web_ui_controller_factory.cc +++ b/browser/ui/webui/brave_web_ui_controller_factory.cc @@ -1,9 +1,12 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public +/* Copyright (c) 2019 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/. */ #include "brave/browser/ui/webui/brave_web_ui_controller_factory.h" +#include + #include "brave/browser/ui/webui/brave_adblock_ui.h" #include "brave/browser/ui/webui/brave_md_settings_ui.h" #include "brave/browser/ui/webui/brave_new_tab_ui.h" @@ -85,7 +88,6 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui, WebUI::TypeID BraveWebUIControllerFactory::GetWebUIType( content::BrowserContext* browser_context, const GURL& url) const { - WebUIFactoryFunction function = GetWebUIFactoryFunction(NULL, url); if (function) { return reinterpret_cast(function); diff --git a/browser/ui/webui/brave_welcome_ui_browsertest.cc b/browser/ui/webui/brave_welcome_ui_browsertest.cc index 6ce6eeaca29f..b3aecd8e08ea 100644 --- a/browser/ui/webui/brave_welcome_ui_browsertest.cc +++ b/browser/ui/webui/brave_welcome_ui_browsertest.cc @@ -1,4 +1,5 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public +/* Copyright (c) 2019 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/. */ diff --git a/chromium_src/chrome/browser/browser_about_handler.cc b/chromium_src/chrome/browser/browser_about_handler.cc index 69818d5f0eb9..a0cf98a0a22a 100644 --- a/chromium_src/chrome/browser/browser_about_handler.cc +++ b/chromium_src/chrome/browser/browser_about_handler.cc @@ -1,9 +1,10 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public +/* Copyright (c) 2019 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/. */ #define FixupBrowserAboutURL FixupBrowserAboutURL_ChromiumImpl -#include "../../../../chrome/browser/browser_about_handler.cc" +#include "../../../../chrome/browser/browser_about_handler.cc" // NOLINT #undef FixupBrowserAboutURL #include "brave/common/url_constants.h" diff --git a/chromium_src/chrome/browser/ui/browser.cc b/chromium_src/chrome/browser/ui/browser.cc index 8a2594db4b37..420e1a8f6894 100644 --- a/chromium_src/chrome/browser/ui/browser.cc +++ b/chromium_src/chrome/browser/ui/browser.cc @@ -1,4 +1,5 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public +/* Copyright (c) 2019 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/. */ @@ -7,8 +8,9 @@ #include "brave/browser/ui/brave_browser_content_setting_bubble_model_delegate.h" #include "brave/browser/ui/brave_browser_command_controller.h" -#define BrowserContentSettingBubbleModelDelegate BraveBrowserContentSettingBubbleModelDelegate +#define BrowserContentSettingBubbleModelDelegate + BraveBrowserContentSettingBubbleModelDelegate #define BrowserCommandController BraveBrowserCommandController -#include "../../../../../chrome/browser/ui/browser.cc" +#include "../../../../../chrome/browser/ui/browser.cc" // NOLINT #undef BrowserContentSettingBubbleModelDelegate #undef BrowserCommandController diff --git a/common/webui_url_constants.cc b/common/webui_url_constants.cc index cd7ba3ce7ad5..e9f78af170d1 100644 --- a/common/webui_url_constants.cc +++ b/common/webui_url_constants.cc @@ -1,4 +1,5 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public +/* Copyright (c) 2019 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/. */ diff --git a/common/webui_url_constants.h b/common/webui_url_constants.h index e8c30b0aa310..4648d9d3c199 100644 --- a/common/webui_url_constants.h +++ b/common/webui_url_constants.h @@ -1,3 +1,8 @@ +/* Copyright (c) 2019 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_COMMON_WEBUI_URL_CONSTANTS_H_ #define BRAVE_COMMON_WEBUI_URL_CONSTANTS_H_