2013-06-04 19:41:37 +02:00
|
|
|
// Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights
|
|
|
|
// reserved. Use of this source code is governed by a BSD-style license that
|
|
|
|
// can be found in the LICENSE file.
|
|
|
|
|
2015-11-26 03:53:12 +01:00
|
|
|
#include "libcef/common/net/scheme_registration.h"
|
|
|
|
|
2020-06-28 23:05:36 +02:00
|
|
|
#include "libcef/common/app_manager.h"
|
|
|
|
#include "libcef/common/net/scheme_info.h"
|
|
|
|
#include "libcef/features/runtime.h"
|
2013-06-04 19:41:37 +02:00
|
|
|
|
2021-07-23 18:40:13 +02:00
|
|
|
#include "base/containers/contains.h"
|
2013-06-04 19:41:37 +02:00
|
|
|
#include "content/public/common/url_constants.h"
|
2015-07-16 23:40:01 +02:00
|
|
|
#include "extensions/common/constants.h"
|
2014-06-12 22:28:58 +02:00
|
|
|
#include "url/url_constants.h"
|
2019-04-24 04:50:25 +02:00
|
|
|
#include "url/url_util.h"
|
2013-06-04 19:41:37 +02:00
|
|
|
|
|
|
|
namespace scheme {
|
|
|
|
|
2017-01-23 18:36:54 +01:00
|
|
|
void AddInternalSchemes(content::ContentClient::Schemes* schemes) {
|
2020-06-28 23:05:36 +02:00
|
|
|
if (!cef::IsAlloyRuntimeEnabled())
|
|
|
|
return;
|
|
|
|
|
2015-08-14 16:41:08 +02:00
|
|
|
// chrome: and chrome-devtools: schemes are registered in
|
|
|
|
// RenderThreadImpl::RegisterSchemes().
|
2015-10-12 20:13:13 +02:00
|
|
|
// Access restrictions for chrome-extension: and chrome-extension-resource:
|
2020-06-28 20:29:44 +02:00
|
|
|
// schemes will be applied in AlloyContentRendererClient::WillSendRequest().
|
2020-06-28 23:05:36 +02:00
|
|
|
static CefSchemeInfo internal_schemes[] = {
|
2017-05-17 11:29:28 +02:00
|
|
|
{
|
|
|
|
extensions::kExtensionScheme, true, /* is_standard */
|
|
|
|
false, /* is_local */
|
|
|
|
false, /* is_display_isolated */
|
|
|
|
true, /* is_secure */
|
|
|
|
true, /* is_cors_enabled */
|
|
|
|
true, /* is_csp_bypassing */
|
|
|
|
},
|
2013-06-04 19:41:37 +02:00
|
|
|
};
|
|
|
|
|
2017-01-23 18:36:54 +01:00
|
|
|
// The |is_display_isolated| value is excluded here because it's registered
|
|
|
|
// with Blink only.
|
|
|
|
for (size_t i = 0; i < sizeof(internal_schemes) / sizeof(internal_schemes[0]);
|
|
|
|
++i) {
|
|
|
|
if (internal_schemes[i].is_standard)
|
|
|
|
schemes->standard_schemes.push_back(internal_schemes[i].scheme_name);
|
|
|
|
if (internal_schemes[i].is_local)
|
|
|
|
schemes->local_schemes.push_back(internal_schemes[i].scheme_name);
|
|
|
|
if (internal_schemes[i].is_secure)
|
|
|
|
schemes->secure_schemes.push_back(internal_schemes[i].scheme_name);
|
|
|
|
if (internal_schemes[i].is_cors_enabled)
|
|
|
|
schemes->cors_enabled_schemes.push_back(internal_schemes[i].scheme_name);
|
2017-03-03 23:37:23 +01:00
|
|
|
if (internal_schemes[i].is_csp_bypassing)
|
|
|
|
schemes->csp_bypassing_schemes.push_back(internal_schemes[i].scheme_name);
|
2020-06-28 23:05:36 +02:00
|
|
|
CefAppManager::Get()->AddCustomScheme(&internal_schemes[i]);
|
2013-06-04 19:41:37 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IsInternalHandledScheme(const std::string& scheme) {
|
|
|
|
static const char* schemes[] = {
|
2021-09-20 11:06:23 +02:00
|
|
|
url::kAboutScheme,
|
|
|
|
url::kBlobScheme,
|
|
|
|
content::kChromeDevToolsScheme,
|
|
|
|
content::kChromeUIScheme,
|
|
|
|
url::kDataScheme,
|
|
|
|
extensions::kExtensionScheme,
|
|
|
|
url::kFileScheme,
|
|
|
|
url::kFileSystemScheme,
|
|
|
|
url::kHttpScheme,
|
|
|
|
url::kHttpsScheme,
|
|
|
|
url::kJavaScriptScheme,
|
|
|
|
url::kWsScheme,
|
|
|
|
url::kWssScheme,
|
2013-06-04 19:41:37 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
for (size_t i = 0; i < sizeof(schemes) / sizeof(schemes[0]); ++i) {
|
|
|
|
if (scheme == schemes[i])
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-04-24 04:50:25 +02:00
|
|
|
bool IsStandardScheme(const std::string& scheme) {
|
|
|
|
url::Component scheme_comp(0, scheme.length());
|
|
|
|
return url::IsStandard(scheme.c_str(), scheme_comp);
|
|
|
|
}
|
|
|
|
|
2020-08-14 21:28:23 +02:00
|
|
|
// Should return the same value as SecurityOrigin::isLocal and
|
|
|
|
// SchemeRegistry::shouldTreatURLSchemeAsCorsEnabled.
|
|
|
|
bool IsCorsEnabledScheme(const std::string& scheme) {
|
|
|
|
return base::Contains(url::GetCorsEnabledSchemes(), scheme);
|
|
|
|
}
|
|
|
|
|
2013-06-04 19:41:37 +02:00
|
|
|
} // namespace scheme
|