Skip to content

Commit

Permalink
Merge pull request #10781 from brave/extension_state_mismatch
Browse files Browse the repository at this point in the history
Fix #19069 - IsWebstoreUpdateUrl should return true for kChromeWebstoreUpdateURL even when component-updater switch is set
  • Loading branch information
jumde authored Nov 3, 2021
2 parents c256325 + e6fa4be commit 82a3309
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
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 @@ -657,6 +657,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

0 comments on commit 82a3309

Please sign in to comment.