mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
This commit is contained in:
2
BUILD.gn
2
BUILD.gn
@@ -598,6 +598,8 @@ static_library("libcef_static") {
|
||||
"libcef/renderer/render_urlrequest_impl.cc",
|
||||
"libcef/renderer/render_urlrequest_impl.h",
|
||||
"libcef/renderer/thread_util.h",
|
||||
"libcef/renderer/url_loader_throttle_provider_impl.cc",
|
||||
"libcef/renderer/url_loader_throttle_provider_impl.h",
|
||||
"libcef/renderer/v8_impl.cc",
|
||||
"libcef/renderer/v8_impl.h",
|
||||
"libcef/utility/content_utility_client.cc",
|
||||
|
@@ -199,7 +199,7 @@ void CefExtensionSystem::Init() {
|
||||
// mime_handler_private.idl), and returns the unique View ID via the
|
||||
// |payload| argument.
|
||||
// 5. The unique View ID arrives in the renderer process via
|
||||
// ResourceLoader::didReceiveData and triggers creation of a new Document.
|
||||
// ResourceLoader::DidReceiveData and triggers creation of a new Document.
|
||||
// DOMImplementation::createDocument indirectly calls
|
||||
// RendererBlinkPlatformImpl::getPluginList to retrieve the list of
|
||||
// supported plugins from the browser process. If a plugin supports the
|
||||
|
@@ -566,6 +566,13 @@ bool CefMainDelegate::BasicStartupComplete(int* exit_code) {
|
||||
}
|
||||
}
|
||||
|
||||
if (features::kMimeHandlerViewInCrossProcessFrame.default_state ==
|
||||
base::FEATURE_ENABLED_BY_DEFAULT) {
|
||||
// TODO: Add support for cross-process mime handler view (see issue #2727)
|
||||
disable_features.push_back(
|
||||
features::kMimeHandlerViewInCrossProcessFrame.name);
|
||||
}
|
||||
|
||||
if (!disable_features.empty()) {
|
||||
DCHECK(!base::FeatureList::GetInstance());
|
||||
std::string disable_features_str =
|
||||
|
@@ -37,6 +37,7 @@
|
||||
#include "libcef/renderer/render_message_filter.h"
|
||||
#include "libcef/renderer/render_thread_observer.h"
|
||||
#include "libcef/renderer/thread_util.h"
|
||||
#include "libcef/renderer/url_loader_throttle_provider_impl.h"
|
||||
#include "libcef/renderer/v8_impl.h"
|
||||
|
||||
#include "base/command_line.h"
|
||||
@@ -623,6 +624,12 @@ void CefContentRendererClient::CreateRendererService(
|
||||
service_binding_.Bind(std::move(service_request));
|
||||
}
|
||||
|
||||
std::unique_ptr<content::URLLoaderThrottleProvider>
|
||||
CefContentRendererClient::CreateURLLoaderThrottleProvider(
|
||||
content::URLLoaderThrottleProviderType provider_type) {
|
||||
return std::make_unique<CefURLLoaderThrottleProviderImpl>(provider_type);
|
||||
}
|
||||
|
||||
void CefContentRendererClient::OnBindInterface(
|
||||
const service_manager::BindSourceInfo& remote_info,
|
||||
const std::string& name,
|
||||
|
@@ -138,6 +138,9 @@ class CefContentRendererClient
|
||||
void DevToolsAgentDetached() override;
|
||||
void CreateRendererService(
|
||||
service_manager::mojom::ServiceRequest service_request) override;
|
||||
std::unique_ptr<content::URLLoaderThrottleProvider>
|
||||
CreateURLLoaderThrottleProvider(
|
||||
content::URLLoaderThrottleProviderType provider_type) override;
|
||||
|
||||
// service_manager::Service implementation.
|
||||
void OnBindInterface(const service_manager::BindSourceInfo& remote_info,
|
||||
|
78
libcef/renderer/url_loader_throttle_provider_impl.cc
Normal file
78
libcef/renderer/url_loader_throttle_provider_impl.cc
Normal file
@@ -0,0 +1,78 @@
|
||||
// Copyright 2018 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 "libcef/renderer/url_loader_throttle_provider_impl.h"
|
||||
|
||||
#include "libcef/common/extensions/extensions_util.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "base/feature_list.h"
|
||||
#include "content/public/common/content_features.h"
|
||||
#include "content/public/renderer/render_frame.h"
|
||||
#include "extensions/renderer/guest_view/mime_handler_view/mime_handler_view_container.h"
|
||||
#include "services/network/public/cpp/features.h"
|
||||
#include "third_party/blink/public/platform/web_url.h"
|
||||
|
||||
CefURLLoaderThrottleProviderImpl::CefURLLoaderThrottleProviderImpl(
|
||||
content::URLLoaderThrottleProviderType type)
|
||||
: type_(type) {
|
||||
DETACH_FROM_THREAD(thread_checker_);
|
||||
}
|
||||
|
||||
CefURLLoaderThrottleProviderImpl::~CefURLLoaderThrottleProviderImpl() {
|
||||
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
|
||||
}
|
||||
|
||||
CefURLLoaderThrottleProviderImpl::CefURLLoaderThrottleProviderImpl(
|
||||
const CefURLLoaderThrottleProviderImpl& other)
|
||||
: type_(other.type_) {
|
||||
DETACH_FROM_THREAD(thread_checker_);
|
||||
}
|
||||
|
||||
std::unique_ptr<content::URLLoaderThrottleProvider>
|
||||
CefURLLoaderThrottleProviderImpl::Clone() {
|
||||
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
|
||||
return base::WrapUnique(new CefURLLoaderThrottleProviderImpl(*this));
|
||||
}
|
||||
|
||||
std::vector<std::unique_ptr<content::URLLoaderThrottle>>
|
||||
CefURLLoaderThrottleProviderImpl::CreateThrottles(
|
||||
int render_frame_id,
|
||||
const blink::WebURLRequest& request,
|
||||
content::ResourceType resource_type) {
|
||||
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
|
||||
|
||||
std::vector<std::unique_ptr<content::URLLoaderThrottle>> throttles;
|
||||
|
||||
bool network_service_enabled =
|
||||
base::FeatureList::IsEnabled(network::features::kNetworkService);
|
||||
// Some throttles have already been added in the browser for frame resources.
|
||||
// Don't add them for frame requests.
|
||||
bool is_frame_resource = content::IsResourceTypeFrame(resource_type);
|
||||
|
||||
DCHECK(!is_frame_resource ||
|
||||
type_ == content::URLLoaderThrottleProviderType::kFrame);
|
||||
|
||||
if (extensions::ExtensionsEnabled() && network_service_enabled &&
|
||||
type_ == content::URLLoaderThrottleProviderType::kFrame &&
|
||||
resource_type == content::ResourceType::kObject) {
|
||||
content::RenderFrame* render_frame =
|
||||
content::RenderFrame::FromRoutingID(render_frame_id);
|
||||
auto mime_handlers =
|
||||
extensions::MimeHandlerViewContainer::FromRenderFrame(render_frame);
|
||||
GURL gurl(request.Url());
|
||||
for (auto* handler : mime_handlers) {
|
||||
auto throttle = handler->MaybeCreatePluginThrottle(gurl);
|
||||
if (throttle) {
|
||||
throttles.push_back(std::move(throttle));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return throttles;
|
||||
}
|
||||
|
||||
void CefURLLoaderThrottleProviderImpl::SetOnline(bool is_online) {}
|
45
libcef/renderer/url_loader_throttle_provider_impl.h
Normal file
45
libcef/renderer/url_loader_throttle_provider_impl.h
Normal file
@@ -0,0 +1,45 @@
|
||||
// Copyright 2018 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.
|
||||
|
||||
#ifndef CEF_LIBCEF_RENDERER_URL_LOADER_THROTTLE_PROVIDER_IMPL_H_
|
||||
#define CEF_LIBCEF_RENDERER_URL_LOADER_THROTTLE_PROVIDER_IMPL_H_
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "base/threading/thread_checker.h"
|
||||
#include "content/public/renderer/url_loader_throttle_provider.h"
|
||||
|
||||
// Instances must be constructed on the render thread, and then used and
|
||||
// destructed on a single thread, which can be different from the render thread.
|
||||
class CefURLLoaderThrottleProviderImpl
|
||||
: public content::URLLoaderThrottleProvider {
|
||||
public:
|
||||
explicit CefURLLoaderThrottleProviderImpl(
|
||||
content::URLLoaderThrottleProviderType type);
|
||||
|
||||
~CefURLLoaderThrottleProviderImpl() override;
|
||||
|
||||
// content::URLLoaderThrottleProvider implementation.
|
||||
std::unique_ptr<content::URLLoaderThrottleProvider> Clone() override;
|
||||
std::vector<std::unique_ptr<content::URLLoaderThrottle>> CreateThrottles(
|
||||
int render_frame_id,
|
||||
const blink::WebURLRequest& request,
|
||||
content::ResourceType resource_type) override;
|
||||
void SetOnline(bool is_online) override;
|
||||
|
||||
private:
|
||||
// This copy constructor works in conjunction with Clone(), not intended for
|
||||
// general use.
|
||||
CefURLLoaderThrottleProviderImpl(
|
||||
const CefURLLoaderThrottleProviderImpl& other);
|
||||
|
||||
content::URLLoaderThrottleProviderType type_;
|
||||
|
||||
THREAD_CHECKER(thread_checker_);
|
||||
|
||||
DISALLOW_ASSIGN(CefURLLoaderThrottleProviderImpl);
|
||||
};
|
||||
|
||||
#endif // CEF_LIBCEF_RENDERER_URL_LOADER_THROTTLE_PROVIDER_IMPL_H_
|
Reference in New Issue
Block a user