Skip to content

Commit

Permalink
Fix newtab page overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
bbondy committed Nov 20, 2018
1 parent 5e1210a commit 3969711
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
15 changes: 1 addition & 14 deletions browser/brave_content_browser_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,29 +54,18 @@ bool HandleURLRewrite(GURL* url,
return true;
}

if (url->SchemeIs(content::kChromeUIScheme) &&
url->host() == chrome::kChromeUINewTabHost) {
// Disable new tab overrides, but keep it the same
return true;
}

return false;
}

bool HandleURLReverseRewrite(GURL* url,
content::BrowserContext* browser_context) {
// Handle mapping new tab URL to ourselves
if (url->SchemeIs(content::kChromeUIScheme) &&
url->host() == chrome::kChromeUINewTabHost) {
return true;
}
if (url->spec() == kBraveUIWelcomeURL) {
return true;
}
return false;
}

}
} // namespace

BraveContentBrowserClient::BraveContentBrowserClient(std::unique_ptr<ui::DataPack> data_pack,
ChromeFeatureListCreator* chrome_feature_list_creator) :
Expand All @@ -95,8 +84,6 @@ content::BrowserMainParts* BraveContentBrowserClient::CreateBrowserMainParts(

void BraveContentBrowserClient::BrowserURLHandlerCreated(
content::BrowserURLHandler* handler) {
// Insert handler for chrome://newtab so that we handle it
// before anything else can.
handler->AddHandlerPair(&webtorrent::HandleMagnetURLRewrite,
content::BrowserURLHandler::null_handler());
handler->AddHandlerPair(&webtorrent::HandleTorrentURLRewrite,
Expand Down
19 changes: 18 additions & 1 deletion chromium_src/chrome/browser/chrome_content_browser_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "build/build_config.h" // For OS_MACOSX
#include "chrome/browser/search/search.h"
#include "content/public/browser/browser_url_handler.h"

#if defined(OS_MACOSX)
#include "brave/browser/brave_browser_main_parts_mac.h"
Expand All @@ -15,8 +17,23 @@
#define ChromeBrowserMainExtraPartsViewsLinux BraveBrowserMainExtraPartsViewsLinux
#endif

#define HandleNewTabURLRewrite HandleNewTabURLRewrite_ChromiumImpl
#define HandleNewTabURLReverseRewrite HandleNewTabURLReverseRewrite_ChromiumImpl

namespace search {
bool HandleNewTabURLRewrite(GURL* url, content::BrowserContext* bc) {
return false;
}
bool HandleNewTabURLReverseRewrite(GURL* url, content::BrowserContext* bc) {
return false;
}
} // namespace search

#include "../../../../chrome/browser/chrome_content_browser_client.cc"

#undef HandleNewTabURLRewrite
#undef HandleNewTabURLReverseRewrite_ChromiumImpl

#if defined(OS_LINUX)
#undef ChromeBrowserMainExtraPartsViewsLinux
#endif
#endif

0 comments on commit 3969711

Please sign in to comment.