mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Apply clang-format to all C, C++ and ObjC files (issue #2171)
This commit is contained in:
@@ -16,9 +16,7 @@
|
||||
#include "content/public/browser/storage_partition.h"
|
||||
|
||||
CefBrowserContext::CefBrowserContext(bool is_proxy)
|
||||
: is_proxy_(is_proxy),
|
||||
extension_system_(NULL) {
|
||||
}
|
||||
: is_proxy_(is_proxy), extension_system_(NULL) {}
|
||||
|
||||
CefBrowserContext::~CefBrowserContext() {
|
||||
// Should be cleared in Shutdown().
|
||||
@@ -89,8 +87,8 @@ void CefBrowserContext::Shutdown() {
|
||||
if (resource_context_.get()) {
|
||||
// Destruction of the ResourceContext will trigger destruction of all
|
||||
// associated URLRequests.
|
||||
content::BrowserThread::DeleteSoon(
|
||||
content::BrowserThread::IO, FROM_HERE, resource_context_.release());
|
||||
content::BrowserThread::DeleteSoon(content::BrowserThread::IO, FROM_HERE,
|
||||
resource_context_.release());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,7 +106,7 @@ net::URLRequestContextGetter* CefBrowserContext::CreateMediaRequestContext() {
|
||||
}
|
||||
|
||||
net::URLRequestContextGetter*
|
||||
CefBrowserContext::CreateMediaRequestContextForStoragePartition(
|
||||
CefBrowserContext::CreateMediaRequestContextForStoragePartition(
|
||||
const base::FilePath& partition_path,
|
||||
bool in_memory) {
|
||||
return nullptr;
|
||||
@@ -130,9 +128,9 @@ void CefBrowserContext::OnRenderFrameDeleted(int render_process_id,
|
||||
// deletion of |resource_context_| will execute on the IO thread, and this
|
||||
// callback will be executed first.
|
||||
CEF_POST_TASK(CEF_IOT,
|
||||
base::Bind(&CefResourceContext::ClearPluginLoadDecision,
|
||||
base::Unretained(resource_context_.get()),
|
||||
render_process_id));
|
||||
base::Bind(&CefResourceContext::ClearPluginLoadDecision,
|
||||
base::Unretained(resource_context_.get()),
|
||||
render_process_id));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,7 +141,7 @@ void CefBrowserContext::OnPurgePluginListCache() {
|
||||
// deletion of |resource_context_| will execute on the IO thread, and this
|
||||
// callback will be executed first.
|
||||
CEF_POST_TASK(CEF_IOT,
|
||||
base::Bind(&CefResourceContext::ClearPluginLoadDecision,
|
||||
base::Unretained(resource_context_.get()), -1));
|
||||
base::Bind(&CefResourceContext::ClearPluginLoadDecision,
|
||||
base::Unretained(resource_context_.get()), -1));
|
||||
}
|
||||
}
|
||||
|
@@ -115,7 +115,7 @@
|
||||
// CefBrowserMainParts::PostMainMessageLoopRun() (*Impl). This may be delayed
|
||||
// if other network-related objects still have a reference to it.
|
||||
// 6. CefURLRequestContext* is destroyed on the IO thread due to
|
||||
// CefURLRequestContextGetter* destruction.
|
||||
// CefURLRequestContextGetter* destruction.
|
||||
*/
|
||||
|
||||
class CefRequestContextImpl;
|
||||
@@ -187,9 +187,7 @@ class CefBrowserContext : public ChromeProfileStub {
|
||||
return extension_system_;
|
||||
}
|
||||
|
||||
bool is_proxy() const {
|
||||
return is_proxy_;
|
||||
}
|
||||
bool is_proxy() const { return is_proxy_; }
|
||||
|
||||
protected:
|
||||
~CefBrowserContext() override;
|
||||
|
@@ -35,8 +35,8 @@
|
||||
#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/download_manager.h"
|
||||
#include "content/public/browser/storage_partition.h"
|
||||
#include "extensions/browser/extension_protocols.h"
|
||||
#include "extensions/common/constants.h"
|
||||
@@ -149,8 +149,7 @@ class ImplManager {
|
||||
base::LazyInstance<ImplManager>::DestructorAtExit g_manager =
|
||||
LAZY_INSTANCE_INITIALIZER;
|
||||
#else
|
||||
base::LazyInstance<ImplManager>::Leaky g_manager =
|
||||
LAZY_INSTANCE_INITIALIZER;
|
||||
base::LazyInstance<ImplManager>::Leaky g_manager = LAZY_INSTANCE_INITIALIZER;
|
||||
#endif
|
||||
|
||||
} // namespace
|
||||
@@ -159,9 +158,7 @@ base::LazyInstance<ImplManager>::Leaky g_manager =
|
||||
// CefBrowserContext sharing the same VisitedLinkMaster.
|
||||
class CefVisitedLinkListener : public visitedlink::VisitedLinkMaster::Listener {
|
||||
public:
|
||||
CefVisitedLinkListener() {
|
||||
DCHECK(listener_map_.empty());
|
||||
}
|
||||
CefVisitedLinkListener() { DCHECK(listener_map_.empty()); }
|
||||
|
||||
void CreateListenerForContext(const CefBrowserContext* context) {
|
||||
CEF_REQUIRE_UIT();
|
||||
@@ -203,7 +200,7 @@ class CefVisitedLinkListener : public visitedlink::VisitedLinkMaster::Listener {
|
||||
private:
|
||||
// Map of CefBrowserContext to the associated VisitedLinkEventListener.
|
||||
typedef std::map<const CefBrowserContext*,
|
||||
std::unique_ptr<visitedlink::VisitedLinkEventListener> >
|
||||
std::unique_ptr<visitedlink::VisitedLinkEventListener>>
|
||||
ListenerMap;
|
||||
ListenerMap listener_map_;
|
||||
|
||||
@@ -212,8 +209,7 @@ class CefVisitedLinkListener : public visitedlink::VisitedLinkMaster::Listener {
|
||||
|
||||
CefBrowserContextImpl::CefBrowserContextImpl(
|
||||
const CefRequestContextSettings& settings)
|
||||
: CefBrowserContext(false),
|
||||
settings_(settings) {
|
||||
: CefBrowserContext(false), settings_(settings) {
|
||||
g_manager.Get().AddImpl(this);
|
||||
}
|
||||
|
||||
@@ -253,8 +249,8 @@ void CefBrowserContextImpl::Initialize() {
|
||||
base::ThreadRestrictions::ScopedAllowIO allow_io;
|
||||
if (!base::DirectoryExists(cache_path_) &&
|
||||
!base::CreateDirectory(cache_path_)) {
|
||||
LOG(ERROR) << "The cache_path directory could not be created: " <<
|
||||
cache_path_.value();
|
||||
LOG(ERROR) << "The cache_path directory could not be created: "
|
||||
<< cache_path_.value();
|
||||
cache_path_ = base::FilePath();
|
||||
CefString(&settings_.cache_path).clear();
|
||||
}
|
||||
@@ -271,8 +267,8 @@ void CefBrowserContextImpl::Initialize() {
|
||||
|
||||
// Initialize a temporary PrefService object that may be referenced during
|
||||
// BrowserContextServices initialization.
|
||||
pref_service_ = browser_prefs::CreatePrefService(
|
||||
this, base::FilePath(), false, true);
|
||||
pref_service_ =
|
||||
browser_prefs::CreatePrefService(this, base::FilePath(), false, true);
|
||||
|
||||
CefBrowserContext::Initialize();
|
||||
|
||||
@@ -283,12 +279,11 @@ void CefBrowserContextImpl::Initialize() {
|
||||
// Initialize visited links management.
|
||||
base::FilePath visited_link_path;
|
||||
if (!cache_path_.empty())
|
||||
visited_link_path = cache_path_.Append(FILE_PATH_LITERAL("Visited Links"));
|
||||
visited_link_path = cache_path_.Append(FILE_PATH_LITERAL("Visited Links"));
|
||||
visitedlink_listener_ = new CefVisitedLinkListener;
|
||||
visitedlink_master_.reset(
|
||||
new visitedlink::VisitedLinkMaster(visitedlink_listener_, this,
|
||||
!visited_link_path.empty(), false,
|
||||
visited_link_path, 0));
|
||||
visitedlink_master_.reset(new visitedlink::VisitedLinkMaster(
|
||||
visitedlink_listener_, this, !visited_link_path.empty(), false,
|
||||
visited_link_path, 0));
|
||||
visitedlink_listener_->CreateListenerForContext(this);
|
||||
visitedlink_master_->Init();
|
||||
|
||||
@@ -376,8 +371,8 @@ base::FilePath CefBrowserContextImpl::GetPath() const {
|
||||
}
|
||||
|
||||
std::unique_ptr<content::ZoomLevelDelegate>
|
||||
CefBrowserContextImpl::CreateZoomLevelDelegate(
|
||||
const base::FilePath& partition_path) {
|
||||
CefBrowserContextImpl::CreateZoomLevelDelegate(
|
||||
const base::FilePath& partition_path) {
|
||||
if (cache_path_.empty())
|
||||
return std::unique_ptr<content::ZoomLevelDelegate>();
|
||||
|
||||
@@ -391,7 +386,7 @@ bool CefBrowserContextImpl::IsOffTheRecord() const {
|
||||
}
|
||||
|
||||
content::DownloadManagerDelegate*
|
||||
CefBrowserContextImpl::GetDownloadManagerDelegate() {
|
||||
CefBrowserContextImpl::GetDownloadManagerDelegate() {
|
||||
DCHECK(!download_manager_delegate_.get());
|
||||
|
||||
content::DownloadManager* manager = BrowserContext::GetDownloadManager(this);
|
||||
@@ -405,17 +400,17 @@ content::BrowserPluginGuestManager* CefBrowserContextImpl::GetGuestManager() {
|
||||
}
|
||||
|
||||
storage::SpecialStoragePolicy*
|
||||
CefBrowserContextImpl::GetSpecialStoragePolicy() {
|
||||
CefBrowserContextImpl::GetSpecialStoragePolicy() {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
content::PushMessagingService*
|
||||
CefBrowserContextImpl::GetPushMessagingService() {
|
||||
CefBrowserContextImpl::GetPushMessagingService() {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
content::SSLHostStateDelegate*
|
||||
CefBrowserContextImpl::GetSSLHostStateDelegate() {
|
||||
CefBrowserContextImpl::GetSSLHostStateDelegate() {
|
||||
if (!ssl_host_state_delegate_.get())
|
||||
ssl_host_state_delegate_.reset(new CefSSLHostStateDelegate());
|
||||
return ssl_host_state_delegate_.get();
|
||||
@@ -428,7 +423,7 @@ content::PermissionManager* CefBrowserContextImpl::GetPermissionManager() {
|
||||
}
|
||||
|
||||
content::BackgroundSyncController*
|
||||
CefBrowserContextImpl::GetBackgroundSyncController() {
|
||||
CefBrowserContextImpl::GetBackgroundSyncController() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -447,32 +442,30 @@ net::URLRequestContextGetter* CefBrowserContextImpl::CreateRequestContext(
|
||||
// Handle only chrome-extension:// requests. CEF does not support
|
||||
// chrome-extension-resource:// requests (it does not store shared extension
|
||||
// data in its installation directory).
|
||||
extensions::InfoMap* extension_info_map =
|
||||
extension_system()->info_map();
|
||||
extensions::InfoMap* extension_info_map = extension_system()->info_map();
|
||||
(*protocol_handlers)[extensions::kExtensionScheme] =
|
||||
linked_ptr<net::URLRequestJobFactory::ProtocolHandler>(
|
||||
extensions::CreateExtensionProtocolHandler(
|
||||
IsOffTheRecord(), extension_info_map).release());
|
||||
extensions::CreateExtensionProtocolHandler(IsOffTheRecord(),
|
||||
extension_info_map)
|
||||
.release());
|
||||
}
|
||||
|
||||
url_request_getter_ = new CefURLRequestContextGetterImpl(
|
||||
settings_,
|
||||
GetPrefs(),
|
||||
settings_, GetPrefs(),
|
||||
BrowserThread::GetTaskRunnerForThread(BrowserThread::IO),
|
||||
BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE),
|
||||
protocol_handlers,
|
||||
std::move(proxy_config_service),
|
||||
protocol_handlers, std::move(proxy_config_service),
|
||||
std::move(request_interceptors));
|
||||
resource_context()->set_url_request_context_getter(url_request_getter_.get());
|
||||
return url_request_getter_.get();
|
||||
}
|
||||
|
||||
net::URLRequestContextGetter*
|
||||
CefBrowserContextImpl::CreateRequestContextForStoragePartition(
|
||||
const base::FilePath& partition_path,
|
||||
bool in_memory,
|
||||
content::ProtocolHandlerMap* protocol_handlers,
|
||||
content::URLRequestInterceptorScopedVector request_interceptors) {
|
||||
CefBrowserContextImpl::CreateRequestContextForStoragePartition(
|
||||
const base::FilePath& partition_path,
|
||||
bool in_memory,
|
||||
content::ProtocolHandlerMap* protocol_handlers,
|
||||
content::URLRequestInterceptorScopedVector request_interceptors) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -518,7 +511,7 @@ HostContentSettingsMap* CefBrowserContextImpl::GetHostContentSettingsMap() {
|
||||
const base::CommandLine* command_line =
|
||||
base::CommandLine::ForCurrentProcess();
|
||||
const std::string& plugin_policy_str =
|
||||
command_line->GetSwitchValueASCII(switches::kPluginPolicy);
|
||||
command_line->GetSwitchValueASCII(switches::kPluginPolicy);
|
||||
if (!plugin_policy_str.empty()) {
|
||||
ContentSetting plugin_policy = CONTENT_SETTING_ALLOW;
|
||||
if (base::LowerCaseEqualsASCII(plugin_policy_str,
|
||||
|
@@ -39,8 +39,7 @@ class CefBrowserContextImpl : public CefBrowserContext,
|
||||
const base::FilePath& cache_path);
|
||||
|
||||
// Returns the underlying CefBrowserContextImpl if any.
|
||||
static CefBrowserContextImpl* GetForContext(
|
||||
content::BrowserContext* context);
|
||||
static CefBrowserContextImpl* GetForContext(content::BrowserContext* context);
|
||||
|
||||
// Returns all existing CefBrowserContextImpl.
|
||||
static std::vector<CefBrowserContextImpl*> GetAll();
|
||||
@@ -72,14 +71,12 @@ class CefBrowserContextImpl : public CefBrowserContext,
|
||||
content::BackgroundSyncController* GetBackgroundSyncController() override;
|
||||
net::URLRequestContextGetter* CreateRequestContext(
|
||||
content::ProtocolHandlerMap* protocol_handlers,
|
||||
content::URLRequestInterceptorScopedVector request_interceptors)
|
||||
override;
|
||||
content::URLRequestInterceptorScopedVector request_interceptors) override;
|
||||
net::URLRequestContextGetter* CreateRequestContextForStoragePartition(
|
||||
const base::FilePath& partition_path,
|
||||
bool in_memory,
|
||||
content::ProtocolHandlerMap* protocol_handlers,
|
||||
content::URLRequestInterceptorScopedVector request_interceptors)
|
||||
override;
|
||||
content::URLRequestInterceptorScopedVector request_interceptors) override;
|
||||
content::StoragePartition* GetStoragePartitionProxy(
|
||||
content::BrowserContext* browser_context,
|
||||
content::StoragePartition* partition_impl) override;
|
||||
|
@@ -88,8 +88,8 @@ void CefBrowserContextProxy::Initialize() {
|
||||
CefBrowserContext::PostInitialize();
|
||||
}
|
||||
|
||||
base::SupportsUserData::Data*
|
||||
CefBrowserContextProxy::GetUserData(const void* key) const {
|
||||
base::SupportsUserData::Data* CefBrowserContextProxy::GetUserData(
|
||||
const void* key) const {
|
||||
if (ShouldProxyUserData(key))
|
||||
return parent_->GetUserData(key);
|
||||
return BrowserContext::GetUserData(key);
|
||||
@@ -122,8 +122,8 @@ base::FilePath CefBrowserContextProxy::GetPath() const {
|
||||
}
|
||||
|
||||
std::unique_ptr<content::ZoomLevelDelegate>
|
||||
CefBrowserContextProxy::CreateZoomLevelDelegate(
|
||||
const base::FilePath& partition_path) {
|
||||
CefBrowserContextProxy::CreateZoomLevelDelegate(
|
||||
const base::FilePath& partition_path) {
|
||||
return parent_->CreateZoomLevelDelegate(partition_path);
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ bool CefBrowserContextProxy::IsOffTheRecord() const {
|
||||
}
|
||||
|
||||
content::DownloadManagerDelegate*
|
||||
CefBrowserContextProxy::GetDownloadManagerDelegate() {
|
||||
CefBrowserContextProxy::GetDownloadManagerDelegate() {
|
||||
DCHECK(!download_manager_delegate_.get());
|
||||
|
||||
content::DownloadManager* manager = BrowserContext::GetDownloadManager(this);
|
||||
@@ -145,17 +145,17 @@ content::BrowserPluginGuestManager* CefBrowserContextProxy::GetGuestManager() {
|
||||
}
|
||||
|
||||
storage::SpecialStoragePolicy*
|
||||
CefBrowserContextProxy::GetSpecialStoragePolicy() {
|
||||
CefBrowserContextProxy::GetSpecialStoragePolicy() {
|
||||
return parent_->GetSpecialStoragePolicy();
|
||||
}
|
||||
|
||||
content::PushMessagingService*
|
||||
CefBrowserContextProxy::GetPushMessagingService() {
|
||||
CefBrowserContextProxy::GetPushMessagingService() {
|
||||
return parent_->GetPushMessagingService();
|
||||
}
|
||||
|
||||
content::SSLHostStateDelegate*
|
||||
CefBrowserContextProxy::GetSSLHostStateDelegate() {
|
||||
CefBrowserContextProxy::GetSSLHostStateDelegate() {
|
||||
return parent_->GetSSLHostStateDelegate();
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@ content::PermissionManager* CefBrowserContextProxy::GetPermissionManager() {
|
||||
}
|
||||
|
||||
content::BackgroundSyncController*
|
||||
CefBrowserContextProxy::GetBackgroundSyncController() {
|
||||
CefBrowserContextProxy::GetBackgroundSyncController() {
|
||||
return parent_->GetBackgroundSyncController();
|
||||
}
|
||||
|
||||
@@ -178,11 +178,11 @@ net::URLRequestContextGetter* CefBrowserContextProxy::CreateRequestContext(
|
||||
}
|
||||
|
||||
net::URLRequestContextGetter*
|
||||
CefBrowserContextProxy::CreateRequestContextForStoragePartition(
|
||||
const base::FilePath& partition_path,
|
||||
bool in_memory,
|
||||
content::ProtocolHandlerMap* protocol_handlers,
|
||||
content::URLRequestInterceptorScopedVector request_interceptors) {
|
||||
CefBrowserContextProxy::CreateRequestContextForStoragePartition(
|
||||
const base::FilePath& partition_path,
|
||||
bool in_memory,
|
||||
content::ProtocolHandlerMap* protocol_handlers,
|
||||
content::URLRequestInterceptorScopedVector request_interceptors) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -231,8 +231,7 @@ CefBrowserContextProxy::GetOrCreateStoragePartitionProxy(
|
||||
resource_context()->set_url_request_context_getter(
|
||||
url_request_getter.get());
|
||||
storage_partition_proxy_.reset(
|
||||
new CefStoragePartitionProxy(partition_impl,
|
||||
url_request_getter.get()));
|
||||
new CefStoragePartitionProxy(partition_impl, url_request_getter.get()));
|
||||
|
||||
// Associates UserData keys with the ResourceContext.
|
||||
// Called from StoragePartitionImplMap::Get() for CefBrowserContextImpl.
|
||||
|
@@ -47,14 +47,12 @@ class CefBrowserContextProxy : public CefBrowserContext {
|
||||
content::BackgroundSyncController* GetBackgroundSyncController() override;
|
||||
net::URLRequestContextGetter* CreateRequestContext(
|
||||
content::ProtocolHandlerMap* protocol_handlers,
|
||||
content::URLRequestInterceptorScopedVector request_interceptors)
|
||||
override;
|
||||
content::URLRequestInterceptorScopedVector request_interceptors) override;
|
||||
net::URLRequestContextGetter* CreateRequestContextForStoragePartition(
|
||||
const base::FilePath& partition_path,
|
||||
bool in_memory,
|
||||
content::ProtocolHandlerMap* protocol_handlers,
|
||||
content::URLRequestInterceptorScopedVector request_interceptors)
|
||||
override;
|
||||
content::URLRequestInterceptorScopedVector request_interceptors) override;
|
||||
void RegisterInProcessServices(StaticServiceMap* services) override;
|
||||
|
||||
// Profile methods.
|
||||
@@ -69,11 +67,9 @@ class CefBrowserContextProxy : public CefBrowserContext {
|
||||
void AddVisitedURLs(const std::vector<GURL>& urls) override;
|
||||
|
||||
content::StoragePartition* GetOrCreateStoragePartitionProxy(
|
||||
content::StoragePartition* partition_impl);
|
||||
content::StoragePartition* partition_impl);
|
||||
|
||||
CefBrowserContextImpl* parent() const {
|
||||
return parent_;
|
||||
}
|
||||
CefBrowserContextImpl* parent() const { return parent_; }
|
||||
|
||||
private:
|
||||
// Allow deletion via std::unique_ptr() only.
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -80,7 +80,7 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
// Used for handling the response to command messages.
|
||||
class CommandResponseHandler : public virtual CefBaseRefCounted {
|
||||
public:
|
||||
virtual void OnResponse(const std::string& response) =0;
|
||||
virtual void OnResponse(const std::string& response) = 0;
|
||||
};
|
||||
|
||||
// Interface to implement for observers that wish to be informed of changes
|
||||
@@ -89,7 +89,7 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
public:
|
||||
// Called before |browser| is destroyed. Any references to |browser| should
|
||||
// be cleared when this method is called.
|
||||
virtual void OnBrowserDestroyed(CefBrowserHostImpl* browser) =0;
|
||||
virtual void OnBrowserDestroyed(CefBrowserHostImpl* browser) = 0;
|
||||
|
||||
protected:
|
||||
virtual ~Observer() {}
|
||||
@@ -142,11 +142,12 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
static CefRefPtr<CefBrowserHostImpl> GetBrowserForRequest(
|
||||
const net::URLRequest* request);
|
||||
// Returns the browser associated with the specified view routing IDs.
|
||||
static CefRefPtr<CefBrowserHostImpl> GetBrowserForView(
|
||||
int render_process_id, int render_routing_id);
|
||||
static CefRefPtr<CefBrowserHostImpl> GetBrowserForView(int render_process_id,
|
||||
int render_routing_id);
|
||||
// Returns the browser associated with the specified frame routing IDs.
|
||||
static CefRefPtr<CefBrowserHostImpl> GetBrowserForFrame(
|
||||
int render_process_id, int render_routing_id);
|
||||
int render_process_id,
|
||||
int render_routing_id);
|
||||
|
||||
// CefBrowserHost methods.
|
||||
CefRefPtr<CefBrowser> GetBrowser() override;
|
||||
@@ -160,13 +161,12 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
CefRefPtr<CefRequestContext> GetRequestContext() override;
|
||||
double GetZoomLevel() override;
|
||||
void SetZoomLevel(double zoomLevel) override;
|
||||
void RunFileDialog(
|
||||
FileDialogMode mode,
|
||||
const CefString& title,
|
||||
const CefString& default_file_path,
|
||||
const std::vector<CefString>& accept_filters,
|
||||
int selected_accept_filter,
|
||||
CefRefPtr<CefRunFileDialogCallback> callback) override;
|
||||
void RunFileDialog(FileDialogMode mode,
|
||||
const CefString& title,
|
||||
const CefString& default_file_path,
|
||||
const std::vector<CefString>& accept_filters,
|
||||
int selected_accept_filter,
|
||||
CefRefPtr<CefRunFileDialogCallback> callback) override;
|
||||
void StartDownload(const CefString& url) override;
|
||||
void DownloadImage(const CefString& image_url,
|
||||
bool is_favicon,
|
||||
@@ -177,8 +177,11 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
void PrintToPDF(const CefString& path,
|
||||
const CefPdfPrintSettings& settings,
|
||||
CefRefPtr<CefPdfPrintCallback> callback) override;
|
||||
void Find(int identifier, const CefString& searchText,
|
||||
bool forward, bool matchCase, bool findNext) override;
|
||||
void Find(int identifier,
|
||||
const CefString& searchText,
|
||||
bool forward,
|
||||
bool matchCase,
|
||||
bool findNext) override;
|
||||
void StopFinding(bool clearSelection) override;
|
||||
void ShowDevTools(const CefWindowInfo& windowInfo,
|
||||
CefRefPtr<CefClient> client,
|
||||
@@ -186,9 +189,8 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
const CefPoint& inspect_element_at) override;
|
||||
void CloseDevTools() override;
|
||||
bool HasDevTools() override;
|
||||
void GetNavigationEntries(
|
||||
CefRefPtr<CefNavigationEntryVisitor> visitor,
|
||||
bool current_only) override;
|
||||
void GetNavigationEntries(CefRefPtr<CefNavigationEntryVisitor> visitor,
|
||||
bool current_only) override;
|
||||
void SetMouseCursorChangeDisabled(bool disabled) override;
|
||||
bool IsMouseCursorChangeDisabled() override;
|
||||
bool IsWindowRenderingDisabled() override;
|
||||
@@ -201,11 +203,12 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
void SendKeyEvent(const CefKeyEvent& event) override;
|
||||
void SendMouseClickEvent(const CefMouseEvent& event,
|
||||
MouseButtonType type,
|
||||
bool mouseUp, int clickCount) override;
|
||||
void SendMouseMoveEvent(const CefMouseEvent& event,
|
||||
bool mouseLeave) override;
|
||||
bool mouseUp,
|
||||
int clickCount) override;
|
||||
void SendMouseMoveEvent(const CefMouseEvent& event, bool mouseLeave) override;
|
||||
void SendMouseWheelEvent(const CefMouseEvent& event,
|
||||
int deltaX, int deltaY) override;
|
||||
int deltaX,
|
||||
int deltaY) override;
|
||||
void SendFocusEvent(bool setFocus) override;
|
||||
void SendCaptureLostEvent() override;
|
||||
void NotifyMoveOrResizeStarted() override;
|
||||
@@ -215,7 +218,8 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
const std::vector<CefCompositionUnderline>& underlines,
|
||||
const CefRange& replacement_range,
|
||||
const CefRange& selection_range) override;
|
||||
void ImeCommitText(const CefString& text, const CefRange& replacement_range,
|
||||
void ImeCommitText(const CefString& text,
|
||||
const CefRange& replacement_range,
|
||||
int relative_cursor_pos) override;
|
||||
void ImeFinishComposingText(bool keep_selection) override;
|
||||
void ImeCancelComposition() override;
|
||||
@@ -252,9 +256,8 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
size_t GetFrameCount() override;
|
||||
void GetFrameIdentifiers(std::vector<int64>& identifiers) override;
|
||||
void GetFrameNames(std::vector<CefString>& names) override;
|
||||
bool SendProcessMessage(
|
||||
CefProcessId target_process,
|
||||
CefRefPtr<CefProcessMessage> message) override;
|
||||
bool SendProcessMessage(CefProcessId target_process,
|
||||
CefRefPtr<CefProcessMessage> message) override;
|
||||
|
||||
// Returns true if windowless rendering is enabled.
|
||||
bool IsWindowless() const;
|
||||
@@ -299,16 +302,21 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
const std::string& extra_headers);
|
||||
|
||||
// Load the specified string.
|
||||
void LoadString(int64 frame_id, const std::string& string,
|
||||
void LoadString(int64 frame_id,
|
||||
const std::string& string,
|
||||
const std::string& url);
|
||||
|
||||
// Send a command to the renderer for execution.
|
||||
void SendCommand(int64 frame_id, const std::string& command,
|
||||
void SendCommand(int64 frame_id,
|
||||
const std::string& command,
|
||||
CefRefPtr<CefResponseManager::Handler> responseHandler);
|
||||
|
||||
// Send code to the renderer for execution.
|
||||
void SendCode(int64 frame_id, bool is_javascript, const std::string& code,
|
||||
const std::string& script_url, int script_start_line,
|
||||
void SendCode(int64 frame_id,
|
||||
bool is_javascript,
|
||||
const std::string& code,
|
||||
const std::string& script_url,
|
||||
int script_start_line,
|
||||
CefRefPtr<CefResponseManager::Handler> responseHandler);
|
||||
|
||||
bool SendProcessMessage(CefProcessId target_process,
|
||||
@@ -329,13 +337,12 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
// scaling will be applied to the result.
|
||||
gfx::Point GetScreenPoint(const gfx::Point& view) const;
|
||||
|
||||
void StartDragging(
|
||||
const content::DropData& drop_data,
|
||||
blink::WebDragOperationsMask allowed_ops,
|
||||
const gfx::ImageSkia& image,
|
||||
const gfx::Vector2d& image_offset,
|
||||
const content::DragEventSourceInfo& event_info,
|
||||
content::RenderWidgetHostImpl* source_rwh);
|
||||
void StartDragging(const content::DropData& drop_data,
|
||||
blink::WebDragOperationsMask allowed_ops,
|
||||
const gfx::ImageSkia& image,
|
||||
const gfx::Vector2d& image_offset,
|
||||
const content::DragEventSourceInfo& event_info,
|
||||
content::RenderWidgetHostImpl* source_rwh);
|
||||
void UpdateDragCursor(blink::WebDragOperation operation);
|
||||
|
||||
// Thread safe accessors.
|
||||
@@ -354,9 +361,8 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
const CefFileDialogRunner::FileChooserParams& params,
|
||||
const CefFileDialogRunner::RunFileChooserCallback& callback);
|
||||
|
||||
bool HandleContextMenu(
|
||||
content::WebContents* web_contents,
|
||||
const content::ContextMenuParams& params);
|
||||
bool HandleContextMenu(content::WebContents* web_contents,
|
||||
const content::ContextMenuParams& params);
|
||||
|
||||
// Returns the WebContents most likely to handle an action. If extensions are
|
||||
// enabled and this browser has a full-page guest (for example, a full-page
|
||||
@@ -379,8 +385,7 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
void LoadingStateChanged(content::WebContents* source,
|
||||
bool to_different_document) override;
|
||||
void CloseContents(content::WebContents* source) override;
|
||||
void UpdateTargetURL(content::WebContents* source,
|
||||
const GURL& url) override;
|
||||
void UpdateTargetURL(content::WebContents* source, const GURL& url) override;
|
||||
bool DidAddMessageToConsole(content::WebContents* source,
|
||||
int32_t level,
|
||||
const base::string16& message,
|
||||
@@ -389,20 +394,17 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
void BeforeUnloadFired(content::WebContents* source,
|
||||
bool proceed,
|
||||
bool* proceed_to_fire_unload) override;
|
||||
bool TakeFocus(content::WebContents* source,
|
||||
bool reverse) override;
|
||||
bool HandleContextMenu(
|
||||
const content::ContextMenuParams& params) override;
|
||||
bool TakeFocus(content::WebContents* source, bool reverse) override;
|
||||
bool HandleContextMenu(const content::ContextMenuParams& params) override;
|
||||
content::KeyboardEventProcessingResult PreHandleKeyboardEvent(
|
||||
content::WebContents* source,
|
||||
const content::NativeWebKeyboardEvent& event) override;
|
||||
void HandleKeyboardEvent(
|
||||
content::WebContents* source,
|
||||
const content::NativeWebKeyboardEvent& event) override;
|
||||
bool CanDragEnter(
|
||||
content::WebContents* source,
|
||||
const content::DropData& data,
|
||||
blink::WebDragOperationsMask operations_allowed) override;
|
||||
bool CanDragEnter(content::WebContents* source,
|
||||
const content::DropData& data,
|
||||
blink::WebDragOperationsMask operations_allowed) override;
|
||||
void GetCustomWebContentsView(
|
||||
content::WebContents* web_contents,
|
||||
const GURL& target_url,
|
||||
@@ -420,9 +422,8 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
content::WebContents* web_contents) override;
|
||||
content::JavaScriptDialogManager* GetJavaScriptDialogManager(
|
||||
content::WebContents* source) override;
|
||||
void RunFileChooser(
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
const content::FileChooserParams& params) override;
|
||||
void RunFileChooser(content::RenderFrameHost* render_frame_host,
|
||||
const content::FileChooserParams& params) override;
|
||||
bool EmbedsFullscreenWidget() const override;
|
||||
void EnterFullscreenModeForTab(content::WebContents* web_contents,
|
||||
const GURL& origin) override;
|
||||
@@ -431,13 +432,12 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
const content::WebContents* web_contents) const override;
|
||||
blink::WebDisplayMode GetDisplayMode(
|
||||
const content::WebContents* web_contents) const override;
|
||||
void FindReply(
|
||||
content::WebContents* web_contents,
|
||||
int request_id,
|
||||
int number_of_matches,
|
||||
const gfx::Rect& selection_rect,
|
||||
int active_match_ordinal,
|
||||
bool final_update) override;
|
||||
void FindReply(content::WebContents* web_contents,
|
||||
int request_id,
|
||||
int number_of_matches,
|
||||
const gfx::Rect& selection_rect,
|
||||
int active_match_ordinal,
|
||||
bool final_update) override;
|
||||
void UpdatePreferredSize(content::WebContents* source,
|
||||
const gfx::Size& pref_size) override;
|
||||
void RequestMediaAccessPermission(
|
||||
@@ -507,11 +507,10 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
void OnFrameIdentified(int64 frame_id,
|
||||
int64 parent_frame_id,
|
||||
base::string16 name);
|
||||
void OnDidFinishLoad(
|
||||
int64 frame_id,
|
||||
const GURL& validated_url,
|
||||
bool is_main_frame,
|
||||
int http_status_code);
|
||||
void OnDidFinishLoad(int64 frame_id,
|
||||
const GURL& validated_url,
|
||||
bool is_main_frame,
|
||||
int http_status_code);
|
||||
void OnUpdateDraggableRegions(
|
||||
const std::vector<Cef_DraggableRegion_Params>& regions);
|
||||
void OnRequest(const Cef_Request_Params& params);
|
||||
@@ -520,16 +519,17 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
|
||||
// content::NotificationObserver methods.
|
||||
void Observe(int type,
|
||||
const content::NotificationSource& source,
|
||||
const content::NotificationDetails& details) override;
|
||||
const content::NotificationSource& source,
|
||||
const content::NotificationDetails& details) override;
|
||||
|
||||
CefBrowserHostImpl(const CefBrowserSettings& settings,
|
||||
CefRefPtr<CefClient> client,
|
||||
content::WebContents* web_contents,
|
||||
scoped_refptr<CefBrowserInfo> browser_info,
|
||||
CefRefPtr<CefBrowserHostImpl> opener,
|
||||
CefRefPtr<CefRequestContext> request_context,
|
||||
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate);
|
||||
CefBrowserHostImpl(
|
||||
const CefBrowserSettings& settings,
|
||||
CefRefPtr<CefClient> client,
|
||||
content::WebContents* web_contents,
|
||||
scoped_refptr<CefBrowserInfo> browser_info,
|
||||
CefRefPtr<CefBrowserHostImpl> opener,
|
||||
CefRefPtr<CefRequestContext> request_context,
|
||||
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate);
|
||||
|
||||
// Give the platform delegate an opportunity to create the host window.
|
||||
bool CreateHostWindow();
|
||||
@@ -544,13 +544,10 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
// Remove the references to all frames and mark them as detached.
|
||||
void DetachAllFrames();
|
||||
|
||||
void OnAddressChange(CefRefPtr<CefFrame> frame,
|
||||
const GURL& url);
|
||||
void OnAddressChange(CefRefPtr<CefFrame> frame, const GURL& url);
|
||||
void OnLoadStart(CefRefPtr<CefFrame> frame,
|
||||
ui::PageTransition transition_type);
|
||||
void OnLoadError(CefRefPtr<CefFrame> frame,
|
||||
const GURL& url,
|
||||
int error_code);
|
||||
void OnLoadError(CefRefPtr<CefFrame> frame, const GURL& url, int error_code);
|
||||
void OnLoadEnd(CefRefPtr<CefFrame> frame,
|
||||
const GURL& url,
|
||||
int http_status_code);
|
||||
@@ -588,7 +585,7 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
bool queue_messages_;
|
||||
|
||||
// Map of unique frame ids to CefFrameHostImpl references.
|
||||
typedef std::map<int64, CefRefPtr<CefFrameHostImpl> > FrameMap;
|
||||
typedef std::map<int64, CefRefPtr<CefFrameHostImpl>> FrameMap;
|
||||
FrameMap frames_;
|
||||
// The unique frame id currently identified as the main frame.
|
||||
int64 main_frame_id_;
|
||||
|
@@ -12,41 +12,45 @@
|
||||
// CefBrowserInfo::RenderIDManager
|
||||
|
||||
CefBrowserInfo::RenderIDManager::RenderIDManager(base::Lock* lock)
|
||||
: lock_(lock) {
|
||||
: lock_(lock) {
|
||||
DCHECK(lock);
|
||||
}
|
||||
|
||||
void CefBrowserInfo::RenderIDManager::add_render_view_id(
|
||||
int render_process_id, int render_routing_id) {
|
||||
int render_process_id,
|
||||
int render_routing_id) {
|
||||
add_render_id(&render_view_id_set_, render_process_id, render_routing_id);
|
||||
}
|
||||
|
||||
void CefBrowserInfo::RenderIDManager::add_render_frame_id(
|
||||
int render_process_id, int render_routing_id) {
|
||||
int render_process_id,
|
||||
int render_routing_id) {
|
||||
add_render_id(&render_frame_id_set_, render_process_id, render_routing_id);
|
||||
}
|
||||
|
||||
void CefBrowserInfo::RenderIDManager::remove_render_view_id(
|
||||
int render_process_id, int render_routing_id) {
|
||||
int render_process_id,
|
||||
int render_routing_id) {
|
||||
remove_render_id(&render_view_id_set_, render_process_id, render_routing_id);
|
||||
}
|
||||
|
||||
void CefBrowserInfo::RenderIDManager::remove_render_frame_id(
|
||||
int render_process_id, int render_routing_id) {
|
||||
int render_process_id,
|
||||
int render_routing_id) {
|
||||
remove_render_id(&render_frame_id_set_, render_process_id, render_routing_id);
|
||||
}
|
||||
|
||||
bool CefBrowserInfo::RenderIDManager::is_render_view_id_match(
|
||||
int render_process_id, int render_routing_id) const {
|
||||
return is_render_id_match(&render_view_id_set_,
|
||||
render_process_id,
|
||||
int render_process_id,
|
||||
int render_routing_id) const {
|
||||
return is_render_id_match(&render_view_id_set_, render_process_id,
|
||||
render_routing_id);
|
||||
}
|
||||
|
||||
bool CefBrowserInfo::RenderIDManager::is_render_frame_id_match(
|
||||
int render_process_id, int render_routing_id) const {
|
||||
return is_render_id_match(&render_frame_id_set_,
|
||||
render_process_id,
|
||||
int render_process_id,
|
||||
int render_routing_id) const {
|
||||
return is_render_id_match(&render_frame_id_set_, render_process_id,
|
||||
render_routing_id);
|
||||
}
|
||||
|
||||
@@ -80,8 +84,8 @@ void CefBrowserInfo::RenderIDManager::remove_render_id(RenderIdSet* id_set,
|
||||
if (id_set->empty())
|
||||
return;
|
||||
|
||||
bool erased = id_set->erase(
|
||||
std::make_pair(render_process_id, render_routing_id)) != 0;
|
||||
bool erased =
|
||||
id_set->erase(std::make_pair(render_process_id, render_routing_id)) != 0;
|
||||
DCHECK(erased);
|
||||
}
|
||||
|
||||
@@ -99,7 +103,6 @@ bool CefBrowserInfo::RenderIDManager::is_render_id_match(
|
||||
return (it != id_set->end());
|
||||
}
|
||||
|
||||
|
||||
// CefBrowserInfo
|
||||
|
||||
CefBrowserInfo::CefBrowserInfo(int browser_id, bool is_popup)
|
||||
@@ -111,8 +114,7 @@ CefBrowserInfo::CefBrowserInfo(int browser_id, bool is_popup)
|
||||
DCHECK_GT(browser_id, 0);
|
||||
}
|
||||
|
||||
CefBrowserInfo::~CefBrowserInfo() {
|
||||
}
|
||||
CefBrowserInfo::~CefBrowserInfo() {}
|
||||
|
||||
void CefBrowserInfo::set_windowless(bool windowless) {
|
||||
is_windowless_ = windowless;
|
||||
|
@@ -39,10 +39,10 @@ class CefBrowserInfo : public base::RefCountedThreadSafe<CefBrowserInfo> {
|
||||
bool is_render_view_id_match(int render_process_id,
|
||||
int render_routing_id) const;
|
||||
bool is_render_frame_id_match(int render_process_id,
|
||||
int render_routing_id)const ;
|
||||
int render_routing_id) const;
|
||||
|
||||
private:
|
||||
typedef std::set<std::pair<int, int> > RenderIdSet;
|
||||
typedef std::set<std::pair<int, int>> RenderIdSet;
|
||||
|
||||
void add_render_id(RenderIdSet* id_set,
|
||||
int render_process_id,
|
||||
@@ -81,9 +81,7 @@ class CefBrowserInfo : public base::RefCountedThreadSafe<CefBrowserInfo> {
|
||||
void set_windowless(bool windowless);
|
||||
|
||||
// Returns the render ID manager for this browser.
|
||||
RenderIDManager* render_id_manager() {
|
||||
return &render_id_manager_;
|
||||
}
|
||||
RenderIDManager* render_id_manager() { return &render_id_manager_; }
|
||||
|
||||
// Returns the render ID manager for guest views owned by this browser.
|
||||
RenderIDManager* guest_render_id_manager() {
|
||||
|
@@ -6,20 +6,20 @@
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "libcef/browser/browser_platform_delegate.h"
|
||||
#include "libcef/browser/browser_host_impl.h"
|
||||
#include "libcef/browser/browser_platform_delegate.h"
|
||||
#include "libcef/browser/extensions/browser_extensions_util.h"
|
||||
#include "libcef/browser/thread_util.h"
|
||||
#include "libcef/common/cef_messages.h"
|
||||
#include "libcef/common/extensions/extensions_util.h"
|
||||
#include "libcef/browser/extensions/browser_extensions_util.h"
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "content/common/view_messages.h"
|
||||
#include "content/public/browser/render_frame_host.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
#include "content/public/browser/render_view_host.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "content/public/common/child_process_host.h"
|
||||
#include "content/common/view_messages.h"
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -32,25 +32,24 @@ void TranslatePopupFeatures(const blink::mojom::WindowFeatures& webKitFeatures,
|
||||
features.width = static_cast<int>(webKitFeatures.width);
|
||||
features.widthSet = webKitFeatures.has_width;
|
||||
features.height = static_cast<int>(webKitFeatures.height);
|
||||
features.heightSet = webKitFeatures.has_height;
|
||||
features.heightSet = webKitFeatures.has_height;
|
||||
|
||||
features.menuBarVisible = webKitFeatures.menu_bar_visible;
|
||||
features.statusBarVisible = webKitFeatures.status_bar_visible;
|
||||
features.toolBarVisible = webKitFeatures.tool_bar_visible;
|
||||
features.locationBarVisible = webKitFeatures.location_bar_visible;
|
||||
features.scrollbarsVisible = webKitFeatures.scrollbars_visible;
|
||||
features.resizable = webKitFeatures.resizable;
|
||||
features.menuBarVisible = webKitFeatures.menu_bar_visible;
|
||||
features.statusBarVisible = webKitFeatures.status_bar_visible;
|
||||
features.toolBarVisible = webKitFeatures.tool_bar_visible;
|
||||
features.locationBarVisible = webKitFeatures.location_bar_visible;
|
||||
features.scrollbarsVisible = webKitFeatures.scrollbars_visible;
|
||||
features.resizable = webKitFeatures.resizable;
|
||||
|
||||
features.fullscreen = webKitFeatures.fullscreen;
|
||||
features.dialog = webKitFeatures.dialog;
|
||||
features.fullscreen = webKitFeatures.fullscreen;
|
||||
features.dialog = webKitFeatures.dialog;
|
||||
}
|
||||
|
||||
CefBrowserInfoManager* g_info_manager = nullptr;
|
||||
|
||||
} // namespace
|
||||
|
||||
CefBrowserInfoManager::CefBrowserInfoManager()
|
||||
: next_browser_id_(0) {
|
||||
CefBrowserInfoManager::CefBrowserInfoManager() : next_browser_id_(0) {
|
||||
DCHECK(!g_info_manager);
|
||||
g_info_manager = this;
|
||||
}
|
||||
@@ -100,8 +99,8 @@ scoped_refptr<CefBrowserInfo> CefBrowserInfoManager::CreatePopupBrowserInfo(
|
||||
|
||||
scoped_refptr<CefBrowserInfo> browser_info =
|
||||
new CefBrowserInfo(++next_browser_id_, true);
|
||||
browser_info->render_id_manager()->add_render_view_id(
|
||||
render_process_id, render_view_routing_id);
|
||||
browser_info->render_id_manager()->add_render_view_id(render_process_id,
|
||||
render_view_routing_id);
|
||||
browser_info->render_id_manager()->add_render_frame_id(
|
||||
render_process_id, render_frame_routing_id);
|
||||
browser_info_list_.push_back(browser_info);
|
||||
@@ -117,8 +116,8 @@ scoped_refptr<CefBrowserInfo> CefBrowserInfoManager::CreatePopupBrowserInfo(
|
||||
if (info->render_process_id == render_process_id &&
|
||||
info->render_view_routing_id == render_view_routing_id &&
|
||||
info->render_frame_routing_id == render_frame_routing_id) {
|
||||
SendNewBrowserInfoResponse(render_process_id, browser_info.get(),
|
||||
false, info->reply_msg);
|
||||
SendNewBrowserInfoResponse(render_process_id, browser_info.get(), false,
|
||||
info->reply_msg);
|
||||
|
||||
pending_new_browser_info_list_.erase(it);
|
||||
break;
|
||||
@@ -153,15 +152,13 @@ bool CefBrowserInfoManager::CanCreateWindow(
|
||||
}
|
||||
|
||||
if (is_guest_view) {
|
||||
content::OpenURLParams params(target_url,
|
||||
referrer,
|
||||
disposition,
|
||||
ui::PAGE_TRANSITION_LINK,
|
||||
true);
|
||||
content::OpenURLParams params(target_url, referrer, disposition,
|
||||
ui::PAGE_TRANSITION_LINK, true);
|
||||
params.user_gesture = user_gesture;
|
||||
|
||||
// Pass navigation to the owner browser.
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
CEF_POST_TASK(
|
||||
CEF_UIT,
|
||||
base::Bind(base::IgnoreResult(&CefBrowserHostImpl::OpenURLFromTab),
|
||||
browser.get(), nullptr, params));
|
||||
|
||||
@@ -210,17 +207,12 @@ bool CefBrowserInfoManager::CanCreateWindow(
|
||||
window_info->height = cef_features.height;
|
||||
#endif
|
||||
|
||||
allow = !handler->OnBeforePopup(browser.get(),
|
||||
frame,
|
||||
pending_popup->target_url.spec(),
|
||||
allow = !handler->OnBeforePopup(
|
||||
browser.get(), frame, pending_popup->target_url.spec(),
|
||||
pending_popup->target_frame_name,
|
||||
static_cast<cef_window_open_disposition_t>(disposition),
|
||||
user_gesture,
|
||||
cef_features,
|
||||
*window_info,
|
||||
pending_popup->client,
|
||||
pending_popup->settings,
|
||||
no_javascript_access);
|
||||
static_cast<cef_window_open_disposition_t>(disposition), user_gesture,
|
||||
cef_features, *window_info, pending_popup->client,
|
||||
pending_popup->settings, no_javascript_access);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,8 +231,8 @@ bool CefBrowserInfoManager::CanCreateWindow(
|
||||
|
||||
// Filtering needs to be done on the UI thread.
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
base::Bind(FilterPendingPopupURL, opener_render_process_id,
|
||||
base::Passed(&pending_popup)));
|
||||
base::Bind(FilterPendingPopupURL, opener_render_process_id,
|
||||
base::Passed(&pending_popup)));
|
||||
}
|
||||
|
||||
return allow;
|
||||
@@ -288,11 +280,10 @@ void CefBrowserInfoManager::WebContentsCreated(
|
||||
platform_delegate = std::move(pending_popup->platform_delegate);
|
||||
}
|
||||
|
||||
void CefBrowserInfoManager::OnGetNewBrowserInfo(
|
||||
int render_process_id,
|
||||
int render_view_routing_id,
|
||||
int render_frame_routing_id,
|
||||
IPC::Message* reply_msg) {
|
||||
void CefBrowserInfoManager::OnGetNewBrowserInfo(int render_process_id,
|
||||
int render_view_routing_id,
|
||||
int render_frame_routing_id,
|
||||
IPC::Message* reply_msg) {
|
||||
DCHECK_NE(render_process_id, content::ChildProcessHost::kInvalidUniqueID);
|
||||
DCHECK_GT(render_view_routing_id, 0);
|
||||
DCHECK_GT(render_frame_routing_id, 0);
|
||||
@@ -303,9 +294,8 @@ void CefBrowserInfoManager::OnGetNewBrowserInfo(
|
||||
bool is_guest_view = false;
|
||||
|
||||
scoped_refptr<CefBrowserInfo> browser_info = GetBrowserInfo(
|
||||
render_process_id, render_view_routing_id,
|
||||
render_process_id, render_frame_routing_id,
|
||||
&is_guest_view);
|
||||
render_process_id, render_view_routing_id, render_process_id,
|
||||
render_frame_routing_id, &is_guest_view);
|
||||
|
||||
if (browser_info.get()) {
|
||||
// Send the response immediately.
|
||||
@@ -463,11 +453,10 @@ void CefBrowserInfoManager::PushPendingPopup(
|
||||
}
|
||||
|
||||
std::unique_ptr<CefBrowserInfoManager::PendingPopup>
|
||||
CefBrowserInfoManager::PopPendingPopup(
|
||||
PendingPopup::Step step,
|
||||
int opener_process_id,
|
||||
int opener_frame_id,
|
||||
const GURL& target_url) {
|
||||
CefBrowserInfoManager::PopPendingPopup(PendingPopup::Step step,
|
||||
int opener_process_id,
|
||||
int opener_frame_id,
|
||||
const GURL& target_url) {
|
||||
DCHECK_GT(opener_process_id, 0);
|
||||
DCHECK_GT(opener_frame_id, 0);
|
||||
|
||||
@@ -476,8 +465,7 @@ std::unique_ptr<CefBrowserInfoManager::PendingPopup>
|
||||
PendingPopupList::iterator it = pending_popup_list_.begin();
|
||||
for (; it != pending_popup_list_.end(); ++it) {
|
||||
PendingPopup* popup = *it;
|
||||
if (popup->step == step &&
|
||||
popup->opener_process_id == opener_process_id &&
|
||||
if (popup->step == step && popup->opener_process_id == opener_process_id &&
|
||||
popup->opener_frame_id == opener_frame_id &&
|
||||
popup->target_url == target_url) {
|
||||
pending_popup_list_.weak_erase(it);
|
||||
@@ -499,10 +487,10 @@ scoped_refptr<CefBrowserInfo> CefBrowserInfoManager::GetBrowserInfo(
|
||||
if (is_guest_view)
|
||||
*is_guest_view = false;
|
||||
|
||||
const bool valid_view_ids = render_view_process_id > 0 &&
|
||||
render_view_routing_id > 0;
|
||||
const bool valid_frame_ids = render_frame_process_id > 0 &&
|
||||
render_frame_routing_id > 0;
|
||||
const bool valid_view_ids =
|
||||
render_view_process_id > 0 && render_view_routing_id > 0;
|
||||
const bool valid_frame_ids =
|
||||
render_frame_process_id > 0 && render_frame_routing_id > 0;
|
||||
|
||||
BrowserInfoList::const_iterator it = browser_info_list_.begin();
|
||||
for (; it != browser_info_list_.end(); ++it) {
|
||||
@@ -550,7 +538,8 @@ void CefBrowserInfoManager::SendNewBrowserInfoResponse(
|
||||
bool is_guest_view,
|
||||
IPC::Message* reply_msg) {
|
||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
CEF_POST_TASK(
|
||||
CEF_UIT,
|
||||
base::Bind(&CefBrowserInfoManager::SendNewBrowserInfoResponse,
|
||||
render_process_id, browser_info, is_guest_view, reply_msg));
|
||||
return;
|
||||
|
@@ -60,26 +60,25 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
|
||||
|
||||
// Called from CefContentBrowserClient::CanCreateWindow. See comments on
|
||||
// PendingPopup for more information.
|
||||
bool CanCreateWindow(
|
||||
const GURL& target_url,
|
||||
const content::Referrer& referrer,
|
||||
const std::string& frame_name,
|
||||
WindowOpenDisposition disposition,
|
||||
const blink::mojom::WindowFeatures& features,
|
||||
bool user_gesture,
|
||||
bool opener_suppressed,
|
||||
int opener_render_process_id,
|
||||
int opener_render_frame_id,
|
||||
bool* no_javascript_access);
|
||||
bool CanCreateWindow(const GURL& target_url,
|
||||
const content::Referrer& referrer,
|
||||
const std::string& frame_name,
|
||||
WindowOpenDisposition disposition,
|
||||
const blink::mojom::WindowFeatures& features,
|
||||
bool user_gesture,
|
||||
bool opener_suppressed,
|
||||
int opener_render_process_id,
|
||||
int opener_render_frame_id,
|
||||
bool* no_javascript_access);
|
||||
|
||||
// Called from CefBrowserHostImpl::GetCustomWebContentsView. See comments on
|
||||
// PendingPopup for more information.
|
||||
void GetCustomWebContentsView(
|
||||
const GURL& target_url,
|
||||
int opener_render_process_id,
|
||||
int opener_render_frame_id,
|
||||
content::WebContentsView** view,
|
||||
content::RenderViewHostDelegateView** delegate_view);
|
||||
const GURL& target_url,
|
||||
int opener_render_process_id,
|
||||
int opener_render_frame_id,
|
||||
content::WebContentsView** view,
|
||||
content::RenderViewHostDelegateView** delegate_view);
|
||||
|
||||
// Called from CefBrowserHostImpl::WebContentsCreated. See comments on
|
||||
// PendingPopup for more information.
|
||||
@@ -98,11 +97,10 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
|
||||
// exist for explicitly created browsers and guest views. It may sometimes
|
||||
// already exist for traditional popup browsers depending on timing. See
|
||||
// comments on PendingPopup for more information.
|
||||
void OnGetNewBrowserInfo(
|
||||
int render_process_id,
|
||||
int render_view_routing_id,
|
||||
int render_frame_routing_id,
|
||||
IPC::Message* reply_msg);
|
||||
void OnGetNewBrowserInfo(int render_process_id,
|
||||
int render_view_routing_id,
|
||||
int render_frame_routing_id,
|
||||
IPC::Message* reply_msg);
|
||||
|
||||
// Called from CefBrowserHostImpl::DestroyBrowser() when a browser is
|
||||
// destroyed.
|
||||
@@ -125,7 +123,7 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
|
||||
bool* is_guest_view);
|
||||
|
||||
// Retrieves all existing CefBrowserInfo objects.
|
||||
typedef std::list<scoped_refptr<CefBrowserInfo> > BrowserInfoList;
|
||||
typedef std::list<scoped_refptr<CefBrowserInfo>> BrowserInfoList;
|
||||
void GetBrowserInfoList(BrowserInfoList& list);
|
||||
|
||||
private:
|
||||
@@ -176,32 +174,29 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
|
||||
// URIs, rewrites the URL to "about:blank". We need to apply the same filter
|
||||
// otherwise GetCustomWebContentsView will fail to retrieve the PopupInfo.
|
||||
static void FilterPendingPopupURL(
|
||||
int opener_process_id,
|
||||
std::unique_ptr<PendingPopup> pending_popup);
|
||||
int opener_process_id,
|
||||
std::unique_ptr<PendingPopup> pending_popup);
|
||||
|
||||
// Manage pending popups.
|
||||
void PushPendingPopup(std::unique_ptr<PendingPopup> popup);
|
||||
std::unique_ptr<PendingPopup> PopPendingPopup(
|
||||
PendingPopup::Step step,
|
||||
int opener_process_id,
|
||||
int opener_frame_id,
|
||||
const GURL& target_url);
|
||||
std::unique_ptr<PendingPopup> PopPendingPopup(PendingPopup::Step step,
|
||||
int opener_process_id,
|
||||
int opener_frame_id,
|
||||
const GURL& target_url);
|
||||
|
||||
// Retrieves the BrowserInfo matching the specified IDs. If both sets are
|
||||
// valid then this method makes sure both sets have been registered.
|
||||
scoped_refptr<CefBrowserInfo> GetBrowserInfo(
|
||||
int render_view_process_id,
|
||||
int render_view_routing_id,
|
||||
int render_frame_process_id,
|
||||
int render_frame_routing_id,
|
||||
bool* is_guest_view);
|
||||
scoped_refptr<CefBrowserInfo> GetBrowserInfo(int render_view_process_id,
|
||||
int render_view_routing_id,
|
||||
int render_frame_process_id,
|
||||
int render_frame_routing_id,
|
||||
bool* is_guest_view);
|
||||
|
||||
// Send the response for a pending OnGetNewBrowserInfo request.
|
||||
static void SendNewBrowserInfoResponse(
|
||||
int render_process_id,
|
||||
CefBrowserInfo* browser_info,
|
||||
bool is_guest_view,
|
||||
IPC::Message* reply_msg);
|
||||
static void SendNewBrowserInfoResponse(int render_process_id,
|
||||
CefBrowserInfo* browser_info,
|
||||
bool is_guest_view,
|
||||
IPC::Message* reply_msg);
|
||||
|
||||
// Pending request for OnGetNewBrowserInfo.
|
||||
struct PendingNewBrowserInfo {
|
||||
|
@@ -15,8 +15,8 @@
|
||||
#include "libcef/browser/context.h"
|
||||
#include "libcef/browser/devtools_manager_delegate.h"
|
||||
#include "libcef/browser/extensions/browser_context_keyed_service_factories.h"
|
||||
#include "libcef/browser/extensions/extensions_browser_client.h"
|
||||
#include "libcef/browser/extensions/extension_system_factory.h"
|
||||
#include "libcef/browser/extensions/extensions_browser_client.h"
|
||||
#include "libcef/browser/net/chrome_scheme_handler.h"
|
||||
#include "libcef/browser/printing/printing_message_filter.h"
|
||||
#include "libcef/browser/thread_util.h"
|
||||
@@ -74,8 +74,8 @@ class CefAccessTokenStore : public device::AccessTokenStore {
|
||||
callback.Run(access_token_map_, system_context_);
|
||||
}
|
||||
|
||||
void SaveAccessToken(
|
||||
const GURL& server_url, const base::string16& access_token) override {
|
||||
void SaveAccessToken(const GURL& server_url,
|
||||
const base::string16& access_token) override {
|
||||
access_token_map_[server_url] = access_token;
|
||||
}
|
||||
|
||||
@@ -101,17 +101,14 @@ class CefGeolocationDelegate : public device::GeolocationDelegate {
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(CefGeolocationDelegate);
|
||||
};
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
CefBrowserMainParts::CefBrowserMainParts(
|
||||
const content::MainFunctionParams& parameters)
|
||||
: BrowserMainParts(),
|
||||
devtools_delegate_(NULL) {
|
||||
}
|
||||
: BrowserMainParts(), devtools_delegate_(NULL) {}
|
||||
|
||||
CefBrowserMainParts::~CefBrowserMainParts() {
|
||||
}
|
||||
CefBrowserMainParts::~CefBrowserMainParts() {}
|
||||
|
||||
void CefBrowserMainParts::PreMainMessageLoopStart() {
|
||||
if (!base::MessageLoop::current()) {
|
||||
@@ -176,7 +173,8 @@ void CefBrowserMainParts::PreMainMessageLoopRun() {
|
||||
// BrowserContext.
|
||||
extensions_client_.reset(new extensions::CefExtensionsClient());
|
||||
extensions::ExtensionsClient::Set(extensions_client_.get());
|
||||
extensions_browser_client_.reset(new extensions::CefExtensionsBrowserClient);
|
||||
extensions_browser_client_.reset(
|
||||
new extensions::CefExtensionsBrowserClient);
|
||||
extensions::ExtensionsBrowserClient::Set(extensions_browser_client_.get());
|
||||
|
||||
// Register additional KeyedService factories here. See
|
||||
|
@@ -56,9 +56,7 @@ class CefBrowserMainParts : public content::BrowserMainParts {
|
||||
CefRefPtr<CefRequestContextImpl> request_context() const {
|
||||
return global_request_context_;
|
||||
}
|
||||
CefDevToolsDelegate* devtools_delegate() const {
|
||||
return devtools_delegate_;
|
||||
}
|
||||
CefDevToolsDelegate* devtools_delegate() const { return devtools_delegate_; }
|
||||
|
||||
private:
|
||||
#if defined(OS_WIN)
|
||||
@@ -70,7 +68,8 @@ class CefBrowserMainParts : public content::BrowserMainParts {
|
||||
std::unique_ptr<base::MessageLoop> message_loop_;
|
||||
|
||||
std::unique_ptr<extensions::ExtensionsClient> extensions_client_;
|
||||
std::unique_ptr<extensions::ExtensionsBrowserClient> extensions_browser_client_;
|
||||
std::unique_ptr<extensions::ExtensionsBrowserClient>
|
||||
extensions_browser_client_;
|
||||
|
||||
#if defined(USE_AURA)
|
||||
std::unique_ptr<wm::WMState> wm_state_;
|
||||
|
@@ -2,9 +2,9 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
#include <Objbase.h>
|
||||
#include <commctrl.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include "libcef/browser/browser_main.h"
|
||||
|
||||
@@ -23,7 +23,7 @@ void CefBrowserMainParts::PlatformInitialize() {
|
||||
DCHECK(SUCCEEDED(res));
|
||||
INITCOMMONCONTROLSEX InitCtrlEx;
|
||||
InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX);
|
||||
InitCtrlEx.dwICC = ICC_STANDARD_CLASSES;
|
||||
InitCtrlEx.dwICC = ICC_STANDARD_CLASSES;
|
||||
InitCommonControlsEx(&InitCtrlEx);
|
||||
|
||||
// Start COM stuff.
|
||||
|
@@ -14,18 +14,16 @@
|
||||
#include "libcef/common/content_client.h"
|
||||
#include "libcef/common/values_impl.h"
|
||||
|
||||
#include "base/compiler_specific.h"
|
||||
#include "base/bind.h"
|
||||
#include "base/compiler_specific.h"
|
||||
#include "content/common/frame_messages.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
#include "content/public/common/child_process_host.h"
|
||||
|
||||
CefBrowserMessageFilter::CefBrowserMessageFilter(int render_process_id)
|
||||
: render_process_id_(render_process_id) {
|
||||
}
|
||||
: render_process_id_(render_process_id) {}
|
||||
|
||||
CefBrowserMessageFilter::~CefBrowserMessageFilter() {
|
||||
}
|
||||
CefBrowserMessageFilter::~CefBrowserMessageFilter() {}
|
||||
|
||||
void CefBrowserMessageFilter::OnFilterRemoved() {
|
||||
render_process_id_ = content::ChildProcessHost::kInvalidUniqueID;
|
||||
@@ -53,8 +51,8 @@ bool CefBrowserMessageFilter::OnMessageReceived(const IPC::Message& message) {
|
||||
bool CefBrowserMessageFilter::Send(IPC::Message* message) {
|
||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
base::Bind(base::IgnoreResult(&CefBrowserMessageFilter::Send), this,
|
||||
message));
|
||||
base::Bind(base::IgnoreResult(&CefBrowserMessageFilter::Send),
|
||||
this, message));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -78,22 +76,19 @@ void CefBrowserMessageFilter::OnGetNewRenderThreadInfo(
|
||||
app->GetBrowserProcessHandler();
|
||||
if (handler.get()) {
|
||||
CefRefPtr<CefListValueImpl> listValuePtr(
|
||||
new CefListValueImpl(¶ms->extra_info, false, false));
|
||||
new CefListValueImpl(¶ms->extra_info, false, false));
|
||||
handler->OnRenderProcessThreadCreated(listValuePtr.get());
|
||||
listValuePtr->Detach(NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CefBrowserMessageFilter::OnGetNewBrowserInfo(
|
||||
int render_view_routing_id,
|
||||
int render_frame_routing_id,
|
||||
IPC::Message* reply_msg) {
|
||||
void CefBrowserMessageFilter::OnGetNewBrowserInfo(int render_view_routing_id,
|
||||
int render_frame_routing_id,
|
||||
IPC::Message* reply_msg) {
|
||||
if (render_process_id_ != content::ChildProcessHost::kInvalidUniqueID) {
|
||||
CefBrowserInfoManager::GetInstance()->OnGetNewBrowserInfo(
|
||||
render_process_id_,
|
||||
render_view_routing_id,
|
||||
render_frame_routing_id,
|
||||
render_process_id_, render_view_routing_id, render_frame_routing_id,
|
||||
reply_msg);
|
||||
} else {
|
||||
delete reply_msg;
|
||||
@@ -102,9 +97,8 @@ void CefBrowserMessageFilter::OnGetNewBrowserInfo(
|
||||
|
||||
void CefBrowserMessageFilter::OnFrameFocused(int32_t render_frame_routing_id) {
|
||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
base::Bind(&CefBrowserMessageFilter::OnFrameFocused, this,
|
||||
render_frame_routing_id));
|
||||
CEF_POST_TASK(CEF_UIT, base::Bind(&CefBrowserMessageFilter::OnFrameFocused,
|
||||
this, render_frame_routing_id));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -36,10 +36,9 @@ class CefBrowserMessageFilter : public IPC::MessageFilter {
|
||||
// Message handlers.
|
||||
void OnGetNewRenderThreadInfo(
|
||||
CefProcessHostMsg_GetNewRenderThreadInfo_Params* params);
|
||||
void OnGetNewBrowserInfo(
|
||||
int render_view_routing_id,
|
||||
int render_frame_routing_id,
|
||||
IPC::Message* reply_msg);
|
||||
void OnGetNewBrowserInfo(int render_view_routing_id,
|
||||
int render_frame_routing_id,
|
||||
IPC::Message* reply_msg);
|
||||
void OnFrameFocused(int32_t render_frame_routing_id);
|
||||
|
||||
int render_process_id_;
|
||||
@@ -47,5 +46,4 @@ class CefBrowserMessageFilter : public IPC::MessageFilter {
|
||||
DISALLOW_COPY_AND_ASSIGN(CefBrowserMessageFilter);
|
||||
};
|
||||
|
||||
|
||||
#endif // CEF_LIBCEF_BROWSER_BROWSER_MESSAGE_FILTER_H_
|
||||
|
@@ -21,9 +21,7 @@ class MessagePumpExternal : public base::MessagePump {
|
||||
public:
|
||||
MessagePumpExternal(float max_time_slice,
|
||||
CefRefPtr<CefBrowserProcessHandler> handler)
|
||||
: max_time_slice_(max_time_slice),
|
||||
handler_(handler) {
|
||||
}
|
||||
: max_time_slice_(max_time_slice), handler_(handler) {}
|
||||
|
||||
void Run(Delegate* delegate) override {
|
||||
base::TimeTicks start = base::TimeTicks::Now();
|
||||
@@ -42,12 +40,9 @@ class MessagePumpExternal : public base::MessagePump {
|
||||
}
|
||||
}
|
||||
|
||||
void Quit() override {
|
||||
}
|
||||
void Quit() override {}
|
||||
|
||||
void ScheduleWork() override {
|
||||
handler_->OnScheduleMessagePumpWork(0);
|
||||
}
|
||||
void ScheduleWork() override { handler_->OnScheduleMessagePumpWork(0); }
|
||||
|
||||
void ScheduleDelayedWork(const base::TimeTicks& delayed_work_time) override {
|
||||
const base::TimeDelta& delta = delayed_work_time - base::TimeTicks::Now();
|
||||
@@ -68,7 +63,7 @@ class MessagePumpExternal : public base::MessagePump {
|
||||
// We are using an external timer, so we don't have any action based on the
|
||||
// returned next delayed work time.
|
||||
base::TimeTicks next_time;
|
||||
did_delayed_work = delegate->DoDelayedWork(&next_time);
|
||||
did_delayed_work = delegate->DoDelayedWork(&next_time);
|
||||
|
||||
if (!did_work && !did_delayed_work) {
|
||||
did_idle_work = delegate->DoIdleWork();
|
||||
@@ -103,12 +98,11 @@ std::unique_ptr<base::MessagePump> CreatePump() {
|
||||
} // namespace
|
||||
|
||||
CefBrowserMessageLoop::CefBrowserMessageLoop()
|
||||
: base::MessageLoopForUI(CreatePump()) {
|
||||
: base::MessageLoopForUI(CreatePump()) {
|
||||
BindToCurrentThread();
|
||||
}
|
||||
|
||||
CefBrowserMessageLoop::~CefBrowserMessageLoop() {
|
||||
}
|
||||
CefBrowserMessageLoop::~CefBrowserMessageLoop() {}
|
||||
|
||||
// static
|
||||
CefBrowserMessageLoop* CefBrowserMessageLoop::current() {
|
||||
|
@@ -12,9 +12,7 @@
|
||||
#include "content/public/browser/render_view_host.h"
|
||||
#include "content/public/browser/render_widget_host.h"
|
||||
|
||||
CefBrowserPlatformDelegate::CefBrowserPlatformDelegate()
|
||||
: browser_(nullptr) {
|
||||
}
|
||||
CefBrowserPlatformDelegate::CefBrowserPlatformDelegate() : browser_(nullptr) {}
|
||||
|
||||
CefBrowserPlatformDelegate::~CefBrowserPlatformDelegate() {
|
||||
DCHECK(!browser_);
|
||||
@@ -27,8 +25,7 @@ void CefBrowserPlatformDelegate::CreateViewForWebContents(
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegate::WebContentsCreated(
|
||||
content::WebContents* web_contents) {
|
||||
}
|
||||
content::WebContents* web_contents) {}
|
||||
|
||||
void CefBrowserPlatformDelegate::RenderViewCreated(
|
||||
content::RenderViewHost* render_view_host) {
|
||||
@@ -43,11 +40,9 @@ void CefBrowserPlatformDelegate::BrowserCreated(CefBrowserHostImpl* browser) {
|
||||
browser_ = browser;
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegate::NotifyBrowserCreated() {
|
||||
}
|
||||
void CefBrowserPlatformDelegate::NotifyBrowserCreated() {}
|
||||
|
||||
void CefBrowserPlatformDelegate::NotifyBrowserDestroyed() {
|
||||
}
|
||||
void CefBrowserPlatformDelegate::NotifyBrowserDestroyed() {}
|
||||
|
||||
void CefBrowserPlatformDelegate::BrowserDestroyed(CefBrowserHostImpl* browser) {
|
||||
DCHECK(browser_ && browser_ == browser);
|
||||
@@ -80,18 +75,15 @@ void CefBrowserPlatformDelegate::PopupWebContentsCreated(
|
||||
CefRefPtr<CefClient> client,
|
||||
content::WebContents* new_web_contents,
|
||||
CefBrowserPlatformDelegate* new_platform_delegate,
|
||||
bool is_devtools) {
|
||||
}
|
||||
bool is_devtools) {}
|
||||
|
||||
void CefBrowserPlatformDelegate::PopupBrowserCreated(
|
||||
CefBrowserHostImpl* new_browser,
|
||||
bool is_devtools) {
|
||||
}
|
||||
bool is_devtools) {}
|
||||
|
||||
void CefBrowserPlatformDelegate::SendCaptureLostEvent() {
|
||||
content::RenderWidgetHostImpl* widget =
|
||||
content::RenderWidgetHostImpl::From(
|
||||
browser_->web_contents()->GetRenderViewHost()->GetWidget());
|
||||
content::RenderWidgetHostImpl* widget = content::RenderWidgetHostImpl::From(
|
||||
browser_->web_contents()->GetRenderViewHost()->GetWidget());
|
||||
if (widget)
|
||||
widget->LostCapture();
|
||||
}
|
||||
@@ -104,17 +96,16 @@ void CefBrowserPlatformDelegate::NotifyMoveOrResizeStarted() {
|
||||
host->NotifyMoveOrResizeStarted();
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegate::SizeTo(int width, int height) {
|
||||
}
|
||||
void CefBrowserPlatformDelegate::SizeTo(int width, int height) {}
|
||||
#endif
|
||||
|
||||
std::unique_ptr<CefFileDialogRunner>
|
||||
CefBrowserPlatformDelegate::CreateFileDialogRunner() {
|
||||
CefBrowserPlatformDelegate::CreateFileDialogRunner() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::unique_ptr<CefJavaScriptDialogRunner>
|
||||
CefBrowserPlatformDelegate::CreateJavaScriptDialogRunner() {
|
||||
CefBrowserPlatformDelegate::CreateJavaScriptDialogRunner() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -134,7 +125,8 @@ void CefBrowserPlatformDelegate::SetWindowlessFrameRate(int frame_rate) {
|
||||
NOTREACHED();
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegate::ImeSetComposition(const CefString& text,
|
||||
void CefBrowserPlatformDelegate::ImeSetComposition(
|
||||
const CefString& text,
|
||||
const std::vector<CefCompositionUnderline>& underlines,
|
||||
const CefRange& replacement_range,
|
||||
const CefRange& selection_range) {
|
||||
@@ -193,7 +185,8 @@ void CefBrowserPlatformDelegate::UpdateDragCursor(
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegate::DragSourceEndedAt(
|
||||
int x, int y,
|
||||
int x,
|
||||
int y,
|
||||
cef_drag_operations_mask_t op) {
|
||||
NOTREACHED();
|
||||
}
|
||||
|
@@ -11,8 +11,8 @@
|
||||
|
||||
#include "include/cef_client.h"
|
||||
#include "include/cef_drag_data.h"
|
||||
#include "include/views/cef_browser_view.h"
|
||||
#include "include/internal/cef_types.h"
|
||||
#include "include/views/cef_browser_view.h"
|
||||
#include "libcef/browser/browser_host_impl.h"
|
||||
|
||||
#include "base/callback.h"
|
||||
@@ -64,8 +64,7 @@ class CefBrowserPlatformDelegate {
|
||||
virtual void WebContentsCreated(content::WebContents* web_contents);
|
||||
|
||||
// Called after the RenderViewHost is created.
|
||||
virtual void RenderViewCreated(
|
||||
content::RenderViewHost* render_view_host);
|
||||
virtual void RenderViewCreated(content::RenderViewHost* render_view_host);
|
||||
|
||||
// Called after the owning CefBrowserHostImpl is created. Will only be called
|
||||
// a single time per instance. Do not send any client notifications from this
|
||||
@@ -79,7 +78,7 @@ class CefBrowserPlatformDelegate {
|
||||
// Send any notifications related to browser destruction. Called before
|
||||
// BrowserDestroyed().
|
||||
virtual void NotifyBrowserDestroyed();
|
||||
|
||||
|
||||
// Called before the owning CefBrowserHostImpl is destroyed. Will only be
|
||||
// called a single time per instance. All references to the CefBrowserHostImpl
|
||||
// and WebContents should be cleared when this method is called. Do not send
|
||||
@@ -98,7 +97,7 @@ class CefBrowserPlatformDelegate {
|
||||
// Return the OS handle for the window that hosts the browser. For windowed
|
||||
// rendering this will return the most immediate parent window handle. For
|
||||
// windowless rendering this will return the parent window handle specified by
|
||||
// the client, which may be NULL. May be called on multiple threads.
|
||||
// the client, which may be NULL. May be called on multiple threads.
|
||||
virtual CefWindowHandle GetHostWindowHandle() const = 0;
|
||||
|
||||
#if defined(USE_AURA)
|
||||
@@ -130,9 +129,8 @@ class CefBrowserPlatformDelegate {
|
||||
// CefLifeSpanHandler::OnAfterCreated() for the popup browser. It is safe to
|
||||
// make the new browser visible in this callback (for example, add the browser
|
||||
// to a window and show it).
|
||||
virtual void PopupBrowserCreated(
|
||||
CefBrowserHostImpl* new_browser,
|
||||
bool is_devtools);
|
||||
virtual void PopupBrowserCreated(CefBrowserHostImpl* new_browser,
|
||||
bool is_devtools);
|
||||
|
||||
// Returns the background color for the browser. The alpha component will be
|
||||
// either SK_AlphaTRANSPARENT or SK_AlphaOPAQUE (e.g. fully transparent or
|
||||
@@ -187,13 +185,15 @@ class CefBrowserPlatformDelegate {
|
||||
virtual void TranslateClickEvent(blink::WebMouseEvent& result,
|
||||
const CefMouseEvent& mouse_event,
|
||||
CefBrowserHost::MouseButtonType type,
|
||||
bool mouseUp, int clickCount) const = 0;
|
||||
bool mouseUp,
|
||||
int clickCount) const = 0;
|
||||
virtual void TranslateMoveEvent(blink::WebMouseEvent& result,
|
||||
const CefMouseEvent& mouse_event,
|
||||
bool mouseLeave) const = 0;
|
||||
virtual void TranslateWheelEvent(blink::WebMouseWheelEvent& result,
|
||||
const CefMouseEvent& mouse_event,
|
||||
int deltaX, int deltaY) const = 0;
|
||||
int deltaX,
|
||||
int deltaY) const = 0;
|
||||
|
||||
// Returns the OS event handle, if any, associated with |event|.
|
||||
virtual CefEventHandle GetEventHandle(
|
||||
@@ -203,7 +203,8 @@ class CefBrowserPlatformDelegate {
|
||||
virtual std::unique_ptr<CefFileDialogRunner> CreateFileDialogRunner();
|
||||
|
||||
// Create the platform-specific JavaScript dialog runner.
|
||||
virtual std::unique_ptr<CefJavaScriptDialogRunner> CreateJavaScriptDialogRunner();
|
||||
virtual std::unique_ptr<CefJavaScriptDialogRunner>
|
||||
CreateJavaScriptDialogRunner();
|
||||
|
||||
// Create the platform-specific menu runner.
|
||||
virtual std::unique_ptr<CefMenuRunner> CreateMenuRunner() = 0;
|
||||
@@ -245,22 +246,20 @@ class CefBrowserPlatformDelegate {
|
||||
// Drag/drop-related callbacks. See documentation in CefRenderHandler. Only
|
||||
// used with windowless rendering.
|
||||
virtual void DragTargetDragEnter(CefRefPtr<CefDragData> drag_data,
|
||||
const CefMouseEvent& event,
|
||||
cef_drag_operations_mask_t allowed_ops);
|
||||
const CefMouseEvent& event,
|
||||
cef_drag_operations_mask_t allowed_ops);
|
||||
virtual void DragTargetDragOver(const CefMouseEvent& event,
|
||||
cef_drag_operations_mask_t allowed_ops);
|
||||
virtual void DragTargetDragLeave();
|
||||
virtual void DragTargetDrop(const CefMouseEvent& event);
|
||||
virtual void StartDragging(
|
||||
const content::DropData& drop_data,
|
||||
blink::WebDragOperationsMask allowed_ops,
|
||||
const gfx::ImageSkia& image,
|
||||
const gfx::Vector2d& image_offset,
|
||||
const content::DragEventSourceInfo& event_info,
|
||||
content::RenderWidgetHostImpl* source_rwh);
|
||||
virtual void StartDragging(const content::DropData& drop_data,
|
||||
blink::WebDragOperationsMask allowed_ops,
|
||||
const gfx::ImageSkia& image,
|
||||
const gfx::Vector2d& image_offset,
|
||||
const content::DragEventSourceInfo& event_info,
|
||||
content::RenderWidgetHostImpl* source_rwh);
|
||||
virtual void UpdateDragCursor(blink::WebDragOperation operation);
|
||||
virtual void DragSourceEndedAt(int x, int y,
|
||||
cef_drag_operations_mask_t op);
|
||||
virtual void DragSourceEndedAt(int x, int y, cef_drag_operations_mask_t op);
|
||||
virtual void DragSourceSystemDragEnded();
|
||||
virtual void AccessibilityEventReceived(
|
||||
const std::vector<content::AXEventNotificationDetails>& eventData);
|
||||
@@ -276,7 +275,7 @@ class CefBrowserPlatformDelegate {
|
||||
|
||||
static int TranslateModifiers(uint32 cef_modifiers);
|
||||
|
||||
CefBrowserHostImpl *browser_; // Not owned by this object.
|
||||
CefBrowserHostImpl* browser_; // Not owned by this object.
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(CefBrowserPlatformDelegate);
|
||||
|
@@ -67,8 +67,7 @@ std::unique_ptr<CefBrowserPlatformDelegate> CefBrowserPlatformDelegate::Create(
|
||||
const bool is_windowless =
|
||||
create_params.window_info &&
|
||||
create_params.window_info->windowless_rendering_enabled &&
|
||||
create_params.client &&
|
||||
create_params.client->GetRenderHandler().get();
|
||||
create_params.client && create_params.client->GetRenderHandler().get();
|
||||
const SkColor background_color = CefContext::Get()->GetBackgroundColor(
|
||||
&create_params.settings, is_windowless ? STATE_ENABLED : STATE_DISABLED);
|
||||
|
||||
|
@@ -45,7 +45,8 @@ class CefURLFetcherDelegate : public net::URLFetcherDelegate {
|
||||
int64 total,
|
||||
int64_t current_network_bytes) override;
|
||||
void OnURLFetchUploadProgress(const net::URLFetcher* source,
|
||||
int64 current, int64 total) override;
|
||||
int64 current,
|
||||
int64 total) override;
|
||||
|
||||
private:
|
||||
// The context_ pointer will outlive this object.
|
||||
@@ -53,15 +54,12 @@ class CefURLFetcherDelegate : public net::URLFetcherDelegate {
|
||||
int request_flags_;
|
||||
};
|
||||
|
||||
class NET_EXPORT CefURLFetcherResponseWriter :
|
||||
public net::URLFetcherResponseWriter {
|
||||
class CefURLFetcherResponseWriter : public net::URLFetcherResponseWriter {
|
||||
public:
|
||||
CefURLFetcherResponseWriter(
|
||||
CefRefPtr<CefBrowserURLRequest> url_request,
|
||||
scoped_refptr<base::SequencedTaskRunner> task_runner)
|
||||
: url_request_(url_request),
|
||||
task_runner_(task_runner) {
|
||||
}
|
||||
: url_request_(url_request), task_runner_(task_runner) {}
|
||||
|
||||
// net::URLFetcherResponseWriter methods.
|
||||
int Initialize(const net::CompletionCallback& callback) override {
|
||||
@@ -72,7 +70,8 @@ class NET_EXPORT CefURLFetcherResponseWriter :
|
||||
int num_bytes,
|
||||
const net::CompletionCallback& callback) override {
|
||||
if (url_request_.get()) {
|
||||
task_runner_->PostTask(FROM_HERE,
|
||||
task_runner_->PostTask(
|
||||
FROM_HERE,
|
||||
base::Bind(&CefURLFetcherResponseWriter::WriteOnClientThread,
|
||||
url_request_, scoped_refptr<net::IOBuffer>(buffer),
|
||||
num_bytes, callback,
|
||||
@@ -99,14 +98,14 @@ class NET_EXPORT CefURLFetcherResponseWriter :
|
||||
if (client.get())
|
||||
client->OnDownloadData(url_request.get(), buffer->data(), num_bytes);
|
||||
|
||||
source_message_loop_proxy->PostTask(FROM_HERE,
|
||||
source_message_loop_proxy->PostTask(
|
||||
FROM_HERE,
|
||||
base::Bind(&CefURLFetcherResponseWriter::ContinueOnSourceThread,
|
||||
num_bytes, callback));
|
||||
}
|
||||
|
||||
static void ContinueOnSourceThread(
|
||||
int num_bytes,
|
||||
const net::CompletionCallback& callback) {
|
||||
static void ContinueOnSourceThread(int num_bytes,
|
||||
const net::CompletionCallback& callback) {
|
||||
callback.Run(num_bytes);
|
||||
}
|
||||
|
||||
@@ -123,7 +122,6 @@ base::SupportsUserData::Data* CreateURLRequestUserData(
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
// CefBrowserURLRequest::Context ----------------------------------------------
|
||||
|
||||
class CefBrowserURLRequest::Context
|
||||
@@ -133,15 +131,15 @@ class CefBrowserURLRequest::Context
|
||||
CefRefPtr<CefRequest> request,
|
||||
CefRefPtr<CefURLRequestClient> client,
|
||||
CefRefPtr<CefRequestContext> request_context)
|
||||
: url_request_(url_request),
|
||||
request_(request),
|
||||
client_(client),
|
||||
request_context_(request_context),
|
||||
task_runner_(base::MessageLoop::current()->task_runner()),
|
||||
status_(UR_IO_PENDING),
|
||||
error_code_(ERR_NONE),
|
||||
upload_data_size_(0),
|
||||
got_upload_progress_complete_(false) {
|
||||
: url_request_(url_request),
|
||||
request_(request),
|
||||
client_(client),
|
||||
request_context_(request_context),
|
||||
task_runner_(base::MessageLoop::current()->task_runner()),
|
||||
status_(UR_IO_PENDING),
|
||||
error_code_(ERR_NONE),
|
||||
upload_data_size_(0),
|
||||
got_upload_progress_complete_(false) {
|
||||
// Mark the request as read-only.
|
||||
static_cast<CefRequestImpl*>(request_.get())->SetReadOnly(true);
|
||||
}
|
||||
@@ -175,12 +173,11 @@ class CefBrowserURLRequest::Context
|
||||
}
|
||||
|
||||
BrowserThread::PostTaskAndReply(
|
||||
BrowserThread::UI,
|
||||
FROM_HERE,
|
||||
base::Bind(&CefBrowserURLRequest::Context::GetRequestContextOnUIThread,
|
||||
this),
|
||||
base::Bind(&CefBrowserURLRequest::Context::ContinueOnOriginatingThread,
|
||||
this, url, request_type));
|
||||
BrowserThread::UI, FROM_HERE,
|
||||
base::Bind(&CefBrowserURLRequest::Context::GetRequestContextOnUIThread,
|
||||
this),
|
||||
base::Bind(&CefBrowserURLRequest::Context::ContinueOnOriginatingThread,
|
||||
this, url, request_type));
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -211,14 +208,14 @@ class CefBrowserURLRequest::Context
|
||||
int request_flags = request_->GetFlags();
|
||||
|
||||
fetcher_delegate_.reset(new CefURLFetcherDelegate(this, request_flags));
|
||||
fetcher_ = net::URLFetcher::Create(url, request_type,
|
||||
fetcher_delegate_.get());
|
||||
fetcher_ =
|
||||
net::URLFetcher::Create(url, request_type, fetcher_delegate_.get());
|
||||
|
||||
DCHECK(url_request_getter_.get());
|
||||
fetcher_->SetRequestContext(url_request_getter_.get());
|
||||
|
||||
static_cast<CefRequestImpl*>(request_.get())->Get(*fetcher_,
|
||||
upload_data_size_);
|
||||
static_cast<CefRequestImpl*>(request_.get())
|
||||
->Get(*fetcher_, upload_data_size_);
|
||||
|
||||
fetcher_->SetURLRequestUserData(
|
||||
CefURLRequestUserData::kUserDataKey,
|
||||
@@ -277,7 +274,7 @@ class CefBrowserURLRequest::Context
|
||||
|
||||
error_code_ = static_cast<CefURLRequest::ErrorCode>(status.error());
|
||||
|
||||
if(!response_.get())
|
||||
if (!response_.get())
|
||||
OnResponse();
|
||||
}
|
||||
|
||||
@@ -295,7 +292,7 @@ class CefBrowserURLRequest::Context
|
||||
DCHECK(CalledOnValidThread());
|
||||
DCHECK(url_request_.get());
|
||||
|
||||
if(!response_.get())
|
||||
if (!response_.get())
|
||||
OnResponse();
|
||||
|
||||
NotifyUploadProgressIfNecessary();
|
||||
@@ -307,11 +304,11 @@ class CefBrowserURLRequest::Context
|
||||
DCHECK(CalledOnValidThread());
|
||||
DCHECK(url_request_.get());
|
||||
|
||||
if(!response_.get())
|
||||
if (!response_.get())
|
||||
OnResponse();
|
||||
|
||||
client_->OnDownloadData(url_request_.get(), download_data->c_str(),
|
||||
download_data->length());
|
||||
download_data->length());
|
||||
}
|
||||
|
||||
void OnUploadProgress(int64 current, int64 total) {
|
||||
@@ -350,7 +347,7 @@ class CefBrowserURLRequest::Context
|
||||
}
|
||||
|
||||
void OnResponse() {
|
||||
if (fetcher_.get()) {
|
||||
if (fetcher_.get()) {
|
||||
response_ = new CefResponseImpl();
|
||||
CefResponseImpl* responseImpl =
|
||||
static_cast<CefResponseImpl*>(response_.get());
|
||||
@@ -380,25 +377,22 @@ class CefBrowserURLRequest::Context
|
||||
scoped_refptr<net::URLRequestContextGetter> url_request_getter_;
|
||||
};
|
||||
|
||||
|
||||
// CefURLFetcherDelegate ------------------------------------------------------
|
||||
|
||||
namespace {
|
||||
|
||||
CefURLFetcherDelegate::CefURLFetcherDelegate(
|
||||
CefBrowserURLRequest::Context* context, int request_flags)
|
||||
: context_(context),
|
||||
request_flags_(request_flags) {
|
||||
}
|
||||
CefBrowserURLRequest::Context* context,
|
||||
int request_flags)
|
||||
: context_(context), request_flags_(request_flags) {}
|
||||
|
||||
CefURLFetcherDelegate::~CefURLFetcherDelegate() {
|
||||
}
|
||||
CefURLFetcherDelegate::~CefURLFetcherDelegate() {}
|
||||
|
||||
void CefURLFetcherDelegate::OnURLFetchComplete(
|
||||
const net::URLFetcher* source) {
|
||||
void CefURLFetcherDelegate::OnURLFetchComplete(const net::URLFetcher* source) {
|
||||
// Complete asynchronously so as not to delete the URLFetcher while it's still
|
||||
// in the call stack.
|
||||
base::MessageLoop::current()->task_runner()->PostTask(FROM_HERE,
|
||||
base::MessageLoop::current()->task_runner()->PostTask(
|
||||
FROM_HERE,
|
||||
base::Bind(&CefBrowserURLRequest::Context::OnComplete, context_));
|
||||
}
|
||||
|
||||
@@ -412,14 +406,14 @@ void CefURLFetcherDelegate::OnURLFetchDownloadProgress(
|
||||
|
||||
void CefURLFetcherDelegate::OnURLFetchUploadProgress(
|
||||
const net::URLFetcher* source,
|
||||
int64 current, int64 total) {
|
||||
int64 current,
|
||||
int64 total) {
|
||||
if (request_flags_ & UR_FLAG_REPORT_UPLOAD_PROGRESS)
|
||||
context_->OnUploadProgress(current, total);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
// CefBrowserURLRequest -------------------------------------------------------
|
||||
|
||||
CefBrowserURLRequest::CefBrowserURLRequest(
|
||||
@@ -429,8 +423,7 @@ CefBrowserURLRequest::CefBrowserURLRequest(
|
||||
context_ = new Context(this, request, client, request_context);
|
||||
}
|
||||
|
||||
CefBrowserURLRequest::~CefBrowserURLRequest() {
|
||||
}
|
||||
CefBrowserURLRequest::~CefBrowserURLRequest() {}
|
||||
|
||||
bool CefBrowserURLRequest::Start() {
|
||||
if (!VerifyContext())
|
||||
|
@@ -6,6 +6,7 @@
|
||||
#define CEF_LIBCEF_BROWSER_BROWSER_URLREQUEST_IMPL_H_
|
||||
|
||||
#include "include/cef_urlrequest.h"
|
||||
|
||||
#include "base/memory/ref_counted.h"
|
||||
|
||||
class CefBrowserURLRequest : public CefURLRequest {
|
||||
|
@@ -48,8 +48,7 @@ bool GetCefKeyEvent(const content::NativeWebKeyboardEvent& event,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GetCefKeyEvent(const ui::KeyEvent& event,
|
||||
CefKeyEvent& cef_event) {
|
||||
bool GetCefKeyEvent(const ui::KeyEvent& event, CefKeyEvent& cef_event) {
|
||||
content::NativeWebKeyboardEvent native_event(event);
|
||||
return GetCefKeyEvent(native_event, cef_event);
|
||||
}
|
||||
|
@@ -23,8 +23,7 @@ bool GetCefKeyEvent(const content::NativeWebKeyboardEvent& event,
|
||||
CefKeyEvent& cef_event);
|
||||
|
||||
// Convert a ui::KeyEvent to a CefKeyEvent.
|
||||
bool GetCefKeyEvent(const ui::KeyEvent& event,
|
||||
CefKeyEvent& cef_event);
|
||||
bool GetCefKeyEvent(const ui::KeyEvent& event, CefKeyEvent& cef_event);
|
||||
|
||||
} // namespace browser_util
|
||||
|
||||
|
@@ -18,10 +18,10 @@
|
||||
#include "ui/message_center/message_center.h"
|
||||
|
||||
ChromeBrowserProcessStub::ChromeBrowserProcessStub()
|
||||
: initialized_(false),
|
||||
context_initialized_(false),
|
||||
shutdown_(false),
|
||||
locale_("en-US") {
|
||||
: initialized_(false),
|
||||
context_initialized_(false),
|
||||
shutdown_(false),
|
||||
locale_("en-US") {
|
||||
chrome::SetBrowserContextIncognitoHelper(this);
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ void ChromeBrowserProcessStub::EndSession() {
|
||||
};
|
||||
|
||||
metrics_services_manager::MetricsServicesManager*
|
||||
ChromeBrowserProcessStub::GetMetricsServicesManager() {
|
||||
ChromeBrowserProcessStub::GetMetricsServicesManager() {
|
||||
NOTREACHED();
|
||||
return NULL;
|
||||
}
|
||||
@@ -124,18 +124,17 @@ ProfileManager* ChromeBrowserProcessStub::profile_manager() {
|
||||
|
||||
PrefService* ChromeBrowserProcessStub::local_state() {
|
||||
DCHECK(context_initialized_);
|
||||
return profile_manager_->GetLastUsedProfile(
|
||||
profile_manager_->user_data_dir())->GetPrefs();
|
||||
return profile_manager_->GetLastUsedProfile(profile_manager_->user_data_dir())
|
||||
->GetPrefs();
|
||||
}
|
||||
|
||||
net::URLRequestContextGetter*
|
||||
ChromeBrowserProcessStub::system_request_context() {
|
||||
ChromeBrowserProcessStub::system_request_context() {
|
||||
NOTREACHED();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
variations::VariationsService*
|
||||
ChromeBrowserProcessStub::variations_service() {
|
||||
variations::VariationsService* ChromeBrowserProcessStub::variations_service() {
|
||||
NOTREACHED();
|
||||
return NULL;
|
||||
}
|
||||
@@ -146,7 +145,7 @@ BrowserProcessPlatformPart* ChromeBrowserProcessStub::platform_part() {
|
||||
}
|
||||
|
||||
extensions::EventRouterForwarder*
|
||||
ChromeBrowserProcessStub::extension_event_router_forwarder() {
|
||||
ChromeBrowserProcessStub::extension_event_router_forwarder() {
|
||||
DCHECK(context_initialized_);
|
||||
return event_router_forwarder_.get();
|
||||
}
|
||||
@@ -157,7 +156,7 @@ NotificationUIManager* ChromeBrowserProcessStub::notification_ui_manager() {
|
||||
}
|
||||
|
||||
NotificationPlatformBridge*
|
||||
ChromeBrowserProcessStub::notification_platform_bridge() {
|
||||
ChromeBrowserProcessStub::notification_platform_bridge() {
|
||||
NOTREACHED();
|
||||
return NULL;
|
||||
}
|
||||
@@ -168,7 +167,7 @@ message_center::MessageCenter* ChromeBrowserProcessStub::message_center() {
|
||||
}
|
||||
|
||||
policy::BrowserPolicyConnector*
|
||||
ChromeBrowserProcessStub::browser_policy_connector() {
|
||||
ChromeBrowserProcessStub::browser_policy_connector() {
|
||||
NOTREACHED();
|
||||
return NULL;
|
||||
}
|
||||
@@ -214,24 +213,24 @@ printing::PrintJobManager* ChromeBrowserProcessStub::print_job_manager() {
|
||||
}
|
||||
|
||||
printing::PrintPreviewDialogController*
|
||||
ChromeBrowserProcessStub::print_preview_dialog_controller() {
|
||||
ChromeBrowserProcessStub::print_preview_dialog_controller() {
|
||||
NOTREACHED();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
printing::BackgroundPrintingManager*
|
||||
ChromeBrowserProcessStub::background_printing_manager() {
|
||||
ChromeBrowserProcessStub::background_printing_manager() {
|
||||
NOTREACHED();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
IntranetRedirectDetector*
|
||||
ChromeBrowserProcessStub::intranet_redirect_detector() {
|
||||
ChromeBrowserProcessStub::intranet_redirect_detector() {
|
||||
NOTREACHED();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const std::string &ChromeBrowserProcessStub::GetApplicationLocale() {
|
||||
const std::string& ChromeBrowserProcessStub::GetApplicationLocale() {
|
||||
DCHECK(!locale_.empty());
|
||||
return locale_;
|
||||
}
|
||||
@@ -256,7 +255,7 @@ BackgroundModeManager* ChromeBrowserProcessStub::background_mode_manager() {
|
||||
}
|
||||
|
||||
void ChromeBrowserProcessStub::set_background_mode_manager_for_test(
|
||||
std::unique_ptr<BackgroundModeManager> manager) {
|
||||
std::unique_ptr<BackgroundModeManager> manager) {
|
||||
NOTREACHED();
|
||||
}
|
||||
|
||||
@@ -266,26 +265,25 @@ StatusTray* ChromeBrowserProcessStub::status_tray() {
|
||||
}
|
||||
|
||||
safe_browsing::SafeBrowsingService*
|
||||
ChromeBrowserProcessStub::safe_browsing_service() {
|
||||
ChromeBrowserProcessStub::safe_browsing_service() {
|
||||
NOTREACHED();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
safe_browsing::ClientSideDetectionService*
|
||||
ChromeBrowserProcessStub::safe_browsing_detection_service() {
|
||||
ChromeBrowserProcessStub::safe_browsing_detection_service() {
|
||||
NOTREACHED();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
subresource_filter::ContentRulesetService*
|
||||
ChromeBrowserProcessStub::subresource_filter_ruleset_service() {
|
||||
ChromeBrowserProcessStub::subresource_filter_ruleset_service() {
|
||||
NOTREACHED();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
|
||||
void ChromeBrowserProcessStub::StartAutoupdateTimer() {
|
||||
}
|
||||
void ChromeBrowserProcessStub::StartAutoupdateTimer() {}
|
||||
#endif
|
||||
|
||||
net_log::ChromeNetLog* ChromeBrowserProcessStub::net_log() {
|
||||
@@ -294,7 +292,7 @@ net_log::ChromeNetLog* ChromeBrowserProcessStub::net_log() {
|
||||
}
|
||||
|
||||
component_updater::ComponentUpdateService*
|
||||
ChromeBrowserProcessStub::component_updater() {
|
||||
ChromeBrowserProcessStub::component_updater() {
|
||||
NOTREACHED();
|
||||
return NULL;
|
||||
}
|
||||
@@ -305,19 +303,19 @@ CRLSetFetcher* ChromeBrowserProcessStub::crl_set_fetcher() {
|
||||
}
|
||||
|
||||
component_updater::PnaclComponentInstaller*
|
||||
ChromeBrowserProcessStub::pnacl_component_installer() {
|
||||
ChromeBrowserProcessStub::pnacl_component_installer() {
|
||||
NOTREACHED();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
component_updater::SupervisedUserWhitelistInstaller*
|
||||
ChromeBrowserProcessStub::supervised_user_whitelist_installer() {
|
||||
ChromeBrowserProcessStub::supervised_user_whitelist_installer() {
|
||||
NOTREACHED();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
MediaFileSystemRegistry*
|
||||
ChromeBrowserProcessStub::media_file_system_registry() {
|
||||
ChromeBrowserProcessStub::media_file_system_registry() {
|
||||
NOTREACHED();
|
||||
return NULL;
|
||||
}
|
||||
@@ -335,7 +333,7 @@ WebRtcLogUploader* ChromeBrowserProcessStub::webrtc_log_uploader() {
|
||||
#endif
|
||||
|
||||
network_time::NetworkTimeTracker*
|
||||
ChromeBrowserProcessStub::network_time_tracker() {
|
||||
ChromeBrowserProcessStub::network_time_tracker() {
|
||||
NOTREACHED();
|
||||
return NULL;
|
||||
}
|
||||
|
@@ -12,10 +12,10 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "base/compiler_specific.h"
|
||||
#include "chrome/browser/browser_process.h"
|
||||
#include "chrome/browser/extensions/event_router_forwarder.h"
|
||||
#include "chrome/browser/profiles/incognito_helpers.h"
|
||||
#include "base/compiler_specific.h"
|
||||
#include "media/media_features.h"
|
||||
|
||||
class ChromeProfileManagerStub;
|
||||
@@ -24,6 +24,7 @@ class BackgroundModeManager {
|
||||
public:
|
||||
BackgroundModeManager();
|
||||
virtual ~BackgroundModeManager();
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(BackgroundModeManager);
|
||||
};
|
||||
@@ -41,8 +42,8 @@ class ChromeBrowserProcessStub : public BrowserProcess,
|
||||
// BrowserProcess implementation.
|
||||
void ResourceDispatcherHostCreated() override;
|
||||
void EndSession() override;
|
||||
metrics_services_manager::MetricsServicesManager*
|
||||
GetMetricsServicesManager() override;
|
||||
metrics_services_manager::MetricsServicesManager* GetMetricsServicesManager()
|
||||
override;
|
||||
metrics::MetricsService* metrics_service() override;
|
||||
rappor::RapporServiceImpl* rappor_service() override;
|
||||
IOThread* io_thread() override;
|
||||
@@ -53,8 +54,7 @@ class ChromeBrowserProcessStub : public BrowserProcess,
|
||||
net::URLRequestContextGetter* system_request_context() override;
|
||||
variations::VariationsService* variations_service() override;
|
||||
BrowserProcessPlatformPart* platform_part() override;
|
||||
extensions::EventRouterForwarder*
|
||||
extension_event_router_forwarder() override;
|
||||
extensions::EventRouterForwarder* extension_event_router_forwarder() override;
|
||||
NotificationUIManager* notification_ui_manager() override;
|
||||
NotificationPlatformBridge* notification_platform_bridge() override;
|
||||
message_center::MessageCenter* message_center() override;
|
||||
@@ -68,10 +68,9 @@ class ChromeBrowserProcessStub : public BrowserProcess,
|
||||
void CreateDevToolsAutoOpener() override;
|
||||
bool IsShuttingDown() override;
|
||||
printing::PrintJobManager* print_job_manager() override;
|
||||
printing::PrintPreviewDialogController*
|
||||
print_preview_dialog_controller() override;
|
||||
printing::BackgroundPrintingManager*
|
||||
background_printing_manager() override;
|
||||
printing::PrintPreviewDialogController* print_preview_dialog_controller()
|
||||
override;
|
||||
printing::BackgroundPrintingManager* background_printing_manager() override;
|
||||
IntranetRedirectDetector* intranet_redirect_detector() override;
|
||||
const std::string& GetApplicationLocale() override;
|
||||
void SetApplicationLocale(const std::string& locale) override;
|
||||
@@ -82,33 +81,31 @@ class ChromeBrowserProcessStub : public BrowserProcess,
|
||||
std::unique_ptr<BackgroundModeManager> manager) override;
|
||||
StatusTray* status_tray() override;
|
||||
safe_browsing::SafeBrowsingService* safe_browsing_service() override;
|
||||
safe_browsing::ClientSideDetectionService*
|
||||
safe_browsing_detection_service() override;
|
||||
safe_browsing::ClientSideDetectionService* safe_browsing_detection_service()
|
||||
override;
|
||||
subresource_filter::ContentRulesetService*
|
||||
subresource_filter_ruleset_service() override;
|
||||
subresource_filter_ruleset_service() override;
|
||||
|
||||
#if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
|
||||
void StartAutoupdateTimer() override;
|
||||
#endif
|
||||
|
||||
net_log::ChromeNetLog* net_log() override;
|
||||
component_updater::ComponentUpdateService*
|
||||
component_updater() override;
|
||||
component_updater::ComponentUpdateService* component_updater() override;
|
||||
CRLSetFetcher* crl_set_fetcher() override;
|
||||
component_updater::PnaclComponentInstaller*
|
||||
pnacl_component_installer() override;
|
||||
component_updater::PnaclComponentInstaller* pnacl_component_installer()
|
||||
override;
|
||||
component_updater::SupervisedUserWhitelistInstaller*
|
||||
supervised_user_whitelist_installer() override;
|
||||
MediaFileSystemRegistry*
|
||||
media_file_system_registry() override;
|
||||
supervised_user_whitelist_installer() override;
|
||||
MediaFileSystemRegistry* media_file_system_registry() override;
|
||||
bool created_local_state() const override;
|
||||
#if BUILDFLAG(ENABLE_WEBRTC)
|
||||
WebRtcLogUploader* webrtc_log_uploader() override;
|
||||
#endif
|
||||
network_time::NetworkTimeTracker* network_time_tracker() override;
|
||||
gcm::GCMDriver* gcm_driver() override;
|
||||
shell_integration::DefaultWebClientState
|
||||
CachedDefaultWebClientState() override;
|
||||
shell_integration::DefaultWebClientState CachedDefaultWebClientState()
|
||||
override;
|
||||
memory::TabManager* GetTabManager() override;
|
||||
physical_web::PhysicalWebDataSource* GetPhysicalWebDataSource() override;
|
||||
|
||||
|
@@ -28,11 +28,9 @@ CefBrowserContextImpl* GetActiveBrowserContext() {
|
||||
} // namespace
|
||||
|
||||
ChromeProfileManagerStub::ChromeProfileManagerStub()
|
||||
: ProfileManager(base::FilePath()) {
|
||||
}
|
||||
: ProfileManager(base::FilePath()) {}
|
||||
|
||||
ChromeProfileManagerStub::~ChromeProfileManagerStub() {
|
||||
}
|
||||
ChromeProfileManagerStub::~ChromeProfileManagerStub() {}
|
||||
|
||||
Profile* ChromeProfileManagerStub::GetProfile(
|
||||
const base::FilePath& profile_dir) {
|
||||
@@ -54,8 +52,7 @@ bool ChromeProfileManagerStub::IsValidProfile(const void* profile) {
|
||||
if (!profile)
|
||||
return false;
|
||||
return !!CefBrowserContextImpl::GetForContext(
|
||||
reinterpret_cast<content::BrowserContext*>(
|
||||
const_cast<void*>(profile)));
|
||||
reinterpret_cast<content::BrowserContext*>(const_cast<void*>(profile)));
|
||||
}
|
||||
|
||||
Profile* ChromeProfileManagerStub::GetLastUsedProfile(
|
||||
|
@@ -5,11 +5,9 @@
|
||||
|
||||
#include "libcef/browser/chrome_profile_stub.h"
|
||||
|
||||
ChromeProfileStub::ChromeProfileStub() {
|
||||
}
|
||||
ChromeProfileStub::ChromeProfileStub() {}
|
||||
|
||||
ChromeProfileStub::~ChromeProfileStub() {
|
||||
}
|
||||
ChromeProfileStub::~ChromeProfileStub() {}
|
||||
|
||||
scoped_refptr<base::SequencedTaskRunner> ChromeProfileStub::GetIOTaskRunner() {
|
||||
NOTREACHED();
|
||||
@@ -57,7 +55,7 @@ bool ChromeProfileStub::IsLegacySupervised() const {
|
||||
}
|
||||
|
||||
ExtensionSpecialStoragePolicy*
|
||||
ChromeProfileStub::GetExtensionSpecialStoragePolicy() {
|
||||
ChromeProfileStub::GetExtensionSpecialStoragePolicy() {
|
||||
NOTREACHED();
|
||||
return NULL;
|
||||
}
|
||||
@@ -68,7 +66,7 @@ PrefService* ChromeProfileStub::GetOffTheRecordPrefs() {
|
||||
}
|
||||
|
||||
net::URLRequestContextGetter*
|
||||
ChromeProfileStub::GetRequestContextForExtensions() {
|
||||
ChromeProfileStub::GetRequestContextForExtensions() {
|
||||
// TODO(cef): Consider creating a separate context for extensions to match
|
||||
// Chrome behavior.
|
||||
return GetRequestContext();
|
||||
@@ -110,7 +108,7 @@ chrome_browser_net::Predictor* ChromeProfileStub::GetNetworkPredictor() {
|
||||
}
|
||||
|
||||
DevToolsNetworkControllerHandle*
|
||||
ChromeProfileStub::GetDevToolsNetworkControllerHandle() {
|
||||
ChromeProfileStub::GetDevToolsNetworkControllerHandle() {
|
||||
NOTREACHED();
|
||||
return NULL;
|
||||
}
|
||||
@@ -126,8 +124,7 @@ GURL ChromeProfileStub::GetHomePage() {
|
||||
return GURL();
|
||||
}
|
||||
|
||||
bool ChromeProfileStub::WasCreatedByVersionOrLater(
|
||||
const std::string& version) {
|
||||
bool ChromeProfileStub::WasCreatedByVersionOrLater(const std::string& version) {
|
||||
NOTREACHED();
|
||||
return false;
|
||||
}
|
||||
|
@@ -30,8 +30,7 @@ class ChromeProfileStub : public Profile {
|
||||
bool IsSupervised() const override;
|
||||
bool IsChild() const override;
|
||||
bool IsLegacySupervised() const override;
|
||||
ExtensionSpecialStoragePolicy*
|
||||
GetExtensionSpecialStoragePolicy() override;
|
||||
ExtensionSpecialStoragePolicy* GetExtensionSpecialStoragePolicy() override;
|
||||
PrefService* GetOffTheRecordPrefs() override;
|
||||
net::URLRequestContextGetter* GetRequestContextForExtensions() override;
|
||||
net::SSLConfigService* GetSSLConfigService() override;
|
||||
@@ -41,8 +40,8 @@ class ChromeProfileStub : public Profile {
|
||||
void set_last_selected_directory(const base::FilePath& path) override;
|
||||
PrefProxyConfigTracker* GetProxyConfigTracker() override;
|
||||
chrome_browser_net::Predictor* GetNetworkPredictor() override;
|
||||
DevToolsNetworkControllerHandle*
|
||||
GetDevToolsNetworkControllerHandle() override;
|
||||
DevToolsNetworkControllerHandle* GetDevToolsNetworkControllerHandle()
|
||||
override;
|
||||
void ClearNetworkingHistorySince(base::Time time,
|
||||
const base::Closure& completion) override;
|
||||
GURL GetHomePage() override;
|
||||
|
@@ -8,9 +8,9 @@
|
||||
#include <utility>
|
||||
|
||||
#include "libcef/browser/browser_context.h"
|
||||
#include "libcef/browser/browser_host_impl.h"
|
||||
#include "libcef/browser/browser_info.h"
|
||||
#include "libcef/browser/browser_info_manager.h"
|
||||
#include "libcef/browser/browser_host_impl.h"
|
||||
#include "libcef/browser/browser_main.h"
|
||||
#include "libcef/browser/browser_message_filter.h"
|
||||
#include "libcef/browser/browser_platform_delegate.h"
|
||||
@@ -70,9 +70,9 @@
|
||||
#include "content/public/common/service_names.mojom.h"
|
||||
#include "content/public/common/storage_quota_params.h"
|
||||
#include "content/public/common/web_preferences.h"
|
||||
#include "extensions/browser/extensions_browser_client.h"
|
||||
#include "extensions/browser/extension_message_filter.h"
|
||||
#include "extensions/browser/extension_registry.h"
|
||||
#include "extensions/browser/extensions_browser_client.h"
|
||||
#include "extensions/browser/guest_view/extensions_guest_view_message_filter.h"
|
||||
#include "extensions/browser/io_thread_extension_message_filter.h"
|
||||
#include "extensions/common/constants.h"
|
||||
@@ -111,8 +111,7 @@ class CefQuotaCallbackImpl : public CefRequestCallback {
|
||||
public:
|
||||
explicit CefQuotaCallbackImpl(
|
||||
const content::QuotaPermissionContext::PermissionCallback& callback)
|
||||
: callback_(callback) {
|
||||
}
|
||||
: callback_(callback) {}
|
||||
|
||||
~CefQuotaCallbackImpl() {
|
||||
if (!callback_.is_null()) {
|
||||
@@ -120,8 +119,8 @@ class CefQuotaCallbackImpl : public CefRequestCallback {
|
||||
if (CEF_CURRENTLY_ON_IOT()) {
|
||||
RunNow(callback_, false);
|
||||
} else {
|
||||
CEF_POST_TASK(CEF_IOT,
|
||||
base::Bind(&CefQuotaCallbackImpl::RunNow, callback_, false));
|
||||
CEF_POST_TASK(CEF_IOT, base::Bind(&CefQuotaCallbackImpl::RunNow,
|
||||
callback_, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -134,26 +133,23 @@ class CefQuotaCallbackImpl : public CefRequestCallback {
|
||||
}
|
||||
} else {
|
||||
CEF_POST_TASK(CEF_IOT,
|
||||
base::Bind(&CefQuotaCallbackImpl::Continue, this, allow));
|
||||
base::Bind(&CefQuotaCallbackImpl::Continue, this, allow));
|
||||
}
|
||||
}
|
||||
|
||||
void Cancel() override {
|
||||
Continue(false);
|
||||
}
|
||||
void Cancel() override { Continue(false); }
|
||||
|
||||
void Disconnect() {
|
||||
callback_.Reset();
|
||||
}
|
||||
void Disconnect() { callback_.Reset(); }
|
||||
|
||||
private:
|
||||
static void RunNow(
|
||||
const content::QuotaPermissionContext::PermissionCallback& callback,
|
||||
bool allow) {
|
||||
CEF_REQUIRE_IOT();
|
||||
callback.Run(allow ?
|
||||
content::QuotaPermissionContext::QUOTA_PERMISSION_RESPONSE_ALLOW :
|
||||
content::QuotaPermissionContext::QUOTA_PERMISSION_RESPONSE_DISALLOW);
|
||||
callback.Run(
|
||||
allow ? content::QuotaPermissionContext::QUOTA_PERMISSION_RESPONSE_ALLOW
|
||||
: content::QuotaPermissionContext::
|
||||
QUOTA_PERMISSION_RESPONSE_DISALLOW);
|
||||
}
|
||||
|
||||
content::QuotaPermissionContext::PermissionCallback callback_;
|
||||
@@ -168,8 +164,7 @@ class CefAllowCertificateErrorCallbackImpl : public CefRequestCallback {
|
||||
CallbackType;
|
||||
|
||||
explicit CefAllowCertificateErrorCallbackImpl(const CallbackType& callback)
|
||||
: callback_(callback) {
|
||||
}
|
||||
: callback_(callback) {}
|
||||
|
||||
~CefAllowCertificateErrorCallbackImpl() {
|
||||
if (!callback_.is_null()) {
|
||||
@@ -178,8 +173,8 @@ class CefAllowCertificateErrorCallbackImpl : public CefRequestCallback {
|
||||
RunNow(callback_, false);
|
||||
} else {
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
base::Bind(&CefAllowCertificateErrorCallbackImpl::RunNow,
|
||||
callback_, false));
|
||||
base::Bind(&CefAllowCertificateErrorCallbackImpl::RunNow,
|
||||
callback_, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -192,24 +187,20 @@ class CefAllowCertificateErrorCallbackImpl : public CefRequestCallback {
|
||||
}
|
||||
} else {
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
base::Bind(&CefAllowCertificateErrorCallbackImpl::Continue,
|
||||
this, allow));
|
||||
base::Bind(&CefAllowCertificateErrorCallbackImpl::Continue,
|
||||
this, allow));
|
||||
}
|
||||
}
|
||||
|
||||
void Cancel() override {
|
||||
Continue(false);
|
||||
}
|
||||
void Cancel() override { Continue(false); }
|
||||
|
||||
void Disconnect() {
|
||||
callback_.Reset();
|
||||
}
|
||||
void Disconnect() { callback_.Reset(); }
|
||||
|
||||
private:
|
||||
static void RunNow(const CallbackType& callback, bool allow) {
|
||||
CEF_REQUIRE_UIT();
|
||||
callback.Run(allow ? content::CERTIFICATE_REQUEST_RESULT_TYPE_CONTINUE :
|
||||
content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL);
|
||||
callback.Run(allow ? content::CERTIFICATE_REQUEST_RESULT_TYPE_CONTINUE
|
||||
: content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL);
|
||||
}
|
||||
|
||||
CallbackType callback_;
|
||||
@@ -218,13 +209,12 @@ class CefAllowCertificateErrorCallbackImpl : public CefRequestCallback {
|
||||
DISALLOW_COPY_AND_ASSIGN(CefAllowCertificateErrorCallbackImpl);
|
||||
};
|
||||
|
||||
class CefSelectClientCertificateCallbackImpl :
|
||||
public CefSelectClientCertificateCallback {
|
||||
class CefSelectClientCertificateCallbackImpl
|
||||
: public CefSelectClientCertificateCallback {
|
||||
public:
|
||||
explicit CefSelectClientCertificateCallbackImpl(
|
||||
std::unique_ptr<content::ClientCertificateDelegate> delegate)
|
||||
: delegate_(std::move(delegate)) {
|
||||
}
|
||||
: delegate_(std::move(delegate)) {}
|
||||
|
||||
~CefSelectClientCertificateCallbackImpl() {
|
||||
// If Select has not been called, call it with NULL to continue without any
|
||||
@@ -244,8 +234,8 @@ class CefSelectClientCertificateCallbackImpl :
|
||||
RunNow(std::move(delegate_), cert);
|
||||
} else {
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
base::Bind(&CefSelectClientCertificateCallbackImpl::RunNow,
|
||||
base::Passed(std::move(delegate_)), cert));
|
||||
base::Bind(&CefSelectClientCertificateCallbackImpl::RunNow,
|
||||
base::Passed(std::move(delegate_)), cert));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -272,14 +262,12 @@ class CefSelectClientCertificateCallbackImpl :
|
||||
|
||||
class CefQuotaPermissionContext : public content::QuotaPermissionContext {
|
||||
public:
|
||||
CefQuotaPermissionContext() {
|
||||
}
|
||||
CefQuotaPermissionContext() {}
|
||||
|
||||
// The callback will be dispatched on the IO thread.
|
||||
void RequestQuotaPermission(
|
||||
const content::StorageQuotaParams& params,
|
||||
int render_process_id,
|
||||
const PermissionCallback& callback) override {
|
||||
void RequestQuotaPermission(const content::StorageQuotaParams& params,
|
||||
int render_process_id,
|
||||
const PermissionCallback& callback) override {
|
||||
if (params.storage_type != storage::kStorageTypePersistent) {
|
||||
// To match Chrome behavior we only support requesting quota with this
|
||||
// interface for Persistent storage type.
|
||||
@@ -299,10 +287,9 @@ class CefQuotaPermissionContext : public content::QuotaPermissionContext {
|
||||
if (handler.get()) {
|
||||
CefRefPtr<CefQuotaCallbackImpl> callbackImpl(
|
||||
new CefQuotaCallbackImpl(callback));
|
||||
handled = handler->OnQuotaRequest(browser.get(),
|
||||
params.origin_url.spec(),
|
||||
params.requested_size,
|
||||
callbackImpl.get());
|
||||
handled = handler->OnQuotaRequest(
|
||||
browser.get(), params.origin_url.spec(), params.requested_size,
|
||||
callbackImpl.get());
|
||||
if (!handled)
|
||||
callbackImpl->Disconnect();
|
||||
}
|
||||
@@ -331,8 +318,8 @@ breakpad::CrashHandlerHostLinux* CreateCrashHandlerHost(
|
||||
// Uploads will only occur if a non-empty crash URL is specified in
|
||||
// CefMainDelegate::InitCrashReporter.
|
||||
breakpad::CrashHandlerHostLinux* crash_handler =
|
||||
new breakpad::CrashHandlerHostLinux(
|
||||
process_type, dumps_path, true /* upload */);
|
||||
new breakpad::CrashHandlerHostLinux(process_type, dumps_path,
|
||||
true /* upload */);
|
||||
crash_handler->StartUploaderThread();
|
||||
return crash_handler;
|
||||
}
|
||||
@@ -408,12 +395,9 @@ bool NavigationOnUIThread(
|
||||
} else {
|
||||
// Create a temporary frame object for navigation of sub-frames that
|
||||
// don't yet exist.
|
||||
frame = new CefFrameHostImpl(browser.get(),
|
||||
CefFrameHostImpl::kInvalidFrameId,
|
||||
false,
|
||||
CefString(),
|
||||
CefString(),
|
||||
parent_frame_id);
|
||||
frame = new CefFrameHostImpl(
|
||||
browser.get(), CefFrameHostImpl::kInvalidFrameId, false,
|
||||
CefString(), CefString(), parent_frame_id);
|
||||
}
|
||||
|
||||
CefRefPtr<CefRequestImpl> request = new CefRequestImpl();
|
||||
@@ -441,16 +425,13 @@ void FindFrameHostForNavigationHandle(
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
CefContentBrowserClient::CefContentBrowserClient()
|
||||
: browser_main_parts_(NULL) {
|
||||
CefContentBrowserClient::CefContentBrowserClient() : browser_main_parts_(NULL) {
|
||||
plugin_service_filter_.reset(new CefPluginServiceFilter);
|
||||
content::PluginServiceImpl::GetInstance()->SetFilter(
|
||||
plugin_service_filter_.get());
|
||||
}
|
||||
|
||||
CefContentBrowserClient::~CefContentBrowserClient() {
|
||||
}
|
||||
CefContentBrowserClient::~CefContentBrowserClient() {}
|
||||
|
||||
// static
|
||||
CefContentBrowserClient* CefContentBrowserClient::Get() {
|
||||
@@ -481,12 +462,11 @@ void CefContentBrowserClient::RenderProcessWillLaunch(
|
||||
#endif
|
||||
}
|
||||
|
||||
host->AddFilter(new CefPluginInfoMessageFilter(id,
|
||||
static_cast<CefBrowserContext*>(profile)));
|
||||
host->AddFilter(new CefPluginInfoMessageFilter(
|
||||
id, static_cast<CefBrowserContext*>(profile)));
|
||||
|
||||
if (extensions::ExtensionsEnabled()) {
|
||||
host->AddFilter(
|
||||
new extensions::ExtensionMessageFilter(id, profile));
|
||||
host->AddFilter(new extensions::ExtensionMessageFilter(id, profile));
|
||||
host->AddFilter(
|
||||
new extensions::IOThreadExtensionMessageFilter(id, profile));
|
||||
host->AddFilter(
|
||||
@@ -499,8 +479,8 @@ void CefContentBrowserClient::RenderProcessWillLaunch(
|
||||
host->RemoveObserver(CefBrowserInfoManager::GetInstance());
|
||||
host->AddObserver(CefBrowserInfoManager::GetInstance());
|
||||
|
||||
host->Send(new CefProcessMsg_SetIsIncognitoProcess(
|
||||
profile->IsOffTheRecord()));
|
||||
host->Send(
|
||||
new CefProcessMsg_SetIsIncognitoProcess(profile->IsOffTheRecord()));
|
||||
}
|
||||
|
||||
bool CefContentBrowserClient::ShouldUseProcessPerSite(
|
||||
@@ -556,16 +536,14 @@ void CefContentBrowserClient::SiteInstanceGotProcess(
|
||||
static_cast<CefBrowserContext*>(site_instance->GetBrowserContext());
|
||||
|
||||
extensions::ProcessMap::Get(browser_context)
|
||||
->Insert(extension->id(),
|
||||
site_instance->GetProcess()->GetID(),
|
||||
->Insert(extension->id(), site_instance->GetProcess()->GetID(),
|
||||
site_instance->GetId());
|
||||
|
||||
CEF_POST_TASK(CEF_IOT,
|
||||
base::Bind(&extensions::InfoMap::RegisterExtensionProcess,
|
||||
browser_context->extension_system()->info_map(),
|
||||
extension->id(),
|
||||
site_instance->GetProcess()->GetID(),
|
||||
site_instance->GetId()));
|
||||
CEF_POST_TASK(
|
||||
CEF_IOT, base::Bind(&extensions::InfoMap::RegisterExtensionProcess,
|
||||
browser_context->extension_system()->info_map(),
|
||||
extension->id(), site_instance->GetProcess()->GetID(),
|
||||
site_instance->GetId()));
|
||||
}
|
||||
|
||||
void CefContentBrowserClient::SiteInstanceDeleting(
|
||||
@@ -586,20 +564,18 @@ void CefContentBrowserClient::SiteInstanceDeleting(
|
||||
static_cast<CefBrowserContext*>(site_instance->GetBrowserContext());
|
||||
|
||||
extensions::ProcessMap::Get(browser_context)
|
||||
->Remove(extension->id(),
|
||||
site_instance->GetProcess()->GetID(),
|
||||
->Remove(extension->id(), site_instance->GetProcess()->GetID(),
|
||||
site_instance->GetId());
|
||||
|
||||
CEF_POST_TASK(CEF_IOT,
|
||||
base::Bind(&extensions::InfoMap::UnregisterExtensionProcess,
|
||||
browser_context->extension_system()->info_map(),
|
||||
extension->id(),
|
||||
site_instance->GetProcess()->GetID(),
|
||||
site_instance->GetId()));
|
||||
CEF_POST_TASK(
|
||||
CEF_IOT, base::Bind(&extensions::InfoMap::UnregisterExtensionProcess,
|
||||
browser_context->extension_system()->info_map(),
|
||||
extension->id(), site_instance->GetProcess()->GetID(),
|
||||
site_instance->GetId()));
|
||||
}
|
||||
|
||||
std::unique_ptr<base::Value>
|
||||
CefContentBrowserClient::GetServiceManifestOverlay(base::StringPiece name) {
|
||||
std::unique_ptr<base::Value> CefContentBrowserClient::GetServiceManifestOverlay(
|
||||
base::StringPiece name) {
|
||||
int id = -1;
|
||||
if (name == content::mojom::kBrowserServiceName)
|
||||
id = IDR_CEF_BROWSER_MANIFEST_OVERLAY;
|
||||
@@ -617,9 +593,9 @@ CefContentBrowserClient::GetServiceManifestOverlay(base::StringPiece name) {
|
||||
}
|
||||
|
||||
void CefContentBrowserClient::AppendExtraCommandLineSwitches(
|
||||
base::CommandLine* command_line, int child_process_id) {
|
||||
const base::CommandLine* browser_cmd =
|
||||
base::CommandLine::ForCurrentProcess();
|
||||
base::CommandLine* command_line,
|
||||
int child_process_id) {
|
||||
const base::CommandLine* browser_cmd = base::CommandLine::ForCurrentProcess();
|
||||
|
||||
{
|
||||
// Propagate the following switches to all command lines (along with any
|
||||
@@ -647,16 +623,11 @@ void CefContentBrowserClient::AppendExtraCommandLineSwitches(
|
||||
// Propagate the following switches to the renderer command line (along with
|
||||
// any associated values) if present in the browser command line.
|
||||
static const char* const kSwitchNames[] = {
|
||||
switches::kDisableExtensions,
|
||||
switches::kDisablePdfExtension,
|
||||
switches::kDisableScrollBounce,
|
||||
switches::kDisableSpellChecking,
|
||||
switches::kEnableSpeechInput,
|
||||
switches::kEnableSystemFlash,
|
||||
switches::kPpapiFlashArgs,
|
||||
switches::kPpapiFlashPath,
|
||||
switches::kPpapiFlashVersion,
|
||||
switches::kUncaughtExceptionStackSize,
|
||||
switches::kDisableExtensions, switches::kDisablePdfExtension,
|
||||
switches::kDisableScrollBounce, switches::kDisableSpellChecking,
|
||||
switches::kEnableSpeechInput, switches::kEnableSystemFlash,
|
||||
switches::kPpapiFlashArgs, switches::kPpapiFlashPath,
|
||||
switches::kPpapiFlashVersion, switches::kUncaughtExceptionStackSize,
|
||||
};
|
||||
command_line->CopySwitchesFrom(*browser_cmd, kSwitchNames,
|
||||
arraysize(kSwitchNames));
|
||||
@@ -668,9 +639,8 @@ void CefContentBrowserClient::AppendExtraCommandLineSwitches(
|
||||
content::RenderProcessHost::FromID(child_process_id);
|
||||
content::BrowserContext* browser_context =
|
||||
process ? process->GetBrowserContext() : NULL;
|
||||
if (browser_context &&
|
||||
extensions::ProcessMap::Get(browser_context)->Contains(
|
||||
process->GetID())) {
|
||||
if (browser_context && extensions::ProcessMap::Get(browser_context)
|
||||
->Contains(process->GetID())) {
|
||||
command_line->AppendSwitch(extensions::switches::kExtensionProcess);
|
||||
}
|
||||
}
|
||||
@@ -681,8 +651,7 @@ void CefContentBrowserClient::AppendExtraCommandLineSwitches(
|
||||
// Propagate the following switches to the zygote command line (along with
|
||||
// any associated values) if present in the browser command line.
|
||||
static const char* const kSwitchNames[] = {
|
||||
switches::kPpapiFlashPath,
|
||||
switches::kPpapiFlashVersion,
|
||||
switches::kPpapiFlashPath, switches::kPpapiFlashVersion,
|
||||
};
|
||||
command_line->CopySwitchesFrom(*browser_cmd, kSwitchNames,
|
||||
arraysize(kSwitchNames));
|
||||
@@ -721,7 +690,7 @@ void CefContentBrowserClient::AppendExtraCommandLineSwitches(
|
||||
}
|
||||
|
||||
content::QuotaPermissionContext*
|
||||
CefContentBrowserClient::CreateQuotaPermissionContext() {
|
||||
CefContentBrowserClient::CreateQuotaPermissionContext() {
|
||||
return new CefQuotaPermissionContext();
|
||||
}
|
||||
|
||||
@@ -741,7 +710,7 @@ content::MediaObserver* CefContentBrowserClient::GetMediaObserver() {
|
||||
}
|
||||
|
||||
content::SpeechRecognitionManagerDelegate*
|
||||
CefContentBrowserClient::CreateSpeechRecognitionManagerDelegate() {
|
||||
CefContentBrowserClient::CreateSpeechRecognitionManagerDelegate() {
|
||||
const base::CommandLine* command_line =
|
||||
base::CommandLine::ForCurrentProcess();
|
||||
if (command_line->HasSwitch(switches::kEnableSpeechInput))
|
||||
@@ -759,8 +728,8 @@ void CefContentBrowserClient::AllowCertificateError(
|
||||
bool overridable,
|
||||
bool strict_enforcement,
|
||||
bool expired_previous_decision,
|
||||
const base::Callback<
|
||||
void(content::CertificateRequestResultType)>& callback) {
|
||||
const base::Callback<void(content::CertificateRequestResultType)>&
|
||||
callback) {
|
||||
CEF_REQUIRE_UIT();
|
||||
|
||||
if (resource_type != content::ResourceType::RESOURCE_TYPE_MAIN_FRAME) {
|
||||
@@ -817,9 +786,9 @@ void CefContentBrowserClient::SelectClientCertificate(
|
||||
}
|
||||
|
||||
CefRequestHandler::X509CertificateList certs;
|
||||
for (std::vector<scoped_refptr<net::X509Certificate> >::iterator iter =
|
||||
for (std::vector<scoped_refptr<net::X509Certificate>>::iterator iter =
|
||||
cert_request_info->client_certs.begin();
|
||||
iter != cert_request_info->client_certs.end(); iter++) {
|
||||
iter != cert_request_info->client_certs.end(); iter++) {
|
||||
certs.push_back(new CefX509CertificateImpl(*iter));
|
||||
}
|
||||
|
||||
@@ -829,8 +798,7 @@ void CefContentBrowserClient::SelectClientCertificate(
|
||||
bool proceed = handler->OnSelectClientCertificate(
|
||||
browser.get(), cert_request_info->is_proxy,
|
||||
cert_request_info->host_and_port.host(),
|
||||
cert_request_info->host_and_port.port(),
|
||||
certs, callbackImpl.get());
|
||||
cert_request_info->host_and_port.port(), certs, callbackImpl.get());
|
||||
|
||||
if (!proceed && !certs.empty()) {
|
||||
callbackImpl->Select(certs[0]);
|
||||
@@ -899,7 +867,7 @@ void CefContentBrowserClient::DidCreatePpapiPlugin(
|
||||
}
|
||||
|
||||
content::DevToolsManagerDelegate*
|
||||
CefContentBrowserClient::GetDevToolsManagerDelegate() {
|
||||
CefContentBrowserClient::GetDevToolsManagerDelegate() {
|
||||
return new CefDevToolsManagerDelegate();
|
||||
}
|
||||
|
||||
@@ -921,9 +889,9 @@ CefContentBrowserClient::CreateThrottlesForNavigation(
|
||||
// comments in content/browser/frame_host/navigation_handle_impl.h.
|
||||
content::WebContents* web_contents = navigation_handle->GetWebContents();
|
||||
content::RenderFrameHost* parent_frame_host = NULL;
|
||||
web_contents->ForEachFrame(
|
||||
base::Bind(FindFrameHostForNavigationHandle,
|
||||
navigation_handle, &parent_frame_host));
|
||||
web_contents->ForEachFrame(base::Bind(FindFrameHostForNavigationHandle,
|
||||
navigation_handle,
|
||||
&parent_frame_host));
|
||||
DCHECK(parent_frame_host);
|
||||
|
||||
parent_frame_id = parent_frame_host->GetRoutingID();
|
||||
@@ -961,10 +929,9 @@ void CefContentBrowserClient::GetAdditionalMappedFilesForChildProcess(
|
||||
}
|
||||
#endif // defined(OS_POSIX) && !defined(OS_MACOSX)
|
||||
|
||||
|
||||
#if defined(OS_WIN)
|
||||
const wchar_t* CefContentBrowserClient::GetResourceDllName() {
|
||||
static wchar_t file_path[MAX_PATH+1] = {0};
|
||||
static wchar_t file_path[MAX_PATH + 1] = {0};
|
||||
|
||||
if (file_path[0] == 0) {
|
||||
// Retrieve the module path (usually libcef.dll).
|
||||
@@ -979,8 +946,7 @@ const wchar_t* CefContentBrowserClient::GetResourceDllName() {
|
||||
return file_path;
|
||||
}
|
||||
|
||||
bool CefContentBrowserClient::PreSpawnRenderer(
|
||||
sandbox::TargetPolicy* policy) {
|
||||
bool CefContentBrowserClient::PreSpawnRenderer(sandbox::TargetPolicy* policy) {
|
||||
return true;
|
||||
}
|
||||
#endif // defined(OS_WIN)
|
||||
@@ -995,8 +961,8 @@ void CefContentBrowserClient::RegisterCustomScheme(const std::string& scheme) {
|
||||
policy->RegisterWebSafeScheme(scheme);
|
||||
}
|
||||
|
||||
CefRefPtr<CefRequestContextImpl>
|
||||
CefContentBrowserClient::request_context() const {
|
||||
CefRefPtr<CefRequestContextImpl> CefContentBrowserClient::request_context()
|
||||
const {
|
||||
return browser_main_parts_->request_context();
|
||||
}
|
||||
|
||||
|
@@ -43,8 +43,7 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
|
||||
// ContentBrowserClient implementation.
|
||||
content::BrowserMainParts* CreateBrowserMainParts(
|
||||
const content::MainFunctionParams& parameters) override;
|
||||
void RenderProcessWillLaunch(
|
||||
content::RenderProcessHost* host) override;
|
||||
void RenderProcessWillLaunch(content::RenderProcessHost* host) override;
|
||||
bool ShouldUseProcessPerSite(content::BrowserContext* browser_context,
|
||||
const GURL& effective_url) override;
|
||||
bool IsHandledURL(const GURL& url) override;
|
||||
@@ -53,16 +52,15 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
|
||||
std::unique_ptr<base::Value> GetServiceManifestOverlay(
|
||||
base::StringPiece name) override;
|
||||
void AppendExtraCommandLineSwitches(base::CommandLine* command_line,
|
||||
int child_process_id) override;
|
||||
content::QuotaPermissionContext*
|
||||
CreateQuotaPermissionContext() override;
|
||||
int child_process_id) override;
|
||||
content::QuotaPermissionContext* CreateQuotaPermissionContext() override;
|
||||
void GetQuotaSettings(
|
||||
content::BrowserContext* context,
|
||||
content::StoragePartition* partition,
|
||||
const storage::OptionalQuotaSettingsCallback& callback) override;
|
||||
content::MediaObserver* GetMediaObserver() override;
|
||||
content::SpeechRecognitionManagerDelegate*
|
||||
CreateSpeechRecognitionManagerDelegate() override;
|
||||
CreateSpeechRecognitionManagerDelegate() override;
|
||||
void AllowCertificateError(
|
||||
content::WebContents* web_contents,
|
||||
int cert_error,
|
||||
@@ -72,8 +70,8 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
|
||||
bool overridable,
|
||||
bool strict_enforcement,
|
||||
bool expired_previous_decision,
|
||||
const base::Callback<
|
||||
void(content::CertificateRequestResultType)>& callback) override;
|
||||
const base::Callback<void(content::CertificateRequestResultType)>&
|
||||
callback) override;
|
||||
void SelectClientCertificate(
|
||||
content::WebContents* web_contents,
|
||||
net::SSLCertRequestInfo* cert_request_info,
|
||||
@@ -96,12 +94,10 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
|
||||
void ResourceDispatcherHostCreated() override;
|
||||
void OverrideWebkitPrefs(content::RenderViewHost* rvh,
|
||||
content::WebPreferences* prefs) override;
|
||||
void BrowserURLHandlerCreated(
|
||||
content::BrowserURLHandler* handler) override;
|
||||
void BrowserURLHandlerCreated(content::BrowserURLHandler* handler) override;
|
||||
std::string GetDefaultDownloadName() override;
|
||||
void DidCreatePpapiPlugin(content::BrowserPpapiHost* browser_host) override;
|
||||
content::DevToolsManagerDelegate* GetDevToolsManagerDelegate()
|
||||
override;
|
||||
content::DevToolsManagerDelegate* GetDevToolsManagerDelegate() override;
|
||||
std::vector<std::unique_ptr<content::NavigationThrottle>>
|
||||
CreateThrottlesForNavigation(
|
||||
content::NavigationHandle* navigation_handle) override;
|
||||
|
@@ -2,13 +2,13 @@
|
||||
// reserved. Use of this source code is governed by a BSD-style license that can
|
||||
// be found in the LICENSE file.
|
||||
|
||||
#include "libcef/browser/context.h"
|
||||
#include "libcef/browser/browser_host_impl.h"
|
||||
#include "libcef/browser/browser_info.h"
|
||||
#include "libcef/browser/browser_info_manager.h"
|
||||
#include "libcef/browser/browser_main.h"
|
||||
#include "libcef/browser/browser_message_loop.h"
|
||||
#include "libcef/browser/chrome_browser_process_stub.h"
|
||||
#include "libcef/browser/context.h"
|
||||
#include "libcef/browser/thread_util.h"
|
||||
#include "libcef/browser/trace_subscriber.h"
|
||||
#include "libcef/common/cef_switches.h"
|
||||
@@ -33,8 +33,8 @@
|
||||
#if defined(OS_WIN)
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "chrome_elf/chrome_elf_main.h"
|
||||
#include "content/public/app/sandbox_helper_win.h"
|
||||
#include "components/crash/content/app/crashpad.h"
|
||||
#include "content/public/app/sandbox_helper_win.h"
|
||||
#include "sandbox/win/src/sandbox_types.h"
|
||||
#endif
|
||||
|
||||
@@ -51,9 +51,7 @@ CefContext* g_context = NULL;
|
||||
// When the process terminates check if CefShutdown() has been called.
|
||||
class CefShutdownChecker {
|
||||
public:
|
||||
~CefShutdownChecker() {
|
||||
DCHECK(!g_context) << "CefShutdown was not called";
|
||||
}
|
||||
~CefShutdownChecker() { DCHECK(!g_context) << "CefShutdown was not called"; }
|
||||
} g_shutdown_checker;
|
||||
#endif // DCHECK_IS_ON()
|
||||
|
||||
@@ -97,13 +95,14 @@ int RunAsCrashpadHandler(const base::CommandLine& command_line) {
|
||||
base::CommandLine::StringVector argv = command_line.argv();
|
||||
const base::CommandLine::StringType process_type =
|
||||
FILE_PATH_LITERAL("--type=");
|
||||
argv.erase(std::remove_if(argv.begin(), argv.end(),
|
||||
[&process_type](const base::CommandLine::StringType& str) {
|
||||
return base::StartsWith(str, process_type,
|
||||
base::CompareCase::SENSITIVE) ||
|
||||
(!str.empty() && str[0] == L'/');
|
||||
}),
|
||||
argv.end());
|
||||
argv.erase(
|
||||
std::remove_if(argv.begin(), argv.end(),
|
||||
[&process_type](const base::CommandLine::StringType& str) {
|
||||
return base::StartsWith(str, process_type,
|
||||
base::CompareCase::SENSITIVE) ||
|
||||
(!str.empty() && str[0] == L'/');
|
||||
}),
|
||||
argv.end());
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
// HandlerMain on macOS uses the system version of getopt_long which expects
|
||||
@@ -184,7 +183,7 @@ int CefExecuteProcess(const CefMainArgs& args,
|
||||
|
||||
CefMainDelegate main_delegate(application);
|
||||
|
||||
// Execute the secondary process.
|
||||
// Execute the secondary process.
|
||||
#if defined(OS_WIN)
|
||||
sandbox::SandboxInterfaceInfo sandbox_info = {0};
|
||||
if (windows_sandbox_info == NULL) {
|
||||
@@ -321,17 +320,12 @@ void CefSetOSModalLoop(bool osModalLoop) {
|
||||
#endif // defined(OS_WIN)
|
||||
}
|
||||
|
||||
|
||||
// CefContext
|
||||
|
||||
CefContext::CefContext()
|
||||
: initialized_(false),
|
||||
shutting_down_(false),
|
||||
init_thread_id_(0) {
|
||||
}
|
||||
: initialized_(false), shutting_down_(false), init_thread_id_(0) {}
|
||||
|
||||
CefContext::~CefContext() {
|
||||
}
|
||||
CefContext::~CefContext() {}
|
||||
|
||||
// static
|
||||
CefContext* CefContext::Get() {
|
||||
@@ -390,8 +384,8 @@ bool CefContext::Initialize(const CefMainArgs& args,
|
||||
if (exit_code >= 0)
|
||||
return false;
|
||||
|
||||
static_cast<ChromeBrowserProcessStub*>(g_browser_process)->Initialize(
|
||||
*base::CommandLine::ForCurrentProcess());
|
||||
static_cast<ChromeBrowserProcessStub*>(g_browser_process)
|
||||
->Initialize(*base::CommandLine::ForCurrentProcess());
|
||||
|
||||
// Run the process. Results in a call to CefMainDelegate::RunProcess() which
|
||||
// will create the browser runner and message loop without blocking.
|
||||
@@ -403,8 +397,8 @@ bool CefContext::Initialize(const CefMainArgs& args,
|
||||
OnContextInitialized();
|
||||
} else {
|
||||
// Continue initialization on the UI thread.
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
base::Bind(&CefContext::OnContextInitialized, base::Unretained(this)));
|
||||
CEF_POST_TASK(CEF_UIT, base::Bind(&CefContext::OnContextInitialized,
|
||||
base::Unretained(this)));
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -425,9 +419,8 @@ void CefContext::Shutdown() {
|
||||
|
||||
// Finish shutdown on the UI thread.
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
base::Bind(&CefContext::FinishShutdownOnUIThread,
|
||||
base::Unretained(this),
|
||||
&uithread_shutdown_event));
|
||||
base::Bind(&CefContext::FinishShutdownOnUIThread,
|
||||
base::Unretained(this), &uithread_shutdown_event));
|
||||
|
||||
/// Block until UI thread shutdown is complete.
|
||||
uithread_shutdown_event.Wait();
|
||||
@@ -448,9 +441,11 @@ bool CefContext::OnInitThread() {
|
||||
SkColor CefContext::GetBackgroundColor(
|
||||
const CefBrowserSettings* browser_settings,
|
||||
cef_state_t windowless_state) const {
|
||||
bool is_windowless = windowless_state == STATE_ENABLED ? true :
|
||||
(windowless_state == STATE_DISABLED ? false :
|
||||
!!settings_.windowless_rendering_enabled);
|
||||
bool is_windowless = windowless_state == STATE_ENABLED
|
||||
? true
|
||||
: (windowless_state == STATE_DISABLED
|
||||
? false
|
||||
: !!settings_.windowless_rendering_enabled);
|
||||
|
||||
// Default to opaque white if no acceptable color values are found.
|
||||
SkColor sk_color = SK_ColorWHITE;
|
||||
@@ -495,8 +490,8 @@ void CefContext::PopulateRequestContextSettings(
|
||||
void CefContext::OnContextInitialized() {
|
||||
CEF_REQUIRE_UIT();
|
||||
|
||||
static_cast<ChromeBrowserProcessStub*>(g_browser_process)->
|
||||
OnContextInitialized();
|
||||
static_cast<ChromeBrowserProcessStub*>(g_browser_process)
|
||||
->OnContextInitialized();
|
||||
|
||||
#if defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_PEPPER_CDMS)
|
||||
CefWidevineLoader::GetInstance()->OnContextInitialized();
|
||||
|
@@ -34,7 +34,7 @@ class CefTraceSubscriber;
|
||||
|
||||
class CefContext {
|
||||
public:
|
||||
typedef std::list<CefRefPtr<CefBrowserHostImpl> > BrowserList;
|
||||
typedef std::list<CefRefPtr<CefBrowserHostImpl>> BrowserList;
|
||||
|
||||
CefContext();
|
||||
~CefContext();
|
||||
@@ -104,8 +104,8 @@ class CefContext {
|
||||
};
|
||||
|
||||
// Helper macro that returns true if the global context is in a valid state.
|
||||
#define CONTEXT_STATE_VALID() \
|
||||
(CefContext::Get() && CefContext::Get()->initialized() && \
|
||||
!CefContext::Get()->shutting_down())
|
||||
#define CONTEXT_STATE_VALID() \
|
||||
(CefContext::Get() && CefContext::Get()->initialized() && \
|
||||
!CefContext::Get()->shutting_down())
|
||||
|
||||
#endif // CEF_LIBCEF_BROWSER_CONTEXT_H_
|
||||
|
@@ -8,9 +8,12 @@
|
||||
|
||||
CefContextMenuParamsImpl::CefContextMenuParamsImpl(
|
||||
content::ContextMenuParams* value)
|
||||
: CefValueBase<CefContextMenuParams, content::ContextMenuParams>(
|
||||
value, NULL, kOwnerNoDelete, true,
|
||||
new CefValueControllerNonThreadSafe()) {
|
||||
: CefValueBase<CefContextMenuParams, content::ContextMenuParams>(
|
||||
value,
|
||||
NULL,
|
||||
kOwnerNoDelete,
|
||||
true,
|
||||
new CefValueControllerNonThreadSafe()) {
|
||||
// Indicate that this object owns the controller.
|
||||
SetOwnsController();
|
||||
}
|
||||
@@ -90,7 +93,7 @@ CefContextMenuParamsImpl::MediaType CefContextMenuParamsImpl::GetMediaType() {
|
||||
}
|
||||
|
||||
CefContextMenuParamsImpl::MediaStateFlags
|
||||
CefContextMenuParamsImpl::GetMediaStateFlags() {
|
||||
CefContextMenuParamsImpl::GetMediaStateFlags() {
|
||||
CEF_VALUE_VERIFY_RETURN(false, CM_MEDIAFLAG_NONE);
|
||||
return static_cast<MediaStateFlags>(const_value().media_flags);
|
||||
}
|
||||
@@ -112,7 +115,7 @@ bool CefContextMenuParamsImpl::GetDictionarySuggestions(
|
||||
if (!suggestions.empty())
|
||||
suggestions.clear();
|
||||
|
||||
if(const_value().dictionary_suggestions.empty())
|
||||
if (const_value().dictionary_suggestions.empty())
|
||||
return false;
|
||||
|
||||
std::vector<base::string16>::const_iterator it =
|
||||
@@ -134,7 +137,7 @@ bool CefContextMenuParamsImpl::IsSpellCheckEnabled() {
|
||||
}
|
||||
|
||||
CefContextMenuParamsImpl::EditStateFlags
|
||||
CefContextMenuParamsImpl::GetEditStateFlags() {
|
||||
CefContextMenuParamsImpl::GetEditStateFlags() {
|
||||
CEF_VALUE_VERIFY_RETURN(false, CM_EDITFLAG_NONE);
|
||||
return static_cast<EditStateFlags>(const_value().edit_flags);
|
||||
}
|
||||
|
@@ -33,8 +33,7 @@ class CefContextMenuParamsImpl
|
||||
MediaStateFlags GetMediaStateFlags() override;
|
||||
CefString GetSelectionText() override;
|
||||
CefString GetMisspelledWord() override;
|
||||
bool GetDictionarySuggestions(
|
||||
std::vector<CefString>& suggestions) override;
|
||||
bool GetDictionarySuggestions(std::vector<CefString>& suggestions) override;
|
||||
bool IsEditable() override;
|
||||
bool IsSpellCheckEnabled() override;
|
||||
EditStateFlags GetEditStateFlags() override;
|
||||
|
@@ -35,9 +35,7 @@ class VisitCookiesCallback : public base::RefCounted<VisitCookiesCallback> {
|
||||
explicit VisitCookiesCallback(
|
||||
const CefCookieManagerImpl::CookieStoreGetter& cookie_store_getter,
|
||||
CefRefPtr<CefCookieVisitor> visitor)
|
||||
: cookie_store_getter_(cookie_store_getter),
|
||||
visitor_(visitor) {
|
||||
}
|
||||
: cookie_store_getter_(cookie_store_getter), visitor_(visitor) {}
|
||||
|
||||
void Run(const net::CookieList& list) {
|
||||
CEF_REQUIRE_IOT();
|
||||
@@ -55,8 +53,8 @@ class VisitCookiesCallback : public base::RefCounted<VisitCookiesCallback> {
|
||||
if (deleteCookie) {
|
||||
net::CookieStore* cookie_store = cookie_store_getter_.Run();
|
||||
if (cookie_store) {
|
||||
cookie_store->DeleteCanonicalCookieAsync(cc,
|
||||
net::CookieMonster::DeleteCallback());
|
||||
cookie_store->DeleteCanonicalCookieAsync(
|
||||
cc, net::CookieMonster::DeleteCallback());
|
||||
}
|
||||
}
|
||||
if (!keepLooping)
|
||||
@@ -73,7 +71,6 @@ class VisitCookiesCallback : public base::RefCounted<VisitCookiesCallback> {
|
||||
CefRefPtr<CefCookieVisitor> visitor_;
|
||||
};
|
||||
|
||||
|
||||
// Methods extracted from net/cookies/cookie_store.cc
|
||||
|
||||
// Determine the cookie domain to use for setting the specified cookie.
|
||||
@@ -84,7 +81,7 @@ bool GetCookieDomain(const GURL& url,
|
||||
if (pc.HasDomain())
|
||||
domain_string = pc.Domain();
|
||||
return net::cookie_util::GetCookieDomainWithString(url, domain_string,
|
||||
result);
|
||||
result);
|
||||
}
|
||||
|
||||
// Always execute the callback asynchronously.
|
||||
@@ -92,7 +89,7 @@ void RunAsyncCompletionOnIOThread(CefRefPtr<CefCompletionCallback> callback) {
|
||||
if (!callback.get())
|
||||
return;
|
||||
CEF_POST_TASK(CEF_IOT,
|
||||
base::Bind(&CefCompletionCallback::OnComplete, callback.get()));
|
||||
base::Bind(&CefCompletionCallback::OnComplete, callback.get()));
|
||||
}
|
||||
|
||||
// Always execute the callback asynchronously.
|
||||
@@ -100,9 +97,8 @@ void DeleteCookiesCallbackImpl(CefRefPtr<CefDeleteCookiesCallback> callback,
|
||||
int num_deleted) {
|
||||
if (!callback.get())
|
||||
return;
|
||||
CEF_POST_TASK(CEF_IOT,
|
||||
base::Bind(&CefDeleteCookiesCallback::OnComplete, callback.get(),
|
||||
num_deleted));
|
||||
CEF_POST_TASK(CEF_IOT, base::Bind(&CefDeleteCookiesCallback::OnComplete,
|
||||
callback.get(), num_deleted));
|
||||
}
|
||||
|
||||
// Always execute the callback asynchronously.
|
||||
@@ -110,8 +106,8 @@ void SetCookieCallbackImpl(CefRefPtr<CefSetCookieCallback> callback,
|
||||
bool success) {
|
||||
if (!callback.get())
|
||||
return;
|
||||
CEF_POST_TASK(CEF_IOT,
|
||||
base::Bind(&CefSetCookieCallback::OnComplete, callback.get(), success));
|
||||
CEF_POST_TASK(CEF_IOT, base::Bind(&CefSetCookieCallback::OnComplete,
|
||||
callback.get(), success));
|
||||
}
|
||||
|
||||
net::CookieStore* GetExistingCookieStoreHelper(
|
||||
@@ -123,10 +119,7 @@ net::CookieStore* GetExistingCookieStoreHelper(
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
CefCookieManagerImpl::CefCookieManagerImpl()
|
||||
: weak_ptr_factory_(this) {
|
||||
}
|
||||
CefCookieManagerImpl::CefCookieManagerImpl() : weak_ptr_factory_(this) {}
|
||||
|
||||
CefCookieManagerImpl::~CefCookieManagerImpl() {
|
||||
CEF_REQUIRE_IOT();
|
||||
@@ -154,9 +147,8 @@ void CefCookieManagerImpl::GetCookieStore(
|
||||
task_runner = base::MessageLoop::current()->task_runner();
|
||||
|
||||
if (!CEF_CURRENTLY_ON_IOT()) {
|
||||
CEF_POST_TASK(CEF_IOT,
|
||||
base::Bind(&CefCookieManagerImpl::GetCookieStore, this, task_runner,
|
||||
callback));
|
||||
CEF_POST_TASK(CEF_IOT, base::Bind(&CefCookieManagerImpl::GetCookieStore,
|
||||
this, task_runner, callback));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -177,16 +169,14 @@ void CefCookieManagerImpl::GetCookieStore(
|
||||
// that case, the CookieStoreGetter will return nullptr instead of keeping
|
||||
// the CefCookieManagerImpl alive (see issue #1882).
|
||||
const CookieStoreGetter& cookie_store_getter =
|
||||
base::Bind(GetExistingCookieStoreHelper,
|
||||
weak_ptr_factory_.GetWeakPtr());
|
||||
base::Bind(GetExistingCookieStoreHelper, weak_ptr_factory_.GetWeakPtr());
|
||||
|
||||
if (task_runner->BelongsToCurrentThread()) {
|
||||
// Execute the callback immediately.
|
||||
callback.Run(cookie_store_getter);
|
||||
} else {
|
||||
// Execute the callback on the target thread.
|
||||
task_runner->PostTask(FROM_HERE,
|
||||
base::Bind(callback, cookie_store_getter));
|
||||
task_runner->PostTask(FROM_HERE, base::Bind(callback, cookie_store_getter));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -210,8 +200,8 @@ void CefCookieManagerImpl::SetSupportedSchemes(
|
||||
CefRefPtr<CefCompletionCallback> callback) {
|
||||
if (!CEF_CURRENTLY_ON_IOT()) {
|
||||
CEF_POST_TASK(CEF_IOT,
|
||||
base::Bind(&CefCookieManagerImpl::SetSupportedSchemes, this, schemes,
|
||||
callback));
|
||||
base::Bind(&CefCookieManagerImpl::SetSupportedSchemes, this,
|
||||
schemes, callback));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -225,10 +215,9 @@ void CefCookieManagerImpl::SetSupportedSchemes(
|
||||
|
||||
bool CefCookieManagerImpl::VisitAllCookies(
|
||||
CefRefPtr<CefCookieVisitor> visitor) {
|
||||
GetCookieStore(
|
||||
BrowserThread::GetTaskRunnerForThread(BrowserThread::IO),
|
||||
base::Bind(&CefCookieManagerImpl::VisitAllCookiesInternal, this,
|
||||
visitor));
|
||||
GetCookieStore(BrowserThread::GetTaskRunnerForThread(BrowserThread::IO),
|
||||
base::Bind(&CefCookieManagerImpl::VisitAllCookiesInternal,
|
||||
this, visitor));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -236,25 +225,22 @@ bool CefCookieManagerImpl::VisitUrlCookies(
|
||||
const CefString& url,
|
||||
bool includeHttpOnly,
|
||||
CefRefPtr<CefCookieVisitor> visitor) {
|
||||
GetCookieStore(
|
||||
BrowserThread::GetTaskRunnerForThread(BrowserThread::IO),
|
||||
base::Bind(&CefCookieManagerImpl::VisitUrlCookiesInternal, this, url,
|
||||
includeHttpOnly, visitor));
|
||||
GetCookieStore(BrowserThread::GetTaskRunnerForThread(BrowserThread::IO),
|
||||
base::Bind(&CefCookieManagerImpl::VisitUrlCookiesInternal,
|
||||
this, url, includeHttpOnly, visitor));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CefCookieManagerImpl::SetCookie(
|
||||
const CefString& url,
|
||||
const CefCookie& cookie,
|
||||
CefRefPtr<CefSetCookieCallback> callback) {
|
||||
bool CefCookieManagerImpl::SetCookie(const CefString& url,
|
||||
const CefCookie& cookie,
|
||||
CefRefPtr<CefSetCookieCallback> callback) {
|
||||
GURL gurl = GURL(url.ToString());
|
||||
if (!gurl.is_valid())
|
||||
return false;
|
||||
|
||||
GetCookieStore(
|
||||
BrowserThread::GetTaskRunnerForThread(BrowserThread::IO),
|
||||
base::Bind(&CefCookieManagerImpl::SetCookieInternal, this, gurl, cookie,
|
||||
callback));
|
||||
GetCookieStore(BrowserThread::GetTaskRunnerForThread(BrowserThread::IO),
|
||||
base::Bind(&CefCookieManagerImpl::SetCookieInternal, this,
|
||||
gurl, cookie, callback));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -267,10 +253,9 @@ bool CefCookieManagerImpl::DeleteCookies(
|
||||
if (!gurl.is_empty() && !gurl.is_valid())
|
||||
return false;
|
||||
|
||||
GetCookieStore(
|
||||
BrowserThread::GetTaskRunnerForThread(BrowserThread::IO),
|
||||
base::Bind(&CefCookieManagerImpl::DeleteCookiesInternal, this, gurl,
|
||||
cookie_name, callback));
|
||||
GetCookieStore(BrowserThread::GetTaskRunnerForThread(BrowserThread::IO),
|
||||
base::Bind(&CefCookieManagerImpl::DeleteCookiesInternal, this,
|
||||
gurl, cookie_name, callback));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -279,7 +264,8 @@ bool CefCookieManagerImpl::SetStoragePath(
|
||||
bool persist_session_cookies,
|
||||
CefRefPtr<CefCompletionCallback> callback) {
|
||||
if (!CEF_CURRENTLY_ON_IOT()) {
|
||||
CEF_POST_TASK(CEF_IOT,
|
||||
CEF_POST_TASK(
|
||||
CEF_IOT,
|
||||
base::Bind(base::IgnoreResult(&CefCookieManagerImpl::SetStoragePath),
|
||||
this, path, persist_session_cookies, callback));
|
||||
return true;
|
||||
@@ -296,8 +282,8 @@ bool CefCookieManagerImpl::SetStoragePath(
|
||||
if (!path.empty())
|
||||
new_path = base::FilePath(path);
|
||||
|
||||
if (cookie_store_.get() && ((storage_path_.empty() && path.empty()) ||
|
||||
storage_path_ == new_path)) {
|
||||
if (cookie_store_.get() &&
|
||||
((storage_path_.empty() && path.empty()) || storage_path_ == new_path)) {
|
||||
// The path has not changed so don't do anything.
|
||||
RunAsyncCompletionOnIOThread(callback);
|
||||
return true;
|
||||
@@ -308,16 +294,12 @@ bool CefCookieManagerImpl::SetStoragePath(
|
||||
// TODO(cef): Move directory creation to the blocking pool instead of
|
||||
// allowing file IO on this thread.
|
||||
base::ThreadRestrictions::ScopedAllowIO allow_io;
|
||||
if (base::DirectoryExists(new_path) ||
|
||||
base::CreateDirectory(new_path)) {
|
||||
if (base::DirectoryExists(new_path) || base::CreateDirectory(new_path)) {
|
||||
const base::FilePath& cookie_path = new_path.AppendASCII("Cookies");
|
||||
persistent_store =
|
||||
new net::SQLitePersistentCookieStore(
|
||||
cookie_path,
|
||||
BrowserThread::GetTaskRunnerForThread(BrowserThread::IO),
|
||||
BrowserThread::GetTaskRunnerForThread(BrowserThread::DB),
|
||||
persist_session_cookies,
|
||||
NULL);
|
||||
persistent_store = new net::SQLitePersistentCookieStore(
|
||||
cookie_path, BrowserThread::GetTaskRunnerForThread(BrowserThread::IO),
|
||||
BrowserThread::GetTaskRunnerForThread(BrowserThread::DB),
|
||||
persist_session_cookies, NULL);
|
||||
} else {
|
||||
NOTREACHED() << "The cookie storage directory could not be created";
|
||||
storage_path_.clear();
|
||||
@@ -427,8 +409,7 @@ void CefCookieManagerImpl::RunMethodWithContext(
|
||||
} else if (request_context_.get()) {
|
||||
// Try again after the request context is initialized.
|
||||
request_context_->GetRequestContextImpl(
|
||||
BrowserThread::GetTaskRunnerForThread(BrowserThread::IO),
|
||||
method);
|
||||
BrowserThread::GetTaskRunnerForThread(BrowserThread::IO), method);
|
||||
} else {
|
||||
NOTREACHED();
|
||||
}
|
||||
@@ -485,9 +466,8 @@ void CefCookieManagerImpl::GetCookieStoreWithContext(
|
||||
CEF_REQUIRE_IOT();
|
||||
DCHECK(request_context->GetExistingCookieStore());
|
||||
|
||||
const CookieStoreGetter& cookie_store_getter =
|
||||
base::Bind(&CefURLRequestContextGetterImpl::GetExistingCookieStore,
|
||||
request_context);
|
||||
const CookieStoreGetter& cookie_store_getter = base::Bind(
|
||||
&CefURLRequestContextGetterImpl::GetExistingCookieStore, request_context);
|
||||
|
||||
if (task_runner->BelongsToCurrentThread()) {
|
||||
// Execute the callback immediately.
|
||||
@@ -555,8 +535,8 @@ void CefCookieManagerImpl::VisitUrlCookiesInternal(
|
||||
new VisitCookiesCallback(cookie_store_getter, visitor));
|
||||
|
||||
GURL gurl = GURL(url.ToString());
|
||||
cookie_store->GetCookieListWithOptionsAsync(gurl, options,
|
||||
base::Bind(&VisitCookiesCallback::Run, callback.get()));
|
||||
cookie_store->GetCookieListWithOptionsAsync(
|
||||
gurl, options, base::Bind(&VisitCookiesCallback::Run, callback.get()));
|
||||
}
|
||||
|
||||
void CefCookieManagerImpl::SetCookieInternal(
|
||||
@@ -584,10 +564,8 @@ void CefCookieManagerImpl::SetCookieInternal(
|
||||
base::Time(), // Creation time.
|
||||
expiration_time,
|
||||
base::Time(), // Last access time.
|
||||
cookie.secure ? true : false,
|
||||
cookie.httponly ? true : false,
|
||||
net::CookieSameSite::DEFAULT_MODE,
|
||||
net::COOKIE_PRIORITY_DEFAULT,
|
||||
cookie.secure ? true : false, cookie.httponly ? true : false,
|
||||
net::CookieSameSite::DEFAULT_MODE, net::COOKIE_PRIORITY_DEFAULT,
|
||||
base::Bind(SetCookieCallbackImpl, callback));
|
||||
}
|
||||
|
||||
@@ -614,8 +592,8 @@ void CefCookieManagerImpl::DeleteCookiesInternal(
|
||||
base::Bind(DeleteCookiesCallbackImpl, callback));
|
||||
} else {
|
||||
// Delete all matching host and domain cookies.
|
||||
cookie_store->DeleteCookieAsync(url, cookie_name,
|
||||
base::Bind(DeleteCookiesCallbackImpl, callback, -1));
|
||||
cookie_store->DeleteCookieAsync(
|
||||
url, cookie_name, base::Bind(DeleteCookiesCallbackImpl, callback, -1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -628,8 +606,7 @@ void CefCookieManagerImpl::FlushStoreInternal(
|
||||
if (!cookie_store)
|
||||
return;
|
||||
|
||||
cookie_store->FlushStore(
|
||||
base::Bind(RunAsyncCompletionOnIOThread, callback));
|
||||
cookie_store->FlushStore(base::Bind(RunAsyncCompletionOnIOThread, callback));
|
||||
}
|
||||
|
||||
// CefCookieManager methods ----------------------------------------------------
|
||||
|
@@ -34,9 +34,8 @@ class CefCookieManagerImpl : public CefCookieManager {
|
||||
// store object can only be accessed on, the IO thread.
|
||||
typedef base::Callback<net::CookieStore*()> CookieStoreGetter;
|
||||
typedef base::Callback<void(const CookieStoreGetter&)> CookieStoreCallback;
|
||||
void GetCookieStore(
|
||||
scoped_refptr<base::SingleThreadTaskRunner> task_runner,
|
||||
const CookieStoreCallback& callback);
|
||||
void GetCookieStore(scoped_refptr<base::SingleThreadTaskRunner> task_runner,
|
||||
const CookieStoreCallback& callback);
|
||||
|
||||
// Returns the existing cookie store object. Logs an error if the cookie
|
||||
// store does not yet exist. Must be called on the IO thread.
|
||||
@@ -46,7 +45,8 @@ class CefCookieManagerImpl : public CefCookieManager {
|
||||
void SetSupportedSchemes(const std::vector<CefString>& schemes,
|
||||
CefRefPtr<CefCompletionCallback> callback) override;
|
||||
bool VisitAllCookies(CefRefPtr<CefCookieVisitor> visitor) override;
|
||||
bool VisitUrlCookies(const CefString& url, bool includeHttpOnly,
|
||||
bool VisitUrlCookies(const CefString& url,
|
||||
bool includeHttpOnly,
|
||||
CefRefPtr<CefCookieVisitor> visitor) override;
|
||||
bool SetCookie(const CefString& url,
|
||||
const CefCookie& cookie,
|
||||
@@ -60,7 +60,8 @@ class CefCookieManagerImpl : public CefCookieManager {
|
||||
bool FlushStore(CefRefPtr<CefCompletionCallback> callback) override;
|
||||
|
||||
static bool GetCefCookie(const net::CanonicalCookie& cc, CefCookie& cookie);
|
||||
static bool GetCefCookie(const GURL& url, const std::string& cookie_line,
|
||||
static bool GetCefCookie(const GURL& url,
|
||||
const std::string& cookie_line,
|
||||
CefCookie& cookie);
|
||||
|
||||
// Set the schemes supported by |cookie_monster|. Default schemes will always
|
||||
@@ -93,30 +94,24 @@ class CefCookieManagerImpl : public CefCookieManager {
|
||||
const CookieStoreCallback& callback,
|
||||
scoped_refptr<CefURLRequestContextGetterImpl> request_context);
|
||||
|
||||
void SetSupportedSchemesInternal(
|
||||
const std::vector<std::string>& schemes,
|
||||
CefRefPtr<CefCompletionCallback> callback);
|
||||
void VisitAllCookiesInternal(
|
||||
CefRefPtr<CefCookieVisitor> visitor,
|
||||
const CookieStoreGetter& cookie_store_getter);
|
||||
void VisitUrlCookiesInternal(
|
||||
const CefString& url,
|
||||
bool includeHttpOnly,
|
||||
CefRefPtr<CefCookieVisitor> visitor,
|
||||
const CookieStoreGetter& cookie_store_getter);
|
||||
void SetCookieInternal(
|
||||
const GURL& url,
|
||||
const CefCookie& cookie,
|
||||
CefRefPtr<CefSetCookieCallback> callback,
|
||||
const CookieStoreGetter& cookie_store_getter);
|
||||
void DeleteCookiesInternal(
|
||||
const GURL& url,
|
||||
const CefString& cookie_name,
|
||||
CefRefPtr<CefDeleteCookiesCallback> callback,
|
||||
const CookieStoreGetter& cookie_store_getter);
|
||||
void FlushStoreInternal(
|
||||
CefRefPtr<CefCompletionCallback> callback,
|
||||
const CookieStoreGetter& cookie_store_getter);
|
||||
void SetSupportedSchemesInternal(const std::vector<std::string>& schemes,
|
||||
CefRefPtr<CefCompletionCallback> callback);
|
||||
void VisitAllCookiesInternal(CefRefPtr<CefCookieVisitor> visitor,
|
||||
const CookieStoreGetter& cookie_store_getter);
|
||||
void VisitUrlCookiesInternal(const CefString& url,
|
||||
bool includeHttpOnly,
|
||||
CefRefPtr<CefCookieVisitor> visitor,
|
||||
const CookieStoreGetter& cookie_store_getter);
|
||||
void SetCookieInternal(const GURL& url,
|
||||
const CefCookie& cookie,
|
||||
CefRefPtr<CefSetCookieCallback> callback,
|
||||
const CookieStoreGetter& cookie_store_getter);
|
||||
void DeleteCookiesInternal(const GURL& url,
|
||||
const CefString& cookie_name,
|
||||
CefRefPtr<CefDeleteCookiesCallback> callback,
|
||||
const CookieStoreGetter& cookie_store_getter);
|
||||
void FlushStoreInternal(CefRefPtr<CefCompletionCallback> callback,
|
||||
const CookieStoreGetter& cookie_store_getter);
|
||||
|
||||
// Used for cookie monsters owned by the context.
|
||||
CefRefPtr<CefRequestContextImpl> request_context_;
|
||||
|
@@ -37,7 +37,6 @@
|
||||
|
||||
namespace {
|
||||
|
||||
|
||||
// ResponseWriter -------------------------------------------------------------
|
||||
|
||||
class ResponseWriter : public net::URLFetcherResponseWriter {
|
||||
@@ -63,12 +62,9 @@ class ResponseWriter : public net::URLFetcherResponseWriter {
|
||||
ResponseWriter::ResponseWriter(
|
||||
base::WeakPtr<CefDevToolsFrontend> shell_devtools,
|
||||
int stream_id)
|
||||
: shell_devtools_(shell_devtools),
|
||||
stream_id_(stream_id) {
|
||||
}
|
||||
: shell_devtools_(shell_devtools), stream_id_(stream_id) {}
|
||||
|
||||
ResponseWriter::~ResponseWriter() {
|
||||
}
|
||||
ResponseWriter::~ResponseWriter() {}
|
||||
|
||||
int ResponseWriter::Initialize(const net::CompletionCallback& callback) {
|
||||
return net::OK;
|
||||
@@ -86,9 +82,9 @@ int ResponseWriter::Write(net::IOBuffer* buffer,
|
||||
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::UI, FROM_HERE,
|
||||
base::Bind(&CefDevToolsFrontend::CallClientFunction,
|
||||
shell_devtools_, "DevToolsAPI.streamWrite",
|
||||
base::Owned(id), base::Owned(chunkValue), nullptr));
|
||||
base::Bind(&CefDevToolsFrontend::CallClientFunction, shell_devtools_,
|
||||
"DevToolsAPI.streamWrite", base::Owned(id),
|
||||
base::Owned(chunkValue), nullptr));
|
||||
return num_bytes;
|
||||
}
|
||||
|
||||
@@ -99,7 +95,8 @@ int ResponseWriter::Finish(int net_error,
|
||||
|
||||
static std::string GetFrontendURL() {
|
||||
return base::StringPrintf("%s://%s/inspector.html",
|
||||
content::kChromeDevToolsScheme, scheme::kChromeDevToolsHost);
|
||||
content::kChromeDevToolsScheme,
|
||||
scheme::kChromeDevToolsHost);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -164,10 +161,9 @@ void CefDevToolsFrontend::InspectElementAt(int x, int y) {
|
||||
}
|
||||
|
||||
void CefDevToolsFrontend::Close() {
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::UI, FROM_HERE,
|
||||
base::Bind(&CefBrowserHostImpl::CloseBrowser, frontend_browser_.get(),
|
||||
true));
|
||||
content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
|
||||
base::Bind(&CefBrowserHostImpl::CloseBrowser,
|
||||
frontend_browser_.get(), true));
|
||||
}
|
||||
|
||||
void CefDevToolsFrontend::DisconnectFromTarget() {
|
||||
@@ -185,8 +181,7 @@ CefDevToolsFrontend::CefDevToolsFrontend(
|
||||
frontend_browser_(frontend_browser),
|
||||
inspected_contents_(inspected_contents),
|
||||
inspect_element_at_(inspect_element_at),
|
||||
weak_factory_(this) {
|
||||
}
|
||||
weak_factory_(this) {}
|
||||
|
||||
CefDevToolsFrontend::~CefDevToolsFrontend() {
|
||||
for (const auto& pair : pending_requests_)
|
||||
@@ -213,8 +208,8 @@ void CefDevToolsFrontend::DocumentAvailableInMainFrame() {
|
||||
agent_host_ = agent_host;
|
||||
agent_host_->AttachClient(this);
|
||||
if (!inspect_element_at_.IsEmpty()) {
|
||||
agent_host_->InspectElement(
|
||||
this, inspect_element_at_.x, inspect_element_at_.y);
|
||||
agent_host_->InspectElement(this, inspect_element_at_.x,
|
||||
inspect_element_at_.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -250,8 +245,7 @@ void CefDevToolsFrontend::HandleMessageFromDevToolsFrontend(
|
||||
base::ListValue* params = NULL;
|
||||
base::DictionaryValue* dict = NULL;
|
||||
std::unique_ptr<base::Value> parsed_message = base::JSONReader::Read(message);
|
||||
if (!parsed_message ||
|
||||
!parsed_message->GetAsDictionary(&dict) ||
|
||||
if (!parsed_message || !parsed_message->GetAsDictionary(&dict) ||
|
||||
!dict->GetString("method", &method)) {
|
||||
return;
|
||||
}
|
||||
@@ -274,8 +268,7 @@ void CefDevToolsFrontend::HandleMessageFromDevToolsFrontend(
|
||||
std::string url;
|
||||
std::string headers;
|
||||
int stream_id;
|
||||
if (!params->GetString(0, &url) ||
|
||||
!params->GetString(1, &headers) ||
|
||||
if (!params->GetString(0, &url) || !params->GetString(1, &headers) ||
|
||||
!params->GetInteger(2, &stream_id)) {
|
||||
return;
|
||||
}
|
||||
@@ -293,8 +286,8 @@ void CefDevToolsFrontend::HandleMessageFromDevToolsFrontend(
|
||||
pending_requests_[fetcher] = request_id;
|
||||
fetcher->SetRequestContext(
|
||||
content::BrowserContext::GetDefaultStoragePartition(
|
||||
web_contents()->GetBrowserContext())->
|
||||
GetURLRequestContext());
|
||||
web_contents()->GetBrowserContext())
|
||||
->GetURLRequestContext());
|
||||
fetcher->SetExtraRequestHeaders(headers);
|
||||
fetcher->SaveResponseWithWriter(
|
||||
std::unique_ptr<net::URLFetcherResponseWriter>(
|
||||
@@ -308,8 +301,7 @@ void CefDevToolsFrontend::HandleMessageFromDevToolsFrontend(
|
||||
} else if (method == "setPreference") {
|
||||
std::string name;
|
||||
std::string value;
|
||||
if (!params->GetString(0, &name) ||
|
||||
!params->GetString(1, &value)) {
|
||||
if (!params->GetString(0, &name) || !params->GetString(1, &value)) {
|
||||
return;
|
||||
}
|
||||
DictionaryPrefUpdate update(GetPrefs(), prefs::kDevToolsPreferences);
|
||||
@@ -335,8 +327,8 @@ void CefDevToolsFrontend::HandleMessageFromDevToolsFrontend(
|
||||
}
|
||||
|
||||
void CefDevToolsFrontend::DispatchProtocolMessage(
|
||||
content::DevToolsAgentHost* agent_host, const std::string& message) {
|
||||
|
||||
content::DevToolsAgentHost* agent_host,
|
||||
const std::string& message) {
|
||||
if (message.length() < kMaxMessageChunkSize) {
|
||||
std::string param;
|
||||
base::EscapeJSONString(message, true, ¶m);
|
||||
@@ -382,11 +374,10 @@ void CefDevToolsFrontend::OnURLFetchComplete(const net::URLFetcher* source) {
|
||||
delete source;
|
||||
}
|
||||
|
||||
void CefDevToolsFrontend::CallClientFunction(
|
||||
const std::string& function_name,
|
||||
const base::Value* arg1,
|
||||
const base::Value* arg2,
|
||||
const base::Value* arg3) {
|
||||
void CefDevToolsFrontend::CallClientFunction(const std::string& function_name,
|
||||
const base::Value* arg1,
|
||||
const base::Value* arg2,
|
||||
const base::Value* arg3) {
|
||||
std::string javascript = function_name + "(";
|
||||
if (arg1) {
|
||||
std::string json;
|
||||
@@ -409,12 +400,12 @@ void CefDevToolsFrontend::CallClientFunction(
|
||||
void CefDevToolsFrontend::SendMessageAck(int request_id,
|
||||
const base::Value* arg) {
|
||||
base::Value id_value(request_id);
|
||||
CallClientFunction("DevToolsAPI.embedderMessageAck",
|
||||
&id_value, arg, nullptr);
|
||||
CallClientFunction("DevToolsAPI.embedderMessageAck", &id_value, arg, nullptr);
|
||||
}
|
||||
|
||||
void CefDevToolsFrontend::AgentHostClosed(
|
||||
content::DevToolsAgentHost* agent_host, bool replaced) {
|
||||
content::DevToolsAgentHost* agent_host,
|
||||
bool replaced) {
|
||||
DCHECK(agent_host == agent_host_.get());
|
||||
agent_host_ = nullptr;
|
||||
Close();
|
||||
@@ -422,5 +413,6 @@ void CefDevToolsFrontend::AgentHostClosed(
|
||||
|
||||
PrefService* CefDevToolsFrontend::GetPrefs() const {
|
||||
return static_cast<CefBrowserContext*>(
|
||||
frontend_browser_->web_contents()->GetBrowserContext())->GetPrefs();
|
||||
frontend_browser_->web_contents()->GetBrowserContext())
|
||||
->GetPrefs();
|
||||
}
|
||||
|
@@ -80,8 +80,7 @@ class CefDevToolsFrontend : public content::WebContentsObserver,
|
||||
// net::URLFetcherDelegate overrides.
|
||||
void OnURLFetchComplete(const net::URLFetcher* source) override;
|
||||
|
||||
void SendMessageAck(int request_id,
|
||||
const base::Value* arg1);
|
||||
void SendMessageAck(int request_id, const base::Value* arg1);
|
||||
|
||||
PrefService* GetPrefs() const;
|
||||
|
||||
|
@@ -81,8 +81,8 @@ std::unique_ptr<content::DevToolsSocketFactory> CreateSocketFactory() {
|
||||
int temp_port;
|
||||
std::string port_str =
|
||||
command_line.GetSwitchValueASCII(switches::kRemoteDebuggingPort);
|
||||
if (base::StringToInt(port_str, &temp_port) &&
|
||||
temp_port >= 1024 && temp_port < 65535) {
|
||||
if (base::StringToInt(port_str, &temp_port) && temp_port >= 1024 &&
|
||||
temp_port < 65535) {
|
||||
port = static_cast<uint16_t>(temp_port);
|
||||
} else {
|
||||
DLOG(WARNING) << "Invalid http debugger port number " << temp_port;
|
||||
@@ -94,7 +94,7 @@ std::unique_ptr<content::DevToolsSocketFactory> CreateSocketFactory() {
|
||||
new TCPServerSocketFactory("127.0.0.1", port));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
// CefDevToolsManagerDelegate ----------------------------------------------
|
||||
|
||||
@@ -106,12 +106,8 @@ void CefDevToolsManagerDelegate::StartHttpHandler(
|
||||
if (!socket_factory)
|
||||
return;
|
||||
content::DevToolsAgentHost::StartRemoteDebuggingServer(
|
||||
std::move(socket_factory),
|
||||
std::string(),
|
||||
browser_context->GetPath(),
|
||||
base::FilePath(),
|
||||
std::string(),
|
||||
CefContentClient::Get()->GetUserAgent());
|
||||
std::move(socket_factory), std::string(), browser_context->GetPath(),
|
||||
base::FilePath(), std::string(), CefContentClient::Get()->GetUserAgent());
|
||||
}
|
||||
|
||||
// static
|
||||
@@ -120,11 +116,9 @@ void CefDevToolsManagerDelegate::StopHttpHandler() {
|
||||
content::DevToolsAgentHost::StopRemoteDebuggingServer();
|
||||
}
|
||||
|
||||
CefDevToolsManagerDelegate::CefDevToolsManagerDelegate() {
|
||||
}
|
||||
CefDevToolsManagerDelegate::CefDevToolsManagerDelegate() {}
|
||||
|
||||
CefDevToolsManagerDelegate::~CefDevToolsManagerDelegate() {
|
||||
}
|
||||
CefDevToolsManagerDelegate::~CefDevToolsManagerDelegate() {}
|
||||
|
||||
scoped_refptr<content::DevToolsAgentHost>
|
||||
CefDevToolsManagerDelegate::CreateNewTarget(const GURL& url) {
|
||||
@@ -135,8 +129,9 @@ CefDevToolsManagerDelegate::CreateNewTarget(const GURL& url) {
|
||||
}
|
||||
|
||||
std::string CefDevToolsManagerDelegate::GetDiscoveryPageHTML() {
|
||||
return ui::ResourceBundle::GetSharedInstance().GetRawDataResource(
|
||||
IDR_CEF_DEVTOOLS_DISCOVERY_PAGE).as_string();
|
||||
return ui::ResourceBundle::GetSharedInstance()
|
||||
.GetRawDataResource(IDR_CEF_DEVTOOLS_DISCOVERY_PAGE)
|
||||
.as_string();
|
||||
}
|
||||
|
||||
std::string CefDevToolsManagerDelegate::GetFrontendResource(
|
||||
|
@@ -22,8 +22,8 @@ class CefDevToolsManagerDelegate : public content::DevToolsManagerDelegate {
|
||||
~CefDevToolsManagerDelegate() override;
|
||||
|
||||
// DevToolsManagerDelegate implementation.
|
||||
scoped_refptr<content::DevToolsAgentHost> CreateNewTarget(const GURL& url)
|
||||
override;
|
||||
scoped_refptr<content::DevToolsAgentHost> CreateNewTarget(
|
||||
const GURL& url) override;
|
||||
std::string GetDiscoveryPageHTML() override;
|
||||
std::string GetFrontendResource(const std::string& path) override;
|
||||
|
||||
|
@@ -9,11 +9,13 @@
|
||||
#include "content/public/browser/download_item.h"
|
||||
#include "url/gurl.h"
|
||||
|
||||
|
||||
CefDownloadItemImpl::CefDownloadItemImpl(content::DownloadItem* value)
|
||||
: CefValueBase<CefDownloadItem, content::DownloadItem>(
|
||||
value, NULL, kOwnerNoDelete, true,
|
||||
new CefValueControllerNonThreadSafe()) {
|
||||
: CefValueBase<CefDownloadItem, content::DownloadItem>(
|
||||
value,
|
||||
NULL,
|
||||
kOwnerNoDelete,
|
||||
true,
|
||||
new CefValueControllerNonThreadSafe()) {
|
||||
// Indicate that this object owns the controller.
|
||||
SetOwnsController();
|
||||
}
|
||||
|
@@ -34,30 +34,27 @@ CefRefPtr<CefDownloadHandler> GetDownloadHandler(
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
// CefBeforeDownloadCallback implementation.
|
||||
class CefBeforeDownloadCallbackImpl : public CefBeforeDownloadCallback {
|
||||
public:
|
||||
CefBeforeDownloadCallbackImpl(
|
||||
const base::WeakPtr<DownloadManager>& manager,
|
||||
uint32 download_id,
|
||||
const base::FilePath& suggested_name,
|
||||
const content::DownloadTargetCallback& callback)
|
||||
CefBeforeDownloadCallbackImpl(const base::WeakPtr<DownloadManager>& manager,
|
||||
uint32 download_id,
|
||||
const base::FilePath& suggested_name,
|
||||
const content::DownloadTargetCallback& callback)
|
||||
: manager_(manager),
|
||||
download_id_(download_id),
|
||||
suggested_name_(suggested_name),
|
||||
callback_(callback) {
|
||||
}
|
||||
callback_(callback) {}
|
||||
|
||||
void Continue(const CefString& download_path,
|
||||
bool show_dialog) override {
|
||||
void Continue(const CefString& download_path, bool show_dialog) override {
|
||||
if (CEF_CURRENTLY_ON_UIT()) {
|
||||
if (download_id_ <= 0)
|
||||
return;
|
||||
|
||||
if (manager_) {
|
||||
base::FilePath path = base::FilePath(download_path);
|
||||
CEF_POST_TASK(CEF_FILET,
|
||||
CEF_POST_TASK(
|
||||
CEF_FILET,
|
||||
base::Bind(&CefBeforeDownloadCallbackImpl::GenerateFilename,
|
||||
manager_, download_id_, suggested_name_, path,
|
||||
show_dialog, callback_));
|
||||
@@ -67,8 +64,8 @@ class CefBeforeDownloadCallbackImpl : public CefBeforeDownloadCallback {
|
||||
callback_.Reset();
|
||||
} else {
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
base::Bind(&CefBeforeDownloadCallbackImpl::Continue, this,
|
||||
download_path, show_dialog));
|
||||
base::Bind(&CefBeforeDownloadCallbackImpl::Continue, this,
|
||||
download_path, show_dialog));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,10 +98,10 @@ class CefBeforeDownloadCallbackImpl : public CefBeforeDownloadCallback {
|
||||
}
|
||||
}
|
||||
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
base::Bind(&CefBeforeDownloadCallbackImpl::ChooseDownloadPath,
|
||||
manager, download_id, suggested_path, show_dialog,
|
||||
callback));
|
||||
CEF_POST_TASK(
|
||||
CEF_UIT,
|
||||
base::Bind(&CefBeforeDownloadCallbackImpl::ChooseDownloadPath, manager,
|
||||
download_id, suggested_path, show_dialog, callback));
|
||||
}
|
||||
|
||||
static void ChooseDownloadPath(
|
||||
@@ -139,7 +136,8 @@ class CefBeforeDownloadCallbackImpl : public CefBeforeDownloadCallback {
|
||||
}
|
||||
}
|
||||
|
||||
browser->RunFileChooser(params,
|
||||
browser->RunFileChooser(
|
||||
params,
|
||||
base::Bind(
|
||||
&CefBeforeDownloadCallbackImpl::ChooseDownloadPathCallback,
|
||||
callback));
|
||||
@@ -147,10 +145,8 @@ class CefBeforeDownloadCallbackImpl : public CefBeforeDownloadCallback {
|
||||
}
|
||||
|
||||
if (!handled) {
|
||||
callback.Run(suggested_path,
|
||||
DownloadItem::TARGET_DISPOSITION_OVERWRITE,
|
||||
content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
|
||||
suggested_path,
|
||||
callback.Run(suggested_path, DownloadItem::TARGET_DISPOSITION_OVERWRITE,
|
||||
content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, suggested_path,
|
||||
content::DOWNLOAD_INTERRUPT_REASON_NONE);
|
||||
}
|
||||
}
|
||||
@@ -159,17 +155,16 @@ class CefBeforeDownloadCallbackImpl : public CefBeforeDownloadCallback {
|
||||
const content::DownloadTargetCallback& callback,
|
||||
int selected_accept_filter,
|
||||
const std::vector<base::FilePath>& file_paths) {
|
||||
DCHECK_LE(file_paths.size(), (size_t) 1);
|
||||
DCHECK_LE(file_paths.size(), (size_t)1);
|
||||
|
||||
base::FilePath path;
|
||||
if (file_paths.size() > 0)
|
||||
path = file_paths.front();
|
||||
|
||||
// The download will be cancelled if |path| is empty.
|
||||
callback.Run(path,
|
||||
DownloadItem::TARGET_DISPOSITION_OVERWRITE,
|
||||
content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
|
||||
path, content::DOWNLOAD_INTERRUPT_REASON_NONE);
|
||||
callback.Run(path, DownloadItem::TARGET_DISPOSITION_OVERWRITE,
|
||||
content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, path,
|
||||
content::DOWNLOAD_INTERRUPT_REASON_NONE);
|
||||
}
|
||||
|
||||
base::WeakPtr<DownloadManager> manager_;
|
||||
@@ -181,31 +176,29 @@ class CefBeforeDownloadCallbackImpl : public CefBeforeDownloadCallback {
|
||||
DISALLOW_COPY_AND_ASSIGN(CefBeforeDownloadCallbackImpl);
|
||||
};
|
||||
|
||||
|
||||
// CefDownloadItemCallback implementation.
|
||||
class CefDownloadItemCallbackImpl : public CefDownloadItemCallback {
|
||||
public:
|
||||
explicit CefDownloadItemCallbackImpl(
|
||||
const base::WeakPtr<DownloadManager>& manager,
|
||||
uint32 download_id)
|
||||
: manager_(manager),
|
||||
download_id_(download_id) {
|
||||
}
|
||||
: manager_(manager), download_id_(download_id) {}
|
||||
|
||||
void Cancel() override {
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
base::Bind(&CefDownloadItemCallbackImpl::DoCancel, this));
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
base::Bind(&CefDownloadItemCallbackImpl::DoCancel, this));
|
||||
}
|
||||
|
||||
void Pause() override {
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
base::Bind(&CefDownloadItemCallbackImpl::DoPause, this));
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
base::Bind(&CefDownloadItemCallbackImpl::DoPause, this));
|
||||
}
|
||||
|
||||
void Resume() override {
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
base::Bind(&CefDownloadItemCallbackImpl::DoResume, this));
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
base::Bind(&CefDownloadItemCallbackImpl::DoResume, this));
|
||||
}
|
||||
|
||||
private:
|
||||
void DoCancel() {
|
||||
if (download_id_ <= 0)
|
||||
@@ -251,11 +244,8 @@ class CefDownloadItemCallbackImpl : public CefDownloadItemCallback {
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
CefDownloadManagerDelegate::CefDownloadManagerDelegate(
|
||||
DownloadManager* manager)
|
||||
: manager_(manager),
|
||||
manager_ptr_factory_(manager) {
|
||||
CefDownloadManagerDelegate::CefDownloadManagerDelegate(DownloadManager* manager)
|
||||
: manager_(manager), manager_ptr_factory_(manager) {
|
||||
DCHECK(manager);
|
||||
manager->AddObserver(this);
|
||||
|
||||
@@ -276,8 +266,7 @@ CefDownloadManagerDelegate::~CefDownloadManagerDelegate() {
|
||||
OnDownloadDestroyed(item_browser_map_.begin()->first);
|
||||
}
|
||||
|
||||
void CefDownloadManagerDelegate::OnDownloadUpdated(
|
||||
DownloadItem* download) {
|
||||
void CefDownloadManagerDelegate::OnDownloadUpdated(DownloadItem* download) {
|
||||
CefRefPtr<CefBrowserHostImpl> browser = GetBrowser(download);
|
||||
CefRefPtr<CefDownloadHandler> handler;
|
||||
if (browser.get())
|
||||
@@ -286,9 +275,8 @@ void CefDownloadManagerDelegate::OnDownloadUpdated(
|
||||
if (handler.get()) {
|
||||
CefRefPtr<CefDownloadItemImpl> download_item(
|
||||
new CefDownloadItemImpl(download));
|
||||
CefRefPtr<CefDownloadItemCallback> callback(
|
||||
new CefDownloadItemCallbackImpl(manager_ptr_factory_.GetWeakPtr(),
|
||||
download->GetId()));
|
||||
CefRefPtr<CefDownloadItemCallback> callback(new CefDownloadItemCallbackImpl(
|
||||
manager_ptr_factory_.GetWeakPtr(), download->GetId()));
|
||||
|
||||
handler->OnDownloadUpdated(browser.get(), download_item.get(), callback);
|
||||
|
||||
@@ -296,8 +284,7 @@ void CefDownloadManagerDelegate::OnDownloadUpdated(
|
||||
}
|
||||
}
|
||||
|
||||
void CefDownloadManagerDelegate::OnDownloadDestroyed(
|
||||
DownloadItem* item) {
|
||||
void CefDownloadManagerDelegate::OnDownloadDestroyed(DownloadItem* item) {
|
||||
item->RemoveObserver(this);
|
||||
|
||||
CefBrowserHostImpl* browser = nullptr;
|
||||
@@ -326,9 +313,8 @@ void CefDownloadManagerDelegate::OnDownloadDestroyed(
|
||||
}
|
||||
}
|
||||
|
||||
void CefDownloadManagerDelegate::OnDownloadCreated(
|
||||
DownloadManager* manager,
|
||||
DownloadItem* item) {
|
||||
void CefDownloadManagerDelegate::OnDownloadCreated(DownloadManager* manager,
|
||||
DownloadItem* item) {
|
||||
item->AddObserver(this);
|
||||
|
||||
CefBrowserHostImpl* browser = nullptr;
|
||||
@@ -345,8 +331,7 @@ void CefDownloadManagerDelegate::OnDownloadCreated(
|
||||
browser->AddObserver(this);
|
||||
}
|
||||
|
||||
void CefDownloadManagerDelegate::ManagerGoingDown(
|
||||
DownloadManager* manager) {
|
||||
void CefDownloadManagerDelegate::ManagerGoingDown(DownloadManager* manager) {
|
||||
DCHECK_EQ(manager, manager_);
|
||||
manager->SetDelegate(NULL);
|
||||
manager->RemoveObserver(this);
|
||||
@@ -358,11 +343,10 @@ bool CefDownloadManagerDelegate::DetermineDownloadTarget(
|
||||
DownloadItem* item,
|
||||
const content::DownloadTargetCallback& callback) {
|
||||
if (!item->GetForcedFilePath().empty()) {
|
||||
callback.Run(item->GetForcedFilePath(),
|
||||
DownloadItem::TARGET_DISPOSITION_OVERWRITE,
|
||||
content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
|
||||
item->GetForcedFilePath(),
|
||||
content::DOWNLOAD_INTERRUPT_REASON_NONE);
|
||||
callback.Run(
|
||||
item->GetForcedFilePath(), DownloadItem::TARGET_DISPOSITION_OVERWRITE,
|
||||
content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, item->GetForcedFilePath(),
|
||||
content::DOWNLOAD_INTERRUPT_REASON_NONE);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -373,12 +357,8 @@ bool CefDownloadManagerDelegate::DetermineDownloadTarget(
|
||||
|
||||
if (handler.get()) {
|
||||
base::FilePath suggested_name = net::GenerateFileName(
|
||||
item->GetURL(),
|
||||
item->GetContentDisposition(),
|
||||
std::string(),
|
||||
item->GetSuggestedFilename(),
|
||||
item->GetMimeType(),
|
||||
"download");
|
||||
item->GetURL(), item->GetContentDisposition(), std::string(),
|
||||
item->GetSuggestedFilename(), item->GetMimeType(), "download");
|
||||
|
||||
CefRefPtr<CefDownloadItemImpl> download_item(new CefDownloadItemImpl(item));
|
||||
CefRefPtr<CefBeforeDownloadCallback> callbackObj(
|
||||
|
@@ -16,11 +16,10 @@
|
||||
#include "content/public/browser/download_manager.h"
|
||||
#include "content/public/browser/download_manager_delegate.h"
|
||||
|
||||
class CefDownloadManagerDelegate
|
||||
: public content::DownloadItem::Observer,
|
||||
public content::DownloadManager::Observer,
|
||||
public content::DownloadManagerDelegate,
|
||||
public CefBrowserHostImpl::Observer {
|
||||
class CefDownloadManagerDelegate : public content::DownloadItem::Observer,
|
||||
public content::DownloadManager::Observer,
|
||||
public content::DownloadManagerDelegate,
|
||||
public CefBrowserHostImpl::Observer {
|
||||
public:
|
||||
explicit CefDownloadManagerDelegate(content::DownloadManager* manager);
|
||||
~CefDownloadManagerDelegate() override;
|
||||
@@ -52,7 +51,7 @@ class CefDownloadManagerDelegate
|
||||
// Map of DownloadItem to originating CefBrowserHostImpl. Maintaining this
|
||||
// map is necessary because DownloadItem::GetWebContents() may return NULL if
|
||||
// the browser navigates while the download is in progress.
|
||||
typedef std::map<content::DownloadItem*, CefBrowserHostImpl* > ItemBrowserMap;
|
||||
typedef std::map<content::DownloadItem*, CefBrowserHostImpl*> ItemBrowserMap;
|
||||
ItemBrowserMap item_browser_map_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(CefDownloadManagerDelegate);
|
||||
|
@@ -43,8 +43,9 @@ bool GetTabById(int tab_id,
|
||||
// BrowserContext.
|
||||
Profile* profile = Profile::FromBrowserContext(browser_context);
|
||||
Profile* incognito_profile =
|
||||
include_incognito && profile->HasOffTheRecordProfile() ?
|
||||
profile->GetOffTheRecordProfile() : NULL;
|
||||
include_incognito && profile->HasOffTheRecordProfile()
|
||||
? profile->GetOffTheRecordProfile()
|
||||
: NULL;
|
||||
|
||||
CefBrowserInfoManager::BrowserInfoList list;
|
||||
CefBrowserInfoManager::GetInstance()->GetBrowserInfoList(list);
|
||||
@@ -65,8 +66,7 @@ bool GetTabById(int tab_id,
|
||||
if (!browser_context)
|
||||
continue;
|
||||
|
||||
if (browser_context == profile ||
|
||||
browser_context == incognito_profile) {
|
||||
if (browser_context == profile || browser_context == incognito_profile) {
|
||||
content::WebContents* web_contents = cef_browser->web_contents();
|
||||
if (SessionTabHelper::IdForTab(web_contents) == tab_id) {
|
||||
if (browser)
|
||||
@@ -94,8 +94,8 @@ bool GetTabById(int tab_id,
|
||||
}
|
||||
|
||||
if (error_message) {
|
||||
*error_message = ErrorUtils::FormatErrorMessage(
|
||||
keys::kTabNotFoundError, base::IntToString(tab_id));
|
||||
*error_message = ErrorUtils::FormatErrorMessage(keys::kTabNotFoundError,
|
||||
base::IntToString(tab_id));
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -134,11 +134,8 @@ content::WebContents* ZoomAPIFunction::GetWebContents(int tab_id) {
|
||||
content::WebContents* web_contents = NULL;
|
||||
if (tab_id != -1) {
|
||||
// We assume this call leaves web_contents unchanged if it is unsuccessful.
|
||||
GetTabById(tab_id,
|
||||
context_,
|
||||
include_incognito(),
|
||||
NULL /* ignore CefBrowserHostImpl* output */,
|
||||
&web_contents,
|
||||
GetTabById(tab_id, context_, include_incognito(),
|
||||
NULL /* ignore CefBrowserHostImpl* output */, &web_contents,
|
||||
&error_);
|
||||
} else {
|
||||
// Use the sender as the default.
|
||||
|
@@ -77,10 +77,10 @@ CefRefPtr<CefBrowserHostImpl> GetOwnerBrowserForFrame(int render_process_id,
|
||||
if (info.get()) {
|
||||
CefRefPtr<CefBrowserHostImpl> browser = info->browser();
|
||||
if (!browser.get()) {
|
||||
LOG(WARNING) << "Found browser id " << info->browser_id() <<
|
||||
" but no browser object matching view process id " <<
|
||||
render_process_id << " and frame routing id " <<
|
||||
render_routing_id;
|
||||
LOG(WARNING) << "Found browser id " << info->browser_id()
|
||||
<< " but no browser object matching view process id "
|
||||
<< render_process_id << " and frame routing id "
|
||||
<< render_routing_id;
|
||||
}
|
||||
return browser;
|
||||
}
|
||||
|
@@ -26,16 +26,16 @@ namespace cefimpl = extensions::cef;
|
||||
// static
|
||||
bool ChromeFunctionRegistry::IsSupported(const std::string& name) {
|
||||
static const char* const supported_apis[] = {
|
||||
"resourcesPrivate",
|
||||
EXTENSION_FUNCTION_NAME(ResourcesPrivateGetStringsFunction),
|
||||
"streamsPrivate",
|
||||
EXTENSION_FUNCTION_NAME(StreamsPrivateAbortFunction),
|
||||
"tabs",
|
||||
EXTENSION_FUNCTION_NAME(cefimpl::TabsGetFunction),
|
||||
EXTENSION_FUNCTION_NAME(cefimpl::TabsSetZoomFunction),
|
||||
EXTENSION_FUNCTION_NAME(cefimpl::TabsGetZoomFunction),
|
||||
EXTENSION_FUNCTION_NAME(cefimpl::TabsSetZoomSettingsFunction),
|
||||
EXTENSION_FUNCTION_NAME(cefimpl::TabsGetZoomSettingsFunction),
|
||||
"resourcesPrivate",
|
||||
EXTENSION_FUNCTION_NAME(ResourcesPrivateGetStringsFunction),
|
||||
"streamsPrivate",
|
||||
EXTENSION_FUNCTION_NAME(StreamsPrivateAbortFunction),
|
||||
"tabs",
|
||||
EXTENSION_FUNCTION_NAME(cefimpl::TabsGetFunction),
|
||||
EXTENSION_FUNCTION_NAME(cefimpl::TabsSetZoomFunction),
|
||||
EXTENSION_FUNCTION_NAME(cefimpl::TabsGetZoomFunction),
|
||||
EXTENSION_FUNCTION_NAME(cefimpl::TabsSetZoomSettingsFunction),
|
||||
EXTENSION_FUNCTION_NAME(cefimpl::TabsGetZoomSettingsFunction),
|
||||
};
|
||||
for (size_t i = 0; i < arraysize(supported_apis); ++i) {
|
||||
if (name == supported_apis[i])
|
||||
|
@@ -12,9 +12,8 @@
|
||||
namespace extensions {
|
||||
|
||||
CefComponentExtensionResourceManager::CefComponentExtensionResourceManager() {
|
||||
AddComponentResourceEntries(
|
||||
kComponentExtensionResources,
|
||||
kComponentExtensionResourcesSize);
|
||||
AddComponentResourceEntries(kComponentExtensionResources,
|
||||
kComponentExtensionResourcesSize);
|
||||
}
|
||||
|
||||
CefComponentExtensionResourceManager::~CefComponentExtensionResourceManager() {}
|
||||
@@ -45,12 +44,12 @@ void CefComponentExtensionResourceManager::AddComponentResourceEntries(
|
||||
const GritResourceMap* entries,
|
||||
size_t size) {
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
base::FilePath resource_path = base::FilePath().AppendASCII(
|
||||
entries[i].name);
|
||||
base::FilePath resource_path =
|
||||
base::FilePath().AppendASCII(entries[i].name);
|
||||
resource_path = resource_path.NormalizePathSeparators();
|
||||
|
||||
DCHECK(path_to_resource_id_.find(resource_path) ==
|
||||
path_to_resource_id_.end());
|
||||
path_to_resource_id_.end());
|
||||
path_to_resource_id_[resource_path] = entries[i].value;
|
||||
}
|
||||
}
|
||||
|
@@ -64,8 +64,7 @@ std::string GenerateId(const base::DictionaryValue* manifest,
|
||||
}
|
||||
|
||||
// Implementation based on ComponentLoader::ParseManifest.
|
||||
base::DictionaryValue* ParseManifest(
|
||||
const std::string& manifest_contents) {
|
||||
base::DictionaryValue* ParseManifest(const std::string& manifest_contents) {
|
||||
JSONStringValueDeserializer deserializer(manifest_contents);
|
||||
std::unique_ptr<base::Value> manifest(deserializer.Deserialize(NULL, NULL));
|
||||
|
||||
@@ -86,11 +85,9 @@ CefExtensionSystem::CefExtensionSystem(BrowserContext* browser_context)
|
||||
renderer_helper_(
|
||||
extensions::RendererStartupHelperFactory::GetForBrowserContext(
|
||||
browser_context)),
|
||||
weak_ptr_factory_(this) {
|
||||
}
|
||||
weak_ptr_factory_(this) {}
|
||||
|
||||
CefExtensionSystem::~CefExtensionSystem() {
|
||||
}
|
||||
CefExtensionSystem::~CefExtensionSystem() {}
|
||||
|
||||
void CefExtensionSystem::Init() {
|
||||
DCHECK(!initialized_);
|
||||
@@ -189,8 +186,7 @@ void CefExtensionSystem::RemoveExtension(const std::string& extension_id) {
|
||||
}
|
||||
}
|
||||
|
||||
void CefExtensionSystem::Shutdown() {
|
||||
}
|
||||
void CefExtensionSystem::Shutdown() {}
|
||||
|
||||
void CefExtensionSystem::InitForRegularProfile(bool extensions_enabled) {
|
||||
DCHECK(!initialized_);
|
||||
@@ -254,14 +250,11 @@ void CefExtensionSystem::RegisterExtensionWithRequestContexts(
|
||||
// TODO(extensions): The |incognito_enabled| value should be set based on
|
||||
// manifest settings.
|
||||
BrowserThread::PostTaskAndReply(
|
||||
BrowserThread::IO,
|
||||
FROM_HERE,
|
||||
base::Bind(&InfoMap::AddExtension,
|
||||
info_map(),
|
||||
base::RetainedRef(extension),
|
||||
base::Time::Now(),
|
||||
true, // incognito_enabled
|
||||
false), // notifications_disabled
|
||||
BrowserThread::IO, FROM_HERE,
|
||||
base::Bind(&InfoMap::AddExtension, info_map(),
|
||||
base::RetainedRef(extension), base::Time::Now(),
|
||||
true, // incognito_enabled
|
||||
false), // notifications_disabled
|
||||
callback);
|
||||
}
|
||||
|
||||
@@ -271,8 +264,7 @@ void CefExtensionSystem::UnregisterExtensionWithRequestContexts(
|
||||
const std::string& extension_id,
|
||||
const UnloadedExtensionInfo::Reason reason) {
|
||||
BrowserThread::PostTask(
|
||||
BrowserThread::IO,
|
||||
FROM_HERE,
|
||||
BrowserThread::IO, FROM_HERE,
|
||||
base::Bind(&InfoMap::RemoveExtension, info_map(), extension_id, reason));
|
||||
}
|
||||
|
||||
@@ -295,11 +287,10 @@ void CefExtensionSystem::InstallUpdate(const std::string& extension_id,
|
||||
base::DeleteFile(temp_dir, true /* recursive */);
|
||||
}
|
||||
|
||||
|
||||
CefExtensionSystem::ComponentExtensionInfo::ComponentExtensionInfo(
|
||||
const base::DictionaryValue* manifest, const base::FilePath& directory)
|
||||
: manifest(manifest),
|
||||
root_directory(directory) {
|
||||
const base::DictionaryValue* manifest,
|
||||
const base::FilePath& directory)
|
||||
: manifest(manifest), root_directory(directory) {
|
||||
if (!root_directory.IsAbsolute()) {
|
||||
// This path structure is required by
|
||||
// url_request_util::MaybeCreateURLRequestResourceBundleJob.
|
||||
@@ -311,16 +302,13 @@ CefExtensionSystem::ComponentExtensionInfo::ComponentExtensionInfo(
|
||||
|
||||
// Implementation based on ComponentLoader::CreateExtension.
|
||||
scoped_refptr<const Extension> CefExtensionSystem::CreateExtension(
|
||||
const ComponentExtensionInfo& info, std::string* utf8_error) {
|
||||
const ComponentExtensionInfo& info,
|
||||
std::string* utf8_error) {
|
||||
// TODO(abarth): We should REQUIRE_MODERN_MANIFEST_VERSION once we've updated
|
||||
// our component extensions to the new manifest version.
|
||||
int flags = Extension::REQUIRE_KEY;
|
||||
return Extension::Create(
|
||||
info.root_directory,
|
||||
Manifest::COMPONENT,
|
||||
*info.manifest,
|
||||
flags,
|
||||
utf8_error);
|
||||
return Extension::Create(info.root_directory, Manifest::COMPONENT,
|
||||
*info.manifest, flags, utf8_error);
|
||||
}
|
||||
|
||||
// Implementation based on ComponentLoader::Load and
|
||||
@@ -343,9 +331,8 @@ const Extension* CefExtensionSystem::LoadExtension(
|
||||
}
|
||||
|
||||
// Implementation based on ExtensionService::UnloadExtension.
|
||||
void CefExtensionSystem::UnloadExtension(
|
||||
const std::string& extension_id,
|
||||
UnloadedExtensionInfo::Reason reason) {
|
||||
void CefExtensionSystem::UnloadExtension(const std::string& extension_id,
|
||||
UnloadedExtensionInfo::Reason reason) {
|
||||
// Make sure the extension gets deleted after we return from this function.
|
||||
int include_mask =
|
||||
ExtensionRegistry::EVERYTHING & ~ExtensionRegistry::TERMINATED;
|
||||
@@ -418,7 +405,7 @@ void CefExtensionSystem::NotifyExtensionLoaded(const Extension* extension) {
|
||||
info.path = base::FilePath::FromUTF8Unsafe(extension->url().spec());
|
||||
|
||||
for (std::set<std::string>::const_iterator mime_type =
|
||||
handler->mime_type_set().begin();
|
||||
handler->mime_type_set().begin();
|
||||
mime_type != handler->mime_type_set().end(); ++mime_type) {
|
||||
content::WebPluginMimeType mime_type_info;
|
||||
mime_type_info.mime_type = *mime_type;
|
||||
|
@@ -97,23 +97,22 @@ class CefExtensionSystem : public ExtensionSystem {
|
||||
};
|
||||
|
||||
scoped_refptr<const Extension> CreateExtension(
|
||||
const ComponentExtensionInfo& info, std::string* utf8_error);
|
||||
const ComponentExtensionInfo& info,
|
||||
std::string* utf8_error);
|
||||
|
||||
// Loads a registered component extension.
|
||||
const Extension* LoadExtension(const ComponentExtensionInfo& info);
|
||||
|
||||
// Unload the specified extension.
|
||||
void UnloadExtension(
|
||||
const std::string& extension_id,
|
||||
extensions::UnloadedExtensionInfo::Reason reason);
|
||||
void UnloadExtension(const std::string& extension_id,
|
||||
extensions::UnloadedExtensionInfo::Reason reason);
|
||||
|
||||
// Handles sending notification that |extension| was loaded.
|
||||
void NotifyExtensionLoaded(const Extension* extension);
|
||||
|
||||
// Handles sending notification that |extension| was unloaded.
|
||||
void NotifyExtensionUnloaded(
|
||||
const Extension* extension,
|
||||
UnloadedExtensionInfo::Reason reason);
|
||||
void NotifyExtensionUnloaded(const Extension* extension,
|
||||
UnloadedExtensionInfo::Reason reason);
|
||||
|
||||
// Completes extension loading after URLRequestContexts have been updated
|
||||
// on the IO thread.
|
||||
|
@@ -35,8 +35,7 @@ CefExtensionSystemFactory::CefExtensionSystemFactory()
|
||||
DependsOn(ExtensionRegistryFactory::GetInstance());
|
||||
}
|
||||
|
||||
CefExtensionSystemFactory::~CefExtensionSystemFactory() {
|
||||
}
|
||||
CefExtensionSystemFactory::~CefExtensionSystemFactory() {}
|
||||
|
||||
KeyedService* CefExtensionSystemFactory::BuildServiceInstanceFor(
|
||||
BrowserContext* context) const {
|
||||
|
@@ -15,11 +15,9 @@ namespace extensions {
|
||||
|
||||
CefExtensionWebContentsObserver::CefExtensionWebContentsObserver(
|
||||
content::WebContents* web_contents)
|
||||
: ExtensionWebContentsObserver(web_contents) {
|
||||
}
|
||||
: ExtensionWebContentsObserver(web_contents) {}
|
||||
|
||||
CefExtensionWebContentsObserver::~CefExtensionWebContentsObserver() {
|
||||
}
|
||||
CefExtensionWebContentsObserver::~CefExtensionWebContentsObserver() {}
|
||||
|
||||
void CefExtensionWebContentsObserver::RenderViewCreated(
|
||||
content::RenderViewHost* render_view_host) {
|
||||
|
@@ -17,8 +17,7 @@ class CefExtensionWebContentsObserver
|
||||
private:
|
||||
friend class content::WebContentsUserData<CefExtensionWebContentsObserver>;
|
||||
|
||||
explicit CefExtensionWebContentsObserver(
|
||||
content::WebContents* web_contents);
|
||||
explicit CefExtensionWebContentsObserver(content::WebContents* web_contents);
|
||||
~CefExtensionWebContentsObserver() override;
|
||||
|
||||
// content::WebContentsObserver overrides.
|
||||
|
@@ -21,8 +21,7 @@
|
||||
|
||||
namespace extensions {
|
||||
|
||||
CefExtensionsAPIClient::CefExtensionsAPIClient() {
|
||||
}
|
||||
CefExtensionsAPIClient::CefExtensionsAPIClient() {}
|
||||
|
||||
AppViewGuestDelegate* CefExtensionsAPIClient::CreateAppViewGuestDelegate()
|
||||
const {
|
||||
@@ -42,9 +41,8 @@ CefExtensionsAPIClient::CreateGuestViewManagerDelegate(
|
||||
// to provide the *Impl object instead of |context| which may be a *Proxy
|
||||
// object. If we don't do this then the Delegate may attempt to access a
|
||||
// *Proxy object that has already been deleted.
|
||||
return base::WrapUnique(
|
||||
new extensions::ExtensionsGuestViewManagerDelegate(
|
||||
CefBrowserContextImpl::GetForContext(context)));
|
||||
return base::WrapUnique(new extensions::ExtensionsGuestViewManagerDelegate(
|
||||
CefBrowserContextImpl::GetForContext(context)));
|
||||
}
|
||||
|
||||
std::unique_ptr<MimeHandlerViewGuestDelegate>
|
||||
@@ -62,9 +60,8 @@ void CefExtensionsAPIClient::AttachWebContentsHelpers(
|
||||
|
||||
// Used by the PDF extension.
|
||||
pdf::PDFWebContentsHelper::CreateForWebContentsWithClient(
|
||||
web_contents,
|
||||
std::unique_ptr<pdf::PDFWebContentsHelperClient>(
|
||||
new CefPDFWebContentsHelperClient()));
|
||||
web_contents, std::unique_ptr<pdf::PDFWebContentsHelperClient>(
|
||||
new CefPDFWebContentsHelperClient()));
|
||||
|
||||
// Used by the tabs extension API.
|
||||
SessionTabHelper::CreateForWebContents(web_contents);
|
||||
|
@@ -22,8 +22,8 @@ class CefExtensionsAPIClient : public ExtensionsAPIClient {
|
||||
std::unique_ptr<MimeHandlerViewGuestDelegate>
|
||||
CreateMimeHandlerViewGuestDelegate(
|
||||
MimeHandlerViewGuest* guest) const override;
|
||||
void AttachWebContentsHelpers(content::WebContents* web_contents) const
|
||||
override;
|
||||
void AttachWebContentsHelpers(
|
||||
content::WebContents* web_contents) const override;
|
||||
};
|
||||
|
||||
} // namespace extensions
|
||||
|
@@ -40,11 +40,9 @@ namespace extensions {
|
||||
|
||||
CefExtensionsBrowserClient::CefExtensionsBrowserClient()
|
||||
: api_client_(new CefExtensionsAPIClient),
|
||||
resource_manager_(new CefComponentExtensionResourceManager) {
|
||||
}
|
||||
resource_manager_(new CefComponentExtensionResourceManager) {}
|
||||
|
||||
CefExtensionsBrowserClient::~CefExtensionsBrowserClient() {
|
||||
}
|
||||
CefExtensionsBrowserClient::~CefExtensionsBrowserClient() {}
|
||||
|
||||
bool CefExtensionsBrowserClient::IsShuttingDown() {
|
||||
return false;
|
||||
@@ -84,8 +82,7 @@ BrowserContext* CefExtensionsBrowserClient::GetOriginalContext(
|
||||
return chrome::GetBrowserContextRedirectedInIncognito(context);
|
||||
}
|
||||
|
||||
bool CefExtensionsBrowserClient::IsGuestSession(
|
||||
BrowserContext* context) const {
|
||||
bool CefExtensionsBrowserClient::IsGuestSession(BrowserContext* context) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -109,10 +106,7 @@ CefExtensionsBrowserClient::MaybeCreateResourceBundleRequestJob(
|
||||
const std::string& content_security_policy,
|
||||
bool send_cors_header) {
|
||||
return chrome_url_request_util::MaybeCreateURLRequestResourceBundleJob(
|
||||
request,
|
||||
network_delegate,
|
||||
directory_path,
|
||||
content_security_policy,
|
||||
request, network_delegate, directory_path, content_security_policy,
|
||||
send_cors_header);
|
||||
}
|
||||
|
||||
@@ -145,11 +139,10 @@ PrefService* CefExtensionsBrowserClient::GetPrefServiceForContext(
|
||||
|
||||
void CefExtensionsBrowserClient::GetEarlyExtensionPrefsObservers(
|
||||
content::BrowserContext* context,
|
||||
std::vector<ExtensionPrefsObserver*>* observers) const {
|
||||
}
|
||||
std::vector<ExtensionPrefsObserver*>* observers) const {}
|
||||
|
||||
ProcessManagerDelegate*
|
||||
CefExtensionsBrowserClient::GetProcessManagerDelegate() const {
|
||||
ProcessManagerDelegate* CefExtensionsBrowserClient::GetProcessManagerDelegate()
|
||||
const {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -165,14 +158,13 @@ bool CefExtensionsBrowserClient::DidVersionUpdate(BrowserContext* context) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void CefExtensionsBrowserClient::PermitExternalProtocolHandler() {
|
||||
}
|
||||
void CefExtensionsBrowserClient::PermitExternalProtocolHandler() {}
|
||||
|
||||
bool CefExtensionsBrowserClient::IsRunningInForcedAppMode() {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CefExtensionsBrowserClient::IsLoggedInAsPublicAccount() {
|
||||
bool CefExtensionsBrowserClient::IsLoggedInAsPublicAccount() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -189,7 +181,7 @@ void CefExtensionsBrowserClient::RegisterExtensionFunctions(
|
||||
// CEF-only APIs.
|
||||
// TODO(cef): Enable if/when CEF exposes its own Mojo APIs. See
|
||||
// libcef/common/extensions/api/README.txt for details.
|
||||
//api::cef::CefGeneratedFunctionRegistry::RegisterAll(registry);
|
||||
// api::cef::CefGeneratedFunctionRegistry::RegisterAll(registry);
|
||||
|
||||
// Chrome APIs whitelisted by CEF.
|
||||
api::cef::ChromeFunctionRegistry::RegisterAll(registry);
|
||||
@@ -218,9 +210,9 @@ void CefExtensionsBrowserClient::BroadcastEventToRenderers(
|
||||
events::HistogramValue histogram_value,
|
||||
const std::string& event_name,
|
||||
std::unique_ptr<base::ListValue> args) {
|
||||
g_browser_process->extension_event_router_forwarder()->
|
||||
BroadcastEventToRenderers(histogram_value, event_name, std::move(args),
|
||||
GURL());
|
||||
g_browser_process->extension_event_router_forwarder()
|
||||
->BroadcastEventToRenderers(histogram_value, event_name, std::move(args),
|
||||
GURL());
|
||||
}
|
||||
|
||||
net::NetLog* CefExtensionsBrowserClient::GetNetLog() {
|
||||
|
@@ -53,11 +53,9 @@ class CefExtensionsBrowserClient : public ExtensionsBrowserClient {
|
||||
content::BrowserContext* context) override;
|
||||
void GetEarlyExtensionPrefsObservers(
|
||||
content::BrowserContext* context,
|
||||
std::vector<ExtensionPrefsObserver*>* observers) const
|
||||
override;
|
||||
std::vector<ExtensionPrefsObserver*>* observers) const override;
|
||||
ProcessManagerDelegate* GetProcessManagerDelegate() const override;
|
||||
std::unique_ptr<ExtensionHostDelegate>
|
||||
CreateExtensionHostDelegate() override;
|
||||
std::unique_ptr<ExtensionHostDelegate> CreateExtensionHostDelegate() override;
|
||||
bool DidVersionUpdate(content::BrowserContext* context) override;
|
||||
void PermitExternalProtocolHandler() override;
|
||||
bool IsRunningInForcedAppMode() override;
|
||||
@@ -71,9 +69,10 @@ class CefExtensionsBrowserClient : public ExtensionsBrowserClient {
|
||||
content::BrowserContext* context) const override;
|
||||
const ComponentExtensionResourceManager*
|
||||
GetComponentExtensionResourceManager() override;
|
||||
void BroadcastEventToRenderers(events::HistogramValue histogram_value,
|
||||
const std::string& event_name,
|
||||
std::unique_ptr<base::ListValue> args) override;
|
||||
void BroadcastEventToRenderers(
|
||||
events::HistogramValue histogram_value,
|
||||
const std::string& event_name,
|
||||
std::unique_ptr<base::ListValue> args) override;
|
||||
net::NetLog* GetNetLog() override;
|
||||
ExtensionCache* GetExtensionCache() override;
|
||||
bool IsBackgroundUpdateAllowed() override;
|
||||
|
@@ -32,11 +32,9 @@ CefRefPtr<CefBrowserHostImpl> GetOwnerBrowser(
|
||||
|
||||
CefMimeHandlerViewGuestDelegate::CefMimeHandlerViewGuestDelegate(
|
||||
MimeHandlerViewGuest* guest)
|
||||
: guest_(guest) {
|
||||
}
|
||||
: guest_(guest) {}
|
||||
|
||||
CefMimeHandlerViewGuestDelegate::~CefMimeHandlerViewGuestDelegate() {
|
||||
}
|
||||
CefMimeHandlerViewGuestDelegate::~CefMimeHandlerViewGuestDelegate() {}
|
||||
|
||||
void CefMimeHandlerViewGuestDelegate::OverrideWebContentsCreateParams(
|
||||
content::WebContents::CreateParams* params) {
|
||||
@@ -64,11 +62,9 @@ void CefMimeHandlerViewGuestDelegate::OnGuestAttached(
|
||||
// Associate guest state information with the owner browser.
|
||||
scoped_refptr<CefBrowserInfo> info = owner_browser->browser_info();
|
||||
info->guest_render_id_manager()->add_render_view_id(
|
||||
view_host->GetProcess()->GetID(),
|
||||
view_host->GetRoutingID());
|
||||
view_host->GetProcess()->GetID(), view_host->GetRoutingID());
|
||||
info->guest_render_id_manager()->add_render_frame_id(
|
||||
main_frame_host->GetProcess()->GetID(),
|
||||
main_frame_host->GetRoutingID());
|
||||
main_frame_host->GetProcess()->GetID(), main_frame_host->GetRoutingID());
|
||||
}
|
||||
|
||||
void CefMimeHandlerViewGuestDelegate::OnGuestDetached(
|
||||
@@ -88,10 +84,9 @@ void CefMimeHandlerViewGuestDelegate::OnGuestDetached(
|
||||
// Disassociate guest state information with the owner browser.
|
||||
scoped_refptr<CefBrowserInfo> info = owner_browser->browser_info();
|
||||
info->guest_render_id_manager()->remove_render_view_id(
|
||||
view_host->GetProcess()->GetID(),
|
||||
view_host->GetRoutingID());
|
||||
info->guest_render_id_manager()->remove_render_frame_id(
|
||||
render_process_id, render_frame_id);
|
||||
view_host->GetProcess()->GetID(), view_host->GetRoutingID());
|
||||
info->guest_render_id_manager()->remove_render_frame_id(render_process_id,
|
||||
render_frame_id);
|
||||
|
||||
CefBrowserContext* context =
|
||||
static_cast<CefBrowserContext*>(web_contents->GetBrowserContext());
|
||||
@@ -107,8 +102,9 @@ bool CefMimeHandlerViewGuestDelegate::HandleContextMenu(
|
||||
content::ContextMenuParams new_params = params;
|
||||
|
||||
gfx::Point guest_coordinates =
|
||||
static_cast<content::WebContentsImpl*>(web_contents)->
|
||||
GetBrowserPluginGuest()->GetScreenCoordinates(gfx::Point());
|
||||
static_cast<content::WebContentsImpl*>(web_contents)
|
||||
->GetBrowserPluginGuest()
|
||||
->GetScreenCoordinates(gfx::Point());
|
||||
|
||||
// Adjust (x,y) position for offset from guest to embedder.
|
||||
new_params.x += guest_coordinates.x();
|
||||
|
@@ -32,12 +32,12 @@ const char kPdfResourceIdentifier[] = "chromium-pdf";
|
||||
const char kPdfPluginName[] = "Chrome PDF Viewer";
|
||||
|
||||
std::string GetManifest() {
|
||||
std::string manifest_contents =
|
||||
ResourceBundle::GetSharedInstance().GetRawDataResource(
|
||||
IDR_PDF_MANIFEST).as_string();
|
||||
std::string manifest_contents = ResourceBundle::GetSharedInstance()
|
||||
.GetRawDataResource(IDR_PDF_MANIFEST)
|
||||
.as_string();
|
||||
DCHECK(manifest_contents.find(kNameTag) != std::string::npos);
|
||||
base::ReplaceFirstSubstringAfterOffset(
|
||||
&manifest_contents, 0, kNameTag, kPdfPluginName);
|
||||
base::ReplaceFirstSubstringAfterOffset(&manifest_contents, 0, kNameTag,
|
||||
kPdfPluginName);
|
||||
|
||||
return manifest_contents;
|
||||
}
|
||||
|
@@ -6,23 +6,17 @@
|
||||
|
||||
namespace extensions {
|
||||
|
||||
CefPDFWebContentsHelperClient::CefPDFWebContentsHelperClient() {
|
||||
}
|
||||
CefPDFWebContentsHelperClient::CefPDFWebContentsHelperClient() {}
|
||||
|
||||
CefPDFWebContentsHelperClient::~CefPDFWebContentsHelperClient() {
|
||||
}
|
||||
CefPDFWebContentsHelperClient::~CefPDFWebContentsHelperClient() {}
|
||||
|
||||
void CefPDFWebContentsHelperClient::UpdateContentRestrictions(
|
||||
content::WebContents* contents,
|
||||
int content_restrictions) {
|
||||
}
|
||||
int content_restrictions) {}
|
||||
|
||||
void CefPDFWebContentsHelperClient::OnPDFHasUnsupportedFeature(
|
||||
content::WebContents* contents) {
|
||||
}
|
||||
content::WebContents* contents) {}
|
||||
|
||||
void CefPDFWebContentsHelperClient::OnSaveURL(
|
||||
content::WebContents* contents) {
|
||||
}
|
||||
void CefPDFWebContentsHelperClient::OnSaveURL(content::WebContents* contents) {}
|
||||
|
||||
} // namespace extensions
|
||||
|
@@ -10,8 +10,7 @@
|
||||
|
||||
namespace extensions {
|
||||
|
||||
class CefPDFWebContentsHelperClient
|
||||
: public pdf::PDFWebContentsHelperClient {
|
||||
class CefPDFWebContentsHelperClient : public pdf::PDFWebContentsHelperClient {
|
||||
public:
|
||||
CefPDFWebContentsHelperClient();
|
||||
~CefPDFWebContentsHelperClient() override;
|
||||
|
@@ -21,16 +21,15 @@ class CefFileDialogCallbackImpl : public CefFileDialogCallback {
|
||||
public:
|
||||
explicit CefFileDialogCallbackImpl(
|
||||
const CefFileDialogRunner::RunFileChooserCallback& callback)
|
||||
: callback_(callback) {
|
||||
}
|
||||
: callback_(callback) {}
|
||||
~CefFileDialogCallbackImpl() override {
|
||||
if (!callback_.is_null()) {
|
||||
// The callback is still pending. Cancel it now.
|
||||
if (CEF_CURRENTLY_ON_UIT()) {
|
||||
CancelNow(callback_);
|
||||
} else {
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
base::Bind(&CefFileDialogCallbackImpl::CancelNow, callback_));
|
||||
CEF_POST_TASK(CEF_UIT, base::Bind(&CefFileDialogCallbackImpl::CancelNow,
|
||||
callback_));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -50,8 +49,8 @@ class CefFileDialogCallbackImpl : public CefFileDialogCallback {
|
||||
}
|
||||
} else {
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
base::Bind(&CefFileDialogCallbackImpl::Continue, this,
|
||||
selected_accept_filter, file_paths));
|
||||
base::Bind(&CefFileDialogCallbackImpl::Continue, this,
|
||||
selected_accept_filter, file_paths));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,17 +62,13 @@ class CefFileDialogCallbackImpl : public CefFileDialogCallback {
|
||||
}
|
||||
} else {
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
base::Bind(&CefFileDialogCallbackImpl::Cancel, this));
|
||||
base::Bind(&CefFileDialogCallbackImpl::Cancel, this));
|
||||
}
|
||||
}
|
||||
|
||||
bool IsConnected() {
|
||||
return !callback_.is_null();
|
||||
}
|
||||
bool IsConnected() { return !callback_.is_null(); }
|
||||
|
||||
void Disconnect() {
|
||||
callback_.Reset();
|
||||
}
|
||||
void Disconnect() { callback_.Reset(); }
|
||||
|
||||
private:
|
||||
static void CancelNow(
|
||||
@@ -88,10 +83,9 @@ class CefFileDialogCallbackImpl : public CefFileDialogCallback {
|
||||
IMPLEMENT_REFCOUNTING(CefFileDialogCallbackImpl);
|
||||
};
|
||||
|
||||
void RunFileDialogDismissed(
|
||||
CefRefPtr<CefRunFileDialogCallback> callback,
|
||||
int selected_accept_filter,
|
||||
const std::vector<base::FilePath>& file_paths) {
|
||||
void RunFileDialogDismissed(CefRefPtr<CefRunFileDialogCallback> callback,
|
||||
int selected_accept_filter,
|
||||
const std::vector<base::FilePath>& file_paths) {
|
||||
std::vector<CefString> paths;
|
||||
if (file_paths.size() > 0) {
|
||||
for (size_t i = 0; i < file_paths.size(); ++i)
|
||||
@@ -100,13 +94,12 @@ void RunFileDialogDismissed(
|
||||
callback->OnFileDialogDismissed(selected_accept_filter, paths);
|
||||
}
|
||||
|
||||
class UploadFolderHelper :
|
||||
public net::DirectoryLister::DirectoryListerDelegate {
|
||||
class UploadFolderHelper
|
||||
: public net::DirectoryLister::DirectoryListerDelegate {
|
||||
public:
|
||||
explicit UploadFolderHelper(
|
||||
const CefFileDialogRunner::RunFileChooserCallback& callback)
|
||||
: callback_(callback) {
|
||||
}
|
||||
: callback_(callback) {}
|
||||
|
||||
~UploadFolderHelper() override {
|
||||
if (!callback_.is_null()) {
|
||||
@@ -114,7 +107,7 @@ class UploadFolderHelper :
|
||||
CancelNow(callback_);
|
||||
} else {
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
base::Bind(&UploadFolderHelper::CancelNow, callback_));
|
||||
base::Bind(&UploadFolderHelper::CancelNow, callback_));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -162,8 +155,7 @@ CefFileDialogManager::CefFileDialogManager(
|
||||
DCHECK(web_contents());
|
||||
}
|
||||
|
||||
CefFileDialogManager::~CefFileDialogManager() {
|
||||
}
|
||||
CefFileDialogManager::~CefFileDialogManager() {}
|
||||
|
||||
void CefFileDialogManager::Destroy() {
|
||||
DCHECK(!file_chooser_pending_);
|
||||
@@ -171,12 +163,12 @@ void CefFileDialogManager::Destroy() {
|
||||
}
|
||||
|
||||
void CefFileDialogManager::RunFileDialog(
|
||||
cef_file_dialog_mode_t mode,
|
||||
const CefString& title,
|
||||
const CefString& default_file_path,
|
||||
const std::vector<CefString>& accept_filters,
|
||||
int selected_accept_filter,
|
||||
CefRefPtr<CefRunFileDialogCallback> callback) {
|
||||
cef_file_dialog_mode_t mode,
|
||||
const CefString& title,
|
||||
const CefString& default_file_path,
|
||||
const std::vector<CefString>& accept_filters,
|
||||
int selected_accept_filter,
|
||||
CefRefPtr<CefRunFileDialogCallback> callback) {
|
||||
DCHECK(callback.get());
|
||||
if (!callback.get())
|
||||
return;
|
||||
@@ -231,9 +223,9 @@ void CefFileDialogManager::RunFileChooser(
|
||||
&CefFileDialogManager::OnRunFileChooserUploadFolderDelegateCallback,
|
||||
weak_ptr_factory_.GetWeakPtr(), params.mode);
|
||||
} else {
|
||||
callback = base::Bind(
|
||||
&CefFileDialogManager::OnRunFileChooserDelegateCallback,
|
||||
weak_ptr_factory_.GetWeakPtr(), params.mode);
|
||||
callback =
|
||||
base::Bind(&CefFileDialogManager::OnRunFileChooserDelegateCallback,
|
||||
weak_ptr_factory_.GetWeakPtr(), params.mode);
|
||||
}
|
||||
|
||||
RunFileChooserInternal(render_frame_host, cef_params, callback);
|
||||
@@ -303,13 +295,9 @@ void CefFileDialogManager::RunFileChooserInternal(
|
||||
CefRefPtr<CefFileDialogCallbackImpl> callbackImpl(
|
||||
new CefFileDialogCallbackImpl(callback));
|
||||
handled = handler->OnFileDialog(
|
||||
browser_,
|
||||
static_cast<cef_file_dialog_mode_t>(mode),
|
||||
params.title,
|
||||
params.default_file_name.value(),
|
||||
accept_filters,
|
||||
params.selected_accept_filter,
|
||||
callbackImpl.get());
|
||||
browser_, static_cast<cef_file_dialog_mode_t>(mode), params.title,
|
||||
params.default_file_name.value(), accept_filters,
|
||||
params.selected_accept_filter, callbackImpl.get());
|
||||
if (!handled) {
|
||||
if (callbackImpl->IsConnected()) {
|
||||
callbackImpl->Disconnect();
|
||||
@@ -342,7 +330,7 @@ void CefFileDialogManager::OnRunFileChooserCallback(
|
||||
|
||||
// Execute the callback asynchronously.
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
base::Bind(callback, selected_accept_filter, file_paths));
|
||||
base::Bind(callback, selected_accept_filter, file_paths));
|
||||
}
|
||||
|
||||
void CefFileDialogManager::OnRunFileChooserUploadFolderDelegateCallback(
|
||||
@@ -357,8 +345,7 @@ void CefFileDialogManager::OnRunFileChooserUploadFolderDelegateCallback(
|
||||
OnRunFileChooserDelegateCallback(mode, selected_accept_filter, file_paths);
|
||||
} else {
|
||||
lister_.reset(new net::DirectoryLister(
|
||||
file_paths[0],
|
||||
net::DirectoryLister::NO_SORT_RECURSIVE,
|
||||
file_paths[0], net::DirectoryLister::NO_SORT_RECURSIVE,
|
||||
new UploadFolderHelper(
|
||||
base::Bind(&CefFileDialogManager::OnRunFileChooserDelegateCallback,
|
||||
weak_ptr_factory_.GetWeakPtr(), mode))));
|
||||
|
@@ -27,9 +27,8 @@ class CefBrowserHostImpl;
|
||||
class CefFileDialogManager : public content::WebContentsObserver {
|
||||
public:
|
||||
// |runner| may be NULL if the platform doesn't implement dialogs.
|
||||
CefFileDialogManager(
|
||||
CefBrowserHostImpl* browser,
|
||||
std::unique_ptr<CefFileDialogRunner> runner);
|
||||
CefFileDialogManager(CefBrowserHostImpl* browser,
|
||||
std::unique_ptr<CefFileDialogRunner> runner);
|
||||
~CefFileDialogManager() override;
|
||||
|
||||
// Delete the runner to free any platform constructs.
|
||||
@@ -37,19 +36,17 @@ class CefFileDialogManager : public content::WebContentsObserver {
|
||||
|
||||
// Called from CefBrowserHostImpl::RunFileChooser.
|
||||
// See CefBrowserHost::RunFileDialog documentation.
|
||||
void RunFileDialog(
|
||||
cef_file_dialog_mode_t mode,
|
||||
const CefString& title,
|
||||
const CefString& default_file_path,
|
||||
const std::vector<CefString>& accept_filters,
|
||||
int selected_accept_filter,
|
||||
CefRefPtr<CefRunFileDialogCallback> callback);
|
||||
void RunFileDialog(cef_file_dialog_mode_t mode,
|
||||
const CefString& title,
|
||||
const CefString& default_file_path,
|
||||
const std::vector<CefString>& accept_filters,
|
||||
int selected_accept_filter,
|
||||
CefRefPtr<CefRunFileDialogCallback> callback);
|
||||
|
||||
// Called from CefBrowserHostImpl::RunFileChooser.
|
||||
// See WebContentsDelegate::RunFileChooser documentation.
|
||||
void RunFileChooser(
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
const content::FileChooserParams& params);
|
||||
void RunFileChooser(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
|
||||
@@ -89,8 +86,7 @@ class CefFileDialogManager : public content::WebContentsObserver {
|
||||
void Cleanup();
|
||||
|
||||
// WebContentsObserver methods:
|
||||
void RenderFrameDeleted(
|
||||
content::RenderFrameHost* render_frame_host) override;
|
||||
void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override;
|
||||
|
||||
// CefBrowserHostImpl pointer is guaranteed to outlive this object.
|
||||
CefBrowserHostImpl* browser_;
|
||||
|
@@ -9,8 +9,8 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/callback.h"
|
||||
#include "base/files/file_path.h"
|
||||
#include "content/public/common/file_chooser_params.h"
|
||||
|
||||
class CefBrowserHostImpl;
|
||||
|
@@ -2,12 +2,12 @@
|
||||
// reserved. Use of this source code is governed by a BSD-style license that can
|
||||
// be found in the LICENSE file.
|
||||
|
||||
#include "libcef/browser/frame_host_impl.h"
|
||||
#include "include/cef_request.h"
|
||||
#include "include/cef_stream.h"
|
||||
#include "include/cef_v8.h"
|
||||
#include "libcef/common/cef_messages.h"
|
||||
#include "libcef/browser/browser_host_impl.h"
|
||||
#include "libcef/browser/frame_host_impl.h"
|
||||
#include "libcef/common/cef_messages.h"
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -15,11 +15,11 @@ namespace {
|
||||
class StringVisitHandler : public CefResponseManager::Handler {
|
||||
public:
|
||||
explicit StringVisitHandler(CefRefPtr<CefStringVisitor> visitor)
|
||||
: visitor_(visitor) {
|
||||
}
|
||||
: visitor_(visitor) {}
|
||||
void OnResponse(const Cef_Response_Params& params) override {
|
||||
visitor_->Visit(params.response);
|
||||
}
|
||||
|
||||
private:
|
||||
CefRefPtr<CefStringVisitor> visitor_;
|
||||
|
||||
@@ -29,16 +29,15 @@ class StringVisitHandler : public CefResponseManager::Handler {
|
||||
// Implementation of CommandResponseHandler for calling ViewText().
|
||||
class ViewTextHandler : public CefResponseManager::Handler {
|
||||
public:
|
||||
explicit ViewTextHandler(CefRefPtr<CefFrameHostImpl> frame)
|
||||
: frame_(frame) {
|
||||
}
|
||||
explicit ViewTextHandler(CefRefPtr<CefFrameHostImpl> frame) : frame_(frame) {}
|
||||
void OnResponse(const Cef_Response_Params& params) override {
|
||||
CefRefPtr<CefBrowser> browser = frame_->GetBrowser();
|
||||
if (browser.get()) {
|
||||
static_cast<CefBrowserHostImpl*>(browser.get())->ViewText(
|
||||
params.response);
|
||||
static_cast<CefBrowserHostImpl*>(browser.get())
|
||||
->ViewText(params.response);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
CefRefPtr<CefFrameHostImpl> frame_;
|
||||
|
||||
@@ -59,12 +58,11 @@ CefFrameHostImpl::CefFrameHostImpl(CefBrowserHostImpl* browser,
|
||||
is_focused_(is_main_frame_), // The main frame always starts focused.
|
||||
url_(url),
|
||||
name_(name),
|
||||
parent_frame_id_(parent_frame_id == kUnspecifiedFrameId ?
|
||||
kInvalidFrameId : parent_frame_id) {
|
||||
}
|
||||
parent_frame_id_(parent_frame_id == kUnspecifiedFrameId
|
||||
? kInvalidFrameId
|
||||
: parent_frame_id) {}
|
||||
|
||||
CefFrameHostImpl::~CefFrameHostImpl() {
|
||||
}
|
||||
CefFrameHostImpl::~CefFrameHostImpl() {}
|
||||
|
||||
bool CefFrameHostImpl::IsValid() {
|
||||
base::AutoLock lock_scope(state_lock_);
|
||||
@@ -234,10 +232,9 @@ void CefFrameHostImpl::VisitDOM(CefRefPtr<CefDOMVisitor> visitor) {
|
||||
NOTREACHED() << "VisitDOM cannot be called from the browser process";
|
||||
}
|
||||
|
||||
void CefFrameHostImpl::SendJavaScript(
|
||||
const std::string& jsCode,
|
||||
const std::string& scriptUrl,
|
||||
int startLine) {
|
||||
void CefFrameHostImpl::SendJavaScript(const std::string& jsCode,
|
||||
const std::string& scriptUrl,
|
||||
int startLine) {
|
||||
if (jsCode.empty())
|
||||
return;
|
||||
if (startLine <= 0) {
|
||||
|
@@ -7,8 +7,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "include/cef_frame.h"
|
||||
#include "libcef/common/response_manager.h"
|
||||
|
||||
#include "base/synchronization/lock.h"
|
||||
|
||||
class CefBrowserHostImpl;
|
||||
@@ -19,11 +21,11 @@ class CefBrowserHostImpl;
|
||||
class CefFrameHostImpl : public CefFrame {
|
||||
public:
|
||||
CefFrameHostImpl(CefBrowserHostImpl* browser,
|
||||
int64 frame_id,
|
||||
bool is_main_frame,
|
||||
const CefString& url,
|
||||
const CefString& name,
|
||||
int64 parent_frame_id);
|
||||
int64 frame_id,
|
||||
bool is_main_frame,
|
||||
const CefString& url,
|
||||
const CefString& name,
|
||||
int64 parent_frame_id);
|
||||
~CefFrameHostImpl() override;
|
||||
|
||||
// CefFrame methods
|
||||
@@ -40,8 +42,7 @@ class CefFrameHostImpl : public CefFrame {
|
||||
void GetText(CefRefPtr<CefStringVisitor> visitor) override;
|
||||
void LoadRequest(CefRefPtr<CefRequest> request) override;
|
||||
void LoadURL(const CefString& url) override;
|
||||
void LoadString(const CefString& string,
|
||||
const CefString& url) override;
|
||||
void LoadString(const CefString& string, const CefString& url) override;
|
||||
void ExecuteJavaScript(const CefString& jsCode,
|
||||
const CefString& scriptUrl,
|
||||
int startLine) override;
|
||||
|
@@ -6,14 +6,15 @@
|
||||
#include "libcef/browser/context.h"
|
||||
#include "libcef/browser/thread_util.h"
|
||||
#include "libcef/common/time_util.h"
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "device/geolocation/geolocation_provider.h"
|
||||
#include "device/geolocation/geoposition.h"
|
||||
|
||||
namespace {
|
||||
|
||||
class CefLocationRequest :
|
||||
public base::RefCountedThreadSafe<CefLocationRequest> {
|
||||
class CefLocationRequest
|
||||
: public base::RefCountedThreadSafe<CefLocationRequest> {
|
||||
public:
|
||||
explicit CefLocationRequest(CefRefPtr<CefGetGeolocationCallback> callback)
|
||||
: callback_(callback) {
|
||||
@@ -99,7 +100,7 @@ bool CefGetGeolocation(CefRefPtr<CefGetGeolocationCallback> callback) {
|
||||
return false;
|
||||
} else {
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
base::Bind(base::IgnoreResult(CefGetGeolocation), callback));
|
||||
base::Bind(base::IgnoreResult(CefGetGeolocation), callback));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -49,13 +49,12 @@ bool PNGMethod(bool with_transparency,
|
||||
std::vector<unsigned char>* compressed) {
|
||||
return gfx::PNGCodec::Encode(
|
||||
reinterpret_cast<unsigned char*>(bitmap.getPixels()),
|
||||
bitmap.colorType() == kBGRA_8888_SkColorType ?
|
||||
gfx::PNGCodec::FORMAT_BGRA : gfx::PNGCodec::FORMAT_RGBA,
|
||||
bitmap.colorType() == kBGRA_8888_SkColorType ? gfx::PNGCodec::FORMAT_BGRA
|
||||
: gfx::PNGCodec::FORMAT_RGBA,
|
||||
gfx::Size(bitmap.width(), bitmap.height()),
|
||||
static_cast<int>(bitmap.rowBytes()),
|
||||
bitmap.alphaType() == kOpaque_SkAlphaType || !with_transparency,
|
||||
std::vector<gfx::PNGCodec::Comment>(),
|
||||
compressed);
|
||||
std::vector<gfx::PNGCodec::Comment>(), compressed);
|
||||
}
|
||||
|
||||
// Compress as JPEG. This internally uses JCS_EXT_RGBX or JCS_EXT_BGRX which
|
||||
@@ -65,13 +64,11 @@ bool JPEGMethod(int quality,
|
||||
std::vector<unsigned char>* compressed) {
|
||||
return gfx::JPEGCodec::Encode(
|
||||
reinterpret_cast<unsigned char*>(bitmap.getPixels()),
|
||||
bitmap.colorType() == kBGRA_8888_SkColorType ?
|
||||
gfx::JPEGCodec::FORMAT_BGRA : gfx::JPEGCodec::FORMAT_RGBA,
|
||||
bitmap.width(),
|
||||
bitmap.height(),
|
||||
static_cast<int>(bitmap.rowBytes()),
|
||||
quality,
|
||||
compressed);
|
||||
bitmap.colorType() == kBGRA_8888_SkColorType
|
||||
? gfx::JPEGCodec::FORMAT_BGRA
|
||||
: gfx::JPEGCodec::FORMAT_RGBA,
|
||||
bitmap.width(), bitmap.height(), static_cast<int>(bitmap.rowBytes()),
|
||||
quality, compressed);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -124,7 +121,7 @@ bool CefImageImpl::AddBitmap(float scale_factor,
|
||||
CEF_REQUIRE_UIT_RETURN(false);
|
||||
const SkColorType ct = GetSkColorType(color_type);
|
||||
const SkAlphaType at = GetSkAlphaType(alpha_type);
|
||||
|
||||
|
||||
// Make sure the client passed in the expected values.
|
||||
if (ct != kBGRA_8888_SkColorType && ct != kRGBA_8888_SkColorType)
|
||||
return false;
|
||||
@@ -166,9 +163,8 @@ bool CefImageImpl::AddJPEG(float scale_factor,
|
||||
size_t jpeg_data_size) {
|
||||
CEF_REQUIRE_UIT_RETURN(false);
|
||||
|
||||
std::unique_ptr<SkBitmap> bitmap(
|
||||
gfx::JPEGCodec::Decode(static_cast<const unsigned char*>(jpeg_data),
|
||||
jpeg_data_size));
|
||||
std::unique_ptr<SkBitmap> bitmap(gfx::JPEGCodec::Decode(
|
||||
static_cast<const unsigned char*>(jpeg_data), jpeg_data_size));
|
||||
if (!bitmap.get())
|
||||
return false;
|
||||
|
||||
@@ -219,12 +215,11 @@ bool CefImageImpl::GetRepresentationInfo(float scale_factor,
|
||||
return true;
|
||||
}
|
||||
|
||||
CefRefPtr<CefBinaryValue> CefImageImpl::GetAsBitmap(
|
||||
float scale_factor,
|
||||
cef_color_type_t color_type,
|
||||
cef_alpha_type_t alpha_type,
|
||||
int& pixel_width,
|
||||
int& pixel_height) {
|
||||
CefRefPtr<CefBinaryValue> CefImageImpl::GetAsBitmap(float scale_factor,
|
||||
cef_color_type_t color_type,
|
||||
cef_alpha_type_t alpha_type,
|
||||
int& pixel_width,
|
||||
int& pixel_height) {
|
||||
CEF_REQUIRE_UIT_RETURN(nullptr);
|
||||
|
||||
const SkColorType desired_ct = GetSkColorType(color_type);
|
||||
@@ -307,8 +302,8 @@ void CefImageImpl::AddBitmaps(int32_t scale_1x_size,
|
||||
|
||||
for (const SkBitmap& bitmap : bitmaps) {
|
||||
const int32_t size = std::max(bitmap.width(), bitmap.height());
|
||||
const float scale_factor = static_cast<float>(size) /
|
||||
static_cast<float>(scale_1x_size);
|
||||
const float scale_factor =
|
||||
static_cast<float>(size) / static_cast<float>(scale_1x_size);
|
||||
AddBitmap(scale_factor, bitmap);
|
||||
}
|
||||
}
|
||||
@@ -327,8 +322,7 @@ gfx::ImageSkia CefImageImpl::GetForced1xScaleRepresentation(
|
||||
return image_skia;
|
||||
}
|
||||
|
||||
bool CefImageImpl::AddBitmap(float scale_factor,
|
||||
const SkBitmap& bitmap) {
|
||||
bool CefImageImpl::AddBitmap(float scale_factor, const SkBitmap& bitmap) {
|
||||
#if DCHECK_IS_ON()
|
||||
{
|
||||
SkAutoLockPixels bitmap_lock(bitmap);
|
||||
@@ -370,9 +364,8 @@ bool CefImageImpl::ConvertBitmap(const SkBitmap& src_bitmap,
|
||||
src_bitmap.alphaType() != target_at);
|
||||
DCHECK(target_bitmap);
|
||||
|
||||
SkImageInfo target_info =
|
||||
SkImageInfo::Make(src_bitmap.width(), src_bitmap.height(), target_ct,
|
||||
target_at);
|
||||
SkImageInfo target_info = SkImageInfo::Make(
|
||||
src_bitmap.width(), src_bitmap.height(), target_ct, target_at);
|
||||
if (!target_bitmap->tryAllocPixels(target_info))
|
||||
return false;
|
||||
|
||||
|
@@ -67,8 +67,7 @@ class CefImageImpl : public CefImage {
|
||||
// |scale_1x_size| is the size in pixels of the 1x factor image. If
|
||||
// |scale_1x_size| is 0 the smallest image size in pixels will be used as the
|
||||
// 1x factor size.
|
||||
void AddBitmaps(int32_t scale_1x_size,
|
||||
const std::vector<SkBitmap>& bitmaps);
|
||||
void AddBitmaps(int32_t scale_1x_size, const std::vector<SkBitmap>& bitmaps);
|
||||
|
||||
// Return a representation of this Image that contains only the bitmap nearest
|
||||
// |scale_factor| as the 1x scale representation. Conceptually this is an
|
||||
@@ -81,8 +80,7 @@ class CefImageImpl : public CefImage {
|
||||
|
||||
private:
|
||||
// Add a bitmap.
|
||||
bool AddBitmap(float scale_factor,
|
||||
const SkBitmap& bitmap);
|
||||
bool AddBitmap(float scale_factor, const SkBitmap& bitmap);
|
||||
|
||||
// Returns the bitmap that most closely matches |scale_factor| or nullptr if
|
||||
// one doesn't exist.
|
||||
|
@@ -21,37 +21,32 @@ class CefJSDialogCallbackImpl : public CefJSDialogCallback {
|
||||
public:
|
||||
CefJSDialogCallbackImpl(
|
||||
const content::JavaScriptDialogManager::DialogClosedCallback& callback)
|
||||
: callback_(callback) {
|
||||
}
|
||||
: callback_(callback) {}
|
||||
~CefJSDialogCallbackImpl() override {
|
||||
if (!callback_.is_null()) {
|
||||
// The callback is still pending. Cancel it now.
|
||||
if (CEF_CURRENTLY_ON_UIT()) {
|
||||
CancelNow(callback_);
|
||||
} else {
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
base::Bind(&CefJSDialogCallbackImpl::CancelNow, callback_));
|
||||
CEF_POST_TASK(CEF_UIT, base::Bind(&CefJSDialogCallbackImpl::CancelNow,
|
||||
callback_));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Continue(bool success,
|
||||
const CefString& user_input) override {
|
||||
void Continue(bool success, const CefString& user_input) override {
|
||||
if (CEF_CURRENTLY_ON_UIT()) {
|
||||
if (!callback_.is_null()) {
|
||||
callback_.Run(success, user_input);
|
||||
callback_.Reset();
|
||||
}
|
||||
} else {
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
base::Bind(&CefJSDialogCallbackImpl::Continue, this, success,
|
||||
user_input));
|
||||
CEF_POST_TASK(CEF_UIT, base::Bind(&CefJSDialogCallbackImpl::Continue,
|
||||
this, success, user_input));
|
||||
}
|
||||
}
|
||||
|
||||
void Disconnect() {
|
||||
callback_.Reset();
|
||||
}
|
||||
void Disconnect() { callback_.Reset(); }
|
||||
|
||||
private:
|
||||
static void CancelNow(
|
||||
@@ -67,18 +62,15 @@ class CefJSDialogCallbackImpl : public CefJSDialogCallback {
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
CefJavaScriptDialogManager::CefJavaScriptDialogManager(
|
||||
CefBrowserHostImpl* browser,
|
||||
std::unique_ptr<CefJavaScriptDialogRunner> runner)
|
||||
: browser_(browser),
|
||||
runner_(std::move(runner)),
|
||||
dialog_running_(false),
|
||||
weak_ptr_factory_(this) {
|
||||
}
|
||||
weak_ptr_factory_(this) {}
|
||||
|
||||
CefJavaScriptDialogManager::~CefJavaScriptDialogManager() {
|
||||
}
|
||||
CefJavaScriptDialogManager::~CefJavaScriptDialogManager() {}
|
||||
|
||||
void CefJavaScriptDialogManager::Destroy() {
|
||||
if (runner_.get()) {
|
||||
@@ -105,10 +97,10 @@ void CefJavaScriptDialogManager::RunJavaScriptDialog(
|
||||
new CefJSDialogCallbackImpl(callback));
|
||||
|
||||
// Execute the user callback.
|
||||
bool handled = handler->OnJSDialog(browser_, origin_url.spec(),
|
||||
static_cast<cef_jsdialog_type_t>(message_type),
|
||||
message_text, default_prompt_text, callbackPtr.get(),
|
||||
*did_suppress_message);
|
||||
bool handled = handler->OnJSDialog(
|
||||
browser_, origin_url.spec(),
|
||||
static_cast<cef_jsdialog_type_t>(message_type), message_text,
|
||||
default_prompt_text, callbackPtr.get(), *did_suppress_message);
|
||||
if (handled) {
|
||||
// Invalid combination of values. Crash sooner rather than later.
|
||||
CHECK(!*did_suppress_message);
|
||||
@@ -166,8 +158,8 @@ void CefJavaScriptDialogManager::RunBeforeUnloadDialog(
|
||||
new CefJSDialogCallbackImpl(callback));
|
||||
|
||||
// Execute the user callback.
|
||||
bool handled = handler->OnBeforeUnloadDialog(browser_, message_text,
|
||||
is_reload, callbackPtr.get());
|
||||
bool handled = handler->OnBeforeUnloadDialog(
|
||||
browser_, message_text, is_reload, callbackPtr.get());
|
||||
if (handled)
|
||||
return;
|
||||
|
||||
@@ -186,8 +178,7 @@ void CefJavaScriptDialogManager::RunBeforeUnloadDialog(
|
||||
|
||||
dialog_running_ = true;
|
||||
|
||||
runner_->Run(browser_,
|
||||
content::JAVASCRIPT_DIALOG_TYPE_CONFIRM,
|
||||
runner_->Run(browser_, content::JAVASCRIPT_DIALOG_TYPE_CONFIRM,
|
||||
base::string16(), // display_url
|
||||
message_text,
|
||||
base::string16(), // default_prompt_text
|
||||
|
@@ -20,27 +20,24 @@ class CefBrowserHostImpl;
|
||||
class CefJavaScriptDialogManager : public content::JavaScriptDialogManager {
|
||||
public:
|
||||
// |runner| may be NULL if the platform doesn't implement dialogs.
|
||||
CefJavaScriptDialogManager(
|
||||
CefBrowserHostImpl* browser,
|
||||
std::unique_ptr<CefJavaScriptDialogRunner> runner);
|
||||
CefJavaScriptDialogManager(CefBrowserHostImpl* browser,
|
||||
std::unique_ptr<CefJavaScriptDialogRunner> runner);
|
||||
~CefJavaScriptDialogManager() override;
|
||||
|
||||
// Delete the runner to free any platform constructs.
|
||||
void Destroy();
|
||||
|
||||
// JavaScriptDialogManager methods.
|
||||
void RunJavaScriptDialog(
|
||||
content::WebContents* web_contents,
|
||||
const GURL& origin_url,
|
||||
content::JavaScriptDialogType message_type,
|
||||
const base::string16& message_text,
|
||||
const base::string16& default_prompt_text,
|
||||
const DialogClosedCallback& callback,
|
||||
bool* did_suppress_message) override;
|
||||
void RunBeforeUnloadDialog(
|
||||
content::WebContents* web_contents,
|
||||
bool is_reload,
|
||||
const DialogClosedCallback& callback) override;
|
||||
void RunJavaScriptDialog(content::WebContents* web_contents,
|
||||
const GURL& origin_url,
|
||||
content::JavaScriptDialogType message_type,
|
||||
const base::string16& message_text,
|
||||
const base::string16& default_prompt_text,
|
||||
const DialogClosedCallback& callback,
|
||||
bool* did_suppress_message) override;
|
||||
void RunBeforeUnloadDialog(content::WebContents* web_contents,
|
||||
bool is_reload,
|
||||
const DialogClosedCallback& callback) override;
|
||||
void CancelDialogs(content::WebContents* web_contents,
|
||||
bool reset_state) override;
|
||||
|
||||
|
@@ -17,16 +17,15 @@ class CefJavaScriptDialogRunner {
|
||||
public:
|
||||
typedef base::Callback<void(bool /* success */,
|
||||
const base::string16& /* user_input */)>
|
||||
DialogClosedCallback;
|
||||
DialogClosedCallback;
|
||||
|
||||
// Run the dialog. Execute |callback| on completion.
|
||||
virtual void Run(
|
||||
CefBrowserHostImpl* browser,
|
||||
content::JavaScriptDialogType message_type,
|
||||
const base::string16& display_url,
|
||||
const base::string16& message_text,
|
||||
const base::string16& default_prompt_text,
|
||||
const DialogClosedCallback& callback) = 0;
|
||||
virtual void Run(CefBrowserHostImpl* browser,
|
||||
content::JavaScriptDialogType message_type,
|
||||
const base::string16& display_url,
|
||||
const base::string16& message_text,
|
||||
const base::string16& default_prompt_text,
|
||||
const DialogClosedCallback& callback) = 0;
|
||||
|
||||
// Cancel a dialog mid-flight.
|
||||
virtual void Cancel() = 0;
|
||||
|
@@ -33,9 +33,8 @@ const content::MediaStreamDevice* FindDefaultDeviceWithId(
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
CefMediaCaptureDevicesDispatcher*
|
||||
CefMediaCaptureDevicesDispatcher::GetInstance() {
|
||||
CefMediaCaptureDevicesDispatcher::GetInstance() {
|
||||
return base::Singleton<CefMediaCaptureDevicesDispatcher>::get();
|
||||
}
|
||||
|
||||
@@ -95,11 +94,9 @@ void CefMediaCaptureDevicesDispatcher::GetRequestedDevice(
|
||||
}
|
||||
}
|
||||
|
||||
void CefMediaCaptureDevicesDispatcher::OnAudioCaptureDevicesChanged() {
|
||||
}
|
||||
void CefMediaCaptureDevicesDispatcher::OnAudioCaptureDevicesChanged() {}
|
||||
|
||||
void CefMediaCaptureDevicesDispatcher::OnVideoCaptureDevicesChanged() {
|
||||
}
|
||||
void CefMediaCaptureDevicesDispatcher::OnVideoCaptureDevicesChanged() {}
|
||||
|
||||
void CefMediaCaptureDevicesDispatcher::OnMediaRequestStateChanged(
|
||||
int render_process_id,
|
||||
@@ -107,21 +104,18 @@ void CefMediaCaptureDevicesDispatcher::OnMediaRequestStateChanged(
|
||||
int page_request_id,
|
||||
const GURL& security_origin,
|
||||
content::MediaStreamType stream_type,
|
||||
content::MediaRequestState state) {
|
||||
}
|
||||
content::MediaRequestState state) {}
|
||||
|
||||
void CefMediaCaptureDevicesDispatcher::OnCreatingAudioStream(
|
||||
int render_process_id,
|
||||
int render_view_id) {
|
||||
}
|
||||
int render_view_id) {}
|
||||
|
||||
void CefMediaCaptureDevicesDispatcher::OnSetCapturingLinkSecured(
|
||||
int render_process_id,
|
||||
int render_frame_id,
|
||||
int page_request_id,
|
||||
content::MediaStreamType stream_type,
|
||||
bool is_secure) {
|
||||
}
|
||||
bool is_secure) {}
|
||||
|
||||
const MediaStreamDevices&
|
||||
CefMediaCaptureDevicesDispatcher::GetAudioCaptureDevices() {
|
||||
|
@@ -43,20 +43,19 @@ class CefMediaCaptureDevicesDispatcher : public content::MediaObserver {
|
||||
// Overridden from content::MediaObserver:
|
||||
void OnAudioCaptureDevicesChanged() override;
|
||||
void OnVideoCaptureDevicesChanged() override;
|
||||
void OnMediaRequestStateChanged(
|
||||
int render_process_id,
|
||||
int render_frame_id,
|
||||
int page_request_id,
|
||||
const GURL& security_origin,
|
||||
content::MediaStreamType stream_type,
|
||||
content::MediaRequestState state) override;
|
||||
void OnCreatingAudioStream(int render_process_id,
|
||||
int render_view_id) override;
|
||||
void OnSetCapturingLinkSecured(int render_process_id,
|
||||
void OnMediaRequestStateChanged(int render_process_id,
|
||||
int render_frame_id,
|
||||
int page_request_id,
|
||||
const GURL& security_origin,
|
||||
content::MediaStreamType stream_type,
|
||||
bool is_secure) override;
|
||||
content::MediaRequestState state) override;
|
||||
void OnCreatingAudioStream(int render_process_id,
|
||||
int render_view_id) override;
|
||||
void OnSetCapturingLinkSecured(int render_process_id,
|
||||
int render_frame_id,
|
||||
int page_request_id,
|
||||
content::MediaStreamType stream_type,
|
||||
bool is_secure) override;
|
||||
|
||||
private:
|
||||
friend struct base::DefaultSingletonTraits<CefMediaCaptureDevicesDispatcher>;
|
||||
|
@@ -34,11 +34,10 @@ const cef_event_flags_t kEmptyEventFlags = static_cast<cef_event_flags_t>(0);
|
||||
|
||||
class CefRunContextMenuCallbackImpl : public CefRunContextMenuCallback {
|
||||
public:
|
||||
typedef base::Callback<void(int,cef_event_flags_t)> Callback;
|
||||
typedef base::Callback<void(int, cef_event_flags_t)> Callback;
|
||||
|
||||
explicit CefRunContextMenuCallbackImpl(const Callback& callback)
|
||||
: callback_(callback) {
|
||||
}
|
||||
: callback_(callback) {}
|
||||
|
||||
~CefRunContextMenuCallbackImpl() {
|
||||
if (!callback_.is_null()) {
|
||||
@@ -46,7 +45,8 @@ class CefRunContextMenuCallbackImpl : public CefRunContextMenuCallback {
|
||||
if (CEF_CURRENTLY_ON_UIT()) {
|
||||
RunNow(callback_, kInvalidCommandId, kEmptyEventFlags);
|
||||
} else {
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
CEF_POST_TASK(
|
||||
CEF_UIT,
|
||||
base::Bind(&CefRunContextMenuCallbackImpl::RunNow, callback_,
|
||||
kInvalidCommandId, kEmptyEventFlags));
|
||||
}
|
||||
@@ -61,18 +61,14 @@ class CefRunContextMenuCallbackImpl : public CefRunContextMenuCallback {
|
||||
}
|
||||
} else {
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
base::Bind(&CefRunContextMenuCallbackImpl::Continue, this,
|
||||
command_id, event_flags));
|
||||
base::Bind(&CefRunContextMenuCallbackImpl::Continue, this,
|
||||
command_id, event_flags));
|
||||
}
|
||||
}
|
||||
|
||||
void Cancel() override {
|
||||
Continue(kInvalidCommandId, kEmptyEventFlags);
|
||||
}
|
||||
void Cancel() override { Continue(kInvalidCommandId, kEmptyEventFlags); }
|
||||
|
||||
void Disconnect() {
|
||||
callback_.Reset();
|
||||
}
|
||||
void Disconnect() { callback_.Reset(); }
|
||||
|
||||
private:
|
||||
static void RunNow(const Callback& callback,
|
||||
@@ -92,11 +88,11 @@ class CefRunContextMenuCallbackImpl : public CefRunContextMenuCallback {
|
||||
|
||||
CefMenuManager::CefMenuManager(CefBrowserHostImpl* browser,
|
||||
std::unique_ptr<CefMenuRunner> runner)
|
||||
: content::WebContentsObserver(browser->web_contents()),
|
||||
browser_(browser),
|
||||
runner_(std::move(runner)),
|
||||
custom_menu_callback_(NULL),
|
||||
weak_ptr_factory_(this) {
|
||||
: content::WebContentsObserver(browser->web_contents()),
|
||||
browser_(browser),
|
||||
runner_(std::move(runner)),
|
||||
custom_menu_callback_(NULL),
|
||||
weak_ptr_factory_(this) {
|
||||
DCHECK(web_contents());
|
||||
DCHECK(runner_.get());
|
||||
model_ = new CefMenuModelImpl(this, nullptr, false);
|
||||
@@ -145,17 +141,14 @@ bool CefMenuManager::CreateContextMenu(
|
||||
// Give the client a chance to modify the model.
|
||||
CefRefPtr<CefClient> client = browser_->GetClient();
|
||||
if (client.get()) {
|
||||
CefRefPtr<CefContextMenuHandler> handler =
|
||||
client->GetContextMenuHandler();
|
||||
CefRefPtr<CefContextMenuHandler> handler = client->GetContextMenuHandler();
|
||||
if (handler.get()) {
|
||||
CefRefPtr<CefContextMenuParamsImpl> paramsPtr(
|
||||
new CefContextMenuParamsImpl(¶ms_));
|
||||
CefRefPtr<CefFrame> frame = browser_->GetFocusedFrame();
|
||||
|
||||
handler->OnBeforeContextMenu(browser_,
|
||||
frame,
|
||||
paramsPtr.get(),
|
||||
model_.get());
|
||||
handler->OnBeforeContextMenu(browser_, frame, paramsPtr.get(),
|
||||
model_.get());
|
||||
|
||||
MenuWillShow(model_);
|
||||
|
||||
@@ -163,17 +156,14 @@ bool CefMenuManager::CreateContextMenu(
|
||||
CefRefPtr<CefRunContextMenuCallbackImpl> callbackImpl(
|
||||
new CefRunContextMenuCallbackImpl(
|
||||
base::Bind(&CefMenuManager::ExecuteCommandCallback,
|
||||
weak_ptr_factory_.GetWeakPtr())));
|
||||
weak_ptr_factory_.GetWeakPtr())));
|
||||
|
||||
// This reference will be cleared when the callback is executed or
|
||||
// the callback object is deleted.
|
||||
custom_menu_callback_ = callbackImpl.get();
|
||||
|
||||
if (handler->RunContextMenu(browser_,
|
||||
frame,
|
||||
paramsPtr.get(),
|
||||
model_.get(),
|
||||
callbackImpl.get())) {
|
||||
if (handler->RunContextMenu(browser_, frame, paramsPtr.get(),
|
||||
model_.get(), callbackImpl.get())) {
|
||||
custom_menu = true;
|
||||
} else {
|
||||
// Callback should not be executed if the handler returns false.
|
||||
@@ -216,17 +206,13 @@ void CefMenuManager::ExecuteCommand(CefRefPtr<CefMenuModelImpl> source,
|
||||
// Give the client a chance to handle the command.
|
||||
CefRefPtr<CefClient> client = browser_->GetClient();
|
||||
if (client.get()) {
|
||||
CefRefPtr<CefContextMenuHandler> handler =
|
||||
client->GetContextMenuHandler();
|
||||
CefRefPtr<CefContextMenuHandler> handler = client->GetContextMenuHandler();
|
||||
if (handler.get()) {
|
||||
CefRefPtr<CefContextMenuParamsImpl> paramsPtr(
|
||||
new CefContextMenuParamsImpl(¶ms_));
|
||||
|
||||
bool handled = handler->OnContextMenuCommand(
|
||||
browser_,
|
||||
browser_->GetFocusedFrame(),
|
||||
paramsPtr.get(),
|
||||
command_id,
|
||||
browser_, browser_->GetFocusedFrame(), paramsPtr.get(), command_id,
|
||||
event_flags);
|
||||
|
||||
// Do not keep references to the parameters in the callback.
|
||||
@@ -274,8 +260,7 @@ void CefMenuManager::MenuClosed(CefRefPtr<CefMenuModelImpl> source) {
|
||||
// Notify the client.
|
||||
CefRefPtr<CefClient> client = browser_->GetClient();
|
||||
if (client.get()) {
|
||||
CefRefPtr<CefContextMenuHandler> handler =
|
||||
client->GetContextMenuHandler();
|
||||
CefRefPtr<CefContextMenuHandler> handler = client->GetContextMenuHandler();
|
||||
if (handler.get()) {
|
||||
handler->OnContextMenuDismissed(browser_, browser_->GetFocusedFrame());
|
||||
}
|
||||
@@ -347,34 +332,31 @@ void CefMenuManager::CreateDefaultModel() {
|
||||
if (!(params_.edit_flags & CM_EDITFLAG_CAN_SELECT_ALL))
|
||||
model_->SetEnabled(MENU_ID_SELECT_ALL, false);
|
||||
|
||||
if(!params_.misspelled_word.empty()) {
|
||||
if (!params_.misspelled_word.empty()) {
|
||||
// Always add a separator before the list of dictionary suggestions or
|
||||
// "No spelling suggestions".
|
||||
model_->AddSeparator();
|
||||
|
||||
if (!params_.dictionary_suggestions.empty()) {
|
||||
for (size_t i = 0;
|
||||
i < params_.dictionary_suggestions.size() &&
|
||||
MENU_ID_SPELLCHECK_SUGGESTION_0 + i <=
|
||||
MENU_ID_SPELLCHECK_SUGGESTION_LAST;
|
||||
for (size_t i = 0; i < params_.dictionary_suggestions.size() &&
|
||||
MENU_ID_SPELLCHECK_SUGGESTION_0 + i <=
|
||||
MENU_ID_SPELLCHECK_SUGGESTION_LAST;
|
||||
++i) {
|
||||
model_->AddItem(MENU_ID_SPELLCHECK_SUGGESTION_0 + static_cast<int>(i),
|
||||
params_.dictionary_suggestions[i].c_str());
|
||||
params_.dictionary_suggestions[i].c_str());
|
||||
}
|
||||
|
||||
// When there are dictionary suggestions add a separator before "Add to
|
||||
// dictionary".
|
||||
model_->AddSeparator();
|
||||
} else {
|
||||
model_->AddItem(
|
||||
MENU_ID_NO_SPELLING_SUGGESTIONS,
|
||||
GetLabel(IDS_CONTENT_CONTEXT_NO_SPELLING_SUGGESTIONS));
|
||||
model_->AddItem(MENU_ID_NO_SPELLING_SUGGESTIONS,
|
||||
GetLabel(IDS_CONTENT_CONTEXT_NO_SPELLING_SUGGESTIONS));
|
||||
model_->SetEnabled(MENU_ID_NO_SPELLING_SUGGESTIONS, false);
|
||||
}
|
||||
|
||||
model_->AddItem(
|
||||
MENU_ID_ADD_TO_DICTIONARY,
|
||||
GetLabel(IDS_CONTENT_CONTEXT_ADD_TO_DICTIONARY));
|
||||
model_->AddItem(MENU_ID_ADD_TO_DICTIONARY,
|
||||
GetLabel(IDS_CONTENT_CONTEXT_ADD_TO_DICTIONARY));
|
||||
}
|
||||
} else if (!params_.selection_text.empty()) {
|
||||
// Something is selected.
|
||||
@@ -418,65 +400,65 @@ void CefMenuManager::ExecuteDefaultCommand(int command_id) {
|
||||
}
|
||||
|
||||
switch (command_id) {
|
||||
// Navigation.
|
||||
case MENU_ID_BACK:
|
||||
browser_->GoBack();
|
||||
break;
|
||||
case MENU_ID_FORWARD:
|
||||
browser_->GoForward();
|
||||
break;
|
||||
case MENU_ID_RELOAD:
|
||||
browser_->Reload();
|
||||
break;
|
||||
case MENU_ID_RELOAD_NOCACHE:
|
||||
browser_->ReloadIgnoreCache();
|
||||
break;
|
||||
case MENU_ID_STOPLOAD:
|
||||
browser_->StopLoad();
|
||||
break;
|
||||
// Navigation.
|
||||
case MENU_ID_BACK:
|
||||
browser_->GoBack();
|
||||
break;
|
||||
case MENU_ID_FORWARD:
|
||||
browser_->GoForward();
|
||||
break;
|
||||
case MENU_ID_RELOAD:
|
||||
browser_->Reload();
|
||||
break;
|
||||
case MENU_ID_RELOAD_NOCACHE:
|
||||
browser_->ReloadIgnoreCache();
|
||||
break;
|
||||
case MENU_ID_STOPLOAD:
|
||||
browser_->StopLoad();
|
||||
break;
|
||||
|
||||
// Editing.
|
||||
case MENU_ID_UNDO:
|
||||
browser_->GetFocusedFrame()->Undo();
|
||||
break;
|
||||
case MENU_ID_REDO:
|
||||
browser_->GetFocusedFrame()->Redo();
|
||||
break;
|
||||
case MENU_ID_CUT:
|
||||
browser_->GetFocusedFrame()->Cut();
|
||||
break;
|
||||
case MENU_ID_COPY:
|
||||
browser_->GetFocusedFrame()->Copy();
|
||||
break;
|
||||
case MENU_ID_PASTE:
|
||||
browser_->GetFocusedFrame()->Paste();
|
||||
break;
|
||||
case MENU_ID_DELETE:
|
||||
browser_->GetFocusedFrame()->Delete();
|
||||
break;
|
||||
case MENU_ID_SELECT_ALL:
|
||||
browser_->GetFocusedFrame()->SelectAll();
|
||||
break;
|
||||
// Editing.
|
||||
case MENU_ID_UNDO:
|
||||
browser_->GetFocusedFrame()->Undo();
|
||||
break;
|
||||
case MENU_ID_REDO:
|
||||
browser_->GetFocusedFrame()->Redo();
|
||||
break;
|
||||
case MENU_ID_CUT:
|
||||
browser_->GetFocusedFrame()->Cut();
|
||||
break;
|
||||
case MENU_ID_COPY:
|
||||
browser_->GetFocusedFrame()->Copy();
|
||||
break;
|
||||
case MENU_ID_PASTE:
|
||||
browser_->GetFocusedFrame()->Paste();
|
||||
break;
|
||||
case MENU_ID_DELETE:
|
||||
browser_->GetFocusedFrame()->Delete();
|
||||
break;
|
||||
case MENU_ID_SELECT_ALL:
|
||||
browser_->GetFocusedFrame()->SelectAll();
|
||||
break;
|
||||
|
||||
// Miscellaneous.
|
||||
case MENU_ID_FIND:
|
||||
// TODO(cef): Implement.
|
||||
NOTIMPLEMENTED();
|
||||
break;
|
||||
case MENU_ID_PRINT:
|
||||
browser_->Print();
|
||||
break;
|
||||
case MENU_ID_VIEW_SOURCE:
|
||||
browser_->GetFocusedFrame()->ViewSource();
|
||||
break;
|
||||
// Miscellaneous.
|
||||
case MENU_ID_FIND:
|
||||
// TODO(cef): Implement.
|
||||
NOTIMPLEMENTED();
|
||||
break;
|
||||
case MENU_ID_PRINT:
|
||||
browser_->Print();
|
||||
break;
|
||||
case MENU_ID_VIEW_SOURCE:
|
||||
browser_->GetFocusedFrame()->ViewSource();
|
||||
break;
|
||||
|
||||
// Spell checking.
|
||||
case MENU_ID_ADD_TO_DICTIONARY:
|
||||
browser_->GetHost()->AddWordToDictionary(params_.misspelled_word);
|
||||
break;
|
||||
// Spell checking.
|
||||
case MENU_ID_ADD_TO_DICTIONARY:
|
||||
browser_->GetHost()->AddWordToDictionary(params_.misspelled_word);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -49,8 +49,7 @@ class CefMenuManager : public CefMenuModelImpl::Delegate,
|
||||
bool FormatLabel(CefRefPtr<CefMenuModelImpl> source,
|
||||
base::string16& label) override;
|
||||
|
||||
void ExecuteCommandCallback(int command_id,
|
||||
cef_event_flags_t event_flags);
|
||||
void ExecuteCommandCallback(int command_id, cef_event_flags_t event_flags);
|
||||
|
||||
// Create the default menu model.
|
||||
void CreateDefaultModel();
|
||||
|
@@ -30,34 +30,28 @@ class CefSimpleMenuModel : public ui::MenuModel {
|
||||
// The Delegate can be NULL, though if it is items can't be checked or
|
||||
// disabled.
|
||||
explicit CefSimpleMenuModel(CefMenuModelImpl* impl)
|
||||
: impl_(impl),
|
||||
menu_model_delegate_(NULL) {
|
||||
}
|
||||
: impl_(impl), menu_model_delegate_(NULL) {}
|
||||
|
||||
// MenuModel methods.
|
||||
bool HasIcons() const override {
|
||||
return false;
|
||||
}
|
||||
bool HasIcons() const override { return false; }
|
||||
|
||||
int GetItemCount() const override {
|
||||
return impl_->GetCount();
|
||||
}
|
||||
int GetItemCount() const override { return impl_->GetCount(); }
|
||||
|
||||
ItemType GetTypeAt(int index) const override {
|
||||
switch (impl_->GetTypeAt(index)) {
|
||||
case MENUITEMTYPE_COMMAND:
|
||||
return TYPE_COMMAND;
|
||||
case MENUITEMTYPE_CHECK:
|
||||
return TYPE_CHECK;
|
||||
case MENUITEMTYPE_RADIO:
|
||||
return TYPE_RADIO;
|
||||
case MENUITEMTYPE_SEPARATOR:
|
||||
return TYPE_SEPARATOR;
|
||||
case MENUITEMTYPE_SUBMENU:
|
||||
return TYPE_SUBMENU;
|
||||
default:
|
||||
NOTREACHED();
|
||||
return TYPE_COMMAND;
|
||||
case MENUITEMTYPE_COMMAND:
|
||||
return TYPE_COMMAND;
|
||||
case MENUITEMTYPE_CHECK:
|
||||
return TYPE_CHECK;
|
||||
case MENUITEMTYPE_RADIO:
|
||||
return TYPE_RADIO;
|
||||
case MENUITEMTYPE_SEPARATOR:
|
||||
return TYPE_SEPARATOR;
|
||||
case MENUITEMTYPE_SUBMENU:
|
||||
return TYPE_SUBMENU;
|
||||
default:
|
||||
NOTREACHED();
|
||||
return TYPE_COMMAND;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,9 +67,7 @@ class CefSimpleMenuModel : public ui::MenuModel {
|
||||
return impl_->GetFormattedLabelAt(index);
|
||||
}
|
||||
|
||||
bool IsItemDynamicAt(int index) const override {
|
||||
return false;
|
||||
}
|
||||
bool IsItemDynamicAt(int index) const override { return false; }
|
||||
|
||||
const gfx::FontList* GetLabelFontListAt(int index) const override {
|
||||
return impl_->GetLabelFontListAt(index);
|
||||
@@ -97,8 +89,8 @@ class CefSimpleMenuModel : public ui::MenuModel {
|
||||
if (alt_pressed)
|
||||
modifiers |= ui::EF_ALT_DOWN;
|
||||
|
||||
*accelerator = ui::Accelerator(static_cast<ui::KeyboardCode>(key_code),
|
||||
modifiers);
|
||||
*accelerator =
|
||||
ui::Accelerator(static_cast<ui::KeyboardCode>(key_code), modifiers);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -112,12 +104,9 @@ class CefSimpleMenuModel : public ui::MenuModel {
|
||||
return impl_->GetGroupIdAt(index);
|
||||
}
|
||||
|
||||
bool GetIconAt(int index, gfx::Image* icon) override {
|
||||
return false;
|
||||
}
|
||||
bool GetIconAt(int index, gfx::Image* icon) override { return false; }
|
||||
|
||||
ui::ButtonMenuItemModel* GetButtonMenuItemAt(
|
||||
int index) const override {
|
||||
ui::ButtonMenuItemModel* GetButtonMenuItemAt(int index) const override {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -129,12 +118,9 @@ class CefSimpleMenuModel : public ui::MenuModel {
|
||||
return impl_->IsVisibleAt(index);
|
||||
}
|
||||
|
||||
void HighlightChangedTo(int index) override {
|
||||
}
|
||||
void HighlightChangedTo(int index) override {}
|
||||
|
||||
void ActivatedAt(int index) override {
|
||||
ActivatedAt(index, 0);
|
||||
}
|
||||
void ActivatedAt(int index) override { ActivatedAt(index, 0); }
|
||||
|
||||
void ActivatedAt(int index, int event_flags) override {
|
||||
impl_->ActivatedAt(index, static_cast<cef_event_flags_t>(event_flags));
|
||||
@@ -172,13 +158,9 @@ class CefSimpleMenuModel : public ui::MenuModel {
|
||||
return impl_->GetBackgroundColor(index, is_hovered, override_color);
|
||||
}
|
||||
|
||||
void MenuWillShow() override {
|
||||
impl_->MenuWillShow();
|
||||
}
|
||||
void MenuWillShow() override { impl_->MenuWillShow(); }
|
||||
|
||||
void MenuWillClose() override {
|
||||
impl_->MenuWillClose();
|
||||
}
|
||||
void MenuWillClose() override { impl_->MenuWillClose(); }
|
||||
|
||||
void SetMenuModelDelegate(
|
||||
ui::MenuModelDelegate* menu_model_delegate) override {
|
||||
@@ -201,15 +183,15 @@ cef_menu_color_type_t GetMenuColorType(bool is_text,
|
||||
bool is_hovered) {
|
||||
if (is_text) {
|
||||
if (is_accelerator) {
|
||||
return is_hovered ? CEF_MENU_COLOR_TEXT_ACCELERATOR_HOVERED :
|
||||
CEF_MENU_COLOR_TEXT_ACCELERATOR;
|
||||
return is_hovered ? CEF_MENU_COLOR_TEXT_ACCELERATOR_HOVERED
|
||||
: CEF_MENU_COLOR_TEXT_ACCELERATOR;
|
||||
}
|
||||
return is_hovered ? CEF_MENU_COLOR_TEXT_HOVERED : CEF_MENU_COLOR_TEXT;
|
||||
}
|
||||
|
||||
|
||||
DCHECK(!is_accelerator);
|
||||
return is_hovered ? CEF_MENU_COLOR_BACKGROUND_HOVERED :
|
||||
CEF_MENU_COLOR_BACKGROUND;
|
||||
return is_hovered ? CEF_MENU_COLOR_BACKGROUND_HOVERED
|
||||
: CEF_MENU_COLOR_BACKGROUND;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -235,8 +217,7 @@ struct CefMenuModelImpl::Item {
|
||||
: type_(type),
|
||||
command_id_(command_id),
|
||||
label_(label),
|
||||
group_id_(group_id) {
|
||||
}
|
||||
group_id_(group_id) {}
|
||||
|
||||
// Basic information.
|
||||
cef_menu_item_type_t type_;
|
||||
@@ -262,7 +243,6 @@ struct CefMenuModelImpl::Item {
|
||||
bool has_font_list_ = false;
|
||||
};
|
||||
|
||||
|
||||
CefMenuModelImpl::CefMenuModelImpl(
|
||||
Delegate* delegate,
|
||||
CefRefPtr<CefMenuModelDelegate> menu_model_delegate,
|
||||
@@ -275,8 +255,7 @@ CefMenuModelImpl::CefMenuModelImpl(
|
||||
model_.reset(new CefSimpleMenuModel(this));
|
||||
}
|
||||
|
||||
CefMenuModelImpl::~CefMenuModelImpl() {
|
||||
}
|
||||
CefMenuModelImpl::~CefMenuModelImpl() {}
|
||||
|
||||
bool CefMenuModelImpl::IsSubMenu() {
|
||||
if (!VerifyContext())
|
||||
@@ -303,8 +282,8 @@ bool CefMenuModelImpl::AddSeparator() {
|
||||
if (!VerifyContext())
|
||||
return false;
|
||||
|
||||
AppendItem(Item(MENUITEMTYPE_SEPARATOR, kSeparatorId, CefString(),
|
||||
kInvalidGroupId));
|
||||
AppendItem(
|
||||
Item(MENUITEMTYPE_SEPARATOR, kSeparatorId, CefString(), kInvalidGroupId));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -312,8 +291,7 @@ bool CefMenuModelImpl::AddItem(int command_id, const CefString& label) {
|
||||
if (!VerifyContext())
|
||||
return false;
|
||||
|
||||
AppendItem(Item(MENUITEMTYPE_COMMAND, command_id, label,
|
||||
kInvalidGroupId));
|
||||
AppendItem(Item(MENUITEMTYPE_COMMAND, command_id, label, kInvalidGroupId));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -325,7 +303,8 @@ bool CefMenuModelImpl::AddCheckItem(int command_id, const CefString& label) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CefMenuModelImpl::AddRadioItem(int command_id, const CefString& label,
|
||||
bool CefMenuModelImpl::AddRadioItem(int command_id,
|
||||
const CefString& label,
|
||||
int group_id) {
|
||||
if (!VerifyContext())
|
||||
return false;
|
||||
@@ -349,13 +328,14 @@ bool CefMenuModelImpl::InsertSeparatorAt(int index) {
|
||||
if (!VerifyContext())
|
||||
return false;
|
||||
|
||||
InsertItemAt(Item(MENUITEMTYPE_SEPARATOR, kSeparatorId, CefString(),
|
||||
kInvalidGroupId),
|
||||
index);
|
||||
InsertItemAt(
|
||||
Item(MENUITEMTYPE_SEPARATOR, kSeparatorId, CefString(), kInvalidGroupId),
|
||||
index);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CefMenuModelImpl::InsertItemAt(int index, int command_id,
|
||||
bool CefMenuModelImpl::InsertItemAt(int index,
|
||||
int command_id,
|
||||
const CefString& label) {
|
||||
if (!VerifyContext())
|
||||
return false;
|
||||
@@ -365,8 +345,9 @@ bool CefMenuModelImpl::InsertItemAt(int index, int command_id,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CefMenuModelImpl::InsertCheckItemAt(int index, int command_id,
|
||||
const CefString& label) {
|
||||
bool CefMenuModelImpl::InsertCheckItemAt(int index,
|
||||
int command_id,
|
||||
const CefString& label) {
|
||||
if (!VerifyContext())
|
||||
return false;
|
||||
|
||||
@@ -375,8 +356,10 @@ bool CefMenuModelImpl::InsertCheckItemAt(int index, int command_id,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CefMenuModelImpl::InsertRadioItemAt(int index, int command_id,
|
||||
const CefString& label, int group_id) {
|
||||
bool CefMenuModelImpl::InsertRadioItemAt(int index,
|
||||
int command_id,
|
||||
const CefString& label,
|
||||
int group_id) {
|
||||
if (!VerifyContext())
|
||||
return false;
|
||||
|
||||
@@ -385,7 +368,9 @@ bool CefMenuModelImpl::InsertRadioItemAt(int index, int command_id,
|
||||
}
|
||||
|
||||
CefRefPtr<CefMenuModel> CefMenuModelImpl::InsertSubMenuAt(
|
||||
int index, int command_id, const CefString& label) {
|
||||
int index,
|
||||
int command_id,
|
||||
const CefString& label) {
|
||||
if (!VerifyContext())
|
||||
return NULL;
|
||||
|
||||
@@ -404,7 +389,7 @@ bool CefMenuModelImpl::RemoveAt(int index) {
|
||||
return false;
|
||||
|
||||
if (index >= 0 && index < static_cast<int>(items_.size())) {
|
||||
items_.erase(items_.begin()+index);
|
||||
items_.erase(items_.begin() + index);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -621,15 +606,19 @@ bool CefMenuModelImpl::HasAcceleratorAt(int index) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CefMenuModelImpl::SetAccelerator(int command_id, int key_code,
|
||||
bool shift_pressed, bool ctrl_pressed,
|
||||
bool CefMenuModelImpl::SetAccelerator(int command_id,
|
||||
int key_code,
|
||||
bool shift_pressed,
|
||||
bool ctrl_pressed,
|
||||
bool alt_pressed) {
|
||||
return SetAcceleratorAt(GetIndexOf(command_id), key_code, shift_pressed,
|
||||
ctrl_pressed, alt_pressed);
|
||||
}
|
||||
|
||||
bool CefMenuModelImpl::SetAcceleratorAt(int index, int key_code,
|
||||
bool shift_pressed, bool ctrl_pressed,
|
||||
bool CefMenuModelImpl::SetAcceleratorAt(int index,
|
||||
int key_code,
|
||||
bool shift_pressed,
|
||||
bool ctrl_pressed,
|
||||
bool alt_pressed) {
|
||||
if (!VerifyContext())
|
||||
return false;
|
||||
@@ -668,15 +657,19 @@ bool CefMenuModelImpl::RemoveAcceleratorAt(int index) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CefMenuModelImpl::GetAccelerator(int command_id, int& key_code,
|
||||
bool& shift_pressed, bool& ctrl_pressed,
|
||||
bool CefMenuModelImpl::GetAccelerator(int command_id,
|
||||
int& key_code,
|
||||
bool& shift_pressed,
|
||||
bool& ctrl_pressed,
|
||||
bool& alt_pressed) {
|
||||
return GetAcceleratorAt(GetIndexOf(command_id), key_code, shift_pressed,
|
||||
ctrl_pressed, alt_pressed);
|
||||
}
|
||||
|
||||
bool CefMenuModelImpl::GetAcceleratorAt(int index, int& key_code,
|
||||
bool& shift_pressed, bool& ctrl_pressed,
|
||||
bool CefMenuModelImpl::GetAcceleratorAt(int index,
|
||||
int& key_code,
|
||||
bool& shift_pressed,
|
||||
bool& ctrl_pressed,
|
||||
bool& alt_pressed) {
|
||||
if (!VerifyContext())
|
||||
return false;
|
||||
@@ -786,7 +779,7 @@ bool CefMenuModelImpl::SetFontListAt(int index, const CefString& font_list) {
|
||||
void CefMenuModelImpl::ActivatedAt(int index, cef_event_flags_t event_flags) {
|
||||
if (!VerifyContext())
|
||||
return;
|
||||
|
||||
|
||||
const int command_id = GetCommandIdAt(index);
|
||||
if (delegate_)
|
||||
delegate_->ExecuteCommand(this, command_id, event_flags);
|
||||
@@ -881,7 +874,7 @@ bool CefMenuModelImpl::GetBackgroundColor(int index,
|
||||
void CefMenuModelImpl::MenuWillShow() {
|
||||
if (!VerifyContext())
|
||||
return;
|
||||
|
||||
|
||||
if (delegate_)
|
||||
delegate_->MenuWillShow(this);
|
||||
if (menu_model_delegate_)
|
||||
@@ -899,8 +892,7 @@ void CefMenuModelImpl::MenuWillClose() {
|
||||
// called after this. It's more convenient for the delegate to be called
|
||||
// afterwards, though, so post a task.
|
||||
base::MessageLoop::current()->task_runner()->PostTask(
|
||||
FROM_HERE,
|
||||
base::Bind(&CefMenuModelImpl::OnMenuClosed, this));
|
||||
FROM_HERE, base::Bind(&CefMenuModelImpl::OnMenuClosed, this));
|
||||
}
|
||||
|
||||
base::string16 CefMenuModelImpl::GetFormattedLabelAt(int index) {
|
||||
@@ -1014,8 +1006,8 @@ void CefMenuModelImpl::OnMouseOutsideMenu(const gfx::Point& screen_point) {
|
||||
if (delegate_)
|
||||
delegate_->MouseOutsideMenu(this, screen_point);
|
||||
if (menu_model_delegate_) {
|
||||
menu_model_delegate_->MouseOutsideMenu(this,
|
||||
CefPoint(screen_point.x(), screen_point.y()));
|
||||
menu_model_delegate_->MouseOutsideMenu(
|
||||
this, CefPoint(screen_point.x(), screen_point.y()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -28,7 +28,7 @@ class CefMenuModelImpl : public CefMenuModel {
|
||||
// optional |event_flags|.
|
||||
virtual void ExecuteCommand(CefRefPtr<CefMenuModelImpl> source,
|
||||
int command_id,
|
||||
cef_event_flags_t event_flags) =0;
|
||||
cef_event_flags_t event_flags) = 0;
|
||||
|
||||
// Called when the user moves the mouse outside the menu and over the owning
|
||||
// window.
|
||||
@@ -43,14 +43,14 @@ class CefMenuModelImpl : public CefMenuModel {
|
||||
bool is_rtl) {}
|
||||
|
||||
// Called when the menu is about to show.
|
||||
virtual void MenuWillShow(CefRefPtr<CefMenuModelImpl> source) =0;
|
||||
virtual void MenuWillShow(CefRefPtr<CefMenuModelImpl> source) = 0;
|
||||
|
||||
// Called when the menu has closed.
|
||||
virtual void MenuClosed(CefRefPtr<CefMenuModelImpl> source) =0;
|
||||
virtual void MenuClosed(CefRefPtr<CefMenuModelImpl> source) = 0;
|
||||
|
||||
// Allows the delegate to modify a menu item label before it's displayed.
|
||||
virtual bool FormatLabel(CefRefPtr<CefMenuModelImpl> source,
|
||||
base::string16& label) =0;
|
||||
base::string16& label) = 0;
|
||||
|
||||
protected:
|
||||
virtual ~Delegate() {}
|
||||
@@ -70,19 +70,23 @@ class CefMenuModelImpl : public CefMenuModel {
|
||||
bool AddSeparator() override;
|
||||
bool AddItem(int command_id, const CefString& label) override;
|
||||
bool AddCheckItem(int command_id, const CefString& label) override;
|
||||
bool AddRadioItem(int command_id, const CefString& label,
|
||||
int group_id) override;
|
||||
bool AddRadioItem(int command_id,
|
||||
const CefString& label,
|
||||
int group_id) override;
|
||||
CefRefPtr<CefMenuModel> AddSubMenu(int command_id,
|
||||
const CefString& label) override;
|
||||
const CefString& label) override;
|
||||
bool InsertSeparatorAt(int index) override;
|
||||
bool InsertItemAt(int index, int command_id,
|
||||
const CefString& label) override;
|
||||
bool InsertCheckItemAt(int index, int command_id,
|
||||
const CefString& label) override;
|
||||
bool InsertRadioItemAt(int index, int command_id,
|
||||
const CefString& label, int group_id) override;
|
||||
CefRefPtr<CefMenuModel> InsertSubMenuAt(int index, int command_id,
|
||||
const CefString& label) override;
|
||||
bool InsertItemAt(int index, int command_id, const CefString& label) override;
|
||||
bool InsertCheckItemAt(int index,
|
||||
int command_id,
|
||||
const CefString& label) override;
|
||||
bool InsertRadioItemAt(int index,
|
||||
int command_id,
|
||||
const CefString& label,
|
||||
int group_id) override;
|
||||
CefRefPtr<CefMenuModel> InsertSubMenuAt(int index,
|
||||
int command_id,
|
||||
const CefString& label) override;
|
||||
bool Remove(int command_id) override;
|
||||
bool RemoveAt(int index) override;
|
||||
int GetIndexOf(int command_id) override;
|
||||
@@ -114,16 +118,28 @@ class CefMenuModelImpl : public CefMenuModel {
|
||||
bool SetCheckedAt(int index, bool checked) override;
|
||||
bool HasAccelerator(int command_id) override;
|
||||
bool HasAcceleratorAt(int index) override;
|
||||
bool SetAccelerator(int command_id, int key_code, bool shift_pressed,
|
||||
bool ctrl_pressed, bool alt_pressed) override;
|
||||
bool SetAcceleratorAt(int index, int key_code, bool shift_pressed,
|
||||
bool ctrl_pressed, bool alt_pressed) override;
|
||||
bool SetAccelerator(int command_id,
|
||||
int key_code,
|
||||
bool shift_pressed,
|
||||
bool ctrl_pressed,
|
||||
bool alt_pressed) override;
|
||||
bool SetAcceleratorAt(int index,
|
||||
int key_code,
|
||||
bool shift_pressed,
|
||||
bool ctrl_pressed,
|
||||
bool alt_pressed) override;
|
||||
bool RemoveAccelerator(int command_id) override;
|
||||
bool RemoveAcceleratorAt(int index) override;
|
||||
bool GetAccelerator(int command_id, int& key_code,
|
||||
bool& shift_pressed, bool& ctrl_pressed, bool& alt_pressed) override;
|
||||
bool GetAcceleratorAt(int index, int& key_code, bool& shift_pressed,
|
||||
bool& ctrl_pressed, bool& alt_pressed) override;
|
||||
bool GetAccelerator(int command_id,
|
||||
int& key_code,
|
||||
bool& shift_pressed,
|
||||
bool& ctrl_pressed,
|
||||
bool& alt_pressed) override;
|
||||
bool GetAcceleratorAt(int index,
|
||||
int& key_code,
|
||||
bool& shift_pressed,
|
||||
bool& ctrl_pressed,
|
||||
bool& alt_pressed) override;
|
||||
bool SetColor(int command_id,
|
||||
cef_menu_color_type_t color_type,
|
||||
cef_color_t color) override;
|
||||
|
@@ -14,8 +14,7 @@ CefBrowserPlatformDelegateNative::CefBrowserPlatformDelegateNative(
|
||||
SkColor background_color)
|
||||
: window_info_(window_info),
|
||||
background_color_(background_color),
|
||||
windowless_handler_(nullptr) {
|
||||
}
|
||||
windowless_handler_(nullptr) {}
|
||||
|
||||
SkColor CefBrowserPlatformDelegateNative::GetBackgroundColor() const {
|
||||
return background_color_;
|
||||
|
@@ -48,8 +48,7 @@ CefBrowserPlatformDelegateNativeLinux::CefBrowserPlatformDelegateNativeLinux(
|
||||
: CefBrowserPlatformDelegateNative(window_info, background_color),
|
||||
host_window_created_(false),
|
||||
window_widget_(nullptr),
|
||||
window_x11_(nullptr) {
|
||||
}
|
||||
window_x11_(nullptr) {}
|
||||
|
||||
void CefBrowserPlatformDelegateNativeLinux::BrowserDestroyed(
|
||||
CefBrowserHostImpl* browser) {
|
||||
@@ -70,8 +69,8 @@ bool CefBrowserPlatformDelegateNativeLinux::CreateHostWindow() {
|
||||
if (window_info_.height == 0)
|
||||
window_info_.height = 600;
|
||||
|
||||
gfx::Rect rect(window_info_.x, window_info_.y,
|
||||
window_info_.width, window_info_.height);
|
||||
gfx::Rect rect(window_info_.x, window_info_.y, window_info_.width,
|
||||
window_info_.height);
|
||||
|
||||
// Create a new window object. It will delete itself when the associated X11
|
||||
// window is destroyed.
|
||||
@@ -85,8 +84,7 @@ bool CefBrowserPlatformDelegateNativeLinux::CreateHostWindow() {
|
||||
|
||||
CefWindowDelegateView* delegate_view =
|
||||
new CefWindowDelegateView(GetBackgroundColor());
|
||||
delegate_view->Init(window_info_.window,
|
||||
browser_->web_contents(),
|
||||
delegate_view->Init(window_info_.window, browser_->web_contents(),
|
||||
gfx::Rect(gfx::Point(), rect.size()));
|
||||
|
||||
window_widget_ = delegate_view->GetWidget();
|
||||
@@ -109,7 +107,8 @@ bool CefBrowserPlatformDelegateNativeLinux::CreateHostWindow() {
|
||||
prefs->inactive_selection_fg_color = SkColorSetRGB(50, 50, 50);
|
||||
|
||||
// Set font-related attributes.
|
||||
CR_DEFINE_STATIC_LOCAL(const gfx::FontRenderParams, params,
|
||||
CR_DEFINE_STATIC_LOCAL(
|
||||
const gfx::FontRenderParams, params,
|
||||
(gfx::GetFontRenderParams(gfx::FontRenderParamsQuery(), NULL)));
|
||||
prefs->should_antialias_text = params.antialiasing;
|
||||
prefs->use_subpixel_positioning = params.subpixel_positioning;
|
||||
@@ -128,8 +127,8 @@ void CefBrowserPlatformDelegateNativeLinux::CloseHostWindow() {
|
||||
window_x11_->Close();
|
||||
}
|
||||
|
||||
CefWindowHandle
|
||||
CefBrowserPlatformDelegateNativeLinux::GetHostWindowHandle() const {
|
||||
CefWindowHandle CefBrowserPlatformDelegateNativeLinux::GetHostWindowHandle()
|
||||
const {
|
||||
if (windowless_handler_)
|
||||
return windowless_handler_->GetParentWindowHandle();
|
||||
return window_info_.window;
|
||||
@@ -176,8 +175,8 @@ void CefBrowserPlatformDelegateNativeLinux::NotifyMoveOrResizeStarted() {
|
||||
// Send updated screen rectangle information to the renderer process so that
|
||||
// popups are displayed in the correct location.
|
||||
content::RenderWidgetHostImpl::From(
|
||||
browser_->web_contents()->GetRenderViewHost()->GetWidget())->
|
||||
SendScreenRects();
|
||||
browser_->web_contents()->GetRenderViewHost()->GetWidget())
|
||||
->SendScreenRects();
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegateNativeLinux::SizeTo(int width, int height) {
|
||||
@@ -239,8 +238,7 @@ void CefBrowserPlatformDelegateNativeLinux::HandleKeyboardEvent(
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegateNativeLinux::HandleExternalProtocol(
|
||||
const GURL& url) {
|
||||
}
|
||||
const GURL& url) {}
|
||||
|
||||
void CefBrowserPlatformDelegateNativeLinux::TranslateKeyEvent(
|
||||
content::NativeWebKeyboardEvent& result,
|
||||
@@ -249,25 +247,24 @@ void CefBrowserPlatformDelegateNativeLinux::TranslateKeyEvent(
|
||||
result.native_key_code = key_event.native_key_code;
|
||||
result.is_system_key = key_event.is_system_key ? 1 : 0;
|
||||
switch (key_event.type) {
|
||||
case KEYEVENT_RAWKEYDOWN:
|
||||
case KEYEVENT_KEYDOWN:
|
||||
result.SetType(blink::WebInputEvent::kRawKeyDown);
|
||||
break;
|
||||
case KEYEVENT_KEYUP:
|
||||
result.SetType(blink::WebInputEvent::kKeyUp);
|
||||
break;
|
||||
case KEYEVENT_CHAR:
|
||||
result.SetType(blink::WebInputEvent::kChar);
|
||||
break;
|
||||
default:
|
||||
NOTREACHED();
|
||||
case KEYEVENT_RAWKEYDOWN:
|
||||
case KEYEVENT_KEYDOWN:
|
||||
result.SetType(blink::WebInputEvent::kRawKeyDown);
|
||||
break;
|
||||
case KEYEVENT_KEYUP:
|
||||
result.SetType(blink::WebInputEvent::kKeyUp);
|
||||
break;
|
||||
case KEYEVENT_CHAR:
|
||||
result.SetType(blink::WebInputEvent::kChar);
|
||||
break;
|
||||
default:
|
||||
NOTREACHED();
|
||||
}
|
||||
|
||||
// Populate DOM values that will be passed to JavaScript handlers via
|
||||
// KeyboardEvent.
|
||||
result.dom_code =
|
||||
static_cast<int>(ui::KeycodeConverter::NativeKeycodeToDomCode(
|
||||
key_event.native_key_code));
|
||||
result.dom_code = static_cast<int>(
|
||||
ui::KeycodeConverter::NativeKeycodeToDomCode(key_event.native_key_code));
|
||||
int keysym = ui::XKeysymForWindowsKeyCode(
|
||||
static_cast<ui::KeyboardCode>(key_event.windows_key_code),
|
||||
!!(key_event.modifiers & EVENTFLAG_SHIFT_DOWN));
|
||||
@@ -277,35 +274,36 @@ void CefBrowserPlatformDelegateNativeLinux::TranslateKeyEvent(
|
||||
result.text[0] = key_event.character;
|
||||
result.unmodified_text[0] = key_event.unmodified_character;
|
||||
|
||||
result.SetModifiers(
|
||||
result.GetModifiers() | TranslateModifiers(key_event.modifiers));
|
||||
result.SetModifiers(result.GetModifiers() |
|
||||
TranslateModifiers(key_event.modifiers));
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegateNativeLinux::TranslateClickEvent(
|
||||
blink::WebMouseEvent& result,
|
||||
const CefMouseEvent& mouse_event,
|
||||
CefBrowserHost::MouseButtonType type,
|
||||
bool mouseUp, int clickCount) const {
|
||||
bool mouseUp,
|
||||
int clickCount) const {
|
||||
TranslateMouseEvent(result, mouse_event);
|
||||
|
||||
switch (type) {
|
||||
case MBT_LEFT:
|
||||
result.SetType(mouseUp ? blink::WebInputEvent::kMouseUp :
|
||||
blink::WebInputEvent::kMouseDown);
|
||||
result.button = blink::WebMouseEvent::Button::kLeft;
|
||||
break;
|
||||
case MBT_MIDDLE:
|
||||
result.SetType(mouseUp ? blink::WebInputEvent::kMouseUp :
|
||||
blink::WebInputEvent::kMouseDown);
|
||||
result.button = blink::WebMouseEvent::Button::kMiddle;
|
||||
break;
|
||||
case MBT_RIGHT:
|
||||
result.SetType(mouseUp ? blink::WebInputEvent::kMouseUp :
|
||||
blink::WebInputEvent::kMouseDown);
|
||||
result.button = blink::WebMouseEvent::Button::kRight;
|
||||
break;
|
||||
default:
|
||||
NOTREACHED();
|
||||
case MBT_LEFT:
|
||||
result.SetType(mouseUp ? blink::WebInputEvent::kMouseUp
|
||||
: blink::WebInputEvent::kMouseDown);
|
||||
result.button = blink::WebMouseEvent::Button::kLeft;
|
||||
break;
|
||||
case MBT_MIDDLE:
|
||||
result.SetType(mouseUp ? blink::WebInputEvent::kMouseUp
|
||||
: blink::WebInputEvent::kMouseDown);
|
||||
result.button = blink::WebMouseEvent::Button::kMiddle;
|
||||
break;
|
||||
case MBT_RIGHT:
|
||||
result.SetType(mouseUp ? blink::WebInputEvent::kMouseUp
|
||||
: blink::WebInputEvent::kMouseDown);
|
||||
result.button = blink::WebMouseEvent::Button::kRight;
|
||||
break;
|
||||
default:
|
||||
NOTREACHED();
|
||||
}
|
||||
|
||||
result.click_count = clickCount;
|
||||
@@ -338,7 +336,8 @@ void CefBrowserPlatformDelegateNativeLinux::TranslateMoveEvent(
|
||||
void CefBrowserPlatformDelegateNativeLinux::TranslateWheelEvent(
|
||||
blink::WebMouseWheelEvent& result,
|
||||
const CefMouseEvent& mouse_event,
|
||||
int deltaX, int deltaY) const {
|
||||
int deltaX,
|
||||
int deltaY) const {
|
||||
result = blink::WebMouseWheelEvent();
|
||||
TranslateMouseEvent(result, mouse_event);
|
||||
|
||||
@@ -374,7 +373,7 @@ CefEventHandle CefBrowserPlatformDelegateNativeLinux::GetEventHandle(
|
||||
}
|
||||
|
||||
std::unique_ptr<CefMenuRunner>
|
||||
CefBrowserPlatformDelegateNativeLinux::CreateMenuRunner() {
|
||||
CefBrowserPlatformDelegateNativeLinux::CreateMenuRunner() {
|
||||
return base::WrapUnique(new CefMenuRunnerLinux);
|
||||
}
|
||||
|
||||
@@ -389,10 +388,9 @@ void CefBrowserPlatformDelegateNativeLinux::TranslateMouseEvent(
|
||||
result.SetPositionInScreen(screen_pt.x(), screen_pt.y());
|
||||
|
||||
// modifiers
|
||||
result.SetModifiers(
|
||||
result.GetModifiers() | TranslateModifiers(mouse_event.modifiers));
|
||||
result.SetModifiers(result.GetModifiers() |
|
||||
TranslateModifiers(mouse_event.modifiers));
|
||||
|
||||
// timestamp
|
||||
result.SetTimeStampSeconds(GetSystemUptime());
|
||||
}
|
||||
|
||||
|
@@ -10,8 +10,8 @@
|
||||
class CefWindowX11;
|
||||
|
||||
// Windowed browser implementation for Linux.
|
||||
class CefBrowserPlatformDelegateNativeLinux :
|
||||
public CefBrowserPlatformDelegateNative {
|
||||
class CefBrowserPlatformDelegateNativeLinux
|
||||
: public CefBrowserPlatformDelegateNative {
|
||||
public:
|
||||
CefBrowserPlatformDelegateNativeLinux(const CefWindowInfo& window_info,
|
||||
SkColor background_color);
|
||||
@@ -35,13 +35,15 @@ class CefBrowserPlatformDelegateNativeLinux :
|
||||
void TranslateClickEvent(blink::WebMouseEvent& result,
|
||||
const CefMouseEvent& mouse_event,
|
||||
CefBrowserHost::MouseButtonType type,
|
||||
bool mouseUp, int clickCount) const override;
|
||||
bool mouseUp,
|
||||
int clickCount) const override;
|
||||
void TranslateMoveEvent(blink::WebMouseEvent& result,
|
||||
const CefMouseEvent& mouse_event,
|
||||
bool mouseLeave) const override;
|
||||
void TranslateWheelEvent(blink::WebMouseWheelEvent& result,
|
||||
const CefMouseEvent& mouse_event,
|
||||
int deltaX, int deltaY) const override;
|
||||
int deltaX,
|
||||
int deltaY) const override;
|
||||
CefEventHandle GetEventHandle(
|
||||
const content::NativeWebKeyboardEvent& event) const override;
|
||||
std::unique_ptr<CefMenuRunner> CreateMenuRunner() override;
|
||||
|
@@ -8,8 +8,8 @@
|
||||
#include "libcef/browser/native/browser_platform_delegate_native.h"
|
||||
|
||||
// Windowed browser implementation for Mac OS X.
|
||||
class CefBrowserPlatformDelegateNativeMac :
|
||||
public CefBrowserPlatformDelegateNative {
|
||||
class CefBrowserPlatformDelegateNativeMac
|
||||
: public CefBrowserPlatformDelegateNative {
|
||||
public:
|
||||
CefBrowserPlatformDelegateNativeMac(const CefWindowInfo& window_info,
|
||||
SkColor background_color);
|
||||
@@ -30,13 +30,15 @@ class CefBrowserPlatformDelegateNativeMac :
|
||||
void TranslateClickEvent(blink::WebMouseEvent& result,
|
||||
const CefMouseEvent& mouse_event,
|
||||
CefBrowserHost::MouseButtonType type,
|
||||
bool mouseUp, int clickCount) const override;
|
||||
bool mouseUp,
|
||||
int clickCount) const override;
|
||||
void TranslateMoveEvent(blink::WebMouseEvent& result,
|
||||
const CefMouseEvent& mouse_event,
|
||||
bool mouseLeave) const override;
|
||||
void TranslateWheelEvent(blink::WebMouseWheelEvent& result,
|
||||
const CefMouseEvent& mouse_event,
|
||||
int deltaX, int deltaY) const override;
|
||||
int deltaX,
|
||||
int deltaY) const override;
|
||||
CefEventHandle GetEventHandle(
|
||||
const content::NativeWebKeyboardEvent& event) const override;
|
||||
std::unique_ptr<CefFileDialogRunner> CreateFileDialogRunner() override;
|
||||
|
@@ -23,8 +23,8 @@
|
||||
#include "third_party/WebKit/public/platform/WebInputEvent.h"
|
||||
#include "third_party/WebKit/public/platform/WebMouseEvent.h"
|
||||
#include "third_party/WebKit/public/platform/WebMouseWheelEvent.h"
|
||||
#import "ui/base/cocoa/cocoa_base_utils.h"
|
||||
#import "ui/base/cocoa/underlay_opengl_hosting_window.h"
|
||||
#import "ui/base/cocoa/cocoa_base_utils.h"
|
||||
#import "ui/base/cocoa/underlay_opengl_hosting_window.h"
|
||||
#include "ui/events/keycodes/keyboard_codes_posix.h"
|
||||
#include "ui/gfx/geometry/rect.h"
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
CefBrowserHostImpl* browser_; // weak
|
||||
}
|
||||
|
||||
@property (nonatomic, assign) CefBrowserHostImpl* browser;
|
||||
@property(nonatomic, assign) CefBrowserHostImpl* browser;
|
||||
|
||||
@end
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
|
||||
@synthesize browser = browser_;
|
||||
|
||||
- (void) dealloc {
|
||||
- (void)dealloc {
|
||||
if (browser_) {
|
||||
// Force the browser to be destroyed and release the reference added in
|
||||
// PlatformCreateWindow().
|
||||
@@ -56,7 +56,7 @@
|
||||
@end
|
||||
|
||||
// Receives notifications from the browser window. Will delete itself when done.
|
||||
@interface CefWindowDelegate : NSObject <NSWindowDelegate> {
|
||||
@interface CefWindowDelegate : NSObject<NSWindowDelegate> {
|
||||
@private
|
||||
CefBrowserHostImpl* browser_; // weak
|
||||
NSWindow* window_;
|
||||
@@ -144,8 +144,7 @@ CefBrowserPlatformDelegateNativeMac::CefBrowserPlatformDelegateNativeMac(
|
||||
const CefWindowInfo& window_info,
|
||||
SkColor background_color)
|
||||
: CefBrowserPlatformDelegateNative(window_info, background_color),
|
||||
host_window_created_(false) {
|
||||
}
|
||||
host_window_created_(false) {}
|
||||
|
||||
void CefBrowserPlatformDelegateNativeMac::BrowserDestroyed(
|
||||
CefBrowserHostImpl* browser) {
|
||||
@@ -168,9 +167,9 @@ bool CefBrowserPlatformDelegateNativeMac::CreateHostWindow() {
|
||||
if (parentView == nil) {
|
||||
// Create a new window.
|
||||
NSRect screen_rect = [[NSScreen mainScreen] visibleFrame];
|
||||
NSRect window_rect = {{window_info_.x,
|
||||
screen_rect.size.height - window_info_.y},
|
||||
{window_info_.width, window_info_.height}};
|
||||
NSRect window_rect = {
|
||||
{window_info_.x, screen_rect.size.height - window_info_.y},
|
||||
{window_info_.width, window_info_.height}};
|
||||
if (window_rect.size.width == 0)
|
||||
window_rect.size.width = 750;
|
||||
if (window_rect.size.height == 0)
|
||||
@@ -182,14 +181,13 @@ bool CefBrowserPlatformDelegateNativeMac::CreateHostWindow() {
|
||||
contentRect.size.height = window_rect.size.height;
|
||||
|
||||
newWnd = [[UnderlayOpenGLHostingWindow alloc]
|
||||
initWithContentRect:window_rect
|
||||
styleMask:(NSTitledWindowMask |
|
||||
NSClosableWindowMask |
|
||||
NSMiniaturizableWindowMask |
|
||||
NSResizableWindowMask |
|
||||
NSUnifiedTitleAndToolbarWindowMask )
|
||||
backing:NSBackingStoreBuffered
|
||||
defer:NO];
|
||||
initWithContentRect:window_rect
|
||||
styleMask:(NSTitledWindowMask | NSClosableWindowMask |
|
||||
NSMiniaturizableWindowMask |
|
||||
NSResizableWindowMask |
|
||||
NSUnifiedTitleAndToolbarWindowMask)
|
||||
backing:NSBackingStoreBuffered
|
||||
defer:NO];
|
||||
|
||||
// Create the delegate for control and browser window events.
|
||||
[[CefWindowDelegate alloc] initWithWindow:newWnd andBrowser:browser_];
|
||||
@@ -229,7 +227,7 @@ bool CefBrowserPlatformDelegateNativeMac::CreateHostWindow() {
|
||||
|
||||
if (newWnd != nil && !window_info_.hidden) {
|
||||
// Show the window.
|
||||
[newWnd makeKeyAndOrderFront: nil];
|
||||
[newWnd makeKeyAndOrderFront:nil];
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -244,8 +242,8 @@ void CefBrowserPlatformDelegateNativeMac::CloseHostWindow() {
|
||||
}
|
||||
}
|
||||
|
||||
CefWindowHandle
|
||||
CefBrowserPlatformDelegateNativeMac::GetHostWindowHandle() const {
|
||||
CefWindowHandle CefBrowserPlatformDelegateNativeMac::GetHostWindowHandle()
|
||||
const {
|
||||
if (windowless_handler_)
|
||||
return windowless_handler_->GetParentWindowHandle();
|
||||
return window_info_.view;
|
||||
@@ -296,8 +294,7 @@ void CefBrowserPlatformDelegateNativeMac::HandleKeyboardEvent(
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegateNativeMac::HandleExternalProtocol(
|
||||
const GURL& url) {
|
||||
}
|
||||
const GURL& url) {}
|
||||
|
||||
void CefBrowserPlatformDelegateNativeMac::TranslateKeyEvent(
|
||||
content::NativeWebKeyboardEvent& result,
|
||||
@@ -328,23 +325,24 @@ void CefBrowserPlatformDelegateNativeMac::TranslateKeyEvent(
|
||||
}
|
||||
}
|
||||
|
||||
NSString* charactersIgnoringModifiers = [[[NSString alloc]
|
||||
initWithCharacters:&key_event.unmodified_character length:1]
|
||||
autorelease];
|
||||
NSString* characters = [[[NSString alloc]
|
||||
initWithCharacters:&key_event.character length:1] autorelease];
|
||||
NSString* charactersIgnoringModifiers =
|
||||
[[[NSString alloc] initWithCharacters:&key_event.unmodified_character
|
||||
length:1] autorelease];
|
||||
NSString* characters =
|
||||
[[[NSString alloc] initWithCharacters:&key_event.character length:1]
|
||||
autorelease];
|
||||
|
||||
NSEvent* synthetic_event =
|
||||
[NSEvent keyEventWithType:event_type
|
||||
location:NSMakePoint(0, 0)
|
||||
modifierFlags:NativeModifiers(key_event.modifiers)
|
||||
timestamp:currentEventTimestamp()
|
||||
windowNumber:0
|
||||
context:nil
|
||||
characters:characters
|
||||
charactersIgnoringModifiers:charactersIgnoringModifiers
|
||||
isARepeat:NO
|
||||
keyCode:key_event.native_key_code];
|
||||
[NSEvent keyEventWithType:event_type
|
||||
location:NSMakePoint(0, 0)
|
||||
modifierFlags:NativeModifiers(key_event.modifiers)
|
||||
timestamp:currentEventTimestamp()
|
||||
windowNumber:0
|
||||
context:nil
|
||||
characters:characters
|
||||
charactersIgnoringModifiers:charactersIgnoringModifiers
|
||||
isARepeat:NO
|
||||
keyCode:key_event.native_key_code];
|
||||
|
||||
result = content::NativeWebKeyboardEvent(synthetic_event);
|
||||
if (key_event.type == KEYEVENT_CHAR)
|
||||
@@ -357,27 +355,28 @@ void CefBrowserPlatformDelegateNativeMac::TranslateClickEvent(
|
||||
blink::WebMouseEvent& result,
|
||||
const CefMouseEvent& mouse_event,
|
||||
CefBrowserHost::MouseButtonType type,
|
||||
bool mouseUp, int clickCount) const {
|
||||
bool mouseUp,
|
||||
int clickCount) const {
|
||||
TranslateMouseEvent(result, mouse_event);
|
||||
|
||||
switch (type) {
|
||||
case MBT_LEFT:
|
||||
result.SetType(mouseUp ? blink::WebInputEvent::kMouseUp :
|
||||
blink::WebInputEvent::kMouseDown);
|
||||
result.button = blink::WebMouseEvent::Button::kLeft;
|
||||
break;
|
||||
case MBT_MIDDLE:
|
||||
result.SetType(mouseUp ? blink::WebInputEvent::kMouseUp :
|
||||
blink::WebInputEvent::kMouseDown);
|
||||
result.button = blink::WebMouseEvent::Button::kMiddle;
|
||||
break;
|
||||
case MBT_RIGHT:
|
||||
result.SetType(mouseUp ? blink::WebInputEvent::kMouseUp :
|
||||
blink::WebInputEvent::kMouseDown);
|
||||
result.button = blink::WebMouseEvent::Button::kRight;
|
||||
break;
|
||||
default:
|
||||
NOTREACHED();
|
||||
case MBT_LEFT:
|
||||
result.SetType(mouseUp ? blink::WebInputEvent::kMouseUp
|
||||
: blink::WebInputEvent::kMouseDown);
|
||||
result.button = blink::WebMouseEvent::Button::kLeft;
|
||||
break;
|
||||
case MBT_MIDDLE:
|
||||
result.SetType(mouseUp ? blink::WebInputEvent::kMouseUp
|
||||
: blink::WebInputEvent::kMouseDown);
|
||||
result.button = blink::WebMouseEvent::Button::kMiddle;
|
||||
break;
|
||||
case MBT_RIGHT:
|
||||
result.SetType(mouseUp ? blink::WebInputEvent::kMouseUp
|
||||
: blink::WebInputEvent::kMouseDown);
|
||||
result.button = blink::WebMouseEvent::Button::kRight;
|
||||
break;
|
||||
default:
|
||||
NOTREACHED();
|
||||
}
|
||||
|
||||
result.click_count = clickCount;
|
||||
@@ -410,7 +409,8 @@ void CefBrowserPlatformDelegateNativeMac::TranslateMoveEvent(
|
||||
void CefBrowserPlatformDelegateNativeMac::TranslateWheelEvent(
|
||||
blink::WebMouseWheelEvent& result,
|
||||
const CefMouseEvent& mouse_event,
|
||||
int deltaX, int deltaY) const {
|
||||
int deltaX,
|
||||
int deltaY) const {
|
||||
result = blink::WebMouseWheelEvent();
|
||||
TranslateMouseEvent(result, mouse_event);
|
||||
|
||||
@@ -444,17 +444,17 @@ CefEventHandle CefBrowserPlatformDelegateNativeMac::GetEventHandle(
|
||||
}
|
||||
|
||||
std::unique_ptr<CefFileDialogRunner>
|
||||
CefBrowserPlatformDelegateNativeMac::CreateFileDialogRunner() {
|
||||
CefBrowserPlatformDelegateNativeMac::CreateFileDialogRunner() {
|
||||
return base::WrapUnique(new CefFileDialogRunnerMac);
|
||||
}
|
||||
|
||||
std::unique_ptr<CefJavaScriptDialogRunner>
|
||||
CefBrowserPlatformDelegateNativeMac::CreateJavaScriptDialogRunner() {
|
||||
CefBrowserPlatformDelegateNativeMac::CreateJavaScriptDialogRunner() {
|
||||
return base::WrapUnique(new CefJavaScriptDialogRunnerMac);
|
||||
}
|
||||
|
||||
std::unique_ptr<CefMenuRunner>
|
||||
CefBrowserPlatformDelegateNativeMac::CreateMenuRunner() {
|
||||
CefBrowserPlatformDelegateNativeMac::CreateMenuRunner() {
|
||||
return base::WrapUnique(new CefMenuRunnerMac);
|
||||
}
|
||||
|
||||
@@ -469,10 +469,9 @@ void CefBrowserPlatformDelegateNativeMac::TranslateMouseEvent(
|
||||
result.SetPositionInScreen(screen_pt.x(), screen_pt.y());
|
||||
|
||||
// modifiers
|
||||
result.SetModifiers(
|
||||
result.GetModifiers() | TranslateModifiers(mouse_event.modifiers));
|
||||
result.SetModifiers(result.GetModifiers() |
|
||||
TranslateModifiers(mouse_event.modifiers));
|
||||
|
||||
// timestamp - Mac OSX specific
|
||||
result.SetTimeStampSeconds(currentEventTimestamp());
|
||||
}
|
||||
|
||||
|
@@ -73,9 +73,9 @@ bool HasExternalHandler(const std::string& scheme) {
|
||||
DWORD size = 0;
|
||||
key.ReadValue(NULL, NULL, &size, NULL);
|
||||
if (size > 2) {
|
||||
// ShellExecute crashes the process when the command is empty.
|
||||
// We check for "2" because it always returns the trailing NULL.
|
||||
return true;
|
||||
// ShellExecute crashes the process when the command is empty.
|
||||
// We check for "2" because it always returns the trailing NULL.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,8 +119,7 @@ CefBrowserPlatformDelegateNativeWin::CefBrowserPlatformDelegateNativeWin(
|
||||
SkColor background_color)
|
||||
: CefBrowserPlatformDelegateNative(window_info, background_color),
|
||||
host_window_created_(false),
|
||||
window_widget_(nullptr) {
|
||||
}
|
||||
window_widget_(nullptr) {}
|
||||
|
||||
void CefBrowserPlatformDelegateNativeWin::BrowserDestroyed(
|
||||
CefBrowserHostImpl* browser) {
|
||||
@@ -138,9 +137,9 @@ bool CefBrowserPlatformDelegateNativeWin::CreateHostWindow() {
|
||||
std::wstring windowName(CefString(&window_info_.window_name));
|
||||
|
||||
// Create the new browser window.
|
||||
window_info_.window = CreateWindowEx(window_info_.ex_style,
|
||||
GetWndClass(), windowName.c_str(), window_info_.style,
|
||||
window_info_.x, window_info_.y, window_info_.width,
|
||||
window_info_.window = CreateWindowEx(
|
||||
window_info_.ex_style, GetWndClass(), windowName.c_str(),
|
||||
window_info_.style, window_info_.x, window_info_.y, window_info_.width,
|
||||
window_info_.height, window_info_.parent_window, window_info_.menu,
|
||||
::GetModuleHandle(NULL), NULL);
|
||||
|
||||
@@ -166,15 +165,15 @@ bool CefBrowserPlatformDelegateNativeWin::CreateHostWindow() {
|
||||
|
||||
// Adjust for potential display scaling.
|
||||
gfx::Point point = gfx::Point(cr.right, cr.bottom);
|
||||
float scale = display::Screen::GetScreen()->
|
||||
GetDisplayNearestPoint(point).device_scale_factor();
|
||||
point = gfx::ToFlooredPoint(
|
||||
gfx::ScalePoint(gfx::PointF(point), 1.0f / scale));
|
||||
float scale = display::Screen::GetScreen()
|
||||
->GetDisplayNearestPoint(point)
|
||||
.device_scale_factor();
|
||||
point =
|
||||
gfx::ToFlooredPoint(gfx::ScalePoint(gfx::PointF(point), 1.0f / scale));
|
||||
|
||||
CefWindowDelegateView* delegate_view =
|
||||
new CefWindowDelegateView(GetBackgroundColor());
|
||||
delegate_view->Init(window_info_.window,
|
||||
browser_->web_contents(),
|
||||
delegate_view->Init(window_info_.window, browser_->web_contents(),
|
||||
gfx::Rect(0, 0, point.x(), point.y()));
|
||||
|
||||
window_widget_ = delegate_view->GetWidget();
|
||||
@@ -190,8 +189,8 @@ void CefBrowserPlatformDelegateNativeWin::CloseHostWindow() {
|
||||
}
|
||||
}
|
||||
|
||||
CefWindowHandle
|
||||
CefBrowserPlatformDelegateNativeWin::GetHostWindowHandle() const {
|
||||
CefWindowHandle CefBrowserPlatformDelegateNativeWin::GetHostWindowHandle()
|
||||
const {
|
||||
if (windowless_handler_)
|
||||
return windowless_handler_->GetParentWindowHandle();
|
||||
return window_info_.window;
|
||||
@@ -278,8 +277,8 @@ void CefBrowserPlatformDelegateNativeWin::SizeTo(int width, int height) {
|
||||
AdjustWindowRectEx(&rect, style, has_menu, ex_style);
|
||||
|
||||
// Size the window.
|
||||
SetWindowPos(window, NULL, 0, 0, rect.right,
|
||||
rect.bottom, SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE);
|
||||
SetWindowPos(window, NULL, 0, 0, rect.right, rect.bottom,
|
||||
SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE);
|
||||
}
|
||||
|
||||
gfx::Point CefBrowserPlatformDelegateNativeWin::GetScreenPoint(
|
||||
@@ -296,10 +295,10 @@ gfx::Point CefBrowserPlatformDelegateNativeWin::GetScreenPoint(
|
||||
bounds_in_screen.y() + view.y());
|
||||
|
||||
// Adjust for potential display scaling.
|
||||
float scale = display::Screen::GetScreen()->
|
||||
GetDisplayNearestPoint(screen_point).device_scale_factor();
|
||||
return gfx::ToFlooredPoint(
|
||||
gfx::ScalePoint(gfx::PointF(screen_point), scale));
|
||||
float scale = display::Screen::GetScreen()
|
||||
->GetDisplayNearestPoint(screen_point)
|
||||
.device_scale_factor();
|
||||
return gfx::ToFlooredPoint(gfx::ScalePoint(gfx::PointF(screen_point), scale));
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegateNativeWin::ViewText(const std::string& text) {
|
||||
@@ -331,7 +330,7 @@ void CefBrowserPlatformDelegateNativeWin::HandleKeyboardEvent(
|
||||
msg.message = event.is_system_key ? WM_SYSKEYUP : WM_KEYUP;
|
||||
break;
|
||||
case blink::WebInputEvent::kChar:
|
||||
msg.message = event.is_system_key ? WM_SYSCHAR: WM_CHAR;
|
||||
msg.message = event.is_system_key ? WM_SYSCHAR : WM_CHAR;
|
||||
break;
|
||||
default:
|
||||
NOTREACHED();
|
||||
@@ -342,7 +341,7 @@ void CefBrowserPlatformDelegateNativeWin::HandleKeyboardEvent(
|
||||
|
||||
UINT scan_code = ::MapVirtualKeyW(event.windows_key_code, MAPVK_VK_TO_VSC);
|
||||
msg.lParam = (scan_code << 16) | // key scan code
|
||||
1; // key repeat count
|
||||
1; // key repeat count
|
||||
if (event.GetModifiers() & content::NativeWebKeyboardEvent::kAltKey)
|
||||
msg.lParam |= (1 << 29);
|
||||
|
||||
@@ -353,8 +352,7 @@ void CefBrowserPlatformDelegateNativeWin::HandleKeyboardEvent(
|
||||
void CefBrowserPlatformDelegateNativeWin::HandleExternalProtocol(
|
||||
const GURL& url) {
|
||||
// Execute on the FILE thread.
|
||||
CEF_POST_TASK(CEF_FILET,
|
||||
base::Bind(ExecuteExternalProtocol, url));
|
||||
CEF_POST_TASK(CEF_FILET, base::Bind(ExecuteExternalProtocol, url));
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegateNativeWin::TranslateKeyEvent(
|
||||
@@ -364,25 +362,24 @@ void CefBrowserPlatformDelegateNativeWin::TranslateKeyEvent(
|
||||
result.native_key_code = key_event.native_key_code;
|
||||
result.is_system_key = key_event.is_system_key ? 1 : 0;
|
||||
switch (key_event.type) {
|
||||
case KEYEVENT_RAWKEYDOWN:
|
||||
case KEYEVENT_KEYDOWN:
|
||||
result.SetType(blink::WebInputEvent::kRawKeyDown);
|
||||
break;
|
||||
case KEYEVENT_KEYUP:
|
||||
result.SetType(blink::WebInputEvent::kKeyUp);
|
||||
break;
|
||||
case KEYEVENT_CHAR:
|
||||
result.SetType(blink::WebInputEvent::kChar);
|
||||
break;
|
||||
default:
|
||||
NOTREACHED();
|
||||
case KEYEVENT_RAWKEYDOWN:
|
||||
case KEYEVENT_KEYDOWN:
|
||||
result.SetType(blink::WebInputEvent::kRawKeyDown);
|
||||
break;
|
||||
case KEYEVENT_KEYUP:
|
||||
result.SetType(blink::WebInputEvent::kKeyUp);
|
||||
break;
|
||||
case KEYEVENT_CHAR:
|
||||
result.SetType(blink::WebInputEvent::kChar);
|
||||
break;
|
||||
default:
|
||||
NOTREACHED();
|
||||
}
|
||||
|
||||
// Populate DOM values that will be passed to JavaScript handlers via
|
||||
// KeyboardEvent.
|
||||
result.dom_code =
|
||||
static_cast<int>(ui::KeycodeConverter::NativeKeycodeToDomCode(
|
||||
key_event.native_key_code));
|
||||
result.dom_code = static_cast<int>(
|
||||
ui::KeycodeConverter::NativeKeycodeToDomCode(key_event.native_key_code));
|
||||
if (result.GetType() == blink::WebInputEvent::kChar) {
|
||||
result.dom_key = ui::DomKey::FromCharacter(key_event.windows_key_code);
|
||||
} else {
|
||||
@@ -399,35 +396,36 @@ void CefBrowserPlatformDelegateNativeWin::TranslateKeyEvent(
|
||||
result.unmodified_text[0] = result.windows_key_code;
|
||||
}
|
||||
|
||||
result.SetModifiers(
|
||||
result.GetModifiers() | TranslateModifiers(key_event.modifiers));
|
||||
result.SetModifiers(result.GetModifiers() |
|
||||
TranslateModifiers(key_event.modifiers));
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegateNativeWin::TranslateClickEvent(
|
||||
blink::WebMouseEvent& result,
|
||||
const CefMouseEvent& mouse_event,
|
||||
CefBrowserHost::MouseButtonType type,
|
||||
bool mouseUp, int clickCount) const {
|
||||
bool mouseUp,
|
||||
int clickCount) const {
|
||||
TranslateMouseEvent(result, mouse_event);
|
||||
|
||||
switch (type) {
|
||||
case MBT_LEFT:
|
||||
result.SetType(mouseUp ? blink::WebInputEvent::kMouseUp :
|
||||
blink::WebInputEvent::kMouseDown);
|
||||
result.button = blink::WebMouseEvent::Button::kLeft;
|
||||
break;
|
||||
case MBT_MIDDLE:
|
||||
result.SetType(mouseUp ? blink::WebInputEvent::kMouseUp :
|
||||
blink::WebInputEvent::kMouseDown);
|
||||
result.button = blink::WebMouseEvent::Button::kMiddle;
|
||||
break;
|
||||
case MBT_RIGHT:
|
||||
result.SetType(mouseUp ? blink::WebInputEvent::kMouseUp :
|
||||
blink::WebInputEvent::kMouseDown);
|
||||
result.button = blink::WebMouseEvent::Button::kRight;
|
||||
break;
|
||||
default:
|
||||
NOTREACHED();
|
||||
case MBT_LEFT:
|
||||
result.SetType(mouseUp ? blink::WebInputEvent::kMouseUp
|
||||
: blink::WebInputEvent::kMouseDown);
|
||||
result.button = blink::WebMouseEvent::Button::kLeft;
|
||||
break;
|
||||
case MBT_MIDDLE:
|
||||
result.SetType(mouseUp ? blink::WebInputEvent::kMouseUp
|
||||
: blink::WebInputEvent::kMouseDown);
|
||||
result.button = blink::WebMouseEvent::Button::kMiddle;
|
||||
break;
|
||||
case MBT_RIGHT:
|
||||
result.SetType(mouseUp ? blink::WebInputEvent::kMouseUp
|
||||
: blink::WebInputEvent::kMouseDown);
|
||||
result.button = blink::WebMouseEvent::Button::kRight;
|
||||
break;
|
||||
default:
|
||||
NOTREACHED();
|
||||
}
|
||||
|
||||
result.click_count = clickCount;
|
||||
@@ -460,7 +458,8 @@ void CefBrowserPlatformDelegateNativeWin::TranslateMoveEvent(
|
||||
void CefBrowserPlatformDelegateNativeWin::TranslateWheelEvent(
|
||||
blink::WebMouseWheelEvent& result,
|
||||
const CefMouseEvent& mouse_event,
|
||||
int deltaX, int deltaY) const {
|
||||
int deltaX,
|
||||
int deltaY) const {
|
||||
TranslateMouseEvent(result, mouse_event);
|
||||
|
||||
result.SetType(blink::WebInputEvent::kMouseWheel);
|
||||
@@ -510,17 +509,17 @@ CefEventHandle CefBrowserPlatformDelegateNativeWin::GetEventHandle(
|
||||
}
|
||||
|
||||
std::unique_ptr<CefFileDialogRunner>
|
||||
CefBrowserPlatformDelegateNativeWin::CreateFileDialogRunner() {
|
||||
CefBrowserPlatformDelegateNativeWin::CreateFileDialogRunner() {
|
||||
return base::WrapUnique(new CefFileDialogRunnerWin);
|
||||
}
|
||||
|
||||
std::unique_ptr<CefJavaScriptDialogRunner>
|
||||
CefBrowserPlatformDelegateNativeWin::CreateJavaScriptDialogRunner() {
|
||||
CefBrowserPlatformDelegateNativeWin::CreateJavaScriptDialogRunner() {
|
||||
return base::WrapUnique(new CefJavaScriptDialogRunnerWin);
|
||||
}
|
||||
|
||||
std::unique_ptr<CefMenuRunner>
|
||||
CefBrowserPlatformDelegateNativeWin::CreateMenuRunner() {
|
||||
CefBrowserPlatformDelegateNativeWin::CreateMenuRunner() {
|
||||
return base::WrapUnique(new CefMenuRunnerWin);
|
||||
}
|
||||
|
||||
@@ -535,8 +534,8 @@ void CefBrowserPlatformDelegateNativeWin::TranslateMouseEvent(
|
||||
result.SetPositionInScreen(screen_pt.x(), screen_pt.y());
|
||||
|
||||
// modifiers
|
||||
result.SetModifiers(
|
||||
result.GetModifiers() | TranslateModifiers(mouse_event.modifiers));
|
||||
result.SetModifiers(result.GetModifiers() |
|
||||
TranslateModifiers(mouse_event.modifiers));
|
||||
|
||||
// timestamp
|
||||
result.SetTimeStampSeconds(GetMessageTime() / 1000.0);
|
||||
@@ -550,18 +549,18 @@ void CefBrowserPlatformDelegateNativeWin::RegisterWindowClass() {
|
||||
|
||||
// Register the window class
|
||||
WNDCLASSEX wcex = {
|
||||
/* cbSize = */ sizeof(WNDCLASSEX),
|
||||
/* style = */ CS_HREDRAW | CS_VREDRAW,
|
||||
/* lpfnWndProc = */ CefBrowserPlatformDelegateNativeWin::WndProc,
|
||||
/* cbClsExtra = */ 0,
|
||||
/* cbWndExtra = */ 0,
|
||||
/* hInstance = */ ::GetModuleHandle(NULL),
|
||||
/* hIcon = */ NULL,
|
||||
/* hCursor = */ LoadCursor(NULL, IDC_ARROW),
|
||||
/* hbrBackground = */ 0,
|
||||
/* lpszMenuName = */ NULL,
|
||||
/* lpszClassName = */ CefBrowserPlatformDelegateNativeWin::GetWndClass(),
|
||||
/* hIconSm = */ NULL,
|
||||
/* cbSize = */ sizeof(WNDCLASSEX),
|
||||
/* style = */ CS_HREDRAW | CS_VREDRAW,
|
||||
/* lpfnWndProc = */ CefBrowserPlatformDelegateNativeWin::WndProc,
|
||||
/* cbClsExtra = */ 0,
|
||||
/* cbWndExtra = */ 0,
|
||||
/* hInstance = */ ::GetModuleHandle(NULL),
|
||||
/* hIcon = */ NULL,
|
||||
/* hCursor = */ LoadCursor(NULL, IDC_ARROW),
|
||||
/* hbrBackground = */ 0,
|
||||
/* lpszMenuName = */ NULL,
|
||||
/* lpszClassName = */ CefBrowserPlatformDelegateNativeWin::GetWndClass(),
|
||||
/* hIconSm = */ NULL,
|
||||
};
|
||||
RegisterClassEx(&wcex);
|
||||
|
||||
@@ -574,64 +573,65 @@ LPCTSTR CefBrowserPlatformDelegateNativeWin::GetWndClass() {
|
||||
}
|
||||
|
||||
// static
|
||||
LRESULT CALLBACK CefBrowserPlatformDelegateNativeWin::WndProc(
|
||||
HWND hwnd, UINT message,
|
||||
WPARAM wParam, LPARAM lParam) {
|
||||
LRESULT CALLBACK CefBrowserPlatformDelegateNativeWin::WndProc(HWND hwnd,
|
||||
UINT message,
|
||||
WPARAM wParam,
|
||||
LPARAM lParam) {
|
||||
CefBrowserPlatformDelegateNativeWin* platform_delegate =
|
||||
static_cast<CefBrowserPlatformDelegateNativeWin*>(
|
||||
gfx::GetWindowUserData(hwnd));
|
||||
CefBrowserHostImpl* browser = nullptr;
|
||||
if (platform_delegate)
|
||||
browser = platform_delegate->browser_;
|
||||
browser = platform_delegate->browser_;
|
||||
|
||||
switch (message) {
|
||||
case WM_CLOSE:
|
||||
if (browser && !browser->TryCloseBrowser()) {
|
||||
// Cancel the close.
|
||||
case WM_CLOSE:
|
||||
if (browser && !browser->TryCloseBrowser()) {
|
||||
// Cancel the close.
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Allow the close.
|
||||
break;
|
||||
|
||||
case WM_DESTROY:
|
||||
if (platform_delegate) {
|
||||
// Clear the user data pointer.
|
||||
gfx::SetWindowUserData(hwnd, NULL);
|
||||
|
||||
// Force the browser to be destroyed. This will result in a call to
|
||||
// BrowserDestroyed() that will release the reference added in
|
||||
// CreateHostWindow().
|
||||
browser->WindowDestroyed();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Allow the close.
|
||||
break;
|
||||
case WM_SIZE:
|
||||
if (platform_delegate && platform_delegate->window_widget_) {
|
||||
// Pass window resize events to the HWND for the DesktopNativeWidgetAura
|
||||
// root window. Passing size 0x0 (wParam == SIZE_MINIMIZED, for example)
|
||||
// will cause the widget to be hidden which reduces resource usage.
|
||||
RECT rc;
|
||||
GetClientRect(hwnd, &rc);
|
||||
SetWindowPos(HWNDForWidget(platform_delegate->window_widget_), NULL,
|
||||
rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top,
|
||||
SWP_NOZORDER);
|
||||
}
|
||||
return 0;
|
||||
|
||||
case WM_DESTROY:
|
||||
if (platform_delegate) {
|
||||
// Clear the user data pointer.
|
||||
gfx::SetWindowUserData(hwnd, NULL);
|
||||
case WM_MOVING:
|
||||
case WM_MOVE:
|
||||
if (browser)
|
||||
browser->NotifyMoveOrResizeStarted();
|
||||
return 0;
|
||||
|
||||
// Force the browser to be destroyed. This will result in a call to
|
||||
// BrowserDestroyed() that will release the reference added in
|
||||
// CreateHostWindow().
|
||||
browser->WindowDestroyed();
|
||||
}
|
||||
return 0;
|
||||
case WM_SETFOCUS:
|
||||
if (browser)
|
||||
browser->SetFocus(true);
|
||||
return 0;
|
||||
|
||||
case WM_SIZE:
|
||||
if (platform_delegate && platform_delegate->window_widget_) {
|
||||
// Pass window resize events to the HWND for the DesktopNativeWidgetAura
|
||||
// root window. Passing size 0x0 (wParam == SIZE_MINIMIZED, for example)
|
||||
// will cause the widget to be hidden which reduces resource usage.
|
||||
RECT rc;
|
||||
GetClientRect(hwnd, &rc);
|
||||
SetWindowPos(HWNDForWidget(platform_delegate->window_widget_), NULL,
|
||||
rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top,
|
||||
SWP_NOZORDER);
|
||||
}
|
||||
return 0;
|
||||
|
||||
case WM_MOVING:
|
||||
case WM_MOVE:
|
||||
if (browser)
|
||||
browser->NotifyMoveOrResizeStarted();
|
||||
return 0;
|
||||
|
||||
case WM_SETFOCUS:
|
||||
if (browser)
|
||||
browser->SetFocus(true);
|
||||
return 0;
|
||||
|
||||
case WM_ERASEBKGND:
|
||||
return 0;
|
||||
case WM_ERASEBKGND:
|
||||
return 0;
|
||||
}
|
||||
|
||||
return DefWindowProc(hwnd, message, wParam, lParam);
|
||||
|
@@ -10,8 +10,8 @@
|
||||
#include "libcef/browser/native/browser_platform_delegate_native.h"
|
||||
|
||||
// Windowed browser implementation for Windows.
|
||||
class CefBrowserPlatformDelegateNativeWin :
|
||||
public CefBrowserPlatformDelegateNative {
|
||||
class CefBrowserPlatformDelegateNativeWin
|
||||
: public CefBrowserPlatformDelegateNative {
|
||||
public:
|
||||
CefBrowserPlatformDelegateNativeWin(const CefWindowInfo& window_info,
|
||||
SkColor background_color);
|
||||
@@ -35,17 +35,20 @@ class CefBrowserPlatformDelegateNativeWin :
|
||||
void TranslateClickEvent(blink::WebMouseEvent& result,
|
||||
const CefMouseEvent& mouse_event,
|
||||
CefBrowserHost::MouseButtonType type,
|
||||
bool mouseUp, int clickCount) const override;
|
||||
bool mouseUp,
|
||||
int clickCount) const override;
|
||||
void TranslateMoveEvent(blink::WebMouseEvent& result,
|
||||
const CefMouseEvent& mouse_event,
|
||||
bool mouseLeave) const override;
|
||||
void TranslateWheelEvent(blink::WebMouseWheelEvent& result,
|
||||
const CefMouseEvent& mouse_event,
|
||||
int deltaX, int deltaY) const override;
|
||||
int deltaX,
|
||||
int deltaY) const override;
|
||||
CefEventHandle GetEventHandle(
|
||||
const content::NativeWebKeyboardEvent& event) const override;
|
||||
std::unique_ptr<CefFileDialogRunner> CreateFileDialogRunner() override;
|
||||
std::unique_ptr<CefJavaScriptDialogRunner> CreateJavaScriptDialogRunner() override;
|
||||
std::unique_ptr<CefJavaScriptDialogRunner> CreateJavaScriptDialogRunner()
|
||||
override;
|
||||
std::unique_ptr<CefMenuRunner> CreateMenuRunner() override;
|
||||
|
||||
private:
|
||||
@@ -54,8 +57,10 @@ class CefBrowserPlatformDelegateNativeWin :
|
||||
|
||||
static void RegisterWindowClass();
|
||||
static LPCTSTR GetWndClass();
|
||||
static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
||||
WPARAM wParam, LPARAM lParam);
|
||||
static LRESULT CALLBACK WndProc(HWND hwnd,
|
||||
UINT message,
|
||||
WPARAM wParam,
|
||||
LPARAM lParam);
|
||||
|
||||
// True if the host window has been created.
|
||||
bool host_window_created_;
|
||||
|
@@ -31,10 +31,10 @@ base::string16 GetDescriptionFromMimeType(const std::string& mime_type) {
|
||||
const char* mime_type;
|
||||
int string_id;
|
||||
} kWildCardMimeTypes[] = {
|
||||
{ "audio", IDS_AUDIO_FILES },
|
||||
{ "image", IDS_IMAGE_FILES },
|
||||
{ "text", IDS_TEXT_FILES },
|
||||
{ "video", IDS_VIDEO_FILES },
|
||||
{"audio", IDS_AUDIO_FILES},
|
||||
{"image", IDS_IMAGE_FILES},
|
||||
{"text", IDS_TEXT_FILES},
|
||||
{"video", IDS_VIDEO_FILES},
|
||||
};
|
||||
|
||||
for (size_t i = 0; i < arraysize(kWildCardMimeTypes); ++i) {
|
||||
@@ -45,10 +45,10 @@ base::string16 GetDescriptionFromMimeType(const std::string& mime_type) {
|
||||
return base::string16();
|
||||
}
|
||||
|
||||
void AddFilters(NSPopUpButton *button,
|
||||
void AddFilters(NSPopUpButton* button,
|
||||
const std::vector<base::string16>& accept_filters,
|
||||
bool include_all_files,
|
||||
std::vector<std::vector<base::string16> >* all_extensions) {
|
||||
std::vector<std::vector<base::string16>>* all_extensions) {
|
||||
for (size_t i = 0; i < accept_filters.size(); ++i) {
|
||||
const base::string16& filter = accept_filters[i];
|
||||
if (filter.empty())
|
||||
@@ -62,11 +62,9 @@ void AddFilters(NSPopUpButton *button,
|
||||
// Treat as a filter of the form "Filter Name|.ext1;.ext2;.ext3".
|
||||
description = filter.substr(0, sep_index);
|
||||
|
||||
const std::vector<base::string16>& ext =
|
||||
base::SplitString(filter.substr(sep_index + 1),
|
||||
base::ASCIIToUTF16(";"),
|
||||
base::TRIM_WHITESPACE,
|
||||
base::SPLIT_WANT_NONEMPTY);
|
||||
const std::vector<base::string16>& ext = base::SplitString(
|
||||
filter.substr(sep_index + 1), base::ASCIIToUTF16(";"),
|
||||
base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
|
||||
for (size_t x = 0; x < ext.size(); ++x) {
|
||||
const base::string16& file_ext = ext[x];
|
||||
if (!file_ext.empty() && file_ext[0] == '.')
|
||||
@@ -131,12 +129,12 @@ void AddFilters(NSPopUpButton *button,
|
||||
@interface CefFilterDelegate : NSObject {
|
||||
@private
|
||||
NSSavePanel* panel_;
|
||||
std::vector<std::vector<base::string16> > extensions_;
|
||||
std::vector<std::vector<base::string16>> extensions_;
|
||||
int selected_index_;
|
||||
}
|
||||
- (id)initWithPanel:(NSSavePanel*)panel
|
||||
andAcceptFilters:(const std::vector<base::string16>&)accept_filters
|
||||
andFilterIndex:(int)index;
|
||||
andAcceptFilters:(const std::vector<base::string16>&)accept_filters
|
||||
andFilterIndex:(int)index;
|
||||
- (void)setFilter:(int)index;
|
||||
- (int)filter;
|
||||
- (void)filterSelectionChanged:(id)sender;
|
||||
@@ -146,14 +144,14 @@ void AddFilters(NSPopUpButton *button,
|
||||
@implementation CefFilterDelegate
|
||||
|
||||
- (id)initWithPanel:(NSSavePanel*)panel
|
||||
andAcceptFilters:(const std::vector<base::string16>&)accept_filters
|
||||
andFilterIndex:(int)index {
|
||||
andAcceptFilters:(const std::vector<base::string16>&)accept_filters
|
||||
andFilterIndex:(int)index {
|
||||
if (self = [super init]) {
|
||||
DCHECK(panel);
|
||||
panel_ = panel;
|
||||
selected_index_ = 0;
|
||||
|
||||
NSPopUpButton *button = [[NSPopUpButton alloc] init];
|
||||
NSPopUpButton* button = [[NSPopUpButton alloc] init];
|
||||
AddFilters(button, accept_filters, true, &extensions_);
|
||||
[button sizeToFit];
|
||||
[button setTarget:self];
|
||||
@@ -181,8 +179,8 @@ void AddFilters(NSPopUpButton *button,
|
||||
if (!extensions_[index].empty()) {
|
||||
acceptArray = [[NSMutableArray alloc] init];
|
||||
for (size_t i = 0; i < extensions_[index].size(); ++i) {
|
||||
[acceptArray addObject:
|
||||
base::SysUTF16ToNSString(extensions_[index][i].substr(1))];
|
||||
[acceptArray
|
||||
addObject:base::SysUTF16ToNSString(extensions_[index][i].substr(1))];
|
||||
}
|
||||
}
|
||||
[panel_ setAllowedFileTypes:acceptArray];
|
||||
@@ -200,7 +198,7 @@ void AddFilters(NSPopUpButton *button,
|
||||
|
||||
// Called when the selected filter is changed via the NSPopUpButton.
|
||||
- (void)filterSelectionChanged:(id)sender {
|
||||
NSPopUpButton *button = (NSPopUpButton*)sender;
|
||||
NSPopUpButton* button = (NSPopUpButton*)sender;
|
||||
[self setFilter:[button indexOfSelectedItem]];
|
||||
}
|
||||
|
||||
@@ -233,11 +231,10 @@ void AddFilters(NSPopUpButton *button,
|
||||
|
||||
namespace {
|
||||
|
||||
void RunOpenFileDialog(
|
||||
const CefFileDialogRunner::FileChooserParams& params,
|
||||
NSView* view,
|
||||
int filter_index,
|
||||
CefFileDialogRunner::RunFileChooserCallback callback) {
|
||||
void RunOpenFileDialog(const CefFileDialogRunner::FileChooserParams& params,
|
||||
NSView* view,
|
||||
int filter_index,
|
||||
CefFileDialogRunner::RunFileChooserCallback callback) {
|
||||
NSOpenPanel* openPanel = [NSOpenPanel openPanel];
|
||||
|
||||
base::string16 title;
|
||||
@@ -245,10 +242,11 @@ void RunOpenFileDialog(
|
||||
title = params.title;
|
||||
} else {
|
||||
title = l10n_util::GetStringUTF16(
|
||||
params.mode == content::FileChooserParams::Open ?
|
||||
IDS_OPEN_FILE_DIALOG_TITLE :
|
||||
(params.mode == content::FileChooserParams::OpenMultiple ?
|
||||
IDS_OPEN_FILES_DIALOG_TITLE : IDS_SELECT_FOLDER_DIALOG_TITLE));
|
||||
params.mode == content::FileChooserParams::Open
|
||||
? IDS_OPEN_FILE_DIALOG_TITLE
|
||||
: (params.mode == content::FileChooserParams::OpenMultiple
|
||||
? IDS_OPEN_FILES_DIALOG_TITLE
|
||||
: IDS_SELECT_FOLDER_DIALOG_TITLE));
|
||||
}
|
||||
[openPanel setTitle:base::SysUTF16ToNSString(title)];
|
||||
|
||||
@@ -268,8 +266,8 @@ void RunOpenFileDialog(
|
||||
[openPanel setNameFieldStringValue:base::SysUTF8ToNSString(filename)];
|
||||
}
|
||||
if (!directory.empty()) {
|
||||
[openPanel setDirectoryURL:
|
||||
[NSURL fileURLWithPath:base::SysUTF8ToNSString(directory)]];
|
||||
[openPanel setDirectoryURL:[NSURL fileURLWithPath:base::SysUTF8ToNSString(
|
||||
directory)]];
|
||||
}
|
||||
|
||||
CefFilterDelegate* filter_delegate = nil;
|
||||
@@ -284,38 +282,42 @@ void RunOpenFileDialog(
|
||||
|
||||
// Further panel configuration.
|
||||
[openPanel setAllowsOtherFileTypes:YES];
|
||||
[openPanel setAllowsMultipleSelection:
|
||||
(params.mode == content::FileChooserParams::OpenMultiple)];
|
||||
[openPanel setCanChooseFiles:
|
||||
(params.mode != content::FileChooserParams::UploadFolder)];
|
||||
[openPanel setCanChooseDirectories:
|
||||
(params.mode == content::FileChooserParams::UploadFolder)];
|
||||
[openPanel
|
||||
setAllowsMultipleSelection:(params.mode ==
|
||||
content::FileChooserParams::OpenMultiple)];
|
||||
[openPanel setCanChooseFiles:(params.mode !=
|
||||
content::FileChooserParams::UploadFolder)];
|
||||
[openPanel
|
||||
setCanChooseDirectories:(params.mode ==
|
||||
content::FileChooserParams::UploadFolder)];
|
||||
[openPanel setShowsHiddenFiles:!params.hidereadonly];
|
||||
|
||||
// Show panel.
|
||||
[openPanel beginSheetModalForWindow:[view window]
|
||||
completionHandler:^(NSInteger returnCode) {
|
||||
int filter_index_to_use =
|
||||
(filter_delegate != nil) ? [filter_delegate filter] : filter_index;
|
||||
if (returnCode == NSFileHandlingPanelOKButton) {
|
||||
std::vector<base::FilePath> files;
|
||||
files.reserve(openPanel.URLs.count);
|
||||
for (NSURL* url in openPanel.URLs) {
|
||||
if (url.isFileURL)
|
||||
files.push_back(base::FilePath(url.path.UTF8String));
|
||||
}
|
||||
callback.Run(filter_index_to_use, files);
|
||||
} else {
|
||||
callback.Run(filter_index_to_use, std::vector<base::FilePath>());
|
||||
}
|
||||
}];
|
||||
[openPanel
|
||||
beginSheetModalForWindow:[view window]
|
||||
completionHandler:^(NSInteger returnCode) {
|
||||
int filter_index_to_use = (filter_delegate != nil)
|
||||
? [filter_delegate filter]
|
||||
: filter_index;
|
||||
if (returnCode == NSFileHandlingPanelOKButton) {
|
||||
std::vector<base::FilePath> files;
|
||||
files.reserve(openPanel.URLs.count);
|
||||
for (NSURL* url in openPanel.URLs) {
|
||||
if (url.isFileURL)
|
||||
files.push_back(base::FilePath(url.path.UTF8String));
|
||||
}
|
||||
callback.Run(filter_index_to_use, files);
|
||||
} else {
|
||||
callback.Run(filter_index_to_use,
|
||||
std::vector<base::FilePath>());
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
void RunSaveFileDialog(
|
||||
const CefFileDialogRunner::FileChooserParams& params,
|
||||
NSView* view,
|
||||
int filter_index,
|
||||
CefFileDialogRunner::RunFileChooserCallback callback) {
|
||||
void RunSaveFileDialog(const CefFileDialogRunner::FileChooserParams& params,
|
||||
NSView* view,
|
||||
int filter_index,
|
||||
CefFileDialogRunner::RunFileChooserCallback callback) {
|
||||
NSSavePanel* savePanel = [NSSavePanel savePanel];
|
||||
|
||||
base::string16 title;
|
||||
@@ -340,8 +342,8 @@ void RunSaveFileDialog(
|
||||
[savePanel setNameFieldStringValue:base::SysUTF8ToNSString(filename)];
|
||||
}
|
||||
if (!directory.empty()) {
|
||||
[savePanel setDirectoryURL:
|
||||
[NSURL fileURLWithPath:base::SysUTF8ToNSString(directory)]];
|
||||
[savePanel setDirectoryURL:[NSURL fileURLWithPath:base::SysUTF8ToNSString(
|
||||
directory)]];
|
||||
}
|
||||
|
||||
CefFilterDelegate* filter_delegate = nil;
|
||||
@@ -357,25 +359,27 @@ void RunSaveFileDialog(
|
||||
[savePanel setShowsHiddenFiles:!params.hidereadonly];
|
||||
|
||||
// Show panel.
|
||||
[savePanel beginSheetModalForWindow:view.window
|
||||
completionHandler:^(NSInteger resultCode) {
|
||||
int filter_index_to_use =
|
||||
(filter_delegate != nil) ? [filter_delegate filter] : filter_index;
|
||||
if (resultCode == NSFileHandlingPanelOKButton) {
|
||||
NSURL* url = savePanel.URL;
|
||||
const char* path = url.path.UTF8String;
|
||||
std::vector<base::FilePath> files(1, base::FilePath(path));
|
||||
callback.Run(filter_index_to_use, files);
|
||||
} else {
|
||||
callback.Run(filter_index_to_use, std::vector<base::FilePath>());
|
||||
}
|
||||
}];
|
||||
[savePanel
|
||||
beginSheetModalForWindow:view.window
|
||||
completionHandler:^(NSInteger resultCode) {
|
||||
int filter_index_to_use = (filter_delegate != nil)
|
||||
? [filter_delegate filter]
|
||||
: filter_index;
|
||||
if (resultCode == NSFileHandlingPanelOKButton) {
|
||||
NSURL* url = savePanel.URL;
|
||||
const char* path = url.path.UTF8String;
|
||||
std::vector<base::FilePath> files(1, base::FilePath(path));
|
||||
callback.Run(filter_index_to_use, files);
|
||||
} else {
|
||||
callback.Run(filter_index_to_use,
|
||||
std::vector<base::FilePath>());
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
CefFileDialogRunnerMac::CefFileDialogRunnerMac() {
|
||||
}
|
||||
CefFileDialogRunnerMac::CefFileDialogRunnerMac() {}
|
||||
|
||||
void CefFileDialogRunnerMac::Run(CefBrowserHostImpl* browser,
|
||||
const FileChooserParams& params,
|
||||
@@ -389,7 +393,7 @@ void CefFileDialogRunnerMac::Run(CefBrowserHostImpl* browser,
|
||||
RunOpenFileDialog(params, owner, filter_index, callback);
|
||||
} else if (params.mode == content::FileChooserParams::Save) {
|
||||
RunSaveFileDialog(params, owner, filter_index, callback);
|
||||
} else {
|
||||
} else {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
}
|
||||
|
@@ -66,8 +66,8 @@ std::wstring FormatFilterForExtensions(
|
||||
bool include_all_files) {
|
||||
const std::wstring all_ext = L"*.*";
|
||||
const std::wstring all_desc =
|
||||
l10n_util::GetStringUTF16(IDS_APP_SAVEAS_ALL_FILES) +
|
||||
L" (" + all_ext + L")";
|
||||
l10n_util::GetStringUTF16(IDS_APP_SAVEAS_ALL_FILES) + L" (" + all_ext +
|
||||
L")";
|
||||
|
||||
DCHECK(file_ext.size() >= ext_desc.size());
|
||||
|
||||
@@ -132,10 +132,10 @@ std::wstring GetDescriptionFromMimeType(const std::string& mime_type) {
|
||||
const char* mime_type;
|
||||
int string_id;
|
||||
} kWildCardMimeTypes[] = {
|
||||
{ "audio", IDS_AUDIO_FILES },
|
||||
{ "image", IDS_IMAGE_FILES },
|
||||
{ "text", IDS_TEXT_FILES },
|
||||
{ "video", IDS_VIDEO_FILES },
|
||||
{"audio", IDS_AUDIO_FILES},
|
||||
{"image", IDS_IMAGE_FILES},
|
||||
{"text", IDS_TEXT_FILES},
|
||||
{"video", IDS_VIDEO_FILES},
|
||||
};
|
||||
|
||||
for (size_t i = 0; i < arraysize(kWildCardMimeTypes); ++i) {
|
||||
@@ -160,11 +160,9 @@ std::wstring GetFilterString(
|
||||
if (sep_index != base::string16::npos) {
|
||||
// Treat as a filter of the form "Filter Name|.ext1;.ext2;.ext3".
|
||||
const base::string16& desc = filter.substr(0, sep_index);
|
||||
const std::vector<base::string16>& ext =
|
||||
base::SplitString(filter.substr(sep_index + 1),
|
||||
base::ASCIIToUTF16(";"),
|
||||
base::TRIM_WHITESPACE,
|
||||
base::SPLIT_WANT_NONEMPTY);
|
||||
const std::vector<base::string16>& ext = base::SplitString(
|
||||
filter.substr(sep_index + 1), base::ASCIIToUTF16(";"),
|
||||
base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
|
||||
std::wstring ext_str;
|
||||
for (size_t x = 0; x < ext.size(); ++x) {
|
||||
const base::string16& file_ext = ext[x];
|
||||
@@ -205,11 +203,10 @@ std::wstring GetFilterString(
|
||||
|
||||
// From chrome/browser/views/shell_dialogs_win.cc
|
||||
|
||||
bool RunOpenFileDialog(
|
||||
const CefFileDialogRunner::FileChooserParams& params,
|
||||
HWND owner,
|
||||
int* filter_index,
|
||||
base::FilePath* path) {
|
||||
bool RunOpenFileDialog(const CefFileDialogRunner::FileChooserParams& params,
|
||||
HWND owner,
|
||||
int* filter_index,
|
||||
base::FilePath* path) {
|
||||
OPENFILENAME ofn;
|
||||
|
||||
// We must do this otherwise the ofn's FlagsEx may be initialized to random
|
||||
@@ -231,7 +228,7 @@ bool RunOpenFileDialog(
|
||||
} else {
|
||||
// The value is a file name and possibly a directory.
|
||||
base::wcslcpy(filename, params.default_file_name.value().c_str(),
|
||||
arraysize(filename));
|
||||
arraysize(filename));
|
||||
directory = params.default_file_name.DirName().value();
|
||||
}
|
||||
}
|
||||
@@ -248,8 +245,8 @@ bool RunOpenFileDialog(
|
||||
|
||||
// We use OFN_NOCHANGEDIR so that the user can rename or delete the directory
|
||||
// without having to close Chrome first.
|
||||
ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR | OFN_EXPLORER |
|
||||
OFN_ENABLESIZING;
|
||||
ofn.Flags =
|
||||
OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR | OFN_EXPLORER | OFN_ENABLESIZING;
|
||||
if (params.hidereadonly)
|
||||
ofn.Flags |= OFN_HIDEREADONLY;
|
||||
|
||||
@@ -358,8 +355,7 @@ bool RunOpenMultiFileDialog(
|
||||
int CALLBACK BrowseCallbackProc(HWND window,
|
||||
UINT message,
|
||||
LPARAM parameter,
|
||||
LPARAM data)
|
||||
{
|
||||
LPARAM data) {
|
||||
if (message == BFFM_INITIALIZED) {
|
||||
// WParam is TRUE since passing a path.
|
||||
// data lParam member of the BROWSEINFO structure.
|
||||
@@ -368,10 +364,9 @@ int CALLBACK BrowseCallbackProc(HWND window,
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool RunOpenFolderDialog(
|
||||
const CefFileDialogRunner::FileChooserParams& params,
|
||||
HWND owner,
|
||||
base::FilePath* path) {
|
||||
bool RunOpenFolderDialog(const CefFileDialogRunner::FileChooserParams& params,
|
||||
HWND owner,
|
||||
base::FilePath* path) {
|
||||
wchar_t dir_buffer[MAX_PATH + 1] = {0};
|
||||
|
||||
bool result = false;
|
||||
@@ -423,11 +418,10 @@ bool RunOpenFolderDialog(
|
||||
return result;
|
||||
}
|
||||
|
||||
bool RunSaveFileDialog(
|
||||
const CefFileDialogRunner::FileChooserParams& params,
|
||||
HWND owner,
|
||||
int* filter_index,
|
||||
base::FilePath* path) {
|
||||
bool RunSaveFileDialog(const CefFileDialogRunner::FileChooserParams& params,
|
||||
HWND owner,
|
||||
int* filter_index,
|
||||
base::FilePath* path) {
|
||||
OPENFILENAME ofn;
|
||||
|
||||
// We must do this otherwise the ofn's FlagsEx may be initialized to random
|
||||
@@ -449,7 +443,7 @@ bool RunSaveFileDialog(
|
||||
} else {
|
||||
// The value is a file name and possibly a directory.
|
||||
base::wcslcpy(filename, params.default_file_name.value().c_str(),
|
||||
arraysize(filename));
|
||||
arraysize(filename));
|
||||
directory = params.default_file_name.DirName().value();
|
||||
}
|
||||
}
|
||||
@@ -466,8 +460,8 @@ bool RunSaveFileDialog(
|
||||
|
||||
// We use OFN_NOCHANGEDIR so that the user can rename or delete the directory
|
||||
// without having to close Chrome first.
|
||||
ofn.Flags = OFN_EXPLORER | OFN_ENABLESIZING | OFN_NOCHANGEDIR |
|
||||
OFN_PATHMUSTEXIST;
|
||||
ofn.Flags =
|
||||
OFN_EXPLORER | OFN_ENABLESIZING | OFN_NOCHANGEDIR | OFN_PATHMUSTEXIST;
|
||||
if (params.hidereadonly)
|
||||
ofn.Flags |= OFN_HIDEREADONLY;
|
||||
if (params.overwriteprompt)
|
||||
@@ -493,8 +487,7 @@ bool RunSaveFileDialog(
|
||||
|
||||
} // namespace
|
||||
|
||||
CefFileDialogRunnerWin::CefFileDialogRunnerWin() {
|
||||
}
|
||||
CefFileDialogRunnerWin::CefFileDialogRunnerWin() {}
|
||||
|
||||
void CefFileDialogRunnerWin::Run(CefBrowserHostImpl* browser,
|
||||
const FileChooserParams& params,
|
||||
|
@@ -24,18 +24,16 @@ class CefJavaScriptDialogRunnerMac : public CefJavaScriptDialogRunner {
|
||||
~CefJavaScriptDialogRunnerMac() override;
|
||||
|
||||
// CefJavaScriptDialogRunner methods:
|
||||
void Run(
|
||||
CefBrowserHostImpl* browser,
|
||||
content::JavaScriptDialogType message_type,
|
||||
const base::string16& display_url,
|
||||
const base::string16& message_text,
|
||||
const base::string16& default_prompt_text,
|
||||
const DialogClosedCallback& callback) override;
|
||||
void Run(CefBrowserHostImpl* browser,
|
||||
content::JavaScriptDialogType message_type,
|
||||
const base::string16& display_url,
|
||||
const base::string16& message_text,
|
||||
const base::string16& default_prompt_text,
|
||||
const DialogClosedCallback& callback) override;
|
||||
void Cancel() override;
|
||||
|
||||
// Callback from CefJavaScriptDialogHelper when the dialog is closed.
|
||||
void DialogClosed(bool success,
|
||||
const base::string16& user_input);
|
||||
void DialogClosed(bool success, const base::string16& user_input);
|
||||
|
||||
private:
|
||||
DialogClosedCallback callback_;
|
||||
|
@@ -23,7 +23,7 @@
|
||||
}
|
||||
|
||||
- (id)initHelperWithCallback:
|
||||
(CefJavaScriptDialogRunner::DialogClosedCallback)callback;
|
||||
(CefJavaScriptDialogRunner::DialogClosedCallback)callback;
|
||||
- (NSAlert*)alert;
|
||||
- (NSTextField*)textField;
|
||||
- (void)alertDidEnd:(NSAlert*)alert
|
||||
@@ -36,7 +36,7 @@
|
||||
@implementation CefJavaScriptDialogHelper
|
||||
|
||||
- (id)initHelperWithCallback:
|
||||
(CefJavaScriptDialogRunner::DialogClosedCallback)callback {
|
||||
(CefJavaScriptDialogRunner::DialogClosedCallback)callback {
|
||||
if (self = [super init])
|
||||
callback_ = callback;
|
||||
|
||||
@@ -80,8 +80,7 @@
|
||||
@end
|
||||
|
||||
CefJavaScriptDialogRunnerMac::CefJavaScriptDialogRunnerMac()
|
||||
: weak_ptr_factory_(this) {
|
||||
}
|
||||
: weak_ptr_factory_(this) {}
|
||||
|
||||
CefJavaScriptDialogRunnerMac::~CefJavaScriptDialogRunnerMac() {
|
||||
Cancel();
|
||||
@@ -97,15 +96,13 @@ void CefJavaScriptDialogRunnerMac::Run(
|
||||
DCHECK(!helper_.get());
|
||||
callback_ = callback;
|
||||
|
||||
bool text_field =
|
||||
message_type == content::JAVASCRIPT_DIALOG_TYPE_PROMPT;
|
||||
bool one_button =
|
||||
message_type == content::JAVASCRIPT_DIALOG_TYPE_ALERT;
|
||||
bool text_field = message_type == content::JAVASCRIPT_DIALOG_TYPE_PROMPT;
|
||||
bool one_button = message_type == content::JAVASCRIPT_DIALOG_TYPE_ALERT;
|
||||
|
||||
helper_.reset(
|
||||
[[CefJavaScriptDialogHelper alloc] initHelperWithCallback:
|
||||
base::Bind(&CefJavaScriptDialogRunnerMac::DialogClosed,
|
||||
weak_ptr_factory_.GetWeakPtr())]);
|
||||
helper_.reset([[CefJavaScriptDialogHelper alloc]
|
||||
initHelperWithCallback:base::Bind(
|
||||
&CefJavaScriptDialogRunnerMac::DialogClosed,
|
||||
weak_ptr_factory_.GetWeakPtr())]);
|
||||
|
||||
// Show the modal dialog.
|
||||
NSAlert* alert = [helper_ alert];
|
||||
@@ -145,11 +142,10 @@ void CefJavaScriptDialogRunnerMac::Run(
|
||||
// building with the 10.11 SDK. See http://crbug.com/383820 for related
|
||||
// discussion.
|
||||
id nilArg = nil;
|
||||
[alert
|
||||
beginSheetModalForWindow:nilArg // nil here makes it app-modal
|
||||
modalDelegate:helper_
|
||||
didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:)
|
||||
contextInfo:this];
|
||||
[alert beginSheetModalForWindow:nilArg // nil here makes it app-modal
|
||||
modalDelegate:helper_
|
||||
didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:)
|
||||
contextInfo:this];
|
||||
|
||||
if ([alert accessoryView])
|
||||
[[alert window] makeFirstResponder:[alert accessoryView]];
|
||||
|
@@ -18,8 +18,10 @@ class CefJavaScriptDialogRunnerWin;
|
||||
HHOOK CefJavaScriptDialogRunnerWin::msg_hook_ = NULL;
|
||||
int CefJavaScriptDialogRunnerWin::msg_hook_user_count_ = 0;
|
||||
|
||||
INT_PTR CALLBACK CefJavaScriptDialogRunnerWin::DialogProc(
|
||||
HWND dialog, UINT message, WPARAM wparam, LPARAM lparam) {
|
||||
INT_PTR CALLBACK CefJavaScriptDialogRunnerWin::DialogProc(HWND dialog,
|
||||
UINT message,
|
||||
WPARAM wparam,
|
||||
LPARAM lparam) {
|
||||
switch (message) {
|
||||
case WM_INITDIALOG: {
|
||||
SetWindowLongPtr(dialog, DWLP_USER, static_cast<LONG_PTR>(lparam));
|
||||
@@ -84,10 +86,7 @@ INT_PTR CALLBACK CefJavaScriptDialogRunnerWin::DialogProc(
|
||||
}
|
||||
|
||||
CefJavaScriptDialogRunnerWin::CefJavaScriptDialogRunnerWin()
|
||||
: dialog_win_(NULL),
|
||||
parent_win_(NULL),
|
||||
hook_installed_(false) {
|
||||
}
|
||||
: dialog_win_(NULL), parent_win_(NULL), hook_installed_(false) {}
|
||||
|
||||
CefJavaScriptDialogRunnerWin::~CefJavaScriptDialogRunnerWin() {
|
||||
Cancel();
|
||||
@@ -129,17 +128,15 @@ void CefJavaScriptDialogRunnerWin::Run(
|
||||
DCHECK(hModule);
|
||||
|
||||
parent_win_ = GetAncestor(browser->GetWindowHandle(), GA_ROOT);
|
||||
dialog_win_ = CreateDialogParam(hModule,
|
||||
MAKEINTRESOURCE(dialog_type),
|
||||
parent_win_,
|
||||
DialogProc,
|
||||
reinterpret_cast<LPARAM>(this));
|
||||
dialog_win_ =
|
||||
CreateDialogParam(hModule, MAKEINTRESOURCE(dialog_type), parent_win_,
|
||||
DialogProc, reinterpret_cast<LPARAM>(this));
|
||||
DCHECK(dialog_win_);
|
||||
|
||||
if (!display_url.empty()) {
|
||||
// Add the display URL to the window title.
|
||||
TCHAR text[64];
|
||||
GetWindowText(dialog_win_, text, sizeof(text)/sizeof(TCHAR));
|
||||
GetWindowText(dialog_win_, text, sizeof(text) / sizeof(TCHAR));
|
||||
|
||||
base::string16 new_window_text =
|
||||
text + base::ASCIIToUTF16(" - ") + display_url;
|
||||
@@ -181,13 +178,14 @@ void CefJavaScriptDialogRunnerWin::Cancel() {
|
||||
}
|
||||
|
||||
// static
|
||||
LRESULT CALLBACK CefJavaScriptDialogRunnerWin::GetMsgProc(
|
||||
int code, WPARAM wparam, LPARAM lparam) {
|
||||
LRESULT CALLBACK CefJavaScriptDialogRunnerWin::GetMsgProc(int code,
|
||||
WPARAM wparam,
|
||||
LPARAM lparam) {
|
||||
// Mostly borrowed from http://support.microsoft.com/kb/q187988/
|
||||
// and http://www.codeproject.com/KB/atl/cdialogmessagehook.aspx.
|
||||
LPMSG msg = reinterpret_cast<LPMSG>(lparam);
|
||||
if (code >= 0 && wparam == PM_REMOVE &&
|
||||
msg->message >= WM_KEYFIRST && msg->message <= WM_KEYLAST) {
|
||||
if (code >= 0 && wparam == PM_REMOVE && msg->message >= WM_KEYFIRST &&
|
||||
msg->message <= WM_KEYLAST) {
|
||||
HWND hwnd = GetActiveWindow();
|
||||
if (::IsWindow(hwnd) && ::IsDialogMessage(hwnd, msg)) {
|
||||
// The value returned from this hookproc is ignored, and it cannot
|
||||
@@ -216,8 +214,7 @@ bool CefJavaScriptDialogRunnerWin::InstallMessageHook() {
|
||||
|
||||
msg_hook_ = ::SetWindowsHookEx(WH_GETMESSAGE,
|
||||
&CefJavaScriptDialogRunnerWin::GetMsgProc,
|
||||
NULL,
|
||||
GetCurrentThreadId());
|
||||
NULL, GetCurrentThreadId());
|
||||
DCHECK(msg_hook_ != NULL);
|
||||
return msg_hook_ != NULL;
|
||||
}
|
||||
|
@@ -15,13 +15,12 @@ class CefJavaScriptDialogRunnerWin : public CefJavaScriptDialogRunner {
|
||||
~CefJavaScriptDialogRunnerWin() override;
|
||||
|
||||
// CefJavaScriptDialogRunner methods:
|
||||
void Run(
|
||||
CefBrowserHostImpl* browser,
|
||||
content::JavaScriptDialogType message_type,
|
||||
const base::string16& display_url,
|
||||
const base::string16& message_text,
|
||||
const base::string16& default_prompt_text,
|
||||
const DialogClosedCallback& callback) override;
|
||||
void Run(CefBrowserHostImpl* browser,
|
||||
content::JavaScriptDialogType message_type,
|
||||
const base::string16& display_url,
|
||||
const base::string16& message_text,
|
||||
const base::string16& default_prompt_text,
|
||||
const DialogClosedCallback& callback) override;
|
||||
void Cancel() override;
|
||||
|
||||
private:
|
||||
@@ -35,7 +34,9 @@ class CefJavaScriptDialogRunnerWin : public CefJavaScriptDialogRunner {
|
||||
|
||||
bool hook_installed_;
|
||||
|
||||
static INT_PTR CALLBACK DialogProc(HWND dialog, UINT message, WPARAM wparam,
|
||||
static INT_PTR CALLBACK DialogProc(HWND dialog,
|
||||
UINT message,
|
||||
WPARAM wparam,
|
||||
LPARAM lparam);
|
||||
|
||||
// Since the message loop we expect to run in isn't going to be nicely
|
||||
|
@@ -10,8 +10,7 @@
|
||||
namespace views {
|
||||
|
||||
Menu2::Menu2(ui::MenuModel* model)
|
||||
: model_(model),
|
||||
wrapper_(MenuWrapper::CreateWrapper(model)) {
|
||||
: model_(model), wrapper_(MenuWrapper::CreateWrapper(model)) {
|
||||
Rebuild();
|
||||
}
|
||||
|
||||
|
@@ -31,10 +31,7 @@ class Menu2 {
|
||||
public:
|
||||
// How the menu is aligned relative to the point it is shown at.
|
||||
// The alignment is reversed by menu if text direction is right to left.
|
||||
enum Alignment {
|
||||
ALIGN_TOPLEFT,
|
||||
ALIGN_TOPRIGHT
|
||||
};
|
||||
enum Alignment { ALIGN_TOPLEFT, ALIGN_TOPRIGHT };
|
||||
|
||||
// Creates a new menu populated with the contents of |model|.
|
||||
// WARNING: this populates the menu on construction by invoking methods on
|
||||
@@ -83,7 +80,6 @@ class Menu2 {
|
||||
void SetMinimumWidth(int width);
|
||||
|
||||
private:
|
||||
|
||||
ui::MenuModel* model_;
|
||||
|
||||
// The object that actually implements the menu.
|
||||
|
@@ -10,8 +10,7 @@
|
||||
#include "base/strings/string_util.h"
|
||||
#include "ui/gfx/geometry/point.h"
|
||||
|
||||
CefMenuRunnerLinux::CefMenuRunnerLinux() {
|
||||
}
|
||||
CefMenuRunnerLinux::CefMenuRunnerLinux() {}
|
||||
|
||||
bool CefMenuRunnerLinux::RunContextMenu(
|
||||
CefBrowserHostImpl* browser,
|
||||
@@ -27,11 +26,9 @@ bool CefMenuRunnerLinux::RunContextMenu(
|
||||
if (!browser->IsWindowless())
|
||||
parent_widget = browser->GetWindowWidget();
|
||||
|
||||
views::MenuRunner::RunResult result =
|
||||
menu_->RunMenuAt(parent_widget,
|
||||
NULL, gfx::Rect(screen_point, gfx::Size()),
|
||||
views::MENU_ANCHOR_TOPRIGHT,
|
||||
ui::MENU_SOURCE_NONE);
|
||||
views::MenuRunner::RunResult result = menu_->RunMenuAt(
|
||||
parent_widget, NULL, gfx::Rect(screen_point, gfx::Size()),
|
||||
views::MENU_ANCHOR_TOPRIGHT, ui::MENU_SOURCE_NONE);
|
||||
ALLOW_UNUSED_LOCAL(result);
|
||||
|
||||
return true;
|
||||
|
@@ -10,7 +10,7 @@
|
||||
|
||||
#include "ui/views/controls/menu/menu_runner.h"
|
||||
|
||||
class CefMenuRunnerLinux: public CefMenuRunner {
|
||||
class CefMenuRunnerLinux : public CefMenuRunner {
|
||||
public:
|
||||
CefMenuRunnerLinux();
|
||||
|
||||
|
@@ -6,17 +6,15 @@
|
||||
|
||||
#include "libcef/browser/browser_host_impl.h"
|
||||
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/compiler_specific.h"
|
||||
#import "base/mac/scoped_sending_event.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#import "ui/base/cocoa/menu_controller.h"
|
||||
#include "ui/gfx/geometry/point.h"
|
||||
|
||||
CefMenuRunnerMac::CefMenuRunnerMac() {
|
||||
}
|
||||
CefMenuRunnerMac::CefMenuRunnerMac() {}
|
||||
|
||||
CefMenuRunnerMac::~CefMenuRunnerMac() {
|
||||
}
|
||||
CefMenuRunnerMac::~CefMenuRunnerMac() {}
|
||||
|
||||
bool CefMenuRunnerMac::RunContextMenu(
|
||||
CefBrowserHostImpl* browser,
|
||||
@@ -88,4 +86,3 @@ void CefMenuRunnerMac::CancelContextMenu() {
|
||||
if (menu_controller_.get())
|
||||
[menu_controller_ cancel];
|
||||
}
|
||||
|
||||
|
@@ -10,8 +10,7 @@
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "ui/gfx/geometry/point.h"
|
||||
|
||||
CefMenuRunnerWin::CefMenuRunnerWin() {
|
||||
}
|
||||
CefMenuRunnerWin::CefMenuRunnerWin() {}
|
||||
|
||||
bool CefMenuRunnerWin::RunContextMenu(
|
||||
CefBrowserHostImpl* browser,
|
||||
|
@@ -10,7 +10,6 @@
|
||||
|
||||
#include "libcef/browser/native/native_menu_win.h"
|
||||
|
||||
|
||||
class CefMenuRunnerWin : public CefMenuRunner {
|
||||
public:
|
||||
CefMenuRunnerWin();
|
||||
|
@@ -57,7 +57,10 @@ namespace {
|
||||
// HDC to back the canvas if one doesn't already exist, tearing it down
|
||||
// before returning. If |src_rect| is null, copies the entire canvas.
|
||||
// Deleted from skia/ext/platform_canvas.h in https://crbug.com/675977#c13
|
||||
void DrawToNativeContext(SkCanvas* canvas, HDC destination_hdc, int x, int y,
|
||||
void DrawToNativeContext(SkCanvas* canvas,
|
||||
HDC destination_hdc,
|
||||
int x,
|
||||
int y,
|
||||
const RECT* src_rect) {
|
||||
RECT temp_rect;
|
||||
if (!src_rect) {
|
||||
@@ -111,9 +114,7 @@ class CefNativeMenuWin::MenuHostWindow {
|
||||
gfx::SetWindowUserData(hwnd_, this);
|
||||
}
|
||||
|
||||
~MenuHostWindow() {
|
||||
DestroyWindow(hwnd_);
|
||||
}
|
||||
~MenuHostWindow() { DestroyWindow(hwnd_); }
|
||||
|
||||
HWND hwnd() const { return hwnd_; }
|
||||
|
||||
@@ -127,17 +128,9 @@ class CefNativeMenuWin::MenuHostWindow {
|
||||
|
||||
WNDCLASSEX window_class;
|
||||
base::win::InitializeWindowClass(
|
||||
kWindowClassName,
|
||||
&base::win::WrappedWindowProc<MenuHostWindowProc>,
|
||||
CS_DBLCLKS,
|
||||
0,
|
||||
0,
|
||||
NULL,
|
||||
reinterpret_cast<HBRUSH>(COLOR_WINDOW+1),
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&window_class);
|
||||
kWindowClassName, &base::win::WrappedWindowProc<MenuHostWindowProc>,
|
||||
CS_DBLCLKS, 0, 0, NULL, reinterpret_cast<HBRUSH>(COLOR_WINDOW + 1),
|
||||
NULL, NULL, NULL, &window_class);
|
||||
ATOM clazz = RegisterClassEx(&window_class);
|
||||
CHECK(clazz);
|
||||
registered = true;
|
||||
@@ -201,8 +194,8 @@ class CefNativeMenuWin::MenuHostWindow {
|
||||
if (data) {
|
||||
gfx::FontList font_list;
|
||||
measure_item_struct->itemWidth =
|
||||
gfx::GetStringWidth(data->label, font_list) +
|
||||
kIconWidth + kItemLeftMargin + views::kItemLabelSpacing -
|
||||
gfx::GetStringWidth(data->label, font_list) + kIconWidth +
|
||||
kItemLeftMargin + views::kItemLabelSpacing -
|
||||
GetSystemMetrics(SM_CXMENUCHECK);
|
||||
if (data->submenu.get())
|
||||
measure_item_struct->itemWidth += kArrowWidth;
|
||||
@@ -275,8 +268,8 @@ class CefNativeMenuWin::MenuHostWindow {
|
||||
static_cast<int>(label.size()), &rect, format | DT_LEFT, NULL);
|
||||
if (!accel.empty())
|
||||
DrawTextEx(dc, const_cast<wchar_t*>(accel.data()),
|
||||
static_cast<int>(accel.size()), &rect,
|
||||
format | DT_RIGHT, NULL);
|
||||
static_cast<int>(accel.size()), &rect, format | DT_RIGHT,
|
||||
NULL);
|
||||
SelectObject(dc, old_font);
|
||||
|
||||
ui::MenuModel::ItemType type =
|
||||
@@ -293,10 +286,12 @@ class CefNativeMenuWin::MenuHostWindow {
|
||||
skia_icon.width(), skia_icon.height(), false);
|
||||
canvas->drawBitmap(*skia_icon.bitmap(), 0, 0);
|
||||
DrawToNativeContext(
|
||||
canvas.get(), 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);
|
||||
canvas.get(), 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);
|
||||
} else if (type == ui::MenuModel::TYPE_CHECK &&
|
||||
data->native_menu_win->model_->IsItemCheckedAt(
|
||||
data->model_index)) {
|
||||
@@ -306,8 +301,9 @@ class CefNativeMenuWin::MenuHostWindow {
|
||||
if (draw_item_struct->itemState & ODS_DISABLED) {
|
||||
state = NativeTheme::kDisabled;
|
||||
} else {
|
||||
state = draw_item_struct->itemState & ODS_SELECTED ?
|
||||
NativeTheme::kHovered : NativeTheme::kNormal;
|
||||
state = draw_item_struct->itemState & ODS_SELECTED
|
||||
? NativeTheme::kHovered
|
||||
: NativeTheme::kNormal;
|
||||
}
|
||||
|
||||
std::unique_ptr<SkCanvas> canvas = skia::CreatePlatformCanvas(
|
||||
@@ -321,17 +317,19 @@ class CefNativeMenuWin::MenuHostWindow {
|
||||
// Draw the background and the check.
|
||||
ui::NativeTheme* native_theme =
|
||||
ui::NativeTheme::GetInstanceForNativeUi();
|
||||
native_theme->Paint(
|
||||
&paint_canvas, NativeTheme::kMenuCheckBackground,
|
||||
state, bounds, extra);
|
||||
native_theme->Paint(
|
||||
&paint_canvas, NativeTheme::kMenuCheck, state, bounds, extra);
|
||||
native_theme->Paint(&paint_canvas, NativeTheme::kMenuCheckBackground,
|
||||
state, bounds, extra);
|
||||
native_theme->Paint(&paint_canvas, NativeTheme::kMenuCheck, state,
|
||||
bounds, extra);
|
||||
|
||||
// Draw checkbox to menu.
|
||||
DrawToNativeContext(canvas.get(), dc,
|
||||
draw_item_struct->rcItem.left + kItemLeftMargin,
|
||||
draw_item_struct->rcItem.top + (draw_item_struct->rcItem.bottom -
|
||||
draw_item_struct->rcItem.top - config.check_height) / 2, NULL);
|
||||
DrawToNativeContext(
|
||||
canvas.get(), dc, draw_item_struct->rcItem.left + kItemLeftMargin,
|
||||
draw_item_struct->rcItem.top +
|
||||
(draw_item_struct->rcItem.bottom -
|
||||
draw_item_struct->rcItem.top - config.check_height) /
|
||||
2,
|
||||
NULL);
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -367,7 +365,7 @@ class CefNativeMenuWin::MenuHostWindow {
|
||||
OnDrawItem(w_param, reinterpret_cast<DRAWITEMSTRUCT*>(l_param));
|
||||
*l_result = 0;
|
||||
return true;
|
||||
// TODO(beng): bring over owner draw from old menu system.
|
||||
// TODO(beng): bring over owner draw from old menu system.
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -395,11 +393,7 @@ class CefNativeMenuWin::MenuHostWindow {
|
||||
|
||||
struct CefNativeMenuWin::HighlightedMenuItemInfo {
|
||||
HighlightedMenuItemInfo()
|
||||
: has_parent(false),
|
||||
has_submenu(false),
|
||||
menu(NULL),
|
||||
position(-1) {
|
||||
}
|
||||
: has_parent(false), has_submenu(false), menu(NULL), position(-1) {}
|
||||
|
||||
bool has_parent;
|
||||
bool has_submenu;
|
||||
@@ -428,8 +422,7 @@ CefNativeMenuWin::CefNativeMenuWin(ui::MenuModel* model, HWND system_menu_for)
|
||||
position_to_select_(-1),
|
||||
parent_(NULL),
|
||||
destroyed_flag_(NULL),
|
||||
menu_to_select_factory_(this) {
|
||||
}
|
||||
menu_to_select_factory_(this) {}
|
||||
|
||||
CefNativeMenuWin::~CefNativeMenuWin() {
|
||||
if (destroyed_flag_)
|
||||
@@ -481,9 +474,8 @@ void CefNativeMenuWin::RunMenuAt(const gfx::Point& point, int alignment) {
|
||||
// does.
|
||||
menu_to_select_factory_.InvalidateWeakPtrs();
|
||||
base::ThreadTaskRunnerHandle::Get()->PostTask(
|
||||
FROM_HERE,
|
||||
base::Bind(&CefNativeMenuWin::DelayedSelect,
|
||||
menu_to_select_factory_.GetWeakPtr()));
|
||||
FROM_HERE, base::Bind(&CefNativeMenuWin::DelayedSelect,
|
||||
menu_to_select_factory_.GetWeakPtr()));
|
||||
menu_action_ = MENU_ACTION_SELECTED;
|
||||
}
|
||||
// Send MenuWillClose after we schedule the select, otherwise MenuWillClose is
|
||||
@@ -502,7 +494,7 @@ void CefNativeMenuWin::Rebuild(MenuInsertionDelegateWin* delegate) {
|
||||
owner_draw_ = model_->HasIcons() || owner_draw_;
|
||||
first_item_index_ = delegate ? delegate->GetInsertionIndex(menu_) : 0;
|
||||
for (int menu_index = first_item_index_;
|
||||
menu_index < first_item_index_ + model_->GetItemCount(); ++menu_index) {
|
||||
menu_index < first_item_index_ + model_->GetItemCount(); ++menu_index) {
|
||||
int model_index = menu_index - first_item_index_;
|
||||
if (model_->GetTypeAt(model_index) == ui::MenuModel::TYPE_SEPARATOR)
|
||||
AddSeparatorItemAt(menu_index, model_index);
|
||||
@@ -585,8 +577,9 @@ bool CefNativeMenuWin::GetHighlightedMenuItemInfo(
|
||||
}
|
||||
|
||||
// static
|
||||
LRESULT CALLBACK CefNativeMenuWin::MenuMessageHook(
|
||||
int n_code, WPARAM w_param, LPARAM l_param) {
|
||||
LRESULT CALLBACK CefNativeMenuWin::MenuMessageHook(int n_code,
|
||||
WPARAM w_param,
|
||||
LPARAM l_param) {
|
||||
LRESULT result = CallNextHookEx(NULL, n_code, w_param, l_param);
|
||||
|
||||
CefNativeMenuWin* this_ptr = open_native_menu_win_;
|
||||
@@ -685,8 +678,10 @@ void CefNativeMenuWin::AddSeparatorItemAt(int menu_index, int model_index) {
|
||||
InsertMenuItem(menu_, menu_index, TRUE, &mii);
|
||||
}
|
||||
|
||||
void CefNativeMenuWin::SetMenuItemState(
|
||||
int menu_index, bool enabled, bool checked, bool is_default) {
|
||||
void CefNativeMenuWin::SetMenuItemState(int menu_index,
|
||||
bool enabled,
|
||||
bool checked,
|
||||
bool is_default) {
|
||||
if (IsSeparatorItemAt(menu_index))
|
||||
return;
|
||||
|
||||
@@ -704,8 +699,8 @@ void CefNativeMenuWin::SetMenuItemState(
|
||||
}
|
||||
|
||||
void CefNativeMenuWin::SetMenuItemLabel(int menu_index,
|
||||
int model_index,
|
||||
const base::string16& label) {
|
||||
int model_index,
|
||||
const base::string16& label) {
|
||||
if (IsSeparatorItemAt(menu_index))
|
||||
return;
|
||||
|
||||
@@ -715,9 +710,10 @@ void CefNativeMenuWin::SetMenuItemLabel(int menu_index,
|
||||
SetMenuItemInfo(menu_, menu_index, MF_BYPOSITION, &mii);
|
||||
}
|
||||
|
||||
void CefNativeMenuWin::UpdateMenuItemInfoForString(MENUITEMINFO* mii,
|
||||
int model_index,
|
||||
const base::string16& label) {
|
||||
void CefNativeMenuWin::UpdateMenuItemInfoForString(
|
||||
MENUITEMINFO* mii,
|
||||
int model_index,
|
||||
const base::string16& label) {
|
||||
base::string16 formatted = label;
|
||||
ui::MenuModel::ItemType type = model_->GetTypeAt(model_index);
|
||||
// Strip out any tabs, otherwise they get interpreted as accelerators and can
|
||||
@@ -738,8 +734,7 @@ void CefNativeMenuWin::UpdateMenuItemInfoForString(MENUITEMINFO* mii,
|
||||
|
||||
// Give Windows a pointer to the label string.
|
||||
mii->fMask |= MIIM_STRING;
|
||||
mii->dwTypeData =
|
||||
const_cast<wchar_t*>(items_[model_index]->label.c_str());
|
||||
mii->dwTypeData = const_cast<wchar_t*>(items_[model_index]->label.c_str());
|
||||
}
|
||||
|
||||
UINT CefNativeMenuWin::GetAlignmentFlags(int alignment) const {
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user