-
Notifications
You must be signed in to change notification settings - Fork 892
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10781 from brave/extension_state_mismatch
Fix #19069 - IsWebstoreUpdateUrl should return true for kChromeWebstoreUpdateURL even when component-updater switch is set
- Loading branch information
Showing
3 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
22
chromium_src/extensions/common/extension_urls_browsertest.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters