Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #19069 - IsWebstoreUpdateUrl should return true for kChromeWebstoreUpdateURL even when component-updater switch is set (uplift to 1.32.x) #11134

Merged
merged 1 commit into from
Nov 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions chromium_src/extensions/common/extension_urls.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* 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/. */

#include "extensions/common/extension_urls.h"

#define IsWebstoreUpdateUrl IsWebstoreUpdateUrl_ChromiumImpl
#include "../../../../extensions/common/extension_urls.cc"
#undef IsWebstoreUpdateUrl

namespace extension_urls {

namespace {

bool IsDefaultWebstoreUpdateUrl(const GURL& update_url) {
GURL store_url = GetDefaultWebstoreUpdateUrl();
return (update_url.host_piece() == store_url.host_piece() &&
update_url.path_piece() == store_url.path_piece());
}

} // namespace

bool IsWebstoreUpdateUrl(const GURL& update_url) {
return IsDefaultWebstoreUpdateUrl(update_url) ||
IsWebstoreUpdateUrl_ChromiumImpl(update_url);
}

} // namespace extension_urls
22 changes: 22 additions & 0 deletions chromium_src/extensions/common/extension_urls_browsertest.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* 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/. */

#include "base/command_line.h"
#include "chrome/test/base/chrome_test_utils.h"
#include "components/component_updater/component_updater_switches.h"
#include "content/public/test/browser_test.h"
#include "extensions/common/extension_urls.h"

using ExtensionUrlsBrowserTest = PlatformBrowserTest;

IN_PROC_BROWSER_TEST_F(ExtensionUrlsBrowserTest, IsWebstoreUpdateUrl) {
GURL url = GURL(extension_urls::kChromeWebstoreUpdateURL);
EXPECT_TRUE(extension_urls::IsWebstoreUpdateUrl(url));

url = GURL(UPDATER_PROD_ENDPOINT);
EXPECT_TRUE(base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kComponentUpdater));
EXPECT_TRUE(extension_urls::IsWebstoreUpdateUrl(url));
}
1 change: 1 addition & 0 deletions test/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,7 @@ if (!is_android) {
"//brave/chromium_src/chrome/browser/ui/views/tabs/tab_hover_card_bubble_view_browsertest.cc",
"//brave/chromium_src/components/content_settings/core/browser/brave_content_settings_registry_browsertest.cc",
"//brave/chromium_src/components/favicon/core/favicon_database_browsertest.cc",
"//brave/chromium_src/extensions/common/extension_urls_browsertest.cc",
"//brave/chromium_src/third_party/blink/public/platform/disable_client_hints_browsertest.cc",
"//brave/chromium_src/third_party/blink/renderer/core/frame/reporting_observer_browsertest.cc",
"//brave/common/brave_channel_info_browsertest.cc",
Expand Down