mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-02-16 20:20:51 +01:00
Update to Chromium revision 170167.
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@933 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
parent
f53c281acd
commit
ea920a4d9e
@ -17,5 +17,5 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
'chromium_url': 'http://src.chromium.org/svn/trunk/src',
|
'chromium_url': 'http://src.chromium.org/svn/trunk/src',
|
||||||
'chromium_revision': '167921',
|
'chromium_revision': '170167',
|
||||||
}
|
}
|
||||||
|
@ -183,10 +183,10 @@ CefBrowserContext::CefBrowserContext()
|
|||||||
}
|
}
|
||||||
|
|
||||||
CefBrowserContext::~CefBrowserContext() {
|
CefBrowserContext::~CefBrowserContext() {
|
||||||
// Clear the download manager delegate here because otherwise we'll crash
|
// Delete the download manager delegate here because otherwise we'll crash
|
||||||
// when it's accessed from the content::BrowserContext destructor.
|
// when it's accessed from the content::BrowserContext destructor.
|
||||||
if (download_manager_delegate_.get())
|
if (download_manager_delegate_.get())
|
||||||
BrowserContext::GetDownloadManager(this)->SetDelegate(NULL);
|
download_manager_delegate_.reset(NULL);
|
||||||
|
|
||||||
if (resource_context_.get()) {
|
if (resource_context_.get()) {
|
||||||
BrowserThread::DeleteSoon(
|
BrowserThread::DeleteSoon(
|
||||||
@ -206,7 +206,8 @@ content::DownloadManagerDelegate*
|
|||||||
CefBrowserContext::GetDownloadManagerDelegate() {
|
CefBrowserContext::GetDownloadManagerDelegate() {
|
||||||
DCHECK(!download_manager_delegate_.get());
|
DCHECK(!download_manager_delegate_.get());
|
||||||
|
|
||||||
download_manager_delegate_ = new CefDownloadManagerDelegate();
|
content::DownloadManager* manager = BrowserContext::GetDownloadManager(this);
|
||||||
|
download_manager_delegate_.reset(new CefDownloadManagerDelegate(manager));
|
||||||
return download_manager_delegate_.get();
|
return download_manager_delegate_.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ class CefBrowserContext : public content::BrowserContext {
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
scoped_ptr<CefResourceContext> resource_context_;
|
scoped_ptr<CefResourceContext> resource_context_;
|
||||||
scoped_refptr<CefDownloadManagerDelegate> download_manager_delegate_;
|
scoped_ptr<CefDownloadManagerDelegate> download_manager_delegate_;
|
||||||
scoped_refptr<net::URLRequestContextGetter> url_request_getter_;
|
scoped_refptr<net::URLRequestContextGetter> url_request_getter_;
|
||||||
scoped_refptr<content::GeolocationPermissionContext>
|
scoped_refptr<content::GeolocationPermissionContext>
|
||||||
geolocation_permission_context_;
|
geolocation_permission_context_;
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include "base/string_util.h"
|
#include "base/string_util.h"
|
||||||
#include "content/public/common/url_fetcher.h"
|
#include "content/public/common/url_fetcher.h"
|
||||||
#include "net/base/load_flags.h"
|
#include "net/base/load_flags.h"
|
||||||
|
#include "net/http/http_request_headers.h"
|
||||||
#include "net/http/http_response_headers.h"
|
#include "net/http/http_response_headers.h"
|
||||||
#include "net/url_request/url_fetcher.h"
|
#include "net/url_request/url_fetcher.h"
|
||||||
#include "net/url_request/url_fetcher_delegate.h"
|
#include "net/url_request/url_fetcher_delegate.h"
|
||||||
|
@ -233,6 +233,10 @@ class CefMediaObserver : public content::MediaObserver {
|
|||||||
int render_process_id,
|
int render_process_id,
|
||||||
int render_view_id,
|
int render_view_id,
|
||||||
const content::MediaStreamDevices& devices) OVERRIDE {}
|
const content::MediaStreamDevices& devices) OVERRIDE {}
|
||||||
|
virtual void OnAudioCaptureDevicesChanged(
|
||||||
|
const content::MediaStreamDevices& devices) OVERRIDE {}
|
||||||
|
virtual void OnVideoCaptureDevicesChanged(
|
||||||
|
const content::MediaStreamDevices& devices) OVERRIDE {}
|
||||||
virtual void OnMediaRequestStateChanged(
|
virtual void OnMediaRequestStateChanged(
|
||||||
int render_process_id,
|
int render_process_id,
|
||||||
int render_view_id,
|
int render_view_id,
|
||||||
|
@ -15,8 +15,8 @@
|
|||||||
|
|
||||||
#include "base/atomic_sequence_num.h"
|
#include "base/atomic_sequence_num.h"
|
||||||
#include "base/file_path.h"
|
#include "base/file_path.h"
|
||||||
|
#include "base/files/scoped_temp_dir.h"
|
||||||
#include "base/memory/scoped_ptr.h"
|
#include "base/memory/scoped_ptr.h"
|
||||||
#include "base/scoped_temp_dir.h"
|
|
||||||
#include "base/threading/platform_thread.h"
|
#include "base/threading/platform_thread.h"
|
||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
@ -93,7 +93,7 @@ class CefContext : public CefBase {
|
|||||||
|
|
||||||
CefSettings settings_;
|
CefSettings settings_;
|
||||||
FilePath cache_path_;
|
FilePath cache_path_;
|
||||||
ScopedTempDir cache_temp_dir_;
|
base::ScopedTempDir cache_temp_dir_;
|
||||||
|
|
||||||
// Map of browsers that currently exist.
|
// Map of browsers that currently exist.
|
||||||
BrowserList browserlist_;
|
BrowserList browserlist_;
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
#include "base/string_util.h"
|
#include "base/string_util.h"
|
||||||
#include "base/utf_string_conversions.h"
|
#include "base/utf_string_conversions.h"
|
||||||
#include "content/public/browser/browser_context.h"
|
#include "content/public/browser/browser_context.h"
|
||||||
#include "content/public/browser/download_manager.h"
|
|
||||||
#include "content/public/browser/web_contents.h"
|
#include "content/public/browser/web_contents.h"
|
||||||
#include "content/public/common/file_chooser_params.h"
|
#include "content/public/common/file_chooser_params.h"
|
||||||
#include "net/base/net_util.h"
|
#include "net/base/net_util.h"
|
||||||
@ -48,20 +47,17 @@ CefRefPtr<CefDownloadHandler> GetDownloadHandler(
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper function to retrieve the DownloadManager.
|
|
||||||
scoped_refptr<content::DownloadManager> GetDownloadManager() {
|
|
||||||
return content::BrowserContext::GetDownloadManager(
|
|
||||||
_Context->browser_context());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// CefBeforeDownloadCallback implementation.
|
// CefBeforeDownloadCallback implementation.
|
||||||
class CefBeforeDownloadCallbackImpl : public CefBeforeDownloadCallback {
|
class CefBeforeDownloadCallbackImpl : public CefBeforeDownloadCallback {
|
||||||
public:
|
public:
|
||||||
CefBeforeDownloadCallbackImpl(int32 download_id,
|
CefBeforeDownloadCallbackImpl(
|
||||||
|
const base::WeakPtr<DownloadManager>& manager,
|
||||||
|
int32 download_id,
|
||||||
const FilePath& suggested_name,
|
const FilePath& suggested_name,
|
||||||
const content::DownloadTargetCallback& callback)
|
const content::DownloadTargetCallback& callback)
|
||||||
: download_id_(download_id),
|
: manager_(manager),
|
||||||
|
download_id_(download_id),
|
||||||
suggested_name_(suggested_name),
|
suggested_name_(suggested_name),
|
||||||
callback_(callback) {
|
callback_(callback) {
|
||||||
}
|
}
|
||||||
@ -72,13 +68,12 @@ class CefBeforeDownloadCallbackImpl : public CefBeforeDownloadCallback {
|
|||||||
if (download_id_ <= 0)
|
if (download_id_ <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
scoped_refptr<content::DownloadManager> manager = GetDownloadManager();
|
if (manager_) {
|
||||||
if (manager) {
|
|
||||||
FilePath path = FilePath(download_path);
|
FilePath path = FilePath(download_path);
|
||||||
CEF_POST_TASK(CEF_FILET,
|
CEF_POST_TASK(CEF_FILET,
|
||||||
base::Bind(&CefBeforeDownloadCallbackImpl::GenerateFilename,
|
base::Bind(&CefBeforeDownloadCallbackImpl::GenerateFilename,
|
||||||
download_id_, suggested_name_, path, show_dialog,
|
manager_, download_id_, suggested_name_, path,
|
||||||
callback_));
|
show_dialog, callback_));
|
||||||
}
|
}
|
||||||
|
|
||||||
download_id_ = 0;
|
download_id_ = 0;
|
||||||
@ -92,6 +87,7 @@ class CefBeforeDownloadCallbackImpl : public CefBeforeDownloadCallback {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
static void GenerateFilename(
|
static void GenerateFilename(
|
||||||
|
base::WeakPtr<DownloadManager> manager,
|
||||||
int32 download_id,
|
int32 download_id,
|
||||||
const FilePath& suggested_name,
|
const FilePath& suggested_name,
|
||||||
const FilePath& download_path,
|
const FilePath& download_path,
|
||||||
@ -120,15 +116,16 @@ class CefBeforeDownloadCallbackImpl : public CefBeforeDownloadCallback {
|
|||||||
|
|
||||||
CEF_POST_TASK(CEF_UIT,
|
CEF_POST_TASK(CEF_UIT,
|
||||||
base::Bind(&CefBeforeDownloadCallbackImpl::ChooseDownloadPath,
|
base::Bind(&CefBeforeDownloadCallbackImpl::ChooseDownloadPath,
|
||||||
download_id, suggested_path, show_dialog, callback));
|
manager, download_id, suggested_path, show_dialog,
|
||||||
|
callback));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ChooseDownloadPath(
|
static void ChooseDownloadPath(
|
||||||
|
base::WeakPtr<DownloadManager> manager,
|
||||||
int32 download_id,
|
int32 download_id,
|
||||||
const FilePath& suggested_path,
|
const FilePath& suggested_path,
|
||||||
bool show_dialog,
|
bool show_dialog,
|
||||||
const content::DownloadTargetCallback& callback) {
|
const content::DownloadTargetCallback& callback) {
|
||||||
scoped_refptr<content::DownloadManager> manager = GetDownloadManager();
|
|
||||||
if (!manager)
|
if (!manager)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -186,6 +183,7 @@ class CefBeforeDownloadCallbackImpl : public CefBeforeDownloadCallback {
|
|||||||
path);
|
path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
base::WeakPtr<DownloadManager> manager_;
|
||||||
int32 download_id_;
|
int32 download_id_;
|
||||||
FilePath suggested_name_;
|
FilePath suggested_name_;
|
||||||
content::DownloadTargetCallback callback_;
|
content::DownloadTargetCallback callback_;
|
||||||
@ -198,8 +196,11 @@ class CefBeforeDownloadCallbackImpl : public CefBeforeDownloadCallback {
|
|||||||
// CefDownloadItemCallback implementation.
|
// CefDownloadItemCallback implementation.
|
||||||
class CefDownloadItemCallbackImpl : public CefDownloadItemCallback {
|
class CefDownloadItemCallbackImpl : public CefDownloadItemCallback {
|
||||||
public:
|
public:
|
||||||
explicit CefDownloadItemCallbackImpl(int32 download_id)
|
explicit CefDownloadItemCallbackImpl(
|
||||||
: download_id_(download_id) {
|
const base::WeakPtr<DownloadManager>& manager,
|
||||||
|
int32 download_id)
|
||||||
|
: manager_(manager),
|
||||||
|
download_id_(download_id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void Cancel() OVERRIDE {
|
virtual void Cancel() OVERRIDE {
|
||||||
@ -212,9 +213,8 @@ class CefDownloadItemCallbackImpl : public CefDownloadItemCallback {
|
|||||||
if (download_id_ <= 0)
|
if (download_id_ <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
scoped_refptr<content::DownloadManager> manager = GetDownloadManager();
|
if (manager_) {
|
||||||
if (manager) {
|
DownloadItem* item = manager_->GetDownload(download_id_);
|
||||||
DownloadItem* item = manager->GetDownload(download_id_);
|
|
||||||
if (item && item->IsInProgress())
|
if (item && item->IsInProgress())
|
||||||
item->Cancel(true);
|
item->Cancel(true);
|
||||||
}
|
}
|
||||||
@ -222,6 +222,7 @@ class CefDownloadItemCallbackImpl : public CefDownloadItemCallback {
|
|||||||
download_id_ = 0;
|
download_id_ = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
base::WeakPtr<DownloadManager> manager_;
|
||||||
int32 download_id_;
|
int32 download_id_;
|
||||||
|
|
||||||
IMPLEMENT_REFCOUNTING(CefDownloadItemCallbackImpl);
|
IMPLEMENT_REFCOUNTING(CefDownloadItemCallbackImpl);
|
||||||
@ -231,20 +232,78 @@ class CefDownloadItemCallbackImpl : public CefDownloadItemCallback {
|
|||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|
||||||
CefDownloadManagerDelegate::CefDownloadManagerDelegate() {
|
CefDownloadManagerDelegate::CefDownloadManagerDelegate(
|
||||||
// Balanced in Shutdown();
|
DownloadManager* manager)
|
||||||
AddRef();
|
: manager_(manager),
|
||||||
|
manager_ptr_factory_(manager) {
|
||||||
|
DCHECK(manager);
|
||||||
|
manager->AddObserver(this);
|
||||||
|
|
||||||
|
DownloadManager::DownloadVector items;
|
||||||
|
manager->GetAllDownloads(&items);
|
||||||
|
DownloadManager::DownloadVector::const_iterator it = items.begin();
|
||||||
|
for (; it != items.end(); ++it) {
|
||||||
|
(*it)->AddObserver(this);
|
||||||
|
observing_.insert(*it);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CefDownloadManagerDelegate::~CefDownloadManagerDelegate() {
|
CefDownloadManagerDelegate::~CefDownloadManagerDelegate() {
|
||||||
|
if (manager_) {
|
||||||
|
manager_->SetDelegate(NULL);
|
||||||
|
manager_->RemoveObserver(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::set<DownloadItem*>::const_iterator it = observing_.begin();
|
||||||
|
for (; it != observing_.end(); ++it)
|
||||||
|
(*it)->RemoveObserver(this);
|
||||||
|
observing_.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefDownloadManagerDelegate::Shutdown() {
|
void CefDownloadManagerDelegate::OnDownloadUpdated(
|
||||||
Release();
|
DownloadItem* download) {
|
||||||
|
CefRefPtr<CefBrowserHostImpl> browser = GetBrowser(download);
|
||||||
|
CefRefPtr<CefDownloadHandler> handler;
|
||||||
|
if (browser.get())
|
||||||
|
handler = GetDownloadHandler(browser);
|
||||||
|
|
||||||
|
if (handler.get()) {
|
||||||
|
CefRefPtr<CefDownloadItemImpl> download_item(
|
||||||
|
new CefDownloadItemImpl(download));
|
||||||
|
CefRefPtr<CefDownloadItemCallback> callback(
|
||||||
|
new CefDownloadItemCallbackImpl(manager_ptr_factory_.GetWeakPtr(),
|
||||||
|
download->GetId()));
|
||||||
|
|
||||||
|
handler->OnDownloadUpdated(browser.get(), download_item.get(), callback);
|
||||||
|
|
||||||
|
download_item->Detach(NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefDownloadManagerDelegate::OnDownloadDestroyed(
|
||||||
|
DownloadItem* download) {
|
||||||
|
download->RemoveObserver(this);
|
||||||
|
observing_.erase(download);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefDownloadManagerDelegate::OnDownloadCreated(
|
||||||
|
DownloadManager* manager,
|
||||||
|
DownloadItem* item) {
|
||||||
|
item->AddObserver(this);
|
||||||
|
observing_.insert(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefDownloadManagerDelegate::ManagerGoingDown(
|
||||||
|
DownloadManager* manager) {
|
||||||
|
DCHECK_EQ(manager, manager_);
|
||||||
|
manager->SetDelegate(NULL);
|
||||||
|
manager->RemoveObserver(this);
|
||||||
|
manager_ptr_factory_.InvalidateWeakPtrs();
|
||||||
|
manager_ = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CefDownloadManagerDelegate::DetermineDownloadTarget(
|
bool CefDownloadManagerDelegate::DetermineDownloadTarget(
|
||||||
content::DownloadItem* item,
|
DownloadItem* item,
|
||||||
const content::DownloadTargetCallback& callback) {
|
const content::DownloadTargetCallback& callback) {
|
||||||
if (!item->GetForcedFilePath().empty()) {
|
if (!item->GetForcedFilePath().empty()) {
|
||||||
callback.Run(item->GetForcedFilePath(),
|
callback.Run(item->GetForcedFilePath(),
|
||||||
@ -270,7 +329,8 @@ bool CefDownloadManagerDelegate::DetermineDownloadTarget(
|
|||||||
|
|
||||||
CefRefPtr<CefDownloadItemImpl> download_item(new CefDownloadItemImpl(item));
|
CefRefPtr<CefDownloadItemImpl> download_item(new CefDownloadItemImpl(item));
|
||||||
CefRefPtr<CefBeforeDownloadCallback> callbackObj(
|
CefRefPtr<CefBeforeDownloadCallback> callbackObj(
|
||||||
new CefBeforeDownloadCallbackImpl(item->GetId(), suggested_name,
|
new CefBeforeDownloadCallbackImpl(manager_ptr_factory_.GetWeakPtr(),
|
||||||
|
item->GetId(), suggested_name,
|
||||||
callback));
|
callback));
|
||||||
|
|
||||||
handler->OnBeforeDownload(browser.get(), download_item.get(),
|
handler->OnBeforeDownload(browser.get(), download_item.get(),
|
||||||
@ -281,28 +341,3 @@ bool CefDownloadManagerDelegate::DetermineDownloadTarget(
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefDownloadManagerDelegate::AddItemToPersistentStore(
|
|
||||||
DownloadItem* item) {
|
|
||||||
static int next_id;
|
|
||||||
scoped_refptr<content::DownloadManager> manager = GetDownloadManager();
|
|
||||||
manager->OnItemAddedToPersistentStore(item->GetId(), ++next_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CefDownloadManagerDelegate::UpdateItemInPersistentStore(
|
|
||||||
DownloadItem* item) {
|
|
||||||
CefRefPtr<CefBrowserHostImpl> browser = GetBrowser(item);
|
|
||||||
CefRefPtr<CefDownloadHandler> handler;
|
|
||||||
if (browser.get())
|
|
||||||
handler = GetDownloadHandler(browser);
|
|
||||||
|
|
||||||
if (handler.get()) {
|
|
||||||
CefRefPtr<CefDownloadItemImpl> download_item(new CefDownloadItemImpl(item));
|
|
||||||
CefRefPtr<CefDownloadItemCallback> callback(
|
|
||||||
new CefDownloadItemCallbackImpl(item->GetId()));
|
|
||||||
|
|
||||||
handler->OnDownloadUpdated(browser.get(), download_item.get(), callback);
|
|
||||||
|
|
||||||
download_item->Detach(NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -6,35 +6,40 @@
|
|||||||
#define CEF_LIBCEF_BROWSER_DOWNLOAD_MANAGER_DELEGATE_H_
|
#define CEF_LIBCEF_BROWSER_DOWNLOAD_MANAGER_DELEGATE_H_
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <set>
|
||||||
|
|
||||||
#include "base/compiler_specific.h"
|
#include "base/compiler_specific.h"
|
||||||
#include "base/memory/ref_counted.h"
|
#include "base/memory/weak_ptr.h"
|
||||||
|
#include "content/public/browser/download_item.h"
|
||||||
|
#include "content/public/browser/download_manager.h"
|
||||||
#include "content/public/browser/download_manager_delegate.h"
|
#include "content/public/browser/download_manager_delegate.h"
|
||||||
|
|
||||||
struct DownloadStateInfo;
|
|
||||||
|
|
||||||
namespace content {
|
|
||||||
class DownloadManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
class CefDownloadManagerDelegate
|
class CefDownloadManagerDelegate
|
||||||
: public content::DownloadManagerDelegate,
|
: public content::DownloadItem::Observer,
|
||||||
public base::RefCountedThreadSafe<CefDownloadManagerDelegate> {
|
public content::DownloadManager::Observer,
|
||||||
|
public content::DownloadManagerDelegate {
|
||||||
public:
|
public:
|
||||||
CefDownloadManagerDelegate();
|
explicit CefDownloadManagerDelegate(content::DownloadManager* manager);
|
||||||
|
~CefDownloadManagerDelegate();
|
||||||
|
|
||||||
|
private:
|
||||||
|
// DownloadItem::Observer methods.
|
||||||
|
virtual void OnDownloadUpdated(content::DownloadItem* download) OVERRIDE;
|
||||||
|
virtual void OnDownloadDestroyed(content::DownloadItem* download) OVERRIDE;
|
||||||
|
|
||||||
|
// DownloadManager::Observer methods.
|
||||||
|
virtual void OnDownloadCreated(content::DownloadManager* manager,
|
||||||
|
content::DownloadItem* item) OVERRIDE;
|
||||||
|
virtual void ManagerGoingDown(content::DownloadManager* manager) OVERRIDE;
|
||||||
|
|
||||||
// DownloadManagerDelegate methods.
|
// DownloadManagerDelegate methods.
|
||||||
virtual void Shutdown() OVERRIDE;
|
|
||||||
virtual bool DetermineDownloadTarget(
|
virtual bool DetermineDownloadTarget(
|
||||||
content::DownloadItem* item,
|
content::DownloadItem* item,
|
||||||
const content::DownloadTargetCallback& callback) OVERRIDE;
|
const content::DownloadTargetCallback& callback) OVERRIDE;
|
||||||
virtual void AddItemToPersistentStore(content::DownloadItem* item) OVERRIDE;
|
|
||||||
virtual void UpdateItemInPersistentStore(
|
|
||||||
content::DownloadItem* item) OVERRIDE;
|
|
||||||
|
|
||||||
private:
|
content::DownloadManager* manager_;
|
||||||
friend class base::RefCountedThreadSafe<CefDownloadManagerDelegate>;
|
base::WeakPtrFactory<content::DownloadManager> manager_ptr_factory_;
|
||||||
|
std::set<content::DownloadItem*> observing_;
|
||||||
virtual ~CefDownloadManagerDelegate();
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(CefDownloadManagerDelegate);
|
DISALLOW_COPY_AND_ASSIGN(CefDownloadManagerDelegate);
|
||||||
};
|
};
|
||||||
|
@ -151,6 +151,10 @@ class CefSimpleMenuModel : public ui::MenuModel {
|
|||||||
menu_model_delegate_ = menu_model_delegate;
|
menu_model_delegate_ = menu_model_delegate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual ui::MenuModelDelegate* GetMenuModelDelegate() const OVERRIDE {
|
||||||
|
return menu_model_delegate_;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CefMenuModelImpl* impl_;
|
CefMenuModelImpl* impl_;
|
||||||
ui::MenuModelDelegate* menu_model_delegate_;
|
ui::MenuModelDelegate* menu_model_delegate_;
|
||||||
|
@ -73,9 +73,11 @@ net::URLRequestJob* CefRequestInterceptor::MaybeInterceptRedirect(
|
|||||||
newUrlStr);
|
newUrlStr);
|
||||||
if (newUrlStr != location.spec()) {
|
if (newUrlStr != location.spec()) {
|
||||||
GURL new_url = GURL(std::string(newUrlStr));
|
GURL new_url = GURL(std::string(newUrlStr));
|
||||||
if (!new_url.is_empty() && new_url.is_valid())
|
if (!new_url.is_empty() && new_url.is_valid()) {
|
||||||
return new net::URLRequestRedirectJob(request, network_delegate,
|
return new net::URLRequestRedirectJob(
|
||||||
new_url);
|
request, network_delegate, new_url,
|
||||||
|
net::URLRequestRedirectJob::REDIRECT_302_FOUND);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,10 @@ content::RenderWidgetHostView* CefWebContentsViewOSR::CreateViewForWidget(
|
|||||||
return view_;
|
return view_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CefWebContentsViewOSR::SetView(content::RenderWidgetHostView* view) {
|
||||||
|
view_ = view;
|
||||||
|
}
|
||||||
|
|
||||||
gfx::NativeView CefWebContentsViewOSR::GetNativeView() const {
|
gfx::NativeView CefWebContentsViewOSR::GetNativeView() const {
|
||||||
return gfx::NativeView();
|
return gfx::NativeView();
|
||||||
}
|
}
|
||||||
|
@ -12,12 +12,11 @@
|
|||||||
#include "content/public/browser/web_contents_view.h"
|
#include "content/public/browser/web_contents_view.h"
|
||||||
|
|
||||||
namespace content {
|
namespace content {
|
||||||
class WebContents;
|
class WebContents;
|
||||||
class WebContentsViewDelegate;
|
class WebContentsViewDelegate;
|
||||||
}
|
}
|
||||||
|
|
||||||
class CefBrowserHostImpl;
|
class CefBrowserHostImpl;
|
||||||
class CefRenderWidgetHostViewOSR;
|
|
||||||
|
|
||||||
// An implementation of WebContentsView for off-screen rendering.
|
// An implementation of WebContentsView for off-screen rendering.
|
||||||
class CefWebContentsViewOSR : public content::WebContentsView,
|
class CefWebContentsViewOSR : public content::WebContentsView,
|
||||||
@ -31,6 +30,7 @@ class CefWebContentsViewOSR : public content::WebContentsView,
|
|||||||
virtual void CreateView(const gfx::Size& initial_size) OVERRIDE;
|
virtual void CreateView(const gfx::Size& initial_size) OVERRIDE;
|
||||||
virtual content::RenderWidgetHostView* CreateViewForWidget(
|
virtual content::RenderWidgetHostView* CreateViewForWidget(
|
||||||
content::RenderWidgetHost* render_widget_host) OVERRIDE;
|
content::RenderWidgetHost* render_widget_host) OVERRIDE;
|
||||||
|
virtual void SetView(content::RenderWidgetHostView* view) OVERRIDE;
|
||||||
virtual gfx::NativeView GetNativeView() const OVERRIDE;
|
virtual gfx::NativeView GetNativeView() const OVERRIDE;
|
||||||
virtual gfx::NativeView GetContentNativeView() const OVERRIDE;
|
virtual gfx::NativeView GetContentNativeView() const OVERRIDE;
|
||||||
virtual gfx::NativeWindow GetTopLevelNativeWindow() const OVERRIDE;
|
virtual gfx::NativeWindow GetTopLevelNativeWindow() const OVERRIDE;
|
||||||
@ -65,7 +65,7 @@ class CefWebContentsViewOSR : public content::WebContentsView,
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
content::WebContents* web_contents_;
|
content::WebContents* web_contents_;
|
||||||
CefRenderWidgetHostViewOSR* view_;
|
content::RenderWidgetHostView* view_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(CefWebContentsViewOSR);
|
DISALLOW_COPY_AND_ASSIGN(CefWebContentsViewOSR);
|
||||||
};
|
};
|
||||||
|
@ -9,6 +9,12 @@
|
|||||||
#include "libcef/common/request_impl.h"
|
#include "libcef/common/request_impl.h"
|
||||||
|
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
|
#include "net/base/upload_data.h"
|
||||||
|
#include "net/base/upload_data_stream.h"
|
||||||
|
#include "net/base/upload_element_reader.h"
|
||||||
|
#include "net/base/upload_bytes_element_reader.h"
|
||||||
|
#include "net/base/upload_file_element_reader.h"
|
||||||
|
#include "net/http/http_request_headers.h"
|
||||||
#include "net/url_request/url_request.h"
|
#include "net/url_request/url_request.h"
|
||||||
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebHTTPHeaderVisitor.h"
|
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebHTTPHeaderVisitor.h"
|
||||||
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
|
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
|
||||||
@ -155,7 +161,7 @@ void CefRequestImpl::Set(net::URLRequest* request) {
|
|||||||
GetHeaderMap(headers, headermap_);
|
GetHeaderMap(headers, headermap_);
|
||||||
|
|
||||||
// Transfer post data, if any
|
// Transfer post data, if any
|
||||||
const net::UploadData* data = request->get_upload();
|
const net::UploadDataStream* data = request->get_upload();
|
||||||
if (data) {
|
if (data) {
|
||||||
postdata_ = CefPostData::Create();
|
postdata_ = CefPostData::Create();
|
||||||
static_cast<CefPostDataImpl*>(postdata_.get())->Set(*data);
|
static_cast<CefPostDataImpl*>(postdata_.get())->Set(*data);
|
||||||
@ -416,6 +422,22 @@ void CefPostDataImpl::Set(const net::UploadData& data) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CefPostDataImpl::Set(const net::UploadDataStream& data_stream) {
|
||||||
|
AutoLock lock_scope(this);
|
||||||
|
CHECK_READONLY_RETURN_VOID();
|
||||||
|
|
||||||
|
CefRefPtr<CefPostDataElement> postelem;
|
||||||
|
|
||||||
|
const ScopedVector<net::UploadElementReader>& elements =
|
||||||
|
data_stream.element_readers();
|
||||||
|
ScopedVector<net::UploadElementReader>::const_iterator it = elements.begin();
|
||||||
|
for (; it != elements.end(); ++it) {
|
||||||
|
postelem = CefPostDataElement::Create();
|
||||||
|
static_cast<CefPostDataElementImpl*>(postelem.get())->Set(**it);
|
||||||
|
AddElement(postelem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CefPostDataImpl::Get(net::UploadData& data) {
|
void CefPostDataImpl::Get(net::UploadData& data) {
|
||||||
AutoLock lock_scope(this);
|
AutoLock lock_scope(this);
|
||||||
|
|
||||||
@ -587,6 +609,28 @@ void CefPostDataElementImpl::Set(const net::UploadElement& element) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CefPostDataElementImpl::Set(
|
||||||
|
const net::UploadElementReader& element_reader) {
|
||||||
|
AutoLock lock_scope(this);
|
||||||
|
CHECK_READONLY_RETURN_VOID();
|
||||||
|
|
||||||
|
const net::UploadBytesElementReader* bytes_reader =
|
||||||
|
element_reader.AsBytesReader();
|
||||||
|
if (bytes_reader) {
|
||||||
|
SetToBytes(bytes_reader->length(), bytes_reader->bytes());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const net::UploadFileElementReader* file_reader =
|
||||||
|
element_reader.AsFileReader();
|
||||||
|
if (file_reader) {
|
||||||
|
SetToFile(file_reader->path().value());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
NOTREACHED();
|
||||||
|
}
|
||||||
|
|
||||||
void CefPostDataElementImpl::Get(net::UploadElement& element) {
|
void CefPostDataElementImpl::Get(net::UploadElement& element) {
|
||||||
AutoLock lock_scope(this);
|
AutoLock lock_scope(this);
|
||||||
|
|
||||||
|
@ -7,11 +7,14 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "include/cef_request.h"
|
#include "include/cef_request.h"
|
||||||
#include "net/base/upload_data.h"
|
|
||||||
#include "net/http/http_request_headers.h"
|
|
||||||
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebHTTPBody.h"
|
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebHTTPBody.h"
|
||||||
|
|
||||||
namespace net {
|
namespace net {
|
||||||
|
class HttpRequestHeaders;
|
||||||
|
class UploadData;
|
||||||
|
class UploadDataStream;
|
||||||
|
class UploadElement;
|
||||||
|
class UploadElementReader;
|
||||||
class URLRequest;
|
class URLRequest;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -95,6 +98,7 @@ class CefPostDataImpl : public CefPostData {
|
|||||||
virtual void RemoveElements();
|
virtual void RemoveElements();
|
||||||
|
|
||||||
void Set(const net::UploadData& data);
|
void Set(const net::UploadData& data);
|
||||||
|
void Set(const net::UploadDataStream& data_stream);
|
||||||
void Get(net::UploadData& data);
|
void Get(net::UploadData& data);
|
||||||
void Set(const WebKit::WebHTTPBody& data);
|
void Set(const WebKit::WebHTTPBody& data);
|
||||||
void Get(WebKit::WebHTTPBody& data);
|
void Get(WebKit::WebHTTPBody& data);
|
||||||
@ -129,6 +133,7 @@ class CefPostDataElementImpl : public CefPostDataElement {
|
|||||||
void* GetBytes() { return data_.bytes.bytes; }
|
void* GetBytes() { return data_.bytes.bytes; }
|
||||||
|
|
||||||
void Set(const net::UploadElement& element);
|
void Set(const net::UploadElement& element);
|
||||||
|
void Set(const net::UploadElementReader& element_reader);
|
||||||
void Get(net::UploadElement& element);
|
void Get(net::UploadElement& element);
|
||||||
void Set(const WebKit::WebHTTPBody::Element& element);
|
void Set(const WebKit::WebHTTPBody::Element& element);
|
||||||
void Get(WebKit::WebHTTPBody::Element& element);
|
void Get(WebKit::WebHTTPBody::Element& element);
|
||||||
|
@ -88,8 +88,10 @@ class CefV8TrackManager {
|
|||||||
|
|
||||||
v8::Handle<v8::Object> object = context->Global();
|
v8::Handle<v8::Object> object = context->Global();
|
||||||
v8::Handle<v8::Value> value = object->GetHiddenValue(context_state_key_);
|
v8::Handle<v8::Value> value = object->GetHiddenValue(context_state_key_);
|
||||||
if (!value.IsEmpty())
|
if (!value.IsEmpty()) {
|
||||||
return static_cast<CefV8ContextState*>(v8::External::Unwrap(value));
|
return static_cast<CefV8ContextState*>(
|
||||||
|
v8::External::Cast(*value)->Value());
|
||||||
|
}
|
||||||
|
|
||||||
scoped_refptr<CefV8ContextState> state = new CefV8ContextState();
|
scoped_refptr<CefV8ContextState> state = new CefV8ContextState();
|
||||||
object->SetHiddenValue(context_state_key_,
|
object->SetHiddenValue(context_state_key_,
|
||||||
@ -123,7 +125,7 @@ class CefV8TrackManager {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
scoped_refptr<CefV8ContextState> state =
|
scoped_refptr<CefV8ContextState> state =
|
||||||
static_cast<CefV8ContextState*>(v8::External::Unwrap(value));
|
static_cast<CefV8ContextState*>(v8::External::Cast(*value)->Value());
|
||||||
state->Detach();
|
state->Detach();
|
||||||
object->DeleteHiddenValue(context_state_key_);
|
object->DeleteHiddenValue(context_state_key_);
|
||||||
|
|
||||||
@ -220,7 +222,7 @@ class V8TrackObject : public CefTrackNode {
|
|||||||
// Attach this track object to the specified V8 object.
|
// Attach this track object to the specified V8 object.
|
||||||
void AttachTo(v8::Handle<v8::Object> object) {
|
void AttachTo(v8::Handle<v8::Object> object) {
|
||||||
object->SetHiddenValue(v8::String::New(kCefTrackObject),
|
object->SetHiddenValue(v8::String::New(kCefTrackObject),
|
||||||
v8::External::Wrap(this));
|
v8::External::New(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve the track object for the specified V8 object.
|
// Retrieve the track object for the specified V8 object.
|
||||||
@ -228,7 +230,7 @@ class V8TrackObject : public CefTrackNode {
|
|||||||
v8::Local<v8::Value> value =
|
v8::Local<v8::Value> value =
|
||||||
object->GetHiddenValue(v8::String::New(kCefTrackObject));
|
object->GetHiddenValue(v8::String::New(kCefTrackObject));
|
||||||
if (!value.IsEmpty())
|
if (!value.IsEmpty())
|
||||||
return static_cast<V8TrackObject*>(v8::External::Unwrap(value));
|
return static_cast<V8TrackObject*>(v8::External::Cast(*value)->Value());
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -383,7 +385,7 @@ v8::Handle<v8::Value> FunctionCallbackImpl(const v8::Arguments& args) {
|
|||||||
WebCore::toScriptExecutionContext(v8::Context::GetCurrent()));
|
WebCore::toScriptExecutionContext(v8::Context::GetCurrent()));
|
||||||
|
|
||||||
CefV8Handler* handler =
|
CefV8Handler* handler =
|
||||||
static_cast<CefV8Handler*>(v8::External::Unwrap(args.Data()));
|
static_cast<CefV8Handler*>(v8::External::Cast(*args.Data())->Value());
|
||||||
|
|
||||||
CefV8ValueList params;
|
CefV8ValueList params;
|
||||||
for (int i = 0; i < args.Length(); i++)
|
for (int i = 0; i < args.Length(); i++)
|
||||||
@ -494,7 +496,7 @@ class ExtensionWrapper : public v8::Extension {
|
|||||||
return v8::Handle<v8::FunctionTemplate>();
|
return v8::Handle<v8::FunctionTemplate>();
|
||||||
|
|
||||||
return v8::FunctionTemplate::New(FunctionCallbackImpl,
|
return v8::FunctionTemplate::New(FunctionCallbackImpl,
|
||||||
v8::External::Wrap(handler_));
|
v8::External::New(handler_));
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -952,7 +954,7 @@ CefRefPtr<CefV8Value> CefV8Value::CreateFunction(
|
|||||||
// Create a new V8 function template.
|
// Create a new V8 function template.
|
||||||
v8::Local<v8::FunctionTemplate> tmpl = v8::FunctionTemplate::New();
|
v8::Local<v8::FunctionTemplate> tmpl = v8::FunctionTemplate::New();
|
||||||
|
|
||||||
v8::Local<v8::Value> data = v8::External::Wrap(handler.get());
|
v8::Local<v8::Value> data = v8::External::New(handler.get());
|
||||||
|
|
||||||
// Set the function handler callback.
|
// Set the function handler callback.
|
||||||
tmpl->SetCallHandler(FunctionCallbackImpl, data);
|
tmpl->SetCallHandler(FunctionCallbackImpl, data);
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#include "include/cef_scheme.h"
|
#include "include/cef_scheme.h"
|
||||||
#include "tests/unittests/test_handler.h"
|
#include "tests/unittests/test_handler.h"
|
||||||
#include "tests/unittests/test_suite.h"
|
#include "tests/unittests/test_suite.h"
|
||||||
#include "base/scoped_temp_dir.h"
|
#include "base/files/scoped_temp_dir.h"
|
||||||
#include "base/synchronization/waitable_event.h"
|
#include "base/synchronization/waitable_event.h"
|
||||||
#include "testing/gtest/include/gtest/gtest.h"
|
#include "testing/gtest/include/gtest/gtest.h"
|
||||||
|
|
||||||
@ -379,7 +379,7 @@ void TestChangeDirectory(CefRefPtr<CefCookieManager> manager,
|
|||||||
base::WaitableEvent event(false, false);
|
base::WaitableEvent event(false, false);
|
||||||
CefCookie cookie;
|
CefCookie cookie;
|
||||||
|
|
||||||
ScopedTempDir temp_dir;
|
base::ScopedTempDir temp_dir;
|
||||||
|
|
||||||
// Create a new temporary directory.
|
// Create a new temporary directory.
|
||||||
EXPECT_TRUE(temp_dir.CreateUniqueTempDir());
|
EXPECT_TRUE(temp_dir.CreateUniqueTempDir());
|
||||||
@ -448,7 +448,7 @@ TEST(CookieTest, DomainCookieInMemory) {
|
|||||||
|
|
||||||
// Test creation of a domain cookie.
|
// Test creation of a domain cookie.
|
||||||
TEST(CookieTest, DomainCookieOnDisk) {
|
TEST(CookieTest, DomainCookieOnDisk) {
|
||||||
ScopedTempDir temp_dir;
|
base::ScopedTempDir temp_dir;
|
||||||
|
|
||||||
// Create a new temporary directory.
|
// Create a new temporary directory.
|
||||||
EXPECT_TRUE(temp_dir.CreateUniqueTempDir());
|
EXPECT_TRUE(temp_dir.CreateUniqueTempDir());
|
||||||
@ -479,7 +479,7 @@ TEST(CookieTest, HostCookieInMemory) {
|
|||||||
|
|
||||||
// Test creation of a host cookie.
|
// Test creation of a host cookie.
|
||||||
TEST(CookieTest, HostCookieOnDisk) {
|
TEST(CookieTest, HostCookieOnDisk) {
|
||||||
ScopedTempDir temp_dir;
|
base::ScopedTempDir temp_dir;
|
||||||
|
|
||||||
// Create a new temporary directory.
|
// Create a new temporary directory.
|
||||||
EXPECT_TRUE(temp_dir.CreateUniqueTempDir());
|
EXPECT_TRUE(temp_dir.CreateUniqueTempDir());
|
||||||
@ -510,7 +510,7 @@ TEST(CookieTest, MultipleCookiesInMemory) {
|
|||||||
|
|
||||||
// Test creation of multiple cookies.
|
// Test creation of multiple cookies.
|
||||||
TEST(CookieTest, MultipleCookiesOnDisk) {
|
TEST(CookieTest, MultipleCookiesOnDisk) {
|
||||||
ScopedTempDir temp_dir;
|
base::ScopedTempDir temp_dir;
|
||||||
|
|
||||||
// Create a new temporary directory.
|
// Create a new temporary directory.
|
||||||
EXPECT_TRUE(temp_dir.CreateUniqueTempDir());
|
EXPECT_TRUE(temp_dir.CreateUniqueTempDir());
|
||||||
@ -538,7 +538,7 @@ TEST(CookieTest, AllCookiesInMemory) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(CookieTest, AllCookiesOnDisk) {
|
TEST(CookieTest, AllCookiesOnDisk) {
|
||||||
ScopedTempDir temp_dir;
|
base::ScopedTempDir temp_dir;
|
||||||
|
|
||||||
// Create a new temporary directory.
|
// Create a new temporary directory.
|
||||||
EXPECT_TRUE(temp_dir.CreateUniqueTempDir());
|
EXPECT_TRUE(temp_dir.CreateUniqueTempDir());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user