mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Add StoragePartition and extension object proxy support (issue #1973)
This commit is contained in:
@@ -7,23 +7,34 @@
|
||||
#include "libcef/browser/content_browser_client.h"
|
||||
#include "libcef/browser/download_manager_delegate.h"
|
||||
#include "libcef/browser/net/url_request_context_getter_proxy.h"
|
||||
#include "libcef/browser/storage_partition_proxy.h"
|
||||
#include "libcef/browser/thread_util.h"
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "chrome/browser/font_family_cache.h"
|
||||
#include "components/guest_view/common/guest_view_constants.h"
|
||||
#include "components/visitedlink/browser/visitedlink_master.h"
|
||||
#include "content/browser/blob_storage/chrome_blob_storage_context.h"
|
||||
#include "content/browser/resource_context_impl.h"
|
||||
#include "content/browser/streams/stream_context.h"
|
||||
#include "content/public/browser/storage_partition.h"
|
||||
|
||||
namespace {
|
||||
|
||||
bool ShouldProxyUserData(const void* key) {
|
||||
// If this value is not proxied the blob data fails to load for the PDF
|
||||
// extension.
|
||||
if (key == content::StreamContext::GetUserDataKey())
|
||||
// If this value is not proxied then multiple StoragePartitionImpl objects
|
||||
// will be created and filesystem API access will fail, among other things.
|
||||
if (key == content::BrowserContext::GetStoragePartitionMapUserDataKey())
|
||||
return true;
|
||||
|
||||
// If these values are not proxied then blob data fails to load for the PDF
|
||||
// extension.
|
||||
// See also the call to InitializeResourceContext().
|
||||
if (key == content::ChromeBlobStorageContext::GetUserDataKey() ||
|
||||
key == content::StreamContext::GetUserDataKey()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// If this value is not proxied then CefBrowserContextImpl::GetGuestManager()
|
||||
// returns NULL.
|
||||
// See also CefExtensionsAPIClient::CreateGuestViewManagerDelegate.
|
||||
@@ -129,6 +140,24 @@ content::BackgroundSyncController*
|
||||
return parent_->GetBackgroundSyncController();
|
||||
}
|
||||
|
||||
net::URLRequestContextGetter* CefBrowserContextProxy::CreateRequestContext(
|
||||
content::ProtocolHandlerMap* protocol_handlers,
|
||||
content::URLRequestInterceptorScopedVector request_interceptors) {
|
||||
// CefBrowserContextImpl::GetOrCreateStoragePartitionProxy is called instead
|
||||
// of this method.
|
||||
NOTREACHED();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
net::URLRequestContextGetter*
|
||||
CefBrowserContextProxy::CreateRequestContextForStoragePartition(
|
||||
const base::FilePath& partition_path,
|
||||
bool in_memory,
|
||||
content::ProtocolHandlerMap* protocol_handlers,
|
||||
content::URLRequestInterceptorScopedVector request_interceptors) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PrefService* CefBrowserContextProxy::GetPrefs() {
|
||||
return parent_->GetPrefs();
|
||||
}
|
||||
@@ -145,29 +174,6 @@ CefRefPtr<CefRequestContextHandler> CefBrowserContextProxy::GetHandler() const {
|
||||
return handler_;
|
||||
}
|
||||
|
||||
net::URLRequestContextGetter* CefBrowserContextProxy::CreateRequestContext(
|
||||
content::ProtocolHandlerMap* protocol_handlers,
|
||||
content::URLRequestInterceptorScopedVector request_interceptors) {
|
||||
CEF_REQUIRE_UIT();
|
||||
DCHECK(!url_request_getter_.get());
|
||||
|
||||
CreateProtocolHandlers(protocol_handlers);
|
||||
|
||||
url_request_getter_ =
|
||||
new CefURLRequestContextGetterProxy(handler_, parent_->request_context());
|
||||
resource_context()->set_url_request_context_getter(url_request_getter_.get());
|
||||
return url_request_getter_.get();
|
||||
}
|
||||
|
||||
net::URLRequestContextGetter*
|
||||
CefBrowserContextProxy::CreateRequestContextForStoragePartition(
|
||||
const base::FilePath& partition_path,
|
||||
bool in_memory,
|
||||
content::ProtocolHandlerMap* protocol_handlers,
|
||||
content::URLRequestInterceptorScopedVector request_interceptors) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
HostContentSettingsMap* CefBrowserContextProxy::GetHostContentSettingsMap() {
|
||||
return parent_->GetHostContentSettingsMap();
|
||||
}
|
||||
@@ -175,3 +181,29 @@ HostContentSettingsMap* CefBrowserContextProxy::GetHostContentSettingsMap() {
|
||||
void CefBrowserContextProxy::AddVisitedURLs(const std::vector<GURL>& urls) {
|
||||
parent_->AddVisitedURLs(urls);
|
||||
}
|
||||
|
||||
content::StoragePartition*
|
||||
CefBrowserContextProxy::GetOrCreateStoragePartitionProxy(
|
||||
content::StoragePartition* partition_impl) {
|
||||
CEF_REQUIRE_UIT();
|
||||
|
||||
if (!storage_partition_proxy_) {
|
||||
scoped_refptr<CefURLRequestContextGetterProxy> url_request_getter =
|
||||
new CefURLRequestContextGetterProxy(handler_,
|
||||
parent_->request_context());
|
||||
resource_context()->set_url_request_context_getter(
|
||||
url_request_getter.get());
|
||||
storage_partition_proxy_.reset(
|
||||
new CefStoragePartitionProxy(partition_impl,
|
||||
url_request_getter.get()));
|
||||
|
||||
// Associates UserData keys with the ResourceContext.
|
||||
// Called from StoragePartitionImplMap::Get() for CefBrowserContextImpl.
|
||||
content::InitializeResourceContext(this);
|
||||
}
|
||||
|
||||
// There should only be one CefStoragePartitionProxy for this
|
||||
// CefBrowserContextProxy.
|
||||
DCHECK_EQ(storage_partition_proxy_->parent(), partition_impl);
|
||||
return storage_partition_proxy_.get();
|
||||
}
|
||||
|
Reference in New Issue
Block a user