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"
|
|
|
|
|
2013-06-05 01:37:26 +02:00
|
|
|
#include "libcef/common/content_client.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"
|
2017-05-17 11:29:28 +02:00
|
|
|
#include "net/net_features.h"
|
2014-06-12 22:28:58 +02:00
|
|
|
#include "url/url_constants.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) {
|
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:
|
|
|
|
// schemes will be applied in CefContentRendererClient::WillSendRequest().
|
2017-01-23 18:36:54 +01:00
|
|
|
static CefContentClient::SchemeInfo 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.
|
2013-06-05 01:37:26 +02:00
|
|
|
CefContentClient* client = CefContentClient::Get();
|
2017-01-23 18:36:54 +01:00
|
|
|
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);
|
2017-01-23 18:36:54 +01:00
|
|
|
client->AddCustomScheme(internal_schemes[i]);
|
2013-06-04 19:41:37 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IsInternalHandledScheme(const std::string& scheme) {
|
|
|
|
static const char* schemes[] = {
|
2014-06-12 22:28:58 +02:00
|
|
|
url::kBlobScheme,
|
2014-02-19 17:27:54 +01:00
|
|
|
content::kChromeDevToolsScheme,
|
|
|
|
content::kChromeUIScheme,
|
2015-07-16 23:40:01 +02:00
|
|
|
extensions::kExtensionScheme,
|
2014-06-12 22:28:58 +02:00
|
|
|
url::kDataScheme,
|
|
|
|
url::kFileScheme,
|
|
|
|
url::kFileSystemScheme,
|
2017-01-23 18:36:54 +01:00
|
|
|
#if !BUILDFLAG(DISABLE_FTP_SUPPORT)
|
|
|
|
url::kFtpScheme,
|
|
|
|
#endif
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IsInternalProtectedScheme(const std::string& scheme) {
|
|
|
|
// Some of these values originate from StoragePartitionImplMap::Get() in
|
|
|
|
// content/browser/storage_partition_impl_map.cc and are modified by
|
|
|
|
// InstallInternalProtectedHandlers().
|
|
|
|
static const char* schemes[] = {
|
2014-06-12 22:28:58 +02:00
|
|
|
url::kBlobScheme,
|
2014-02-19 17:27:54 +01:00
|
|
|
content::kChromeUIScheme,
|
2015-07-16 23:40:01 +02:00
|
|
|
extensions::kExtensionScheme,
|
2014-06-12 22:28:58 +02:00
|
|
|
url::kDataScheme,
|
|
|
|
url::kFileScheme,
|
|
|
|
url::kFileSystemScheme,
|
2016-11-23 21:54:29 +01:00
|
|
|
#if !BUILDFLAG(DISABLE_FTP_SUPPORT)
|
2014-06-12 22:28:58 +02:00
|
|
|
url::kFtpScheme,
|
2013-06-24 20:57:05 +02:00
|
|
|
#endif
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace scheme
|