2012-04-24 20:01:48 +02:00
|
|
|
// Copyright (c) 2012 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.
|
|
|
|
|
|
|
|
#include "libcef/common/scheme_registrar_impl.h"
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
2013-06-05 01:37:26 +02:00
|
|
|
#include "libcef/common/content_client.h"
|
2017-01-23 18:36:54 +01:00
|
|
|
#include "libcef/common/net/scheme_registration.h"
|
2012-04-24 20:01:48 +02:00
|
|
|
|
|
|
|
#include "base/bind.h"
|
|
|
|
#include "base/logging.h"
|
2017-01-23 18:36:54 +01:00
|
|
|
#include "base/strings/string_util.h"
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
void AppendArray(const std::vector<std::string>& source,
|
|
|
|
std::vector<std::string>* target) {
|
|
|
|
if (source.empty())
|
|
|
|
return;
|
|
|
|
target->insert(target->end(), source.begin(), source.end());
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2012-04-24 20:01:48 +02:00
|
|
|
|
2017-02-07 22:25:11 +01:00
|
|
|
CefSchemeRegistrarImpl::CefSchemeRegistrarImpl() {
|
2012-04-24 20:01:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CefSchemeRegistrarImpl::AddCustomScheme(
|
|
|
|
const CefString& scheme_name,
|
|
|
|
bool is_standard,
|
|
|
|
bool is_local,
|
2017-01-23 18:36:54 +01:00
|
|
|
bool is_display_isolated,
|
|
|
|
bool is_secure,
|
|
|
|
bool is_cors_enabled) {
|
|
|
|
const std::string& scheme = base::ToLowerASCII(scheme_name.ToString());
|
|
|
|
if (scheme::IsInternalHandledScheme(scheme) ||
|
|
|
|
registered_schemes_.find(scheme) != registered_schemes_.end()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
registered_schemes_.insert(scheme);
|
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.
|
2012-04-24 20:01:48 +02:00
|
|
|
if (is_standard)
|
2017-01-23 18:36:54 +01:00
|
|
|
schemes_.standard_schemes.push_back(scheme);
|
|
|
|
if (is_local)
|
|
|
|
schemes_.local_schemes.push_back(scheme);
|
|
|
|
if (is_secure)
|
|
|
|
schemes_.secure_schemes.push_back(scheme);
|
|
|
|
if (is_cors_enabled)
|
|
|
|
schemes_.cors_enabled_schemes.push_back(scheme);
|
2012-04-24 20:01:48 +02:00
|
|
|
|
2013-06-05 01:37:26 +02:00
|
|
|
CefContentClient::SchemeInfo scheme_info = {
|
2017-01-23 18:36:54 +01:00
|
|
|
scheme, is_standard, is_local, is_display_isolated, is_secure,
|
|
|
|
is_cors_enabled
|
|
|
|
};
|
2013-06-05 01:37:26 +02:00
|
|
|
CefContentClient::Get()->AddCustomScheme(scheme_info);
|
2013-06-04 19:41:37 +02:00
|
|
|
|
2012-04-24 20:01:48 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-01-23 18:36:54 +01:00
|
|
|
void CefSchemeRegistrarImpl::GetSchemes(
|
|
|
|
content::ContentClient::Schemes* schemes) {
|
|
|
|
AppendArray(schemes_.standard_schemes, &schemes->standard_schemes);
|
|
|
|
AppendArray(schemes_.local_schemes, &schemes->local_schemes);
|
|
|
|
AppendArray(schemes_.secure_schemes, &schemes->secure_schemes);
|
|
|
|
AppendArray(schemes_.cors_enabled_schemes, &schemes->cors_enabled_schemes);
|
2012-04-24 20:01:48 +02:00
|
|
|
}
|