[OnionSoup] Move content::IsOriginSecure into Blink
Currently, content::IsOriginSecure() util is used by ResourceDispatcher, which will be removed along with OnionSoup. This patch moves content::IsOriginSecure() into Blink, so that we could onion-soupify the ResourceDispatcher. Change-Id: I7b9975ccc50bb28e13c37107588c9e071450f39f Bug: 1110032 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2392044 Commit-Queue: Minggang Wang <minggang.wang@intel.com> Reviewed-by: Colin Blundell <blundell@chromium.org> Reviewed-by: Kinuko Yasuda <kinuko@chromium.org> Reviewed-by: Hiroki Nakagawa <nhiroki@chromium.org> Cr-Commit-Position: refs/heads/master@{#804829}
This commit is contained in:

committed by
Commit Bot

parent
a9f48e7f5f
commit
d111b3c809
chrome
browser
devtools
protocol
download
extensions
media
ui
usb
common
components
client_hints
embedder_support
origin_trials
payments
content
permissions
security_state
content
webrtc
content
browser
background_fetch
browsing_data
cache_storage
devtools
protocol
download
frame_host
renderer_host
service_worker
web_package
webauth
common
public
common
renderer
loader
pepper
shell
test
third_party/blink
@ -11,11 +11,11 @@
|
||||
#include "chrome/browser/ssl/security_state_tab_helper.h"
|
||||
#include "components/security_state/content/content_utils.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "content/public/common/origin_util.h"
|
||||
#include "net/cert/x509_certificate.h"
|
||||
#include "net/cert/x509_util.h"
|
||||
#include "net/ssl/ssl_cipher_suite_names.h"
|
||||
#include "net/ssl/ssl_connection_status_flags.h"
|
||||
#include "third_party/blink/public/common/loader/network_utils.h"
|
||||
#include "third_party/boringssl/src/include/openssl/ssl.h"
|
||||
|
||||
namespace {
|
||||
@ -198,7 +198,7 @@ CreateVisibleSecurityState(content::WebContents* web_contents) {
|
||||
|
||||
bool secure_origin = scheme_is_cryptographic;
|
||||
if (!scheme_is_cryptographic)
|
||||
secure_origin = content::IsOriginSecure(state->url);
|
||||
secure_origin = blink::network_utils::IsOriginSecure(state->url);
|
||||
|
||||
bool cert_missing_subject_alt_name =
|
||||
state->certificate &&
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include "components/download/public/common/download_stats.h"
|
||||
#include "content/public/browser/download_item_utils.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "content/public/common/origin_util.h"
|
||||
#include "third_party/blink/public/common/loader/network_utils.h"
|
||||
#include "third_party/blink/public/mojom/devtools/console_message.mojom.h"
|
||||
#include "url/gurl.h"
|
||||
#include "url/origin.h"
|
||||
@ -208,14 +208,14 @@ struct MixedContentDownloadData {
|
||||
// Evaluate download security.
|
||||
is_redirect_chain_secure_ = true;
|
||||
for (const auto& url : item->GetUrlChain()) {
|
||||
if (!content::IsOriginSecure(url)) {
|
||||
if (!blink::network_utils::IsOriginSecure(url)) {
|
||||
is_redirect_chain_secure_ = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
const GURL& dl_url = item->GetURL();
|
||||
bool is_download_secure = is_redirect_chain_secure_ &&
|
||||
(content::IsOriginSecure(dl_url) ||
|
||||
(blink::network_utils::IsOriginSecure(dl_url) ||
|
||||
dl_url.SchemeIsBlob() || dl_url.SchemeIsFile());
|
||||
|
||||
// Configure mixed content status.
|
||||
|
@ -12,8 +12,8 @@
|
||||
#include "chrome/common/chrome_switches.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "content/public/common/origin_util.h"
|
||||
#include "net/base/url_util.h"
|
||||
#include "third_party/blink/public/common/loader/network_utils.h"
|
||||
|
||||
namespace extensions {
|
||||
|
||||
@ -69,11 +69,12 @@ DesktopCaptureChooseDesktopMediaFunction::Run() {
|
||||
|
||||
if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
|
||||
::switches::kAllowHttpScreenCapture) &&
|
||||
!content::IsOriginSecure(origin)) {
|
||||
!blink::network_utils::IsOriginSecure(origin)) {
|
||||
return RespondNow(Error(kDesktopCaptureApiTabUrlNotSecure));
|
||||
}
|
||||
target_name = base::UTF8ToUTF16(content::IsOriginSecure(origin) ?
|
||||
net::GetHostAndOptionalPort(origin) : origin.spec());
|
||||
target_name = base::UTF8ToUTF16(blink::network_utils::IsOriginSecure(origin)
|
||||
? net::GetHostAndOptionalPort(origin)
|
||||
: origin.spec());
|
||||
|
||||
if (!params->target_tab->id ||
|
||||
*params->target_tab->id == api::tabs::TAB_ID_NONE) {
|
||||
|
@ -32,12 +32,12 @@
|
||||
#include "content/public/browser/render_frame_host.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "content/public/common/origin_util.h"
|
||||
#include "extensions/common/features/feature.h"
|
||||
#include "extensions/common/features/feature_provider.h"
|
||||
#include "extensions/common/features/simple_feature.h"
|
||||
#include "extensions/common/permissions/permissions_data.h"
|
||||
#include "extensions/common/switches.h"
|
||||
#include "third_party/blink/public/common/loader/network_utils.h"
|
||||
|
||||
using content::DesktopMediaID;
|
||||
using content::WebContentsMediaCaptureId;
|
||||
@ -458,7 +458,7 @@ ExtensionFunction::ResponseAction TabCaptureGetMediaStreamIdFunction::Run() {
|
||||
return RespondNow(Error(kInvalidOriginError));
|
||||
}
|
||||
|
||||
if (!content::IsOriginSecure(origin)) {
|
||||
if (!blink::network_utils::IsOriginSecure(origin)) {
|
||||
return RespondNow(Error(kTabUrlNotSecure));
|
||||
}
|
||||
|
||||
|
11
chrome/browser/extensions/api/webrtc_desktop_capture_private/webrtc_desktop_capture_private_api.cc
11
chrome/browser/extensions/api/webrtc_desktop_capture_private/webrtc_desktop_capture_private_api.cc
@ -12,8 +12,8 @@
|
||||
#include "chrome/common/extensions/api/tabs.h"
|
||||
#include "chrome/common/extensions/api/webrtc_desktop_capture_private.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "content/public/common/origin_util.h"
|
||||
#include "net/base/url_util.h"
|
||||
#include "third_party/blink/public/common/loader/network_utils.h"
|
||||
|
||||
namespace extensions {
|
||||
|
||||
@ -60,12 +60,13 @@ WebrtcDesktopCapturePrivateChooseDesktopMediaFunction::Run() {
|
||||
GURL origin = rfh->GetLastCommittedURL().GetOrigin();
|
||||
if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
|
||||
::switches::kAllowHttpScreenCapture) &&
|
||||
!content::IsOriginSecure(origin)) {
|
||||
!blink::network_utils::IsOriginSecure(origin)) {
|
||||
return RespondNow(Error(kUrlNotSecure));
|
||||
}
|
||||
base::string16 target_name = base::UTF8ToUTF16(
|
||||
content::IsOriginSecure(origin) ? net::GetHostAndOptionalPort(origin)
|
||||
: origin.spec());
|
||||
base::string16 target_name =
|
||||
base::UTF8ToUTF16(blink::network_utils::IsOriginSecure(origin)
|
||||
? net::GetHostAndOptionalPort(origin)
|
||||
: origin.spec());
|
||||
|
||||
content::WebContents* web_contents =
|
||||
content::WebContents::FromRenderFrameHost(rfh);
|
||||
|
@ -50,7 +50,6 @@
|
||||
#include "content/public/browser/storage_partition.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "content/public/common/content_switches.h"
|
||||
#include "content/public/common/origin_util.h"
|
||||
#include "content/public/common/page_type.h"
|
||||
#include "content/public/common/result_codes.h"
|
||||
#include "content/public/test/background_sync_test_util.h"
|
||||
@ -78,6 +77,7 @@
|
||||
#include "extensions/test/test_extension_dir.h"
|
||||
#include "net/dns/mock_host_resolver.h"
|
||||
#include "net/test/embedded_test_server/embedded_test_server.h"
|
||||
#include "third_party/blink/public/common/loader/network_utils.h"
|
||||
#include "ui/message_center/public/cpp/notification.h"
|
||||
#include "url/url_constants.h"
|
||||
|
||||
@ -1432,7 +1432,7 @@ IN_PROC_BROWSER_TEST_F(ServiceWorkerTest, WebAccessibleResourcesIframeSrc) {
|
||||
embedded_test_server()->GetURL("a.com",
|
||||
"/extensions/api_test/service_worker/"
|
||||
"web_accessible_resources/webpage.html");
|
||||
EXPECT_FALSE(content::IsOriginSecure(page_url));
|
||||
EXPECT_FALSE(blink::network_utils::IsOriginSecure(page_url));
|
||||
|
||||
content::WebContents* web_contents =
|
||||
browsertest_util::AddTab(browser(), page_url);
|
||||
|
@ -41,13 +41,13 @@
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "content/public/common/content_switches.h"
|
||||
#include "content/public/common/origin_util.h"
|
||||
#include "extensions/browser/app_window/app_window.h"
|
||||
#include "extensions/browser/app_window/app_window_registry.h"
|
||||
#include "extensions/common/constants.h"
|
||||
#include "extensions/common/extension.h"
|
||||
#include "extensions/common/switches.h"
|
||||
#include "net/base/url_util.h"
|
||||
#include "third_party/blink/public/common/loader/network_utils.h"
|
||||
#include "third_party/blink/public/common/mediastream/media_stream_request.h"
|
||||
#include "third_party/blink/public/mojom/mediastream/media_stream.mojom-shared.h"
|
||||
#include "third_party/webrtc/modules/desktop_capture/desktop_capture_types.h"
|
||||
@ -79,8 +79,9 @@ base::string16 GetApplicationTitle(content::WebContents* web_contents,
|
||||
return base::UTF8ToUTF16(title);
|
||||
}
|
||||
GURL url = web_contents->GetURL();
|
||||
title = content::IsOriginSecure(url) ? net::GetHostAndOptionalPort(url)
|
||||
: url.GetOrigin().spec();
|
||||
title = blink::network_utils::IsOriginSecure(url)
|
||||
? net::GetHostAndOptionalPort(url)
|
||||
: url.GetOrigin().spec();
|
||||
return base::UTF8ToUTF16(title);
|
||||
}
|
||||
|
||||
@ -176,7 +177,7 @@ void DesktopCaptureAccessHandler::ProcessScreenCaptureAccessRequest(
|
||||
IsBuiltInExtension(request.security_origin);
|
||||
|
||||
const bool origin_is_secure =
|
||||
content::IsOriginSecure(request.security_origin) ||
|
||||
blink::network_utils::IsOriginSecure(request.security_origin) ||
|
||||
base::CommandLine::ForCurrentProcess()->HasSwitch(
|
||||
switches::kAllowHttpScreenCapture);
|
||||
|
||||
|
@ -22,12 +22,12 @@
|
||||
#include "components/content_settings/core/common/content_settings_types.h"
|
||||
#include "content/public/browser/notification_service.h"
|
||||
#include "content/public/common/content_switches.h"
|
||||
#include "content/public/common/origin_util.h"
|
||||
#include "content/public/test/browser_test.h"
|
||||
#include "content/public/test/browser_test_utils.h"
|
||||
#include "media/base/media_switches.h"
|
||||
#include "net/dns/mock_host_resolver.h"
|
||||
#include "net/test/embedded_test_server/embedded_test_server.h"
|
||||
#include "third_party/blink/public/common/loader/network_utils.h"
|
||||
#include "third_party/blink/public/common/mediastream/media_stream_request.h"
|
||||
#include "third_party/blink/public/mojom/mediastream/media_stream.mojom-shared.h"
|
||||
|
||||
@ -73,7 +73,7 @@ class MediaStreamPermissionTest : public WebRtcTestBase {
|
||||
// Uses the default server.
|
||||
GURL url = test_page_url();
|
||||
|
||||
EXPECT_TRUE(content::IsOriginSecure(url));
|
||||
EXPECT_TRUE(blink::network_utils::IsOriginSecure(url));
|
||||
|
||||
ui_test_utils::NavigateToURL(browser, url);
|
||||
return browser->tab_strip_model()->GetActiveWebContents();
|
||||
@ -108,7 +108,8 @@ IN_PROC_BROWSER_TEST_F(MediaStreamPermissionTest,
|
||||
IN_PROC_BROWSER_TEST_F(MediaStreamPermissionTest,
|
||||
TestSecureOriginDenyIsSticky) {
|
||||
content::WebContents* tab_contents = LoadTestPageInTab();
|
||||
EXPECT_TRUE(content::IsOriginSecure(tab_contents->GetLastCommittedURL()));
|
||||
EXPECT_TRUE(blink::network_utils::IsOriginSecure(
|
||||
tab_contents->GetLastCommittedURL()));
|
||||
|
||||
GetUserMediaAndDeny(tab_contents);
|
||||
GetUserMediaAndExpectAutoDenyWithoutPrompt(tab_contents);
|
||||
@ -117,7 +118,8 @@ IN_PROC_BROWSER_TEST_F(MediaStreamPermissionTest,
|
||||
IN_PROC_BROWSER_TEST_F(MediaStreamPermissionTest,
|
||||
TestSecureOriginAcceptIsSticky) {
|
||||
content::WebContents* tab_contents = LoadTestPageInTab();
|
||||
EXPECT_TRUE(content::IsOriginSecure(tab_contents->GetLastCommittedURL()));
|
||||
EXPECT_TRUE(blink::network_utils::IsOriginSecure(
|
||||
tab_contents->GetLastCommittedURL()));
|
||||
|
||||
EXPECT_TRUE(GetUserMediaAndAccept(tab_contents));
|
||||
GetUserMediaAndExpectAutoAcceptWithoutPrompt(tab_contents);
|
||||
|
@ -69,11 +69,11 @@
|
||||
#include "content/public/browser/render_view_host.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "content/public/browser/web_contents_delegate.h"
|
||||
#include "content/public/common/origin_util.h"
|
||||
#include "mojo/public/cpp/bindings/associated_remote.h"
|
||||
#include "ppapi/buildflags/buildflags.h"
|
||||
#include "services/device/public/cpp/device_features.h"
|
||||
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
|
||||
#include "third_party/blink/public/common/loader/network_utils.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
#include "ui/base/resource/resource_bundle.h"
|
||||
#include "ui/base/window_open_disposition.h"
|
||||
@ -1040,7 +1040,7 @@ void ContentSettingMediaStreamBubbleModel::SetRadioGroup() {
|
||||
int radio_block_label_id = 0;
|
||||
if (state_ & (PageSpecificContentSettings::MICROPHONE_BLOCKED |
|
||||
PageSpecificContentSettings::CAMERA_BLOCKED)) {
|
||||
if (content::IsOriginSecure(url)) {
|
||||
if (blink::network_utils::IsOriginSecure(url)) {
|
||||
radio_item_setting_[0] = CONTENT_SETTING_ALLOW;
|
||||
radio_allow_label_id = IDS_BLOCKED_MEDIASTREAM_CAMERA_ALLOW;
|
||||
if (MicrophoneAccessed())
|
||||
|
@ -36,7 +36,6 @@
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "content/public/browser/web_contents_delegate.h"
|
||||
#include "content/public/common/origin_util.h"
|
||||
#include "extensions/buildflags/buildflags.h"
|
||||
#include "net/base/auth.h"
|
||||
#include "net/base/host_port_pair.h"
|
||||
@ -44,6 +43,7 @@
|
||||
#include "net/http/http_auth_scheme.h"
|
||||
#include "net/http/http_transaction_factory.h"
|
||||
#include "net/url_request/url_request_context.h"
|
||||
#include "third_party/blink/public/common/loader/network_utils.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
#include "ui/gfx/text_elider.h"
|
||||
#include "url/origin.h"
|
||||
@ -440,7 +440,7 @@ void LoginHandler::GetDialogStrings(const GURL& request_url,
|
||||
authority_url = request_url;
|
||||
}
|
||||
|
||||
if (!content::IsOriginSecure(authority_url)) {
|
||||
if (!blink::network_utils::IsOriginSecure(authority_url)) {
|
||||
// TODO(asanka): The string should be different for proxies and servers.
|
||||
// http://crbug.com/620756
|
||||
*explanation = l10n_util::GetStringUTF16(IDS_LOGIN_DIALOG_NOT_PRIVATE);
|
||||
|
@ -9,9 +9,9 @@
|
||||
#include "chrome/browser/ssl/security_state_tab_helper.h"
|
||||
#include "chrome/browser/ui/browser.h"
|
||||
#include "content/public/browser/navigation_entry.h"
|
||||
#include "content/public/common/origin_util.h"
|
||||
#include "content/public/common/url_constants.h"
|
||||
#include "extensions/common/constants.h"
|
||||
#include "third_party/blink/public/common/loader/network_utils.h"
|
||||
#include "third_party/blink/public/common/manifest/manifest.h"
|
||||
#include "ui/gfx/favicon_size.h"
|
||||
#include "ui/gfx/image/image_skia.h"
|
||||
@ -36,7 +36,7 @@ bool ManifestWebAppBrowserController::ShouldShowCustomTabBar() const {
|
||||
return false;
|
||||
|
||||
// Show if the web_contents is not on a secure origin.
|
||||
if (!content::IsOriginSecure(app_launch_url_))
|
||||
if (!blink::network_utils::IsOriginSecure(app_launch_url_))
|
||||
return true;
|
||||
|
||||
// Show if web_contents is not currently in scope.
|
||||
|
@ -9,8 +9,8 @@
|
||||
#include "chrome/browser/ui/page_info/chrome_page_info_ui_delegate.h"
|
||||
#include "chrome/common/chrome_features.h"
|
||||
#include "components/strings/grit/components_strings.h"
|
||||
#include "content/public/common/origin_util.h"
|
||||
#include "ppapi/buildflags/buildflags.h"
|
||||
#include "third_party/blink/public/common/loader/network_utils.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
|
||||
PermissionMenuModel::PermissionMenuModel(Profile* profile,
|
||||
@ -85,7 +85,7 @@ bool PermissionMenuModel::ShouldShowAllow(const GURL& url) {
|
||||
// Media only supports CONTENT_SETTING_ALLOW for secure origins.
|
||||
case ContentSettingsType::MEDIASTREAM_MIC:
|
||||
case ContentSettingsType::MEDIASTREAM_CAMERA:
|
||||
return content::IsOriginSecure(url);
|
||||
return blink::network_utils::IsOriginSecure(url);
|
||||
// Chooser permissions do not support CONTENT_SETTING_ALLOW.
|
||||
case ContentSettingsType::SERIAL_GUARD:
|
||||
case ContentSettingsType::USB_GUARD:
|
||||
|
@ -24,8 +24,8 @@
|
||||
#include "content/public/browser/navigation_handle.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "content/public/common/origin_util.h"
|
||||
#include "net/base/url_util.h"
|
||||
#include "third_party/blink/public/common/loader/network_utils.h"
|
||||
#include "ui/gfx/color_palette.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
@ -102,7 +102,7 @@ void SetContentsBorderVisible(content::WebContents* contents, bool visible) {
|
||||
base::string16 GetTabName(content::WebContents* tab) {
|
||||
GURL url = tab->GetLastCommittedURL();
|
||||
const base::string16 tab_name =
|
||||
content::IsOriginSecure(url)
|
||||
blink::network_utils::IsOriginSecure(url)
|
||||
? base::UTF8ToUTF16(net::GetHostAndOptionalPort(url))
|
||||
: url_formatter::FormatUrlForSecurityDisplay(url.GetOrigin());
|
||||
return tab_name.empty() ? tab->GetTitle() : tab_name;
|
||||
|
@ -60,11 +60,11 @@
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "content/public/browser/web_ui.h"
|
||||
#include "content/public/common/content_features.h"
|
||||
#include "content/public/common/origin_util.h"
|
||||
#include "content/public/common/url_constants.h"
|
||||
#include "extensions/browser/extension_registry.h"
|
||||
#include "extensions/common/permissions/api_permission.h"
|
||||
#include "extensions/common/permissions/permissions_data.h"
|
||||
#include "third_party/blink/public/common/loader/network_utils.h"
|
||||
#include "third_party/blink/public/common/page/page_zoom.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
#include "ui/base/text/bytes_formatting.h"
|
||||
@ -313,7 +313,7 @@ bool IsPatternValidForType(const std::string& pattern_string,
|
||||
// return false with a string saying why.
|
||||
GURL url(pattern_string);
|
||||
if (url.is_valid() && map->IsRestrictedToSecureOrigins(content_type) &&
|
||||
!content::IsOriginSecure(url)) {
|
||||
!blink::network_utils::IsOriginSecure(url)) {
|
||||
*out_error = l10n_util::GetStringUTF8(
|
||||
IDS_SETTINGS_NOT_VALID_WEB_ADDRESS_FOR_CONTENT_TYPE);
|
||||
return false;
|
||||
|
@ -28,9 +28,9 @@
|
||||
#include "components/vector_icons/vector_icons.h"
|
||||
#include "content/public/browser/device_service.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "content/public/common/origin_util.h"
|
||||
#include "device/base/features.h"
|
||||
#include "services/device/public/mojom/usb_device.mojom.h"
|
||||
#include "third_party/blink/public/common/loader/network_utils.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
#include "ui/base/page_transition_types.h"
|
||||
#include "ui/base/window_open_disposition.h"
|
||||
@ -215,7 +215,8 @@ void WebUsbDetector::OnDeviceAdded(
|
||||
return;
|
||||
|
||||
const GURL& landing_page = *device_info->webusb_landing_page;
|
||||
if (!landing_page.is_valid() || !content::IsOriginSecure(landing_page))
|
||||
if (!landing_page.is_valid() ||
|
||||
!blink::network_utils::IsOriginSecure(landing_page))
|
||||
return;
|
||||
|
||||
if (base::StartsWith(GetActiveTabURL().spec(), landing_page.spec(),
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "extensions/common/constants.h"
|
||||
#include "ppapi/buildflags/buildflags.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "third_party/blink/public/common/loader/network_utils.h"
|
||||
#include "url/gurl.h"
|
||||
#include "url/origin.h"
|
||||
#include "url/url_util.h"
|
||||
@ -102,10 +103,11 @@ TEST(ChromeContentClientTest, AdditionalSchemes) {
|
||||
EXPECT_EQ("chrome-extension://abcdefghijklmnopqrstuvwxyzabcdef",
|
||||
origin.Serialize());
|
||||
|
||||
EXPECT_TRUE(content::IsOriginSecure(GURL("chrome-native://newtab/")));
|
||||
EXPECT_TRUE(
|
||||
blink::network_utils::IsOriginSecure(GURL("chrome-native://newtab/")));
|
||||
|
||||
GURL chrome_url(content::GetWebUIURL("dummyurl"));
|
||||
EXPECT_TRUE(content::IsOriginSecure(chrome_url));
|
||||
EXPECT_TRUE(blink::network_utils::IsOriginSecure(chrome_url));
|
||||
EXPECT_FALSE(content::OriginCanAccessServiceWorkers(chrome_url));
|
||||
EXPECT_TRUE(
|
||||
content::IsPotentiallyTrustworthyOrigin(url::Origin::Create(chrome_url)));
|
||||
|
@ -4,5 +4,6 @@ include_rules = [
|
||||
"+components/prefs",
|
||||
"+components/policy/core/common",
|
||||
"+content/public/browser",
|
||||
"+third_party/blink/public/common/loader/network_utils.h",
|
||||
"+third_party/blink/public/common/user_agent",
|
||||
]
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
#include "content/public/common/content_features.h"
|
||||
#include "content/public/common/origin_util.h"
|
||||
#include "third_party/blink/public/common/loader/network_utils.h"
|
||||
|
||||
namespace client_hints {
|
||||
|
||||
@ -87,7 +87,8 @@ void ClientHints::PersistClientHints(
|
||||
|
||||
// TODO(tbansal): crbug.com/735518. Consider killing the renderer that sent
|
||||
// the malformed IPC.
|
||||
if (!primary_url.is_valid() || !content::IsOriginSecure(primary_url))
|
||||
if (!primary_url.is_valid() ||
|
||||
!blink::network_utils::IsOriginSecure(primary_url))
|
||||
return;
|
||||
|
||||
if (!IsJavaScriptAllowed(primary_url))
|
||||
|
@ -9,8 +9,8 @@ source_set("common") {
|
||||
]
|
||||
deps = [
|
||||
"//components/content_settings/core/common",
|
||||
"//content/public/common",
|
||||
"//third_party/blink/public:blink_headers",
|
||||
"//third_party/blink/public/common",
|
||||
"//url",
|
||||
]
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
include_rules = [
|
||||
"+third_party/blink/public/common/loader/network_utils.h",
|
||||
"+third_party/blink/public/platform",
|
||||
]
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
#include "components/client_hints/common/client_hints.h"
|
||||
|
||||
#include "content/public/common/origin_util.h"
|
||||
#include "third_party/blink/public/common/loader/network_utils.h"
|
||||
#include "third_party/blink/public/platform/web_client_hints_type.h"
|
||||
#include "url/gurl.h"
|
||||
|
||||
@ -17,7 +17,7 @@ void GetAllowedClientHintsFromSource(
|
||||
if (client_hints_rules.empty())
|
||||
return;
|
||||
|
||||
if (!content::IsOriginSecure(url))
|
||||
if (!blink::network_utils::IsOriginSecure(url))
|
||||
return;
|
||||
|
||||
const GURL& origin = url.GetOrigin();
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include "components/embedder_support/origin_trials/features.h"
|
||||
#include "components/embedder_support/switches.h"
|
||||
#include "content/public/common/content_features.h"
|
||||
#include "content/public/common/origin_util.h"
|
||||
#include "third_party/blink/public/common/loader/network_utils.h"
|
||||
|
||||
namespace embedder_support {
|
||||
|
||||
@ -94,7 +94,7 @@ bool OriginTrialPolicyImpl::IsFeatureDisabledForUser(
|
||||
}
|
||||
|
||||
bool OriginTrialPolicyImpl::IsOriginSecure(const GURL& url) const {
|
||||
return content::IsOriginSecure(url);
|
||||
return blink::network_utils::IsOriginSecure(url);
|
||||
}
|
||||
|
||||
bool OriginTrialPolicyImpl::SetPublicKeysFromASCIIString(
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "base/android/jni_string.h"
|
||||
#include "base/android/scoped_java_ref.h"
|
||||
#include "components/payments/content/android/jni_headers/OriginSecurityChecker_jni.h"
|
||||
#include "content/public/common/origin_util.h"
|
||||
#include "third_party/blink/public/common/loader/network_utils.h"
|
||||
#include "url/gurl.h"
|
||||
|
||||
namespace payments {
|
||||
@ -21,7 +21,7 @@ jboolean JNI_OriginSecurityChecker_IsOriginSecure(
|
||||
JNIEnv* env,
|
||||
const JavaParamRef<jstring>& jurl) {
|
||||
GURL url(ConvertJavaStringToUTF8(env, jurl));
|
||||
return url.is_valid() && content::IsOriginSecure(url);
|
||||
return url.is_valid() && blink::network_utils::IsOriginSecure(url);
|
||||
}
|
||||
|
||||
// static
|
||||
|
@ -39,8 +39,8 @@
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "content/public/common/content_features.h"
|
||||
#include "content/public/common/origin_util.h"
|
||||
#include "services/metrics/public/cpp/ukm_source_id.h"
|
||||
#include "third_party/blink/public/common/loader/network_utils.h"
|
||||
|
||||
namespace payments {
|
||||
namespace {
|
||||
@ -130,7 +130,7 @@ void PaymentRequest::Init(
|
||||
client_.Bind(std::move(client));
|
||||
|
||||
const GURL last_committed_url = delegate_->GetLastCommittedURL();
|
||||
if (!content::IsOriginSecure(last_committed_url)) {
|
||||
if (!blink::network_utils::IsOriginSecure(last_committed_url)) {
|
||||
log_.Error(errors::kNotInASecureOrigin);
|
||||
OnConnectionTerminated();
|
||||
return;
|
||||
|
@ -60,6 +60,7 @@ source_set("permissions") {
|
||||
"//components/vector_icons",
|
||||
"//content/public/browser",
|
||||
"//services/metrics/public/cpp:ukm_builders",
|
||||
"//third_party/blink/public/common",
|
||||
"//ui/base",
|
||||
"//url",
|
||||
]
|
||||
|
@ -14,6 +14,7 @@ include_rules = [
|
||||
"+content/public/test",
|
||||
"+media/base/android/media_drm_bridge.h",
|
||||
"+services/metrics/public/cpp",
|
||||
"+third_party/blink/public/common/loader/network_utils.h",
|
||||
"+third_party/blink/public/mojom/feature_policy",
|
||||
"+third_party/blink/public/mojom/quota",
|
||||
"+ui/base",
|
||||
|
@ -34,7 +34,7 @@
|
||||
#include "content/public/browser/render_frame_host.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "content/public/common/content_features.h"
|
||||
#include "content/public/common/origin_util.h"
|
||||
#include "third_party/blink/public/common/loader/network_utils.h"
|
||||
#include "url/gurl.h"
|
||||
|
||||
namespace permissions {
|
||||
@ -289,7 +289,7 @@ bool PermissionContextBase::IsPermissionAvailableToOrigins(
|
||||
const GURL& requesting_origin,
|
||||
const GURL& embedding_origin) const {
|
||||
if (IsRestrictedToSecureOrigins()) {
|
||||
if (!content::IsOriginSecure(requesting_origin))
|
||||
if (!blink::network_utils::IsOriginSecure(requesting_origin))
|
||||
return false;
|
||||
|
||||
// TODO(raymes): We should check the entire chain of embedders here whenever
|
||||
@ -298,7 +298,7 @@ bool PermissionContextBase::IsPermissionAvailableToOrigins(
|
||||
// the top level and requesting origins.
|
||||
if (!PermissionsClient::Get()->CanBypassEmbeddingOriginCheck(
|
||||
requesting_origin, embedding_origin) &&
|
||||
!content::IsOriginSecure(embedding_origin)) {
|
||||
!blink::network_utils::IsOriginSecure(embedding_origin)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -18,9 +18,9 @@
|
||||
#include "components/ukm/content/source_url_recorder.h"
|
||||
#include "content/public/browser/permission_type.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "content/public/common/origin_util.h"
|
||||
#include "services/metrics/public/cpp/ukm_builders.h"
|
||||
#include "services/metrics/public/cpp/ukm_recorder.h"
|
||||
#include "third_party/blink/public/common/loader/network_utils.h"
|
||||
#include "url/gurl.h"
|
||||
|
||||
#if defined(OS_ANDROID)
|
||||
@ -206,7 +206,7 @@ void PermissionUmaUtil::PermissionRequested(ContentSettingsType content_type,
|
||||
bool success = PermissionUtil::GetPermissionType(content_type, &permission);
|
||||
DCHECK(success);
|
||||
|
||||
bool secure_origin = content::IsOriginSecure(requesting_origin);
|
||||
bool secure_origin = blink::network_utils::IsOriginSecure(requesting_origin);
|
||||
base::UmaHistogramEnumeration("ContentSettings.PermissionRequested",
|
||||
permission, PermissionType::NUM);
|
||||
if (secure_origin) {
|
||||
|
@ -6,6 +6,7 @@ include_rules = [
|
||||
"+content/public/common",
|
||||
"+content/public/test",
|
||||
"+third_party/boringssl/src/include",
|
||||
"+third_party/blink/public/common/loader/network_utils.h",
|
||||
# Allow inclusion of blink API headers (POD/enum only).
|
||||
"+third_party/blink/public/common/security/security_style.h",
|
||||
"+ui/base",
|
||||
@ -18,4 +19,4 @@ specific_include_rules = {
|
||||
"content_utils_unittest\.cc": [
|
||||
"+crypto",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -23,12 +23,12 @@
|
||||
#include "content/public/browser/security_style_explanations.h"
|
||||
#include "content/public/browser/ssl_status.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "content/public/common/origin_util.h"
|
||||
#include "content/public/common/url_constants.h"
|
||||
#include "net/base/net_errors.h"
|
||||
#include "net/cert/x509_certificate.h"
|
||||
#include "net/ssl/ssl_cipher_suite_names.h"
|
||||
#include "net/ssl/ssl_connection_status_flags.h"
|
||||
#include "third_party/blink/public/common/loader/network_utils.h"
|
||||
#include "third_party/blink/public/platform/web_mixed_content_context_type.h"
|
||||
#include "third_party/boringssl/src/include/openssl/ssl.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
@ -512,7 +512,7 @@ blink::SecurityStyle GetSecurityStyle(
|
||||
// Some origins are considered secure even if they're not cryptographic, so
|
||||
// display a more precise summary.
|
||||
if (security_level == security_state::NONE &&
|
||||
content::IsOriginSecure(visible_security_state.url)) {
|
||||
blink::network_utils::IsOriginSecure(visible_security_state.url)) {
|
||||
security_style_explanations->summary =
|
||||
l10n_util::GetStringUTF8(IDS_NON_CRYPTO_SECURE_SUMMARY);
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ source_set("webrtc") {
|
||||
"//components/content_settings/core/common",
|
||||
"//components/permissions",
|
||||
"//content/public/browser",
|
||||
"//content/public/common",
|
||||
"//third_party/blink/public/common",
|
||||
]
|
||||
if (is_android) {
|
||||
deps += [ "//ui/android" ]
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
#include "content/public/browser/render_widget_host_view.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "content/public/common/origin_util.h"
|
||||
#include "third_party/blink/public/common/loader/network_utils.h"
|
||||
#include "third_party/blink/public/mojom/feature_policy/feature_policy.mojom.h"
|
||||
|
||||
#if defined(OS_ANDROID)
|
||||
@ -165,7 +165,7 @@ MediaStreamDevicesController::MediaStreamDevicesController(
|
||||
enumerator_(enumerator),
|
||||
request_(request),
|
||||
callback_(std::move(callback)) {
|
||||
DCHECK(content::IsOriginSecure(request_.security_origin) ||
|
||||
DCHECK(blink::network_utils::IsOriginSecure(request_.security_origin) ||
|
||||
request_.request_type == blink::MEDIA_OPEN_DEVICE_PEPPER_ONLY);
|
||||
|
||||
if (!enumerator_)
|
||||
@ -407,7 +407,7 @@ ContentSetting MediaStreamDevicesController::GetContentSetting(
|
||||
DCHECK(content_type == ContentSettingsType::MEDIASTREAM_MIC ||
|
||||
content_type == ContentSettingsType::MEDIASTREAM_CAMERA);
|
||||
DCHECK(!request_.security_origin.is_empty());
|
||||
DCHECK(content::IsOriginSecure(request_.security_origin) ||
|
||||
DCHECK(blink::network_utils::IsOriginSecure(request_.security_origin) ||
|
||||
request_.request_type == blink::MEDIA_OPEN_DEVICE_PEPPER_ONLY);
|
||||
if (!ContentTypeIsRequested(content_type, request)) {
|
||||
// No denial reason set as it will have been previously set.
|
||||
|
@ -11,8 +11,8 @@
|
||||
#include "content/browser/background_fetch/background_fetch_job_controller.h"
|
||||
#include "content/browser/background_fetch/background_fetch_request_match_params.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/common/origin_util.h"
|
||||
#include "services/network/public/cpp/cors/cors.h"
|
||||
#include "third_party/blink/public/common/loader/network_utils.h"
|
||||
#include "third_party/blink/public/mojom/background_fetch/background_fetch.mojom.h"
|
||||
|
||||
namespace content {
|
||||
@ -29,7 +29,7 @@ bool IsMixedContent(const BackgroundFetchRequestInfo& request) {
|
||||
if (request.fetch_request()->url.is_empty())
|
||||
return false;
|
||||
|
||||
return !IsOriginSecure(request.fetch_request()->url);
|
||||
return !blink::network_utils::IsOriginSecure(request.fetch_request()->url);
|
||||
}
|
||||
|
||||
// Whether the |request| needs CORS preflight.
|
||||
|
@ -17,10 +17,10 @@
|
||||
#include "content/public/browser/clear_site_data_utils.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "content/public/common/content_switches.h"
|
||||
#include "content/public/common/origin_util.h"
|
||||
#include "net/base/load_flags.h"
|
||||
#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
|
||||
#include "net/http/http_response_headers.h"
|
||||
#include "third_party/blink/public/common/loader/network_utils.h"
|
||||
|
||||
namespace content {
|
||||
|
||||
@ -165,7 +165,7 @@ bool ClearSiteDataHandler::HandleHeaderAndOutputConsoleMessages() {
|
||||
|
||||
bool ClearSiteDataHandler::Run() {
|
||||
// Only accept the header on secure non-unique origins.
|
||||
if (!IsOriginSecure(url_)) {
|
||||
if (!blink::network_utils::IsOriginSecure(url_)) {
|
||||
delegate_->AddMessage(url_, "Not supported for insecure origins.",
|
||||
blink::mojom::ConsoleMessageLevel::kError);
|
||||
return false;
|
||||
|
@ -20,7 +20,6 @@
|
||||
#include "content/browser/cache_storage/cache_storage_trace_utils.h"
|
||||
#include "content/common/background_fetch/background_fetch_types.h"
|
||||
#include "content/public/common/content_features.h"
|
||||
#include "content/public/common/origin_util.h"
|
||||
#include "mojo/public/cpp/bindings/message.h"
|
||||
#include "mojo/public/cpp/bindings/pending_associated_remote.h"
|
||||
#include "net/http/http_response_headers.h"
|
||||
@ -28,6 +27,7 @@
|
||||
#include "services/network/public/cpp/cross_origin_resource_policy.h"
|
||||
#include "services/network/public/mojom/cross_origin_embedder_policy.mojom.h"
|
||||
#include "third_party/blink/public/common/blob/blob_utils.h"
|
||||
#include "third_party/blink/public/common/loader/network_utils.h"
|
||||
#include "third_party/blink/public/mojom/fetch/fetch_api_request.mojom.h"
|
||||
#include "url/gurl.h"
|
||||
#include "url/origin.h"
|
||||
@ -45,7 +45,8 @@ using network::mojom::RequestMode;
|
||||
|
||||
// TODO(lucmult): Check this before binding.
|
||||
bool OriginCanAccessCacheStorage(const url::Origin& origin) {
|
||||
return !origin.opaque() && IsOriginSecure(origin.GetURL());
|
||||
return !origin.opaque() &&
|
||||
blink::network_utils::IsOriginSecure(origin.GetURL());
|
||||
}
|
||||
|
||||
// Verifies that the BatchOperation list conforms to the constraints imposed
|
||||
|
@ -54,7 +54,6 @@
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "content/public/common/content_client.h"
|
||||
#include "content/public/common/content_features.h"
|
||||
#include "content/public/common/origin_util.h"
|
||||
#include "net/base/host_port_pair.h"
|
||||
#include "net/base/ip_endpoint.h"
|
||||
#include "net/base/net_errors.h"
|
||||
@ -78,6 +77,7 @@
|
||||
#include "services/network/public/cpp/resource_request.h"
|
||||
#include "services/network/public/cpp/url_loader_completion_status.h"
|
||||
#include "services/network/public/mojom/url_response_head.mojom.h"
|
||||
#include "third_party/blink/public/common/loader/network_utils.h"
|
||||
#include "third_party/blink/public/common/loader/referrer_utils.h"
|
||||
#include "third_party/blink/public/platform/resource_request_blocked_reason.h"
|
||||
#include "third_party/boringssl/src/include/openssl/ssl.h"
|
||||
@ -391,7 +391,7 @@ String securityState(const GURL& url, const net::CertStatus& cert_status) {
|
||||
if (!url.SchemeIsCryptographic()) {
|
||||
// Some origins are considered secure even though they're not cryptographic,
|
||||
// so treat them as secure in the UI.
|
||||
if (IsOriginSecure(url))
|
||||
if (blink::network_utils::IsOriginSecure(url))
|
||||
return Security::SecurityStateEnum::Secure;
|
||||
return Security::SecurityStateEnum::Insecure;
|
||||
}
|
||||
|
@ -65,7 +65,6 @@
|
||||
#include "content/public/browser/web_contents_delegate.h"
|
||||
#include "content/public/browser/web_ui_url_loader_factory.h"
|
||||
#include "content/public/common/content_client.h"
|
||||
#include "content/public/common/origin_util.h"
|
||||
#include "mojo/public/cpp/bindings/pending_receiver.h"
|
||||
#include "mojo/public/cpp/bindings/pending_remote.h"
|
||||
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
|
||||
@ -337,14 +336,14 @@ DownloadManagerImpl::DownloadManagerImpl(BrowserContext* browser_context)
|
||||
in_progress_manager_ =
|
||||
std::make_unique<download::InProgressDownloadManager>(
|
||||
this, base::FilePath(), proto_db_provider,
|
||||
base::BindRepeating(&IsOriginSecure),
|
||||
base::BindRepeating(&blink::network_utils::IsOriginSecure),
|
||||
base::BindRepeating(&DownloadRequestUtils::IsURLSafe),
|
||||
/*wake_lock_provider_binder=*/base::NullCallback());
|
||||
} else {
|
||||
in_progress_manager_->SetDelegate(this);
|
||||
in_progress_manager_->set_download_start_observer(nullptr);
|
||||
in_progress_manager_->set_is_origin_secure_cb(
|
||||
base::BindRepeating(&IsOriginSecure));
|
||||
base::BindRepeating(&blink::network_utils::IsOriginSecure));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "content/public/common/origin_util.h"
|
||||
#include "content/public/common/web_preferences.h"
|
||||
#include "net/base/url_util.h"
|
||||
#include "third_party/blink/public/common/loader/network_utils.h"
|
||||
#include "third_party/blink/public/common/security_context/insecure_request_policy.h"
|
||||
#include "third_party/blink/public/mojom/fetch/fetch_api_request.mojom.h"
|
||||
#include "third_party/blink/public/mojom/security_context/insecure_request_policy.mojom.h"
|
||||
@ -50,7 +51,8 @@ bool IsUrlPotentiallySecure(const GURL& url) {
|
||||
// blob: and filesystem: URLs never hit the network, and access is restricted
|
||||
// to same-origin contexts, so they are not blocked.
|
||||
return url.SchemeIs(url::kBlobScheme) ||
|
||||
url.SchemeIs(url::kFileSystemScheme) || IsOriginSecure(url) ||
|
||||
url.SchemeIs(url::kFileSystemScheme) ||
|
||||
blink::network_utils::IsOriginSecure(url) ||
|
||||
IsPotentiallyTrustworthyOrigin(url::Origin::Create(url));
|
||||
}
|
||||
|
||||
@ -290,7 +292,7 @@ RenderFrameHostImpl* MixedContentNavigationThrottle::InWhichFrameIsContentMixed(
|
||||
blink::mojom::WebFeature::
|
||||
kMixedContentInNonHTTPSFrameThatRestrictsMixedContent);
|
||||
}
|
||||
} else if (!IsOriginSecure(url) &&
|
||||
} else if (!blink::network_utils::IsOriginSecure(url) &&
|
||||
(IsSecureScheme(root->GetLastCommittedOrigin().scheme()) ||
|
||||
IsSecureScheme(parent->GetLastCommittedOrigin().scheme()))) {
|
||||
mixed_content_features_.insert(
|
||||
|
@ -15,13 +15,13 @@
|
||||
#include "content/public/browser/browser_task_traits.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
#include "content/public/common/origin_util.h"
|
||||
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
|
||||
#include "storage/browser/database/database_util.h"
|
||||
#include "storage/browser/database/vfs_backend.h"
|
||||
#include "storage/browser/quota/quota_manager.h"
|
||||
#include "storage/browser/quota/quota_manager_proxy.h"
|
||||
#include "storage/common/database/database_identifier.h"
|
||||
#include "third_party/blink/public/common/loader/network_utils.h"
|
||||
#include "third_party/blink/public/mojom/quota/quota_types.mojom.h"
|
||||
#include "third_party/sqlite/sqlite3.h"
|
||||
#include "url/origin.h"
|
||||
@ -346,7 +346,8 @@ void WebDatabaseHostImpl::OpenedValidated(
|
||||
int64_t estimated_size) {
|
||||
DCHECK(db_tracker_->task_runner()->RunsTasksInCurrentSequence());
|
||||
|
||||
UMA_HISTOGRAM_BOOLEAN("websql.OpenDatabase", IsOriginSecure(origin.GetURL()));
|
||||
UMA_HISTOGRAM_BOOLEAN("websql.OpenDatabase",
|
||||
blink::network_utils::IsOriginSecure(origin.GetURL()));
|
||||
|
||||
int64_t database_size = 0;
|
||||
std::string origin_identifier(storage::GetIdentifierFromOrigin(origin));
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include "mojo/public/cpp/system/functions.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "third_party/blink/public/common/features.h"
|
||||
#include "third_party/blink/public/common/loader/network_utils.h"
|
||||
#include "third_party/blink/public/common/tokens/tokens.h"
|
||||
#include "third_party/blink/public/mojom/service_worker/service_worker_object.mojom.h"
|
||||
#include "third_party/blink/public/mojom/service_worker/service_worker_registration.mojom.h"
|
||||
@ -427,7 +428,7 @@ TEST_F(ServiceWorkerContainerHostTest, ContextSecurity) {
|
||||
GURL url(std::string(kServiceWorkerScheme) + "://host");
|
||||
url::Origin origin = url::Origin::Create(url);
|
||||
EXPECT_TRUE(url.is_valid());
|
||||
EXPECT_FALSE(IsOriginSecure(url));
|
||||
EXPECT_FALSE(blink::network_utils::IsOriginSecure(url));
|
||||
EXPECT_TRUE(OriginCanAccessServiceWorkers(url));
|
||||
container_host_secure_parent->UpdateUrls(
|
||||
url, net::SiteForCookies::FromUrl(url), origin);
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include "content/browser/service_worker/embedded_worker_test_helper.h"
|
||||
#include "content/browser/service_worker/service_worker_context_core.h"
|
||||
#include "content/browser/service_worker/service_worker_test_utils.h"
|
||||
#include "content/public/common/origin_util.h"
|
||||
#include "content/public/test/browser_task_environment.h"
|
||||
#include "content/public/test/test_browser_context.h"
|
||||
#include "content/public/test/test_utils.h"
|
||||
@ -17,6 +16,7 @@
|
||||
#include "net/test/test_data_directory.h"
|
||||
#include "storage/browser/test/mock_special_storage_policy.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "third_party/blink/public/common/loader/network_utils.h"
|
||||
#include "third_party/blink/public/common/origin_trials/origin_trial_policy.h"
|
||||
|
||||
namespace content {
|
||||
@ -328,7 +328,7 @@ class ServiceWorkerRegistryOriginTrialsTest : public ServiceWorkerRegistryTest {
|
||||
}
|
||||
|
||||
bool IsOriginSecure(const GURL& url) const override {
|
||||
return content::IsOriginSecure(url);
|
||||
return blink::network_utils::IsOriginSecure(url);
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -20,7 +20,6 @@
|
||||
#include "content/browser/web_package/signed_exchange_utils.h"
|
||||
#include "content/browser/web_package/signed_exchange_validity_pinger.h"
|
||||
#include "content/public/common/content_features.h"
|
||||
#include "content/public/common/origin_util.h"
|
||||
#include "net/base/load_flags.h"
|
||||
#include "net/base/net_errors.h"
|
||||
#include "net/cert/cert_status_flags.h"
|
||||
@ -33,6 +32,7 @@
|
||||
#include "services/network/public/cpp/source_stream_to_data_pipe.h"
|
||||
#include "services/network/public/cpp/url_loader_completion_status.h"
|
||||
#include "services/network/public/mojom/url_loader_factory.mojom.h"
|
||||
#include "third_party/blink/public/common/loader/network_utils.h"
|
||||
#include "third_party/blink/public/common/loader/url_loader_throttle.h"
|
||||
#include "third_party/blink/public/common/web_package/web_package_request_matcher.h"
|
||||
|
||||
@ -170,7 +170,7 @@ void SignedExchangeLoader::OnStartLoadingResponseBody(
|
||||
}
|
||||
|
||||
signed_exchange_handler_ = std::make_unique<SignedExchangeHandler>(
|
||||
IsOriginSecure(outer_request_.url),
|
||||
blink::network_utils::IsOriginSecure(outer_request_.url),
|
||||
signed_exchange_utils::HasNoSniffHeader(*outer_response_head_),
|
||||
content_type_,
|
||||
std::make_unique<network::DataPipeToSourceStream>(
|
||||
|
@ -35,7 +35,6 @@
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "content/public/common/content_client.h"
|
||||
#include "content/public/common/content_features.h"
|
||||
#include "content/public/common/origin_util.h"
|
||||
#include "crypto/sha2.h"
|
||||
#include "device/base/features.h"
|
||||
#include "device/fido/attestation_statement.h"
|
||||
@ -55,6 +54,7 @@
|
||||
#include "net/der/parse_values.h"
|
||||
#include "net/der/parser.h"
|
||||
#include "services/network/public/cpp/is_potentially_trustworthy.h"
|
||||
#include "third_party/blink/public/common/loader/network_utils.h"
|
||||
#include "url/url_constants.h"
|
||||
#include "url/url_util.h"
|
||||
|
||||
@ -127,7 +127,7 @@ base::Optional<std::string> ProcessAppIdExtension(std::string appid,
|
||||
// Webauthn is only supported on secure origins and |ValidateEffectiveDomain|
|
||||
// has already checked this property of |origin| before this call. Thus this
|
||||
// step is moot.
|
||||
DCHECK(content::IsOriginSecure(origin.GetURL()));
|
||||
DCHECK(blink::network_utils::IsOriginSecure(origin.GetURL()));
|
||||
|
||||
// Step 2: "If the AppID is null or empty, the client must set the AppID to be
|
||||
// the FacetID of the caller, and the operation may proceed without additional
|
||||
|
@ -8,10 +8,10 @@
|
||||
#include "base/metrics/histogram_macros.h"
|
||||
#include "content/browser/frame_host/render_frame_host_impl.h"
|
||||
#include "content/public/browser/render_frame_host.h"
|
||||
#include "content/public/common/origin_util.h"
|
||||
#include "device/fido/features.h"
|
||||
#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
|
||||
#include "services/network/public/cpp/is_potentially_trustworthy.h"
|
||||
#include "third_party/blink/public/common/loader/network_utils.h"
|
||||
#include "third_party/blink/public/mojom/feature_policy/feature_policy_feature.mojom.h"
|
||||
#include "url/gurl.h"
|
||||
#include "url/origin.h"
|
||||
@ -42,7 +42,7 @@ blink::mojom::AuthenticatorStatus ValidateEffectiveDomain(
|
||||
}
|
||||
|
||||
if (url::HostIsIPAddress(caller_origin.host()) ||
|
||||
!IsOriginSecure(caller_origin.GetURL())) {
|
||||
!blink::network_utils::IsOriginSecure(caller_origin.GetURL())) {
|
||||
return blink::mojom::AuthenticatorStatus::INVALID_DOMAIN;
|
||||
}
|
||||
|
||||
@ -50,8 +50,8 @@ blink::mojom::AuthenticatorStatus ValidateEffectiveDomain(
|
||||
// may be supported in the future but the webauthn relying party is
|
||||
// just the domain of the origin so we would have to define how the
|
||||
// authority part of other schemes maps to a "domain" without
|
||||
// collisions. Given the |IsOriginSecure| check, just above, HTTP is
|
||||
// effectively restricted to just "localhost".
|
||||
// collisions. Given the |blink::network_utils::IsOriginSecure| check, just
|
||||
// above, HTTP is effectively restricted to just "localhost".
|
||||
if (caller_origin.scheme() != url::kHttpScheme &&
|
||||
caller_origin.scheme() != url::kHttpsScheme) {
|
||||
return blink::mojom::AuthenticatorStatus::INVALID_PROTOCOL;
|
||||
@ -193,7 +193,7 @@ WebAuthRequestSecurityChecker::ValidateAPrioriAuthenticatedUrl(
|
||||
// https://www.w3.org/TR/mixed-content/#a-priori-authenticated-url
|
||||
if (!url.IsAboutSrcdoc() && !url.IsAboutBlank() &&
|
||||
!url.SchemeIs(url::kDataScheme) &&
|
||||
!network::IsUrlPotentiallyTrustworthy(url)) {
|
||||
!blink::network_utils::IsOriginSecure(url)) {
|
||||
ReportSecurityCheckFailure(
|
||||
RelyingPartySecurityCheckFailure::kIconUrlInvalid);
|
||||
return blink::mojom::AuthenticatorStatus::INVALID_ICON_URL;
|
||||
|
@ -10,27 +10,14 @@
|
||||
#include "base/strings/pattern.h"
|
||||
#include "content/common/url_schemes.h"
|
||||
#include "services/network/public/cpp/is_potentially_trustworthy.h"
|
||||
#include "third_party/blink/public/common/loader/network_utils.h"
|
||||
#include "url/gurl.h"
|
||||
#include "url/url_util.h"
|
||||
|
||||
namespace content {
|
||||
|
||||
bool IsOriginSecure(const GURL& url) {
|
||||
// TODO(lukasza): data: URLs (and opaque origins associated with them) should
|
||||
// be considered insecure according to
|
||||
// https://www.w3.org/TR/powerful-features/#is-url-trustworthy.
|
||||
// Unfortunately, changing this behavior of content::IsOriginSecure breaks
|
||||
// quite a few tests for now (e.g. considering data: insecure makes us think
|
||||
// that https + data = mixed content), so fixing this is postponed to a
|
||||
// follow-up CL. WIP CL @ https://crrev.com/c/1505897.
|
||||
if (url.SchemeIs(url::kDataScheme))
|
||||
return true;
|
||||
|
||||
return network::IsUrlPotentiallyTrustworthy(url);
|
||||
}
|
||||
|
||||
bool OriginCanAccessServiceWorkers(const GURL& url) {
|
||||
if (url.SchemeIsHTTPOrHTTPS() && IsOriginSecure(url))
|
||||
if (url.SchemeIsHTTPOrHTTPS() && blink::network_utils::IsOriginSecure(url))
|
||||
return true;
|
||||
|
||||
if (base::Contains(GetServiceWorkerSchemes(), url.scheme())) {
|
||||
|
@ -8,67 +8,6 @@
|
||||
|
||||
namespace content {
|
||||
|
||||
TEST(OriginUtilTest, IsOriginSecure) {
|
||||
EXPECT_TRUE(IsOriginSecure(GURL("file:///test/fun.html")));
|
||||
EXPECT_TRUE(IsOriginSecure(GURL("file:///test/")));
|
||||
|
||||
EXPECT_TRUE(IsOriginSecure(GURL("https://example.com/fun.html")));
|
||||
EXPECT_FALSE(IsOriginSecure(GURL("http://example.com/fun.html")));
|
||||
|
||||
EXPECT_TRUE(IsOriginSecure(GURL("wss://example.com/fun.html")));
|
||||
EXPECT_FALSE(IsOriginSecure(GURL("ws://example.com/fun.html")));
|
||||
|
||||
EXPECT_TRUE(IsOriginSecure(GURL("http://localhost/fun.html")));
|
||||
EXPECT_TRUE(IsOriginSecure(GURL("http://pumpkin.localhost/fun.html")));
|
||||
EXPECT_TRUE(
|
||||
IsOriginSecure(GURL("http://crumpet.pumpkin.localhost/fun.html")));
|
||||
EXPECT_TRUE(IsOriginSecure(GURL("http://pumpkin.localhost:8080/fun.html")));
|
||||
EXPECT_TRUE(
|
||||
IsOriginSecure(GURL("http://crumpet.pumpkin.localhost:3000/fun.html")));
|
||||
EXPECT_FALSE(IsOriginSecure(GURL("http://localhost.com/fun.html")));
|
||||
EXPECT_TRUE(IsOriginSecure(GURL("https://localhost.com/fun.html")));
|
||||
|
||||
EXPECT_TRUE(IsOriginSecure(GURL("http://127.0.0.1/fun.html")));
|
||||
EXPECT_TRUE(IsOriginSecure(GURL("ftp://127.0.0.1/fun.html")));
|
||||
EXPECT_TRUE(IsOriginSecure(GURL("http://127.3.0.1/fun.html")));
|
||||
EXPECT_FALSE(IsOriginSecure(GURL("http://127.example.com/fun.html")));
|
||||
EXPECT_TRUE(IsOriginSecure(GURL("https://127.example.com/fun.html")));
|
||||
|
||||
EXPECT_TRUE(IsOriginSecure(GURL("http://[::1]/fun.html")));
|
||||
EXPECT_FALSE(IsOriginSecure(GURL("http://[::2]/fun.html")));
|
||||
EXPECT_FALSE(IsOriginSecure(GURL("http://[::1].example.com/fun.html")));
|
||||
|
||||
EXPECT_FALSE(
|
||||
IsOriginSecure(GURL("filesystem:http://www.example.com/temporary/")));
|
||||
EXPECT_FALSE(
|
||||
IsOriginSecure(GURL("filesystem:ftp://www.example.com/temporary/")));
|
||||
EXPECT_TRUE(IsOriginSecure(GURL("filesystem:ftp://127.0.0.1/temporary/")));
|
||||
EXPECT_TRUE(
|
||||
IsOriginSecure(GURL("filesystem:https://www.example.com/temporary/")));
|
||||
|
||||
EXPECT_TRUE(IsOriginSecure(GURL("about:blank")));
|
||||
EXPECT_TRUE(IsOriginSecure(GURL("about:blank#ref")));
|
||||
EXPECT_TRUE(IsOriginSecure(GURL("about:srcdoc")));
|
||||
|
||||
EXPECT_FALSE(IsOriginSecure(GURL("javascript:alert('blah')")));
|
||||
|
||||
// TODO(lukasza): data: URLs (and opaque origins associated with them) should
|
||||
// be considered insecure according to
|
||||
// https://www.w3.org/TR/powerful-features/#is-url-trustworthy.
|
||||
// Unfortunately, changing the behavior of content::IsOriginSecure breaks
|
||||
// quite a few tests for now (e.g. considering data: insecure makes us think
|
||||
// that https + data = mixed content).
|
||||
EXPECT_TRUE(IsOriginSecure(GURL("data:test/plain;blah")));
|
||||
|
||||
EXPECT_FALSE(
|
||||
IsOriginSecure(GURL("blob:http://www.example.com/guid-goes-here")));
|
||||
EXPECT_FALSE(
|
||||
IsOriginSecure(GURL("blob:ftp://www.example.com/guid-goes-here")));
|
||||
EXPECT_TRUE(IsOriginSecure(GURL("blob:ftp://127.0.0.1/guid-goes-here")));
|
||||
EXPECT_TRUE(
|
||||
IsOriginSecure(GURL("blob:https://www.example.com/guid-goes-here")));
|
||||
}
|
||||
|
||||
TEST(OriginUtilTest, IsPotentiallyTrustworthyOrigin) {
|
||||
EXPECT_FALSE(
|
||||
IsPotentiallyTrustworthyOrigin(url::Origin::Create(GURL("about:blank"))));
|
||||
|
@ -12,20 +12,6 @@ class GURL;
|
||||
|
||||
namespace content {
|
||||
|
||||
// Returns true if |url|'s origin is trustworthy. There are two cases:
|
||||
// a) it can be said that |url|'s contents were transferred to the browser in a
|
||||
// way that a network attacker cannot tamper with or observe. (see
|
||||
// https://www.w3.org/TR/powerful-features/#is-origin-trustworthy).
|
||||
// b) IsWhitelistedAsSecureOrigin(url::Origin::Create(url)) returns true.
|
||||
//
|
||||
// Note that this is not equivalent to checking if an entire site is secure
|
||||
// (i.e. no degraded security state UI is displayed to the user), since there
|
||||
// may be insecure iframes present even if this method returns true.
|
||||
//
|
||||
// TODO(lukasza): Remove this function and use
|
||||
// network::IsUrlPotentiallyTrustworthy instead.
|
||||
bool CONTENT_EXPORT IsOriginSecure(const GURL& url);
|
||||
|
||||
// Returns true if the origin can register a service worker. Scheme must be
|
||||
// http (localhost only), https, or a custom-set secure scheme.
|
||||
bool CONTENT_EXPORT OriginCanAccessServiceWorkers(const GURL& url);
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include "build/build_config.h"
|
||||
#include "content/common/inter_process_time_ticks_converter.h"
|
||||
#include "content/common/navigation_params.h"
|
||||
#include "content/public/common/origin_util.h"
|
||||
#include "content/public/renderer/request_peer.h"
|
||||
#include "content/public/renderer/resource_dispatcher_delegate.h"
|
||||
#include "content/renderer/loader/request_extra_data.h"
|
||||
@ -70,7 +69,7 @@ void CheckSchemeForReferrerPolicy(const network::ResourceRequest& request) {
|
||||
net::ReferrerPolicy::CLEAR_ON_TRANSITION_FROM_SECURE_TO_INSECURE) &&
|
||||
request.referrer.SchemeIsCryptographic() &&
|
||||
!url::Origin::Create(request.url).opaque() &&
|
||||
!IsOriginSecure(request.url)) {
|
||||
!blink::network_utils::IsOriginSecure(request.url)) {
|
||||
LOG(FATAL) << "Trying to send secure referrer for insecure request "
|
||||
<< "without an appropriate referrer policy.\n"
|
||||
<< "URL = " << request.url << "\n"
|
||||
|
@ -35,7 +35,6 @@
|
||||
#include "content/public/common/content_constants.h"
|
||||
#include "content/public/common/content_features.h"
|
||||
#include "content/public/common/navigation_policy.h"
|
||||
#include "content/public/common/origin_util.h"
|
||||
#include "content/public/renderer/request_peer.h"
|
||||
#include "content/renderer/loader/request_extra_data.h"
|
||||
#include "content/renderer/loader/resource_dispatcher.h"
|
||||
@ -65,6 +64,7 @@
|
||||
#include "services/network/public/mojom/url_response_head.mojom.h"
|
||||
#include "third_party/blink/public/common/features.h"
|
||||
#include "third_party/blink/public/common/loader/mime_sniffing_throttle.h"
|
||||
#include "third_party/blink/public/common/loader/network_utils.h"
|
||||
#include "third_party/blink/public/common/loader/previews_state.h"
|
||||
#include "third_party/blink/public/common/loader/referrer_utils.h"
|
||||
#include "third_party/blink/public/common/loader/resource_type_util.h"
|
||||
@ -193,7 +193,7 @@ void SetSecurityStyleAndDetails(const GURL& url,
|
||||
if (!url.SchemeIsCryptographic()) {
|
||||
// Some origins are considered secure even though they're not cryptographic,
|
||||
// so treat them as secure in the UI.
|
||||
if (IsOriginSecure(url))
|
||||
if (blink::network_utils::IsOriginSecure(url))
|
||||
response->SetSecurityStyle(blink::SecurityStyle::kSecure);
|
||||
else
|
||||
response->SetSecurityStyle(blink::SecurityStyle::kInsecure);
|
||||
@ -315,8 +315,8 @@ bool IsBannedCrossSiteAuth(network::ResourceRequest* resource_request,
|
||||
// If the first party is secure but the subresource is not, this is
|
||||
// mixed-content. Do not allow the image.
|
||||
if (!allow_cross_origin_auth_prompt &&
|
||||
IsOriginSecure(first_party.RepresentativeUrl()) &&
|
||||
!IsOriginSecure(request_url)) {
|
||||
blink::network_utils::IsOriginSecure(first_party.RepresentativeUrl()) &&
|
||||
!blink::network_utils::IsOriginSecure(request_url)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
#include "build/build_config.h"
|
||||
#include "content/common/frame_messages.h"
|
||||
#include "content/public/common/origin_util.h"
|
||||
#include "content/renderer/pepper/pepper_hung_plugin_filter.h"
|
||||
#include "content/renderer/pepper/pepper_plugin_instance_impl.h"
|
||||
#include "content/renderer/pepper/pepper_proxy_channel_delegate_impl.h"
|
||||
@ -14,6 +13,7 @@
|
||||
#include "content/renderer/pepper/renderer_ppapi_host_impl.h"
|
||||
#include "content/renderer/pepper/renderer_restrict_dispatch_group.h"
|
||||
#include "content/renderer/render_frame_impl.h"
|
||||
#include "third_party/blink/public/common/loader/network_utils.h"
|
||||
#include "third_party/blink/public/web/web_document.h"
|
||||
#include "third_party/blink/public/web/web_plugin_container.h"
|
||||
|
||||
@ -86,7 +86,7 @@ void HostDispatcherWrapper::AddInstance(PP_Instance instance) {
|
||||
PepperPluginInstance* plugin_instance = host->GetPluginInstance(instance);
|
||||
bool is_privileged_context =
|
||||
plugin_instance->GetContainer()->GetDocument().IsSecureContext() &&
|
||||
content::IsOriginSecure(plugin_instance->GetPluginURL());
|
||||
blink::network_utils::IsOriginSecure(plugin_instance->GetPluginURL());
|
||||
render_frame->Send(new FrameHostMsg_DidCreateOutOfProcessPepperInstance(
|
||||
plugin_child_id_, instance,
|
||||
PepperRendererInstanceData(
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include "base/process/process_handle.h"
|
||||
#include "base/single_thread_task_runner.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "content/public/common/origin_util.h"
|
||||
#include "content/renderer/pepper/fullscreen_container.h"
|
||||
#include "content/renderer/pepper/host_globals.h"
|
||||
#include "content/renderer/pepper/pepper_browser_connection.h"
|
||||
@ -26,6 +25,7 @@
|
||||
#include "ipc/ipc_platform_file.h"
|
||||
#include "ppapi/host/ppapi_host.h"
|
||||
#include "ppapi/proxy/host_dispatcher.h"
|
||||
#include "third_party/blink/public/common/loader/network_utils.h"
|
||||
#include "third_party/blink/public/platform/web_rect.h"
|
||||
#include "third_party/blink/public/web/web_document.h"
|
||||
#include "third_party/blink/public/web/web_element.h"
|
||||
@ -288,7 +288,7 @@ bool RendererPpapiHostImpl::IsSecureContext(PP_Instance pp_instance) const {
|
||||
if (!instance)
|
||||
return false;
|
||||
return instance->GetContainer()->GetDocument().IsSecureContext() &&
|
||||
content::IsOriginSecure(instance->GetPluginURL());
|
||||
blink::network_utils::IsOriginSecure(instance->GetPluginURL());
|
||||
}
|
||||
|
||||
int RendererPpapiHostImpl::GetPluginChildId() const {
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include "base/feature_list.h"
|
||||
#include "base/stl_util.h"
|
||||
#include "content/public/common/content_features.h"
|
||||
#include "content/public/common/origin_util.h"
|
||||
#include "third_party/blink/public/common/loader/network_utils.h"
|
||||
|
||||
namespace content {
|
||||
|
||||
@ -42,7 +42,7 @@ std::vector<base::StringPiece> ShellOriginTrialPolicy::GetPublicKeys() const {
|
||||
}
|
||||
|
||||
bool ShellOriginTrialPolicy::IsOriginSecure(const GURL& url) const {
|
||||
return content::IsOriginSecure(url);
|
||||
return blink::network_utils::IsOriginSecure(url);
|
||||
}
|
||||
|
||||
} // namespace content
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
#include "content/test/mock_client_hints_utils.h"
|
||||
|
||||
#include "third_party/blink/public/common/loader/network_utils.h"
|
||||
|
||||
namespace content {
|
||||
|
||||
bool PersistClientHintsHelper(const GURL& url,
|
||||
@ -11,7 +13,7 @@ bool PersistClientHintsHelper(const GURL& url,
|
||||
base::TimeDelta expiration_duration,
|
||||
ClientHintsContainer* container) {
|
||||
DCHECK(container);
|
||||
if (!content::IsOriginSecure(url) ||
|
||||
if (!blink::network_utils::IsOriginSecure(url) ||
|
||||
expiration_duration <= base::TimeDelta()) {
|
||||
return false;
|
||||
}
|
||||
|
1
third_party/blink/common/BUILD.gn
vendored
1
third_party/blink/common/BUILD.gn
vendored
@ -238,6 +238,7 @@ source_set("common_unittests_sources") {
|
||||
"input/synthetic_web_input_event_builders_unittest.cc",
|
||||
"input/web_input_event_unittest.cc",
|
||||
"loader/mime_sniffing_throttle_unittest.cc",
|
||||
"loader/network_utils_unittest.cc",
|
||||
"loader/referrer_utils_unittest.cc",
|
||||
"loader/throttling_url_loader_unittest.cc",
|
||||
"manifest/manifest_icon_selector_unittest.cc",
|
||||
|
16
third_party/blink/common/loader/network_utils.cc
vendored
16
third_party/blink/common/loader/network_utils.cc
vendored
@ -7,7 +7,9 @@
|
||||
#include "base/feature_list.h"
|
||||
#include "build/build_config.h"
|
||||
#include "net/net_buildflags.h"
|
||||
#include "services/network/public/cpp/is_potentially_trustworthy.h"
|
||||
#include "third_party/blink/public/common/features.h"
|
||||
#include "url/url_constants.h"
|
||||
|
||||
namespace blink {
|
||||
namespace network_utils {
|
||||
@ -35,5 +37,19 @@ bool IsURLHandledByNetworkService(const GURL& url) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IsOriginSecure(const GURL& url) {
|
||||
// TODO(lukasza): data: URLs (and opaque origins associated with them) should
|
||||
// be considered insecure according to
|
||||
// https://www.w3.org/TR/powerful-features/#is-url-trustworthy.
|
||||
// Unfortunately, changing this behavior of NetworkUtils::IsOriginSecure
|
||||
// breaks quite a few tests for now (e.g. considering data: insecure makes us
|
||||
// think that https + data = mixed content), so fixing this is postponed to a
|
||||
// follow-up CL. WIP CL @ https://crrev.com/c/1505897.
|
||||
if (url.SchemeIs(url::kDataScheme))
|
||||
return true;
|
||||
|
||||
return network::IsUrlPotentiallyTrustworthy(url);
|
||||
}
|
||||
|
||||
} // namespace network_utils
|
||||
} // namespace blink
|
||||
|
86
third_party/blink/common/loader/network_utils_unittest.cc
vendored
Normal file
86
third_party/blink/common/loader/network_utils_unittest.cc
vendored
Normal file
@ -0,0 +1,86 @@
|
||||
// Copyright 2020 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "third_party/blink/public/common/loader/network_utils.h"
|
||||
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "url/gurl.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
TEST(OriginUtilTest, IsOriginSecure) {
|
||||
EXPECT_TRUE(network_utils::IsOriginSecure(GURL("file:///test/fun.html")));
|
||||
EXPECT_TRUE(network_utils::IsOriginSecure(GURL("file:///test/")));
|
||||
|
||||
EXPECT_TRUE(
|
||||
network_utils::IsOriginSecure(GURL("https://example.com/fun.html")));
|
||||
EXPECT_FALSE(
|
||||
network_utils::IsOriginSecure(GURL("http://example.com/fun.html")));
|
||||
|
||||
EXPECT_TRUE(
|
||||
network_utils::IsOriginSecure(GURL("wss://example.com/fun.html")));
|
||||
EXPECT_FALSE(
|
||||
network_utils::IsOriginSecure(GURL("ws://example.com/fun.html")));
|
||||
|
||||
EXPECT_TRUE(network_utils::IsOriginSecure(GURL("http://localhost/fun.html")));
|
||||
EXPECT_TRUE(
|
||||
network_utils::IsOriginSecure(GURL("http://pumpkin.localhost/fun.html")));
|
||||
EXPECT_TRUE(network_utils::IsOriginSecure(
|
||||
GURL("http://crumpet.pumpkin.localhost/fun.html")));
|
||||
EXPECT_TRUE(network_utils::IsOriginSecure(
|
||||
GURL("http://pumpkin.localhost:8080/fun.html")));
|
||||
EXPECT_TRUE(network_utils::IsOriginSecure(
|
||||
GURL("http://crumpet.pumpkin.localhost:3000/fun.html")));
|
||||
EXPECT_FALSE(
|
||||
network_utils::IsOriginSecure(GURL("http://localhost.com/fun.html")));
|
||||
EXPECT_TRUE(
|
||||
network_utils::IsOriginSecure(GURL("https://localhost.com/fun.html")));
|
||||
|
||||
EXPECT_TRUE(network_utils::IsOriginSecure(GURL("http://127.0.0.1/fun.html")));
|
||||
EXPECT_TRUE(network_utils::IsOriginSecure(GURL("ftp://127.0.0.1/fun.html")));
|
||||
EXPECT_TRUE(network_utils::IsOriginSecure(GURL("http://127.3.0.1/fun.html")));
|
||||
EXPECT_FALSE(
|
||||
network_utils::IsOriginSecure(GURL("http://127.example.com/fun.html")));
|
||||
EXPECT_TRUE(
|
||||
network_utils::IsOriginSecure(GURL("https://127.example.com/fun.html")));
|
||||
|
||||
EXPECT_TRUE(network_utils::IsOriginSecure(GURL("http://[::1]/fun.html")));
|
||||
EXPECT_FALSE(network_utils::IsOriginSecure(GURL("http://[::2]/fun.html")));
|
||||
EXPECT_FALSE(
|
||||
network_utils::IsOriginSecure(GURL("http://[::1].example.com/fun.html")));
|
||||
|
||||
EXPECT_FALSE(network_utils::IsOriginSecure(
|
||||
GURL("filesystem:http://www.example.com/temporary/")));
|
||||
EXPECT_FALSE(network_utils::IsOriginSecure(
|
||||
GURL("filesystem:ftp://www.example.com/temporary/")));
|
||||
EXPECT_TRUE(network_utils::IsOriginSecure(
|
||||
GURL("filesystem:ftp://127.0.0.1/temporary/")));
|
||||
EXPECT_TRUE(network_utils::IsOriginSecure(
|
||||
GURL("filesystem:https://www.example.com/temporary/")));
|
||||
|
||||
EXPECT_TRUE(network_utils::IsOriginSecure(GURL("about:blank")));
|
||||
EXPECT_TRUE(network_utils::IsOriginSecure(GURL("about:blank#ref")));
|
||||
EXPECT_TRUE(network_utils::IsOriginSecure(GURL("about:srcdoc")));
|
||||
|
||||
EXPECT_FALSE(network_utils::IsOriginSecure(GURL("javascript:alert('blah')")));
|
||||
|
||||
// TODO(lukasza): data: URLs (and opaque origins associated with them) should
|
||||
// be considered insecure according to
|
||||
// https://www.w3.org/TR/powerful-features/#is-url-trustworthy.
|
||||
// Unfortunately, changing the behavior of network_utils::IsOriginSecure
|
||||
// breaks quite a few tests for now (e.g. considering data: insecure makes us
|
||||
// think that https + data = mixed content).
|
||||
EXPECT_TRUE(network_utils::IsOriginSecure(GURL("data:test/plain;blah")));
|
||||
|
||||
EXPECT_FALSE(network_utils::IsOriginSecure(
|
||||
GURL("blob:http://www.example.com/guid-goes-here")));
|
||||
EXPECT_FALSE(network_utils::IsOriginSecure(
|
||||
GURL("blob:ftp://www.example.com/guid-goes-here")));
|
||||
EXPECT_TRUE(network_utils::IsOriginSecure(
|
||||
GURL("blob:ftp://127.0.0.1/guid-goes-here")));
|
||||
EXPECT_TRUE(network_utils::IsOriginSecure(
|
||||
GURL("blob:https://www.example.com/guid-goes-here")));
|
||||
}
|
||||
|
||||
} // namespace blink
|
@ -27,6 +27,20 @@ BLINK_COMMON_EXPORT bool AlwaysAccessNetwork(
|
||||
// handled by the network stack when the Network Service is disabled.
|
||||
BLINK_COMMON_EXPORT bool IsURLHandledByNetworkService(const GURL& url);
|
||||
|
||||
// Returns true if |url|'s origin is trustworthy. There are two cases:
|
||||
// a) it can be said that |url|'s contents were transferred to the browser in
|
||||
// a way that a network attacker cannot tamper with or observe. (see
|
||||
// https://www.w3.org/TR/powerful-features/#is-origin-trustworthy).
|
||||
// b) IsWhitelistedAsSecureOrigin(url::Origin::Create(url)) returns true.
|
||||
//
|
||||
// Note that this is not equivalent to checking if an entire site is secure
|
||||
// (i.e. no degraded security state UI is displayed to the user), since there
|
||||
// may be insecure iframes present even if this method returns true.
|
||||
//
|
||||
// TODO(lukasza): Remove this function and use
|
||||
// network::IsUrlPotentiallyTrustworthy instead.
|
||||
BLINK_COMMON_EXPORT bool IsOriginSecure(const GURL& url);
|
||||
|
||||
} // namespace network_utils
|
||||
} // namespace blink
|
||||
|
||||
|
Reference in New Issue
Block a user