-
Notifications
You must be signed in to change notification settings - Fork 877
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Hide Uphold linking flow from webRequest (brave/brave-browser#4928)
- Loading branch information
Showing
7 changed files
with
106 additions
and
1 deletion.
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
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) 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 https://mozilla.org/MPL/2.0/. */ | ||
|
||
#include "brave/browser/extensions/api/brave_extensions_api_client.h" | ||
|
||
#include "brave/extensions/common/brave_extension_urls.h" | ||
|
||
namespace extensions { | ||
|
||
bool BraveExtensionsAPIClient::ShouldHideBrowserNetworkRequest( | ||
const WebRequestInfo& request) const { | ||
const GURL& url = request.url; | ||
if (extension_urls::IsBraveProtectedUrl(url::Origin::Create(url), | ||
url.path_piece())) { | ||
return true; | ||
} | ||
return ChromeExtensionsAPIClient::ShouldHideBrowserNetworkRequest(request); | ||
} | ||
|
||
} // namespace extensions |
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,21 @@ | ||
/* 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 https://mozilla.org/MPL/2.0/. */ | ||
|
||
#ifndef BRAVE_BROWSER_EXTENSIONS_API_BRAVE_EXTENSIONS_API_CLIENT_H_ | ||
#define BRAVE_BROWSER_EXTENSIONS_API_BRAVE_EXTENSIONS_API_CLIENT_H_ | ||
|
||
#include "chrome/browser/extensions/api/chrome_extensions_api_client.h" | ||
#include "extensions/browser/api/web_request/web_request_info.h" | ||
|
||
namespace extensions { | ||
|
||
class BraveExtensionsAPIClient : public ChromeExtensionsAPIClient { | ||
bool ShouldHideBrowserNetworkRequest( | ||
const WebRequestInfo& request) const override; | ||
}; | ||
|
||
} // namespace extensions | ||
|
||
#endif // BRAVE_BROWSER_EXTENSIONS_API_BRAVE_EXTENSIONS_API_CLIENT_H_ |
8 changes: 7 additions & 1 deletion
8
chromium_src/chrome/browser/extensions/chrome_extensions_browser_client.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 |
---|---|---|
@@ -1,9 +1,15 @@ | ||
// Copyright (c) 2019 The Brave Authors. All rights reserved. | ||
/* 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 https://mozilla.org/MPL/2.0/. */ | ||
|
||
#include "brave/browser/extensions/api/brave_extensions_api_client.h" | ||
#include "brave/browser/extensions/updater/brave_update_client_config.h" | ||
#include "chrome/browser/extensions/chrome_extensions_browser_client.h" | ||
#include "chrome/browser/extensions/updater/chrome_update_client_config.h" | ||
|
||
#define ChromeUpdateClientConfig BraveUpdateClientConfig | ||
#define ChromeExtensionsAPIClient BraveExtensionsAPIClient | ||
#include "../../../../../chrome/browser/extensions/chrome_extensions_browser_client.cc" // NOLINT | ||
#undef ChromeUpdateClientConfig | ||
#undef ChromeExtensionsAPIClient |
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,12 @@ | ||
source_set("common") { | ||
sources = [ | ||
"brave_extension_urls.cc", | ||
"brave_extension_urls.h", | ||
] | ||
|
||
deps = [ | ||
"//base", | ||
"//extensions/common", | ||
"//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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* 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 https://mozilla.org/MPL/2.0/. */ | ||
|
||
#include "brave/extensions/common/brave_extension_urls.h" | ||
|
||
#include "base/strings/string_util.h" | ||
#include "url/origin.h" | ||
|
||
namespace extension_urls { | ||
|
||
bool IsBraveProtectedUrl(const url::Origin& origin, base::StringPiece path) { | ||
return ((origin.DomainIs("sandbox.uphold.com") || | ||
origin.DomainIs("uphold.com")) && | ||
base::StartsWith(path, "/authorize/", | ||
base::CompareCase::SENSITIVE)) || | ||
(origin.DomainIs("api.uphold.com") && | ||
base::StartsWith(path, "/oauth2/token", | ||
base::CompareCase::SENSITIVE)); | ||
} | ||
|
||
} // namespace extension_urls |
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,18 @@ | ||
/* 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 https://mozilla.org/MPL/2.0/. */ | ||
|
||
#ifndef BRAVE_EXTENSIONS_COMMON_EXTENSION_URLS_H_ | ||
#define BRAVE_EXTENSIONS_COMMON_EXTENSION_URLS_H_ | ||
|
||
#include "extensions/common/extension_urls.h" | ||
|
||
namespace extension_urls { | ||
|
||
// Returns true if the URL points to a security-critical service. | ||
bool IsBraveProtectedUrl(const url::Origin& origin, base::StringPiece path); | ||
|
||
} // namespace extension_urls | ||
|
||
#endif // BRAVE_EXTENSIONS_COMMON_EXTENSION_URLS_H_ |