Update to Chromium revision 318e6f54 (#400326)

This commit is contained in:
Marshall Greenblatt
2016-06-20 18:59:23 -04:00
parent 66425def4a
commit 05ee60b7b4
78 changed files with 679 additions and 442 deletions

View File

@@ -29,9 +29,9 @@
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/guest_view/browser/guest_view_manager.h"
#include "components/prefs/pref_service.h"
#include "components/ui/zoom/zoom_event_manager.h"
#include "components/visitedlink/browser/visitedlink_event_listener.h"
#include "components/visitedlink/browser/visitedlink_master.h"
#include "components/zoom/zoom_event_manager.h"
#include "content/public/browser/download_manager.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/storage_partition.h"
@@ -343,7 +343,7 @@ std::unique_ptr<content::ZoomLevelDelegate>
return base::WrapUnique(new ChromeZoomLevelPrefs(
GetPrefs(), cache_path_, partition_path,
ui_zoom::ZoomEventManager::GetForBrowserContext(this)->GetWeakPtr()));
zoom::ZoomEventManager::GetForBrowserContext(this)->GetWeakPtr()));
}
bool CefBrowserContextImpl::IsOffTheRecord() const {

View File

@@ -695,7 +695,8 @@ void CefBrowserHostImpl::StartDownload(const CefString& url) {
return;
std::unique_ptr<content::DownloadUrlParameters> params(
content::DownloadUrlParameters::FromWebContents(web_contents(), gurl));
content::DownloadUrlParameters::CreateForWebContentsMainFrame(
web_contents(), gurl));
manager->DownloadUrl(std::move(params));
}
@@ -2243,10 +2244,10 @@ content::JavaScriptDialogManager*
}
void CefBrowserHostImpl::RunFileChooser(
content::WebContents* web_contents,
content::RenderFrameHost* render_frame_host,
const content::FileChooserParams& params) {
EnsureFileDialogManager();
file_dialog_manager_->RunFileChooser(web_contents, params);
file_dialog_manager_->RunFileChooser(render_frame_host, params);
}
bool CefBrowserHostImpl::HandleContextMenu(

View File

@@ -404,7 +404,7 @@ class CefBrowserHostImpl : public CefBrowserHost,
content::JavaScriptDialogManager* GetJavaScriptDialogManager(
content::WebContents* source) override;
void RunFileChooser(
content::WebContents* web_contents,
content::RenderFrameHost* render_frame_host,
const content::FileChooserParams& params) override;
bool EmbedsFullscreenWidget() const override;
void EnterFullscreenModeForTab(content::WebContents* web_contents,

View File

@@ -69,7 +69,6 @@ void CefBrowserMainParts::PreMainMessageLoopStart() {
if (!base::MessageLoop::current()) {
// Create the browser message loop.
message_loop_.reset(new CefBrowserMessageLoop());
message_loop_->set_thread_name("CrBrowserMain");
}
}

View File

@@ -28,6 +28,7 @@
#include "chrome/browser/component_updater/widevine_cdm_component_installer.h"
#include "chrome/browser/printing/print_job_manager.h"
#include "components/component_updater/component_updater_service.h"
#include "components/network_session_configurator/switches.h"
#include "components/update_client/configurator.h"
#include "content/public/app/content_main.h"
#include "content/public/app/content_main_runner.h"
@@ -326,7 +327,9 @@ void CefContext::Shutdown() {
if (settings_.multi_threaded_message_loop) {
// Events that will be used to signal when shutdown is complete. Start in
// non-signaled mode so that the event will block.
base::WaitableEvent uithread_shutdown_event(false, false);
base::WaitableEvent uithread_shutdown_event(
base::WaitableEvent::ResetPolicy::AUTOMATIC,
base::WaitableEvent::InitialState::NOT_SIGNALED);
// Finish shutdown on the UI thread.
CEF_POST_TASK(CEF_UIT,

View File

@@ -12,6 +12,7 @@
#include "base/command_line.h"
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
#include "base/json/string_escape.h"
#include "base/memory/ptr_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
@@ -158,7 +159,7 @@ void CefDevToolsFrontend::Close() {
void CefDevToolsFrontend::DisconnectFromTarget() {
if (!agent_host_)
return;
agent_host_->DetachClient();
agent_host_->DetachClient(this);
agent_host_ = NULL;
}
@@ -206,7 +207,7 @@ void CefDevToolsFrontend::DocumentAvailableInMainFrame() {
void CefDevToolsFrontend::WebContentsDestroyed() {
if (agent_host_)
agent_host_->DetachClient();
agent_host_->DetachClient(this);
delete this;
}
@@ -228,11 +229,12 @@ void CefDevToolsFrontend::HandleMessageFromDevToolsFrontend(
dict->GetList("params", &params);
if (method == "dispatchProtocolMessage" && params && params->GetSize() == 1) {
if (!agent_host_ || !agent_host_->IsAttached())
return;
std::string protocol_message;
if (!params->GetString(0, &protocol_message))
return;
if (agent_host_)
agent_host_->DispatchProtocolMessage(protocol_message);
agent_host_->DispatchProtocolMessage(this, protocol_message);
} else if (method == "loadCompleted") {
web_contents()->GetMainFrame()->ExecuteJavaScriptForTests(
base::ASCIIToUTF16("DevToolsAPI.setUseSoftMenu(true);"));
@@ -298,18 +300,21 @@ void CefDevToolsFrontend::DispatchProtocolMessage(
content::DevToolsAgentHost* agent_host,
const std::string& message) {
if (message.length() < kMaxMessageChunkSize) {
base::string16 javascript = base::UTF8ToUTF16(
"DevToolsAPI.dispatchMessage(" + message + ");");
std::string param;
base::EscapeJSONString(message, true, &param);
std::string code = "DevToolsAPI.dispatchMessage(" + param + ");";
base::string16 javascript = base::UTF8ToUTF16(code);
web_contents()->GetMainFrame()->ExecuteJavaScriptForTests(javascript);
return;
}
base::FundamentalValue total_size(static_cast<int>(message.length()));
size_t total_size = message.length();
for (size_t pos = 0; pos < message.length(); pos += kMaxMessageChunkSize) {
std::string param;
base::JSONWriter::Write(
base::StringValue(message.substr(pos, kMaxMessageChunkSize)), &param);
std::string code = "DevToolsAPI.dispatchMessageChunk(" + param + ");";
base::EscapeJSONString(message.substr(pos, kMaxMessageChunkSize), true,
&param);
std::string code = "DevToolsAPI.dispatchMessageChunk(" + param + "," +
std::to_string(pos ? 0 : total_size) + ");";
base::string16 javascript = base::UTF8ToUTF16(code);
web_contents()->GetMainFrame()->ExecuteJavaScriptForTests(javascript);
}

View File

@@ -122,17 +122,19 @@ void CefExtensionSystem::Init() {
// 5. A MimeHandlerViewGuest and CefMimeHandlerViewGuestDelegate is created in
// the browser process.
// 6. MimeHandlerViewGuest navigates to the PDF extension URL.
// 7. PDF extension resources are provided from bundle via
// 7. Access to PDF extension resources is checked by
// CefExtensionsBrowserClient::AllowCrossRendererResourceLoad.
// 8. PDF extension resources are provided from bundle via
// CefExtensionsBrowserClient::MaybeCreateResourceBundleRequestJob and
// CefComponentExtensionResourceManager.
// 8. The PDF extension communicates via the chrome.mimeHandlerPrivate Mojo
// 9. The PDF extension communicates via the chrome.mimeHandlerPrivate Mojo
// API which is implemented as described in
// libcef/common/extensions/api/README.txt.
// 9. The PDF extension requests a plugin to handle
// 10.The PDF extension requests a plugin to handle
// kPDFPluginOutOfProcessMimeType which loads the PDF PPAPI plugin.
// 10.Routing of print-related commands are handled by ChromePDFPrintClient
// 11.Routing of print-related commands are handled by ChromePDFPrintClient
// and CefPrintWebViewHelperDelegate in the renderer process.
// 11.The PDF extension is granted access to chrome://resources via
// 12.The PDF extension is granted access to chrome://resources via
// CefExtensionWebContentsObserver::RenderViewCreated in the browser
// process.
if (PdfExtensionEnabled()) {

View File

@@ -27,6 +27,7 @@
#include "extensions/browser/extension_host_delegate.h"
#include "extensions/browser/mojo/service_registration.h"
#include "extensions/browser/url_request_util.h"
#include "extensions/common/constants.h"
using content::BrowserContext;
using content::BrowserThread;
@@ -114,6 +115,13 @@ bool CefExtensionsBrowserClient::AllowCrossRendererResourceLoad(
bool is_incognito,
const Extension* extension,
InfoMap* extension_info_map) {
// TODO(cef): This bypasses additional checks added to
// AllowCrossRendererResourceLoad() in https://crrev.com/5cf9d45c. Figure out
// why permission is not being granted based on "web_accessible_resources"
// specified in the PDF extension manifest.json file.
if (extension->id() == extension_misc::kPdfExtensionId)
return true;
bool allowed = false;
if (url_request_util::AllowCrossRendererResourceLoad(
request, is_incognito, extension, extension_info_map, &allowed)) {

View File

@@ -12,7 +12,7 @@
#include "libcef/browser/thread_util.h"
#include "base/threading/worker_pool.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/common/file_chooser_file_info.h"
#include "net/base/directory_lister.h"
@@ -158,6 +158,7 @@ CefFileDialogManager::CefFileDialogManager(
browser_(browser),
runner_(std::move(runner)),
file_chooser_pending_(false),
render_frame_host_(nullptr),
weak_ptr_factory_(this) {
DCHECK(web_contents());
}
@@ -217,40 +218,41 @@ void CefFileDialogManager::RunFileDialog(
}
void CefFileDialogManager::RunFileChooser(
content::WebContents* web_contents,
content::RenderFrameHost* render_frame_host,
const content::FileChooserParams& params) {
CEF_REQUIRE_UIT();
DCHECK_EQ(web_contents, this->web_contents());
content::RenderViewHost* render_view_host = web_contents->GetRenderViewHost();
if (!render_view_host)
return;
DCHECK(render_frame_host);
CefFileDialogRunner::FileChooserParams cef_params;
static_cast<content::FileChooserParams&>(cef_params) = params;
if (lister_) {
// Cancel the previous upload folder run.
lister_->Cancel();
lister_.reset();
}
CefFileDialogRunner::RunFileChooserCallback callback;
if (params.mode == content::FileChooserParams::UploadFolder) {
RunFileChooser(cef_params,
base::Bind(
&CefFileDialogManager::OnRunFileChooserUploadFolderDelegateCallback,
weak_ptr_factory_.GetWeakPtr(), params.mode));
return;
callback = base::Bind(
&CefFileDialogManager::OnRunFileChooserUploadFolderDelegateCallback,
weak_ptr_factory_.GetWeakPtr(), params.mode);
} else {
callback = base::Bind(
&CefFileDialogManager::OnRunFileChooserDelegateCallback,
weak_ptr_factory_.GetWeakPtr(), params.mode);
}
RunFileChooser(cef_params,
base::Bind(&CefFileDialogManager::OnRunFileChooserDelegateCallback,
weak_ptr_factory_.GetWeakPtr(), params.mode));
RunFileChooserInternal(render_frame_host, cef_params, callback);
}
void CefFileDialogManager::RunFileChooser(
const CefFileDialogRunner::FileChooserParams& params,
const CefFileDialogRunner::RunFileChooserCallback& callback) {
const CefFileDialogRunner::RunFileChooserCallback& host_callback =
base::Bind(&CefFileDialogManager::OnRunFileChooserCallback,
weak_ptr_factory_.GetWeakPtr(), callback);
RunFileChooserInternal(nullptr, params, host_callback);
}
void CefFileDialogManager::RunFileChooserInternal(
content::RenderFrameHost* render_frame_host,
const CefFileDialogRunner::FileChooserParams& params,
const CefFileDialogRunner::RunFileChooserCallback& callback) {
CEF_REQUIRE_UIT();
if (file_chooser_pending_) {
@@ -260,11 +262,7 @@ void CefFileDialogManager::RunFileChooser(
}
file_chooser_pending_ = true;
// Ensure that the |file_chooser_pending_| flag is cleared.
const CefFileDialogRunner::RunFileChooserCallback& host_callback =
base::Bind(&CefFileDialogManager::OnRunFileChooserCallback,
weak_ptr_factory_.GetWeakPtr(), callback);
render_frame_host_ = render_frame_host;
bool handled = false;
@@ -304,7 +302,7 @@ void CefFileDialogManager::RunFileChooser(
accept_filters.push_back(*it);
CefRefPtr<CefFileDialogCallbackImpl> callbackImpl(
new CefFileDialogCallbackImpl(host_callback));
new CefFileDialogCallbackImpl(callback));
handled = handler->OnFileDialog(
browser_,
static_cast<cef_file_dialog_mode_t>(mode),
@@ -327,10 +325,10 @@ void CefFileDialogManager::RunFileChooser(
if (!handled) {
if (runner_.get()) {
runner_->Run(browser_, params, host_callback);
runner_->Run(browser_, params, callback);
} else {
LOG(WARNING) << "No file dialog runner available for this platform";
host_callback.Run(0, std::vector<base::FilePath>());
callback.Run(0, std::vector<base::FilePath>());
}
}
}
@@ -341,7 +339,7 @@ void CefFileDialogManager::OnRunFileChooserCallback(
const std::vector<base::FilePath>& file_paths) {
CEF_REQUIRE_UIT();
file_chooser_pending_ = false;
Cleanup();
// Execute the callback asynchronously.
CEF_POST_TASK(CEF_UIT,
@@ -375,17 +373,6 @@ void CefFileDialogManager::OnRunFileChooserDelegateCallback(
const std::vector<base::FilePath>& file_paths) {
CEF_REQUIRE_UIT();
if (lister_.get())
lister_.reset();
if (!web_contents())
return;
content::RenderViewHost* render_view_host =
web_contents()->GetRenderViewHost();
if (!render_view_host)
return;
// Convert FilePath list to SelectedFileInfo list.
std::vector<content::FileChooserFileInfo> selected_files;
for (size_t i = 0; i < file_paths.size(); ++i) {
@@ -395,5 +382,22 @@ void CefFileDialogManager::OnRunFileChooserDelegateCallback(
}
// Notify our RenderViewHost in all cases.
render_view_host->FilesSelectedInChooser(selected_files, mode);
if (render_frame_host_)
render_frame_host_->FilesSelectedInChooser(selected_files, mode);
Cleanup();
}
void CefFileDialogManager::Cleanup() {
if (lister_)
lister_.reset();
render_frame_host_ = nullptr;
file_chooser_pending_ = false;
}
void CefFileDialogManager::RenderFrameDeleted(
content::RenderFrameHost* render_frame_host) {
if (render_frame_host == render_frame_host_)
render_frame_host_ = nullptr;
}

View File

@@ -48,8 +48,8 @@ class CefFileDialogManager : public content::WebContentsObserver {
// Called from CefBrowserHostImpl::RunFileChooser.
// See WebContentsDelegate::RunFileChooser documentation.
void RunFileChooser(
content::WebContents* web_contents,
const content::FileChooserParams& params);
content::RenderFrameHost* render_frame_host,
const content::FileChooserParams& params);
// Run the file chooser dialog specified by |params|. Only a single dialog may
// be pending at any given time. |callback| will be executed asynchronously
@@ -59,7 +59,13 @@ class CefFileDialogManager : public content::WebContentsObserver {
const CefFileDialogRunner::RunFileChooserCallback& callback);
private:
// Used with RunFileChooser to clear the |file_chooser_pending_| flag.
void RunFileChooserInternal(
content::RenderFrameHost* render_frame_host,
const CefFileDialogRunner::FileChooserParams& params,
const CefFileDialogRunner::RunFileChooserCallback& callback);
// Used with the RunFileChooser variant where the caller specifies a callback
// (no associated RenderFrameHost).
void OnRunFileChooserCallback(
const CefFileDialogRunner::RunFileChooserCallback& callback,
int selected_accept_filter,
@@ -72,12 +78,20 @@ class CefFileDialogManager : public content::WebContentsObserver {
int selected_accept_filter,
const std::vector<base::FilePath>& file_paths);
// Used with WebContentsDelegate::RunFileChooser to notify the WebContents.
// Used with WebContentsDelegate::RunFileChooser to notify the
// RenderFrameHost.
void OnRunFileChooserDelegateCallback(
content::FileChooserParams::Mode mode,
int selected_accept_filter,
const std::vector<base::FilePath>& file_paths);
// Clean up state associated with the last run.
void Cleanup();
// WebContentsObserver methods:
void RenderFrameDeleted(
content::RenderFrameHost* render_frame_host) override;
// CefBrowserHostImpl pointer is guaranteed to outlive this object.
CefBrowserHostImpl* browser_;
@@ -86,6 +100,9 @@ class CefFileDialogManager : public content::WebContentsObserver {
// True if a file chooser is currently pending.
bool file_chooser_pending_;
// RenderFrameHost associated with the pending file chooser. May be nullptr.
content::RenderFrameHost* render_frame_host_;
// Used for asynchronously listing directory contents.
std::unique_ptr<net::DirectoryLister> lister_;

View File

@@ -17,6 +17,7 @@
#include "libcef/browser/thread_util.h"
#include "base/files/file_util.h"
#include "base/memory/ref_counted_memory.h"
#include "base/strings/utf_string_conversions.h"
#include "base/win/registry.h"
#include "content/public/browser/native_web_keyboard_event.h"

View File

@@ -258,16 +258,15 @@ class NativeMenuWin::MenuHostWindow {
gfx::Image icon;
if (data->native_menu_win->model_->GetIconAt(data->model_index, &icon)) {
// We currently don't support items with both icons and checkboxes.
const gfx::ImageSkia* skia_icon = icon.ToImageSkia();
const gfx::ImageSkia skia_icon = icon.AsImageSkia();
DCHECK(type != ui::MenuModel::TYPE_CHECK);
gfx::Canvas canvas(
skia_icon->GetRepresentation(1.0f),
false);
gfx::Canvas canvas(skia_icon.size(), 1.0f, false);
canvas.DrawImageInt(skia_icon, 0, 0);
skia::DrawToNativeContext(
canvas.sk_canvas(), dc,
draw_item_struct->rcItem.left + kItemLeftMargin,
draw_item_struct->rcItem.top + (draw_item_struct->rcItem.bottom -
draw_item_struct->rcItem.top - skia_icon->height()) / 2, NULL);
draw_item_struct->rcItem.top - skia_icon.height()) / 2, NULL);
} else if (type == ui::MenuModel::TYPE_CHECK &&
data->native_menu_win->model_->IsItemCheckedAt(
data->model_index)) {

View File

@@ -287,15 +287,6 @@ void CefResourceRequestJob::GetLoadTimingInfo(
load_timing_info->receive_headers_end = receive_headers_end_;
}
bool CefResourceRequestJob::GetResponseCookies(
std::vector<std::string>* cookies) {
CEF_REQUIRE_IOT();
cookies->clear();
FetchResponseCookies(cookies);
return true;
}
bool CefResourceRequestJob::IsRedirectResponse(GURL* location,
int* http_status_code) {
CEF_REQUIRE_IOT();

View File

@@ -39,7 +39,6 @@ class CefResourceRequestJob : public net::URLRequestJob {
void GetResponseInfo(net::HttpResponseInfo* info) override;
void GetLoadTimingInfo(
net::LoadTimingInfo* load_timing_info) const override;
bool GetResponseCookies(std::vector<std::string>* cookies) override;
bool IsRedirectResponse(GURL* location, int* http_status_code)
override;
bool GetMimeType(std::string* mime_type) const override;

View File

@@ -27,6 +27,7 @@
#include "build/build_config.h"
#include "chrome/browser/net/proxy_service_factory.h"
#include "chrome/common/pref_names.h"
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/common/content_client.h"
@@ -120,9 +121,18 @@ CefURLRequestContextGetterImpl::CefURLRequestContextGetterImpl(
std::swap(protocol_handlers_, *protocol_handlers);
auto io_thread_proxy =
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO);
quick_check_enabled_.Init(prefs::kQuickCheckEnabled, pref_service);
quick_check_enabled_.MoveToThread(io_thread_proxy);
pac_https_url_stripping_enabled_.Init(prefs::kPacHttpsUrlStrippingEnabled,
pref_service);
pac_https_url_stripping_enabled_.MoveToThread(io_thread_proxy);
force_google_safesearch_.Init(prefs::kForceGoogleSafeSearch, pref_service);
force_google_safesearch_.MoveToThread(
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO));
force_google_safesearch_.MoveToThread(io_thread_proxy);
#if defined(OS_POSIX) && !defined(OS_ANDROID)
gsapi_library_name_ = pref_service->GetString(prefs::kGSSAPILibraryName);
@@ -138,8 +148,24 @@ CefURLRequestContextGetterImpl::~CefURLRequestContextGetterImpl() {
storage_->set_proxy_service(NULL);
}
// static
void CefURLRequestContextGetterImpl::RegisterPrefs(
PrefRegistrySimple* registry) {
// Based on IOThread::RegisterPrefs.
#if defined(OS_POSIX) && !defined(OS_ANDROID)
registry->RegisterStringPref(prefs::kGSSAPILibraryName, std::string());
#endif
registry->RegisterBooleanPref(prefs::kQuickCheckEnabled, true);
registry->RegisterBooleanPref(prefs::kPacHttpsUrlStrippingEnabled, true);
// Based on ProfileImpl::RegisterProfilePrefs.
registry->RegisterBooleanPref(prefs::kForceGoogleSafeSearch, false);
}
void CefURLRequestContextGetterImpl::ShutdownOnUIThread() {
CEF_REQUIRE_UIT();
quick_check_enabled_.Destroy();
pac_https_url_stripping_enabled_.Destroy();
force_google_safesearch_.Destroy();
}
@@ -189,7 +215,8 @@ net::URLRequestContext* CefURLRequestContextGetterImpl::GetURLRequestContext() {
url_request_context_->network_delegate(),
std::move(proxy_config_service_),
*command_line,
true);
quick_check_enabled_.GetValue(),
pac_https_url_stripping_enabled_.GetValue());
storage_->set_proxy_service(std::move(system_proxy_service));
storage_->set_ssl_config_service(new net::SSLConfigServiceDefaults);

View File

@@ -21,6 +21,7 @@
#include "content/public/browser/browser_context.h"
#include "net/url_request/url_request_job_factory.h"
class PrefRegistrySimple;
class PrefService;
namespace base {
@@ -53,6 +54,9 @@ class CefURLRequestContextGetterImpl : public CefURLRequestContextGetter {
content::URLRequestInterceptorScopedVector request_interceptors);
~CefURLRequestContextGetterImpl() override;
// Register preferences. Called from browser_prefs::CreatePrefService().
static void RegisterPrefs(PrefRegistrySimple* registry);
// Called when the BrowserContextImpl is destroyed.
void ShutdownOnUIThread();
@@ -106,6 +110,9 @@ class CefURLRequestContextGetterImpl : public CefURLRequestContextGetter {
std::vector<CefRefPtr<CefRequestContextHandler> > handler_list_;
BooleanPrefMember quick_check_enabled_;
BooleanPrefMember pac_https_url_stripping_enabled_;
// Member variables which are pointed to by the various context objects.
mutable BooleanPrefMember force_google_safesearch_;

View File

@@ -217,16 +217,19 @@ void CefBrowserPlatformDelegateOsr::DragTargetDragEnter(
if (!rvh)
return;
drag_data_ = drag_data;
CefDragDataImpl* data_impl = static_cast<CefDragDataImpl*>(drag_data.get());
base::AutoLock lock_scope(data_impl->lock());
const content::DropData& drop_data = data_impl->drop_data();
content::DropData* drop_data = data_impl->drop_data();
const gfx::Point client_pt(event.x, event.y);
const gfx::Point& screen_pt = GetScreenPoint(client_pt);
blink::WebDragOperationsMask ops =
static_cast<blink::WebDragOperationsMask>(allowed_ops);
int modifiers = TranslateModifiers(event.modifiers);
rvh->DragTargetDragEnter(drop_data, client_pt, screen_pt, ops, modifiers);
rvh->FilterDropData(drop_data);
rvh->DragTargetDragEnter(*drop_data, client_pt, screen_pt, ops, modifiers);
}
void CefBrowserPlatformDelegateOsr::DragTargetDragOver(
@@ -258,11 +261,19 @@ void CefBrowserPlatformDelegateOsr::DragTargetDrop(const CefMouseEvent& event) {
if (!rvh)
return;
const gfx::Point client_pt(event.x, event.y);
const gfx::Point& screen_pt = GetScreenPoint(client_pt);
int modifiers = TranslateModifiers(event.modifiers);
{
CefDragDataImpl* data_impl =
static_cast<CefDragDataImpl*>(drag_data_.get());
base::AutoLock lock_scope(data_impl->lock());
content::DropData* drop_data = data_impl->drop_data();
const gfx::Point client_pt(event.x, event.y);
const gfx::Point& screen_pt = GetScreenPoint(client_pt);
int modifiers = TranslateModifiers(event.modifiers);
rvh->DragTargetDrop(client_pt, screen_pt, modifiers);
rvh->DragTargetDrop(*drop_data, client_pt, screen_pt, modifiers);
}
drag_data_ = nullptr;
}
void CefBrowserPlatformDelegateOsr::DragSourceEndedAt(

View File

@@ -83,6 +83,9 @@ class CefBrowserPlatformDelegateOsr :
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate_;
CefWebContentsViewOSR* view_osr_; // Not owned by this class.
// Pending drag/drop data.
CefRefPtr<CefDragData> drag_data_;
};
#endif // CEF_LIBCEF_BROWSER_OSR_BROWSER_PLATFORM_DELEGATE_OSR_H_

View File

@@ -409,9 +409,11 @@ class CefBeginFrameTimer : public cc::DelayBasedTimeSourceClient {
CefBeginFrameTimer(int frame_rate_threshold_ms,
const base::Closure& callback)
: callback_(callback) {
time_source_ = cc::DelayBasedTimeSource::Create(
base::TimeDelta::FromMilliseconds(frame_rate_threshold_ms),
content::BrowserThread::GetMessageLoopProxyForThread(CEF_UIT).get());
time_source_.reset(new cc::DelayBasedTimeSource(
content::BrowserThread::GetMessageLoopProxyForThread(CEF_UIT).get()));
time_source_->SetTimebaseAndInterval(
base::TimeTicks(),
base::TimeDelta::FromMilliseconds(frame_rate_threshold_ms));
time_source_->SetClient(this);
}
@@ -1006,6 +1008,11 @@ CefRenderWidgetHostViewOSR::CreateSoftwareOutputDevice(
return base::WrapUnique(software_output_device_);
}
int CefRenderWidgetHostViewOSR::DelegatedFrameHostGetGpuMemoryBufferClientId()
const {
return render_widget_host_->GetProcess()->GetID();
}
ui::Layer* CefRenderWidgetHostViewOSR::DelegatedFrameHostGetLayer() const {
return root_layer_.get();
}
@@ -1020,8 +1027,7 @@ SkColor CefRenderWidgetHostViewOSR::DelegatedFrameHostGetGutterColor(
// may not match the page's, so use black as the gutter color to avoid
// flashes of brighter colors during the transition.
if (render_widget_host_->delegate() &&
render_widget_host_->delegate()->IsFullscreenForCurrentTab(
render_widget_host_)) {
render_widget_host_->delegate()->IsFullscreenForCurrentTab()) {
return SK_ColorBLACK;
}
return color;

View File

@@ -25,7 +25,6 @@
#if defined(OS_MACOSX)
#include "content/browser/renderer_host/browser_compositor_view_mac.h"
#include "ui/accelerated_widget_mac/accelerated_widget_mac.h"
#endif
#if defined(OS_WIN)
@@ -76,11 +75,12 @@ class CefWindowX11;
// RenderWidgetHostView class hierarchy described in render_widget_host_view.h.
///////////////////////////////////////////////////////////////////////////////
#if defined(OS_MACOSX)
class AcceleratedWidgetMacNSViewHelper;
#endif
class CefRenderWidgetHostViewOSR
: public content::RenderWidgetHostViewBase,
#if defined(OS_MACOSX)
public ui::AcceleratedWidgetMacNSView,
#endif
public ui::CompositorDelegate,
public content::DelegatedFrameHostClient {
public:
@@ -183,14 +183,6 @@ class CefRenderWidgetHostViewOSR
const std::vector<gfx::Rect>& character_bounds) override;
#endif
#if defined(OS_MACOSX)
// AcceleratedWidgetMacNSView implementation.
NSView* AcceleratedWidgetGetNSView() const override;
void AcceleratedWidgetGetVSyncParameters(
base::TimeTicks* timebase, base::TimeDelta* interval) const override;
void AcceleratedWidgetSwapCompleted() override;
#endif // defined(OS_MACOSX)
bool OnMessageReceived(const IPC::Message& msg) override;
// Message handlers.
@@ -201,6 +193,7 @@ class CefRenderWidgetHostViewOSR
ui::Compositor* compositor) override;
// DelegatedFrameHostClient implementation.
virtual int DelegatedFrameHostGetGpuMemoryBufferClientId() const override;
ui::Layer* DelegatedFrameHostGetLayer() const override;
bool DelegatedFrameHostIsVisible() const override;
SkColor DelegatedFrameHostGetGutterColor(SkColor color) const override;
@@ -295,6 +288,8 @@ class CefRenderWidgetHostViewOSR
void OnScrollOffsetChanged();
#if defined(OS_MACOSX)
friend class AcceleratedWidgetMacNSViewHelper;
// Returns composition character boundary rectangle. The |range| is
// composition based range. Also stores |actual_range| which is corresponding
// to actually used range for returned rectangle.
@@ -339,6 +334,7 @@ class CefRenderWidgetHostViewOSR
NSWindow* window_;
CALayer* background_layer_;
std::unique_ptr<content::BrowserCompositorMac> browser_compositor_;
AcceleratedWidgetMacNSViewHelper* accelerated_widget_helper_;
#elif defined(USE_X11)
CefWindowX11* window_;
std::unique_ptr<ui::XScopedCursor> invisible_cursor_;

View File

@@ -17,6 +17,7 @@
#include "base/compiler_specific.h"
#include "base/strings/utf_string_conversions.h"
#include "content/common/view_messages.h"
#include "ui/accelerated_widget_mac/accelerated_widget_mac.h"
#include "ui/events/latency_info.h"
namespace {
@@ -30,6 +31,35 @@ CefTextInputClientOSRMac* GetInputClientFromContext(
} // namespace
class AcceleratedWidgetMacNSViewHelper : public ui::AcceleratedWidgetMacNSView {
public:
explicit AcceleratedWidgetMacNSViewHelper(CefRenderWidgetHostViewOSR* view)
: view_(view) {
}
virtual ~AcceleratedWidgetMacNSViewHelper() {}
NSView* AcceleratedWidgetGetNSView() const override {
return [view_->window_ contentView];
}
void AcceleratedWidgetGetVSyncParameters(
base::TimeTicks* timebase, base::TimeDelta* interval) const override {
*timebase = base::TimeTicks();
*interval = base::TimeDelta();
}
void AcceleratedWidgetSwapCompleted() override {
}
private:
// Guaranteed to outlive this object.
CefRenderWidgetHostViewOSR* view_;
DISALLOW_COPY_AND_ASSIGN(AcceleratedWidgetMacNSViewHelper);
};
ui::AcceleratedWidgetMac* CefRenderWidgetHostViewOSR::GetAcceleratedWidgetMac()
const {
if (browser_compositor_)
@@ -109,19 +139,6 @@ void CefRenderWidgetHostViewOSR::SelectionBoundsChanged(
first_selection_rect_ = params.anchor_rect;
}
NSView* CefRenderWidgetHostViewOSR::AcceleratedWidgetGetNSView() const {
return [window_ contentView];
}
void CefRenderWidgetHostViewOSR::AcceleratedWidgetGetVSyncParameters(
base::TimeTicks* timebase, base::TimeDelta* interval) const {
*timebase = base::TimeTicks();
*interval = base::TimeDelta();
}
void CefRenderWidgetHostViewOSR::AcceleratedWidgetSwapCompleted() {
}
CefTextInputContext CefRenderWidgetHostViewOSR::GetNSTextInputContext() {
if (!text_input_context_osr_mac_) {
CefTextInputClientOSRMac* text_input_client_osr_mac =
@@ -305,10 +322,12 @@ void CefRenderWidgetHostViewOSR::PlatformCreateCompositorWidget() {
[content_view setWantsLayer:YES];
browser_compositor_ = content::BrowserCompositorMac::Create();
accelerated_widget_helper_ = new AcceleratedWidgetMacNSViewHelper(this);
compositor_.reset(browser_compositor_->compositor());
compositor_->SetRootLayer(root_layer_.get());
browser_compositor_->accelerated_widget_mac()->SetNSView(this);
browser_compositor_->accelerated_widget_mac()->SetNSView(
accelerated_widget_helper_);
browser_compositor_->compositor()->SetVisible(true);
// CEF needs the browser compositor to remain responsive whereas normal
@@ -335,4 +354,7 @@ void CefRenderWidgetHostViewOSR::PlatformDestroyCompositorWidget() {
browser_compositor_->compositor()->SetScaleAndSize(1.0, gfx::Size(0, 0));
browser_compositor_->compositor()->SetRootLayer(NULL);
content::BrowserCompositorMac::Recycle(std::move(browser_compositor_));
delete accelerated_widget_helper_;
accelerated_widget_helper_ = nullptr;
}

View File

@@ -5,6 +5,7 @@
#include "libcef/browser/prefs/browser_prefs.h"
#include "libcef/browser/media_capture_devices_dispatcher.h"
#include "libcef/browser/net/url_request_context_getter_impl.h"
#include "libcef/browser/prefs/renderer_prefs.h"
#include "libcef/common/cef_switches.h"
@@ -126,6 +127,7 @@ std::unique_ptr<PrefService> CreatePrefService(const base::FilePath& pref_path)
PrefProxyConfigTrackerImpl::RegisterPrefs(registry.get());
extensions::ExtensionPrefs::RegisterProfilePrefs(registry.get());
HostContentSettingsMap::RegisterProfilePrefs(registry.get());
CefURLRequestContextGetterImpl::RegisterPrefs(registry.get());
renderer_prefs::RegisterProfilePrefs(registry.get());
update_client::RegisterPrefs(registry.get());
@@ -160,14 +162,6 @@ std::unique_ptr<PrefService> CreatePrefService(const base::FilePath& pref_path)
registry->RegisterBooleanPref(prefs::kPluginsAllowOutdated, false);
registry->RegisterBooleanPref(prefs::kPluginsAlwaysAuthorize, false);
// Network preferences.
// Based on ProfileImpl::RegisterProfilePrefs.
registry->RegisterBooleanPref(prefs::kForceGoogleSafeSearch, false);
// Based on IOThread::RegisterPrefs.
#if defined(OS_POSIX) && !defined(OS_ANDROID)
registry->RegisterStringPref(prefs::kGSSAPILibraryName, std::string());
#endif
if (command_line->HasSwitch(switches::kEnablePreferenceTesting)) {
// Preferences used with unit tests.
registry->RegisterBooleanPref("test.bool", true);

View File

@@ -140,7 +140,7 @@ void SavePdfFile(scoped_refptr<base::RefCountedBytes> data,
DCHECK_CURRENTLY_ON(BrowserThread::FILE);
DCHECK_GT(data->size(), 0U);
PdfMetafileSkia metafile;
PdfMetafileSkia metafile(PDF_SKIA_DOCUMENT_TYPE);
metafile.InitFromData(static_cast<const void*>(data->front()), data->size());
base::File file(path,

View File

@@ -151,7 +151,8 @@ void PrintViewManagerBase::OnDidPrintPage(
}
}
std::unique_ptr<PdfMetafileSkia> metafile(new PdfMetafileSkia);
std::unique_ptr<PdfMetafileSkia> metafile(
new PdfMetafileSkia(PDF_SKIA_DOCUMENT_TYPE));
if (metafile_must_be_valid) {
if (!metafile->InitFromData(shared_buf->memory(), params.data_size)) {
NOTREACHED() << "Invalid metafile header";
@@ -214,16 +215,8 @@ void PrintViewManagerBase::Observe(
int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
switch (type) {
case chrome::NOTIFICATION_PRINT_JOB_EVENT: {
OnNotifyPrintJobEvent(*content::Details<JobEventDetails>(details).ptr());
break;
}
default: {
NOTREACHED();
break;
}
}
DCHECK_EQ(chrome::NOTIFICATION_PRINT_JOB_EVENT, type);
OnNotifyPrintJobEvent(*content::Details<JobEventDetails>(details).ptr());
}
void PrintViewManagerBase::OnNotifyPrintJobEvent(

View File

@@ -84,20 +84,23 @@ bool CefResourceDispatcherHostDelegate::HandleExternalProtocol(
const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter,
bool is_main_frame,
ui::PageTransition page_transition,
bool has_user_gesture) {
if (CEF_CURRENTLY_ON_UIT()) {
content::WebContents* web_contents = web_contents_getter.Run();
CefRefPtr<CefBrowserHostImpl> browser =
CefBrowserHostImpl::GetBrowserForContents(web_contents);
if (browser.get())
browser->HandleExternalProtocol(url);
} else {
bool has_user_gesture,
content::ResourceContext* resource_context) {
if (!CEF_CURRENTLY_ON_UIT()) {
CEF_POST_TASK(CEF_UIT,
base::Bind(base::IgnoreResult(&CefResourceDispatcherHostDelegate::
HandleExternalProtocol),
base::Unretained(this), url, child_id, web_contents_getter,
is_main_frame, page_transition, has_user_gesture));
is_main_frame, page_transition, has_user_gesture,
resource_context));
return false;
}
content::WebContents* web_contents = web_contents_getter.Run();
CefRefPtr<CefBrowserHostImpl> browser =
CefBrowserHostImpl::GetBrowserForContents(web_contents);
if (browser.get())
browser->HandleExternalProtocol(url);
return false;
}

View File

@@ -28,7 +28,8 @@ class CefResourceDispatcherHostDelegate
web_contents_getter,
bool is_main_frame,
ui::PageTransition page_transition,
bool has_user_gesture) override;
bool has_user_gesture,
content::ResourceContext* resource_context) override;
bool ShouldInterceptResourceAsStream(net::URLRequest* request,
const base::FilePath& plugin_path,
const std::string& mime_type,

View File

@@ -200,7 +200,7 @@ display::Display GetDisplayMatchingBounds(const gfx::Rect& bounds,
find_bounds);
}
#endif
return display::Screen::GetScreen()->GetDisplayMatching(bounds);
return display::Screen::GetScreen()->GetDisplayMatching(find_bounds);
}
void ConvertPointFromPixels(gfx::Point* point,