mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-02-23 15:37:51 +01:00
Fix PDF extension loading with custom request context handler (issue #1710)
This commit is contained in:
parent
e343da7e40
commit
2c3d761ad0
@ -10,8 +10,28 @@
|
||||
#include "libcef/browser/url_request_context_getter_proxy.h"
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "components/guest_view/common/guest_view_constants.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())
|
||||
return true;
|
||||
|
||||
// If this value is not proxied then CefBrowserContextImpl::GetGuestManager()
|
||||
// returns NULL.
|
||||
if (key == guest_view::kGuestViewManagerKeyName)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
CefBrowserContextProxy::CefBrowserContextProxy(
|
||||
CefRefPtr<CefRequestContextHandler> handler,
|
||||
scoped_refptr<CefBrowserContextImpl> parent)
|
||||
@ -26,6 +46,27 @@ CefBrowserContextProxy::~CefBrowserContextProxy() {
|
||||
parent_->RemoveProxy(this);
|
||||
}
|
||||
|
||||
base::SupportsUserData::Data*
|
||||
CefBrowserContextProxy::GetUserData(const void* key) const {
|
||||
if (ShouldProxyUserData(key))
|
||||
return parent_->GetUserData(key);
|
||||
return BrowserContext::GetUserData(key);
|
||||
}
|
||||
|
||||
void CefBrowserContextProxy::SetUserData(const void* key, Data* data) {
|
||||
if (ShouldProxyUserData(key))
|
||||
parent_->SetUserData(key, data);
|
||||
else
|
||||
BrowserContext::SetUserData(key, data);
|
||||
}
|
||||
|
||||
void CefBrowserContextProxy::RemoveUserData(const void* key) {
|
||||
if (ShouldProxyUserData(key))
|
||||
parent_->RemoveUserData(key);
|
||||
else
|
||||
BrowserContext::RemoveUserData(key);
|
||||
}
|
||||
|
||||
base::FilePath CefBrowserContextProxy::GetPath() const {
|
||||
return parent_->GetPath();
|
||||
}
|
||||
|
@ -29,6 +29,11 @@ class CefBrowserContextProxy : public CefBrowserContext {
|
||||
CefBrowserContextProxy(CefRefPtr<CefRequestContextHandler> handler,
|
||||
scoped_refptr<CefBrowserContextImpl> parent);
|
||||
|
||||
// SupportsUserData methods.
|
||||
Data* GetUserData(const void* key) const override;
|
||||
void SetUserData(const void* key, Data* data) override;
|
||||
void RemoveUserData(const void* key) override;
|
||||
|
||||
// BrowserContext methods.
|
||||
base::FilePath GetPath() const override;
|
||||
scoped_ptr<content::ZoomLevelDelegate> CreateZoomLevelDelegate(
|
||||
|
@ -190,4 +190,16 @@ patches = [
|
||||
'name': 'browser_frame_host_guest_1687',
|
||||
'path': '../content/browser/frame_host/',
|
||||
},
|
||||
{
|
||||
# Fix loading of the PDF extension with proxy BrowserContext.
|
||||
# https://bitbucket.org/chromiumembedded/cef/issues/1710
|
||||
'name': 'stream_context_1710',
|
||||
'path': '../content/browser/streams/',
|
||||
},
|
||||
{
|
||||
# Fix loading of the PDF extension with proxy BrowserContext.
|
||||
# https://bitbucket.org/chromiumembedded/cef/issues/1710
|
||||
'name': 'supports_user_data_1710',
|
||||
'path': '../base/',
|
||||
},
|
||||
]
|
||||
|
27
patch/patches/stream_context_1710.patch
Normal file
27
patch/patches/stream_context_1710.patch
Normal file
@ -0,0 +1,27 @@
|
||||
diff --git stream_context.cc stream_context.cc
|
||||
index e338396..150cde5 100644
|
||||
--- stream_context.cc
|
||||
+++ stream_context.cc
|
||||
@@ -19,6 +19,10 @@ namespace content {
|
||||
|
||||
StreamContext::StreamContext() {}
|
||||
|
||||
+const void* StreamContext::GetUserDataKey() {
|
||||
+ return kStreamContextKeyName;
|
||||
+}
|
||||
+
|
||||
StreamContext* StreamContext::GetFor(BrowserContext* context) {
|
||||
if (!context->GetUserData(kStreamContextKeyName)) {
|
||||
scoped_refptr<StreamContext> stream = new StreamContext();
|
||||
diff --git stream_context.h stream_context.h
|
||||
index ad8f65c..60310db 100644
|
||||
--- stream_context.h
|
||||
+++ stream_context.h
|
||||
@@ -28,6 +28,7 @@ class StreamContext
|
||||
public:
|
||||
StreamContext();
|
||||
|
||||
+ CONTENT_EXPORT static const void* GetUserDataKey();
|
||||
CONTENT_EXPORT static StreamContext* GetFor(BrowserContext* browser_context);
|
||||
|
||||
void InitializeOnIOThread();
|
17
patch/patches/supports_user_data_1710.patch
Normal file
17
patch/patches/supports_user_data_1710.patch
Normal file
@ -0,0 +1,17 @@
|
||||
diff --git supports_user_data.h supports_user_data.h
|
||||
index 711ee7d..cf38fc0 100644
|
||||
--- supports_user_data.h
|
||||
+++ supports_user_data.h
|
||||
@@ -32,9 +32,9 @@ class BASE_EXPORT SupportsUserData {
|
||||
// Multiple user data values can be stored under different keys.
|
||||
// This object will TAKE OWNERSHIP of the given data pointer, and will
|
||||
// delete the object if it is changed or the object is destroyed.
|
||||
- Data* GetUserData(const void* key) const;
|
||||
- void SetUserData(const void* key, Data* data);
|
||||
- void RemoveUserData(const void* key);
|
||||
+ virtual Data* GetUserData(const void* key) const;
|
||||
+ virtual void SetUserData(const void* key, Data* data);
|
||||
+ virtual void RemoveUserData(const void* key);
|
||||
|
||||
// SupportsUserData is not thread-safe, and on debug build will assert it is
|
||||
// only used on one thread. Calling this method allows the caller to hand
|
Loading…
x
Reference in New Issue
Block a user