Add geolocation support (issue #365).

git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/963@628 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt 2012-05-17 19:51:58 +00:00
parent e193688d10
commit 266f4e7a27
29 changed files with 1178 additions and 2 deletions

41
cef.gyp
View File

@ -501,6 +501,8 @@
'libcef_dll/cpptoc/drag_data_cpptoc.h',
'libcef_dll/cpptoc/frame_cpptoc.cc',
'libcef_dll/cpptoc/frame_cpptoc.h',
'libcef_dll/cpptoc/geolocation_callback_cpptoc.cc',
'libcef_dll/cpptoc/geolocation_callback_cpptoc.h',
'libcef_dll/cpptoc/post_data_cpptoc.cc',
'libcef_dll/cpptoc/post_data_cpptoc.h',
'libcef_dll/cpptoc/post_data_element_cpptoc.cc',
@ -552,6 +554,8 @@
'libcef_dll/ctocpp/find_handler_ctocpp.h',
'libcef_dll/ctocpp/focus_handler_ctocpp.cc',
'libcef_dll/ctocpp/focus_handler_ctocpp.h',
'libcef_dll/ctocpp/geolocation_handler_ctocpp.cc',
'libcef_dll/ctocpp/geolocation_handler_ctocpp.h',
'libcef_dll/ctocpp/jsdialog_handler_ctocpp.cc',
'libcef_dll/ctocpp/jsdialog_handler_ctocpp.h',
'libcef_dll/ctocpp/keyboard_handler_ctocpp.cc',
@ -623,6 +627,7 @@
'link_settings': {
'libraries': [
'-lcomctl32.lib',
'-llocationapi.lib',
],
},
'msvs_settings': {
@ -796,6 +801,7 @@
'libcef/browser_settings.h',
'libcef/browser_socket_stream_bridge.cc',
'libcef/browser_socket_stream_bridge.h',
'libcef/browser_thread_stub.cc',
'libcef/browser_webcookiejar_impl.cc',
'libcef/browser_webcookiejar_impl.h',
'libcef/browser_webblobregistry_impl.cc',
@ -857,6 +863,8 @@
'libcef/download_util.cc',
'libcef/download_util.h',
'libcef/external_protocol_handler.h',
'libcef/geolocation_client.cc',
'libcef/geolocation_client.h',
'libcef/http_header_utils.cc',
'libcef/http_header_utils.h',
'libcef/origin_whitelist_impl.cc',
@ -885,6 +893,19 @@
'libcef/zip_reader_impl.h',
# DevTools resource IDs generated by grit
'<(grit_out_dir)/grit/devtools_resources_map.cc',
# Geolocation implementation
'../content/browser/cancelable_request.cc',
'../content/browser/geolocation/access_token_store.cc',
'../content/browser/geolocation/device_data_provider.cc',
'../content/browser/geolocation/empty_device_data_provider.cc',
'../content/browser/geolocation/geolocation_provider.cc',
'../content/browser/geolocation/location_arbitrator.cc',
'../content/browser/geolocation/location_provider.cc',
'../content/browser/geolocation/network_location_provider.cc',
'../content/browser/geolocation/network_location_request.cc',
'../content/browser/geolocation/wifi_data_provider_common.cc',
'../content/common/geoposition.cc',
'../content/common/net/url_fetcher_impl.cc',
],
'conditions': [
['OS=="win"', {
@ -915,6 +936,11 @@
'libcef/web_drop_target_win.h',
'libcef/webview_host_win.cc',
'libcef/webwidget_host_win.cc',
# Geolocation implementation
'../content/browser/geolocation/wifi_data_provider_common_win.cc',
'../content/browser/geolocation/wifi_data_provider_win.cc',
'../content/browser/geolocation/win7_location_api_win.cc',
'../content/browser/geolocation/win7_location_provider_win.cc',
],
}],
[ 'OS=="mac"', {
@ -937,16 +963,25 @@
'libcef/web_drag_utils_mac.mm',
'libcef/web_drop_target_mac.h',
'libcef/web_drop_target_mac.mm',
# Build necessary Mozilla sources
# Necessary Mozilla sources
'../third_party/mozilla/NSPasteboard+Utils.h',
'../third_party/mozilla/NSPasteboard+Utils.mm',
'../third_party/mozilla/NSString+Utils.h',
'../third_party/mozilla/NSString+Utils.mm',
'../third_party/mozilla/NSURL+Utils.h',
'../third_party/mozilla/NSURL+Utils.m',
# Geolocation implementation
'../content/browser/geolocation/core_location_data_provider_mac.mm',
'../content/browser/geolocation/core_location_provider_mac.mm',
'../content/browser/geolocation/wifi_data_provider_corewlan_mac.mm',
'../content/browser/geolocation/wifi_data_provider_mac.cc',
],
}],
[ 'OS=="linux" or OS=="freebsd" or OS=="openbsd"', {
'dependencies': [
'../build/linux/system.gyp:dbus',
'../dbus/dbus.gyp:dbus',
],
'sources': [
'<@(includes_linux)',
'libcef/browser_impl_gtk.cc',
@ -956,6 +991,10 @@
'libcef/external_protocol_handler_gtk.cc',
'libcef/webview_host_gtk.cc',
'libcef/webwidget_host_gtk.cc',
# Geolocation implementation
'../content/browser/geolocation/gps_location_provider_linux.cc',
'../content/browser/geolocation/libgps_wrapper_linux.cc',
'../content/browser/geolocation/wifi_data_provider_linux.cc',
],
}],
],

View File

@ -158,6 +158,8 @@
'libcef_dll/cpptoc/find_handler_cpptoc.h',
'libcef_dll/cpptoc/focus_handler_cpptoc.cc',
'libcef_dll/cpptoc/focus_handler_cpptoc.h',
'libcef_dll/cpptoc/geolocation_handler_cpptoc.cc',
'libcef_dll/cpptoc/geolocation_handler_cpptoc.h',
'libcef_dll/cpptoc/jsdialog_handler_cpptoc.cc',
'libcef_dll/cpptoc/jsdialog_handler_cpptoc.h',
'libcef_dll/cpptoc/keyboard_handler_cpptoc.cc',
@ -216,6 +218,8 @@
'libcef_dll/ctocpp/drag_data_ctocpp.h',
'libcef_dll/ctocpp/frame_ctocpp.cc',
'libcef_dll/ctocpp/frame_ctocpp.h',
'libcef_dll/ctocpp/geolocation_callback_ctocpp.cc',
'libcef_dll/ctocpp/geolocation_callback_ctocpp.h',
'libcef_dll/ctocpp/post_data_ctocpp.cc',
'libcef_dll/ctocpp/post_data_ctocpp.h',
'libcef_dll/ctocpp/post_data_element_ctocpp.cc',

View File

@ -1880,6 +1880,58 @@ public:
};
///
// Callback interface used for asynchronous continuation of geolocation
// permission requests.
///
/*--cef(source=library)--*/
class CefGeolocationCallback : public virtual CefBase
{
public:
///
// Call to allow or deny geolocation access.
///
/*--cef(capi_name=cont)--*/
virtual void Continue(bool allow) =0;
};
///
// Implement this interface to handle events related to geolocation permission
// requests. The methods of this class will be called on the UI thread.
///
/*--cef(source=client)--*/
class CefGeolocationHandler : public virtual CefBase
{
public:
///
// Called when a page requests permission to access geolocation information.
// |requesting_url| is the URL requesting permission and |request_id| is the
// unique ID for the permission request. Call CefGeolocationCallback::Continue
// to allow or deny the permission request.
///
/*--cef()--*/
virtual void OnRequestGeolocationPermission(
CefRefPtr<CefBrowser> browser,
const CefString& requesting_url,
int request_id,
CefRefPtr<CefGeolocationCallback> callback) {
}
///
// Called when a geolocation access request is canceled. |requesting_url| is
// the URL that originally requested permission and |request_id| is the unique
// ID for the permission request.
///
/*--cef()--*/
virtual void OnCancelGeolocationPermission(
CefRefPtr<CefBrowser> browser,
const CefString& requesting_url,
int request_id) {
}
};
///
// Implement this interface to provide handler implementations.
///
@ -1972,6 +2024,15 @@ public:
///
/*--cef()--*/
virtual CefRefPtr<CefDragHandler> GetDragHandler() { return NULL; }
///
// Return the handler for geolocation permissions requests. If no handler is
// provided geolocation access will be denied by default.
///
/*--cef()--*/
virtual CefRefPtr<CefGeolocationHandler> GetGeolocationHandler() {
return NULL;
}
};

View File

@ -1655,6 +1655,57 @@ typedef struct _cef_drag_handler_t
} cef_drag_handler_t;
///
// Callback structure used for asynchronous continuation of geolocation
// permission requests.
///
typedef struct _cef_geolocation_callback_t
{
// Base structure.
cef_base_t base;
///
// Call to allow or deny geolocation access.
///
void (CEF_CALLBACK *cont)(struct _cef_geolocation_callback_t* self,
int allow);
} cef_geolocation_callback_t;
///
// Implement this structure to handle events related to geolocation permission
// requests. The functions of this structure will be called on the UI thread.
///
typedef struct _cef_geolocation_handler_t
{
// Base structure.
cef_base_t base;
///
// Called when a page requests permission to access geolocation information.
// |requesting_url| is the URL requesting permission and |request_id| is the
// unique ID for the permission request. Call
// cef_geolocation_callback_t::Continue to allow or deny the permission
// request.
///
void (CEF_CALLBACK *on_request_geolocation_permission)(
struct _cef_geolocation_handler_t* self, struct _cef_browser_t* browser,
const cef_string_t* requesting_url, int request_id,
struct _cef_geolocation_callback_t* callback);
///
// Called when a geolocation access request is canceled. |requesting_url| is
// the URL that originally requested permission and |request_id| is the unique
// ID for the permission request.
///
void (CEF_CALLBACK *on_cancel_geolocation_permission)(
struct _cef_geolocation_handler_t* self, struct _cef_browser_t* browser,
const cef_string_t* requesting_url, int request_id);
} cef_geolocation_handler_t;
///
// Implement this structure to provide handler implementations.
///
@ -1747,6 +1798,13 @@ typedef struct _cef_client_t
struct _cef_drag_handler_t* (CEF_CALLBACK *get_drag_handler)(
struct _cef_client_t* self);
///
// Return the handler for geolocation permissions requests. If no handler is
// provided geolocation access will be denied by default.
///
struct _cef_geolocation_handler_t* (CEF_CALLBACK *get_geolocation_handler)(
struct _cef_client_t* self);
} cef_client_t;

View File

@ -367,6 +367,12 @@ void CefBrowserImpl::CloseDevTools() {
base::Bind(&CefBrowserImpl::UIT_CloseDevTools, this));
}
WebKit::WebGeolocationClient* CefBrowserImpl::UIT_GetGeolocationClient() {
if (!geolocation_client_)
geolocation_client_ = new CefGeolocationClient(this);
return geolocation_client_;
}
bool CefBrowserImpl::GetSize(PaintElementType type, int& width, int& height) {
if (!CefThread::CurrentlyOn(CefThread::UI)) {
NOTREACHED() << "called on invalid thread";

View File

@ -20,6 +20,7 @@
#include "libcef/browser_navigation_controller.h"
#include "libcef/browser_request_context_proxy.h"
#include "libcef/cef_thread.h"
#include "libcef/geolocation_client.h"
#include "libcef/tracker.h"
#if defined(OS_WIN)
#include "libcef/printing/win_printing_context.h"
@ -312,6 +313,7 @@ class CefBrowserImpl : public CefBrowser {
void UIT_SetZoomLevel(double zoomLevel);
void UIT_ShowDevTools();
void UIT_CloseDevTools();
WebKit::WebGeolocationClient* UIT_GetGeolocationClient();
void UIT_VisitDOM(CefRefPtr<CefFrame> frame,
CefRefPtr<CefDOMVisitor> visitor);
@ -386,6 +388,9 @@ class CefBrowserImpl : public CefBrowser {
scoped_refptr<BrowserRequestContextProxy> request_context_proxy_;
// The geolocation client attached to this view, lazily initialized.
scoped_refptr<CefGeolocationClient> geolocation_client_;
CefString title_;
double zoom_level_;

View File

@ -0,0 +1,54 @@
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that can
// be found in the LICENSE file.
#include "content/public/browser/browser_thread.h"
#include "libcef/cef_thread.h"
// Stub implementations to convert BrowserThread calls to CefThread.
namespace content {
namespace {
int GetCefId(BrowserThread::ID browser_id) {
switch (browser_id) {
case BrowserThread::UI:
return CefThread::UI;
case BrowserThread::IO:
return CefThread::IO;
case BrowserThread::FILE:
return CefThread::FILE;
default:
break;
}
// The specified BrowserThread ID is not supported.
NOTREACHED();
return -1;
}
} // namespace
// static
bool BrowserThread::PostTask(ID identifier,
const tracked_objects::Location& from_here,
const base::Closure& task) {
int cef_id = GetCefId(identifier);
if (cef_id < 0)
return false;
return CefThread::PostTask(static_cast<CefThread::ID>(cef_id), from_here,
task);
}
// static
bool BrowserThread::CurrentlyOn(ID identifier) {
int cef_id = GetCefId(identifier);
if (cef_id < 0)
return false;
return CefThread::CurrentlyOn(static_cast<CefThread::ID>(cef_id));
}
} // namespace content

View File

@ -38,10 +38,10 @@ BrowserWebKitInit::BrowserWebKitInit()
WebKit::WebRuntimeFeatures::enablePushState(true);
WebKit::WebRuntimeFeatures::enableIndexedDatabase(true);
WebKit::WebRuntimeFeatures::enableFileSystem(true);
WebKit::WebRuntimeFeatures::enableGeolocation(true);
// TODO: Enable these once the implementation supports it.
WebKit::WebRuntimeFeatures::enableNotifications(false);
WebKit::WebRuntimeFeatures::enableGeolocation(false);
WebKit::WebRuntimeFeatures::enableSpeechInput(false);
WebKit::WebRuntimeFeatures::enableTouch(false);
WebKit::WebRuntimeFeatures::enableDeviceMotion(false);

View File

@ -476,6 +476,10 @@ int BrowserWebViewDelegate::historyForwardListCount() {
- current_index - 1;
}
WebKit::WebGeolocationClient* BrowserWebViewDelegate::geolocationClient() {
return browser_->UIT_GetGeolocationClient();
}
// WebPermissionClient -------------------------------------------------------
bool BrowserWebViewDelegate::allowScriptExtension(

View File

@ -123,6 +123,7 @@ class BrowserWebViewDelegate : public WebKit::WebViewClient,
virtual void navigateBackForwardSoon(int offset) OVERRIDE;
virtual int historyBackListCount() OVERRIDE;
virtual int historyForwardListCount() OVERRIDE;
virtual WebKit::WebGeolocationClient* geolocationClient() OVERRIDE;
// WebKit::WebWidgetClient
virtual void didInvalidateRect(const WebKit::WebRect& rect) OVERRIDE;

View File

@ -0,0 +1,347 @@
// Copyright (c) 2012 The Chromium Embedded Framework Authors.
// Portions copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "libcef/geolocation_client.h"
#include "libcef/browser_impl.h"
#include "include/cef.h"
#include "libcef/cef_context.h"
#include "libcef/cef_thread.h"
#include "base/bind.h"
#include "base/logging.h"
#include "content/browser/geolocation/access_token_store.h"
#include "content/browser/geolocation/arbitrator_dependency_factory.h"
#include "content/browser/geolocation/geolocation_observer.h"
#include "content/browser/geolocation/geolocation_provider.h"
#include "content/browser/geolocation/location_provider.h"
#include "content/common/geoposition.h"
#include "content/public/common/content_switches.h"
#include "net/url_request/url_request_context_getter.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebGeolocationPermissionRequest.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebGeolocationPermissionRequestManager.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebGeolocationClient.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebGeolocationPosition.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebGeolocationError.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
using WebKit::WebGeolocationController;
using WebKit::WebGeolocationError;
using WebKit::WebGeolocationPermissionRequest;
using WebKit::WebGeolocationPermissionRequestManager;
using WebKit::WebGeolocationPosition;
namespace {
class CefURLRequestContextGetter : public net::URLRequestContextGetter {
public:
CefURLRequestContextGetter() {}
virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE {
return _Context->request_context();
}
virtual scoped_refptr<base::MessageLoopProxy>
GetIOMessageLoopProxy() const OVERRIDE {
return CefThread::GetMessageLoopProxyForThread(CefThread::IO);
}
private:
DISALLOW_COPY_AND_ASSIGN(CefURLRequestContextGetter);
};
// In-memory store for access tokens used by geolocation.
class CefAccessTokenStore : public AccessTokenStore {
public:
CefAccessTokenStore() {}
virtual void DoLoadAccessTokens(
scoped_refptr<CancelableRequest<LoadAccessTokensCallbackType> > req)
OVERRIDE {
if (!request_context_getter_)
request_context_getter_ = new CefURLRequestContextGetter;
req->ForwardResultAsync(access_token_set_, request_context_getter_);
}
virtual void SaveAccessToken(
const GURL& server_url, const string16& access_token) OVERRIDE {
access_token_set_[server_url] = access_token;
}
private:
AccessTokenSet access_token_set_;
scoped_refptr<CefURLRequestContextGetter> request_context_getter_;
DISALLOW_COPY_AND_ASSIGN(CefAccessTokenStore);
};
void NotifyArbitratorPermissionGranted(const GURL& requesting_frame) {
DCHECK(CefThread::CurrentlyOn(CefThread::IO));
GeolocationProvider::GetInstance()->OnPermissionGranted(requesting_frame);
}
} // namespace
// CefGeolocationCallback implementation.
class CefGeolocationCallbackImpl : public CefGeolocationCallback {
public:
CefGeolocationCallbackImpl(CefGeolocationClient* client, int bridge_id)
: client_(client),
bridge_id_(bridge_id) {}
virtual void Continue(bool allow) OVERRIDE {
if (CefThread::CurrentlyOn(CefThread::UI)) {
if (client_) {
client_->OnPermissionSet(bridge_id_, allow);
client_ = NULL;
}
} else {
CefThread::PostTask(CefThread::UI, FROM_HERE,
base::Bind(&CefGeolocationCallbackImpl::Continue, this, allow));
}
}
private:
scoped_refptr<CefGeolocationClient> client_;
int bridge_id_;
IMPLEMENT_REFCOUNTING(CefGeolocationCallbackImpl);
};
CefGeolocationClient::CefGeolocationClient(CefBrowserImpl* browser)
: browser_(browser),
pending_permissions_(new WebGeolocationPermissionRequestManager()),
enable_high_accuracy_(false),
updating_(false),
location_provider_(NULL) {
}
CefGeolocationClient::~CefGeolocationClient() {}
void CefGeolocationClient::geolocationDestroyed() {
DCHECK(CefThread::CurrentlyOn(CefThread::UI));
controller_.reset();
DCHECK(!updating_);
}
void CefGeolocationClient::startUpdating() {
DCHECK(CefThread::CurrentlyOn(CefThread::UI));
CefThread::PostTask(CefThread::IO, FROM_HERE,
base::Bind(&CefGeolocationClient::OnStartUpdating, this,
enable_high_accuracy_));
updating_ = true;
}
void CefGeolocationClient::stopUpdating() {
DCHECK(CefThread::CurrentlyOn(CefThread::UI));
CefThread::PostTask(CefThread::IO, FROM_HERE,
base::Bind(&CefGeolocationClient::OnStopUpdating, this));
updating_ = false;
}
void CefGeolocationClient::setEnableHighAccuracy(bool enable_high_accuracy) {
DCHECK(CefThread::CurrentlyOn(CefThread::UI));
// GeolocationController calls setEnableHighAccuracy(true) before
// startUpdating in response to the first high-accuracy Geolocation
// subscription. When the last high-accuracy Geolocation unsubscribes
// it calls setEnableHighAccuracy(false) after stopUpdating.
bool has_changed = enable_high_accuracy_ != enable_high_accuracy;
enable_high_accuracy_ = enable_high_accuracy;
// We have a different accuracy requirement. Request browser to update.
if (updating_ && has_changed)
startUpdating();
}
void CefGeolocationClient::setController(
WebGeolocationController* controller) {
controller_.reset(controller);
}
bool CefGeolocationClient::lastPosition(WebGeolocationPosition&) {
DCHECK(CefThread::CurrentlyOn(CefThread::UI));
// The latest position is stored in the browser, not the renderer, so we
// would have to fetch it synchronously to give a good value here. The
// WebCore::GeolocationController already caches the last position it
// receives, so there is not much benefit to more position caching here.
return false;
}
void CefGeolocationClient::requestPermission(
const WebGeolocationPermissionRequest& permissionRequest) {
DCHECK(CefThread::CurrentlyOn(CefThread::UI));
int bridge_id = pending_permissions_->add(permissionRequest);
string16 origin = permissionRequest.securityOrigin().toString();
CefRefPtr<CefClient> client = browser_->GetClient();
if (client.get()) {
CefRefPtr<CefGeolocationHandler> handler =
client->GetGeolocationHandler();
if (handler.get()) {
CefRefPtr<CefGeolocationCallbackImpl> callbackPtr(
new CefGeolocationCallbackImpl(this, bridge_id));
handler->OnRequestGeolocationPermission(browser_, origin, bridge_id,
callbackPtr.get());
return;
}
}
// Disallow geolocation access by default.
OnPermissionSet(bridge_id, false);
}
void CefGeolocationClient::cancelPermissionRequest(
const WebGeolocationPermissionRequest& permissionRequest) {
DCHECK(CefThread::CurrentlyOn(CefThread::UI));
int bridge_id;
if (!pending_permissions_->remove(permissionRequest, bridge_id))
return;
string16 origin = permissionRequest.securityOrigin().toString();
CefRefPtr<CefClient> client = browser_->GetClient();
if (client.get()) {
CefRefPtr<CefGeolocationHandler> handler =
client->GetGeolocationHandler();
if (handler.get())
handler->OnCancelGeolocationPermission(browser_, origin, bridge_id);
}
}
void CefGeolocationClient::OnStartUpdating(bool enable_high_accuracy) {
DCHECK(CefThread::CurrentlyOn(CefThread::IO));
if (!location_provider_)
location_provider_ = GeolocationProvider::GetInstance();
// Re-add to re-establish our options, in case they changed.
location_provider_->AddObserver(
this, GeolocationObserverOptions(enable_high_accuracy));
}
void CefGeolocationClient::OnStopUpdating() {
DCHECK(CefThread::CurrentlyOn(CefThread::IO));
if (location_provider_) {
location_provider_->RemoveObserver(this);
location_provider_ = NULL;
}
}
void CefGeolocationClient::OnLocationUpdate(const Geoposition& position) {
DCHECK(CefThread::CurrentlyOn(CefThread::IO));
CefThread::PostTask(CefThread::UI, FROM_HERE,
base::Bind(&CefGeolocationClient::OnPositionUpdated, this, position));
}
// Permission for using geolocation has been set.
void CefGeolocationClient::OnPermissionSet(int bridge_id, bool is_allowed) {
DCHECK(CefThread::CurrentlyOn(CefThread::UI));
WebGeolocationPermissionRequest permissionRequest;
if (!pending_permissions_->remove(bridge_id, permissionRequest))
return;
permissionRequest.setIsAllowed(is_allowed);
if (is_allowed) {
string16 origin = permissionRequest.securityOrigin().toString();
CefThread::PostTask(
CefThread::IO, FROM_HERE,
base::Bind(&NotifyArbitratorPermissionGranted, GURL(origin)));
}
}
// We have an updated geolocation position or error code.
void CefGeolocationClient::OnPositionUpdated(const Geoposition& geoposition) {
DCHECK(CefThread::CurrentlyOn(CefThread::UI));
// It is possible for the browser process to have queued an update message
// before receiving the stop updating message.
if (!updating_)
return;
DCHECK(geoposition.IsInitialized());
if (geoposition.IsValidFix()) {
controller_->positionChanged(
WebGeolocationPosition(
geoposition.timestamp.ToDoubleT(),
geoposition.latitude, geoposition.longitude,
geoposition.accuracy,
geoposition.is_valid_altitude(), geoposition.altitude,
geoposition.is_valid_altitude_accuracy(),
geoposition.altitude_accuracy,
geoposition.is_valid_heading(), geoposition.heading,
geoposition.is_valid_speed(), geoposition.speed));
} else {
WebGeolocationError::Error code;
switch (geoposition.error_code) {
case Geoposition::ERROR_CODE_PERMISSION_DENIED:
code = WebGeolocationError::ErrorPermissionDenied;
break;
case Geoposition::ERROR_CODE_POSITION_UNAVAILABLE:
code = WebGeolocationError::ErrorPositionUnavailable;
break;
default:
DCHECK(false);
NOTREACHED() << geoposition.error_code;
return;
}
controller_->errorOccurred(
WebGeolocationError(
code, WebKit::WebString::fromUTF8(geoposition.error_message)));
}
}
// Replacement for content/browser/geolocation/arbitrator_dependency_factory.cc
// GeolocationArbitratorDependencyFactory
GeolocationArbitratorDependencyFactory::
~GeolocationArbitratorDependencyFactory() {
}
// DefaultGeolocationArbitratorDependencyFactory
DefaultGeolocationArbitratorDependencyFactory::GetTimeNow
DefaultGeolocationArbitratorDependencyFactory::GetTimeFunction() {
return base::Time::Now;
}
AccessTokenStore*
DefaultGeolocationArbitratorDependencyFactory::NewAccessTokenStore() {
return new CefAccessTokenStore;
}
LocationProviderBase*
DefaultGeolocationArbitratorDependencyFactory::NewNetworkLocationProvider(
AccessTokenStore* access_token_store,
net::URLRequestContextGetter* context,
const GURL& url,
const string16& access_token) {
return ::NewNetworkLocationProvider(access_token_store, context,
url, access_token);
}
LocationProviderBase*
DefaultGeolocationArbitratorDependencyFactory::NewSystemLocationProvider() {
return ::NewSystemLocationProvider();
}
// Extract from content/public/common/content_switches.cc.
namespace switches {
const char kExperimentalLocationFeatures[] = "experimental-location-features";
} // namespace switches

View File

@ -0,0 +1,88 @@
// Copyright (c) 2012 The Chromium Embedded Framework Authors.
// Portions copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CEF_LIBCEF_GEOLOCATION_CLIENT_H_
#define CEF_LIBCEF_GEOLOCATION_CLIENT_H_
#pragma once
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "content/browser/geolocation/geolocation_observer.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebGeolocationClient.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebGeolocationController.h"
class CefBrowserImpl;
class CefGeolocationCallbackImpl;
class GeolocationProvider;
struct Geoposition;
namespace WebKit {
class WebGeolocationController;
class WebGeolocationPermissionRequest;
class WebGeolocationPermissionRequestManager;
class WebGeolocationPosition;
}
// Delegate for Geolocation messages used by WebKit.
class CefGeolocationClient
: public WebKit::WebGeolocationClient,
public GeolocationObserver,
public base::RefCountedThreadSafe<CefGeolocationClient> {
public:
explicit CefGeolocationClient(CefBrowserImpl* browser);
virtual ~CefGeolocationClient();
private:
friend class CefGeolocationCallbackImpl;
// WebGeolocationClient methods.
virtual void geolocationDestroyed();
virtual void startUpdating();
virtual void stopUpdating();
virtual void setEnableHighAccuracy(bool enable_high_accuracy);
virtual void setController(WebKit::WebGeolocationController* controller);
virtual bool lastPosition(WebKit::WebGeolocationPosition& position);
virtual void requestPermission(
const WebKit::WebGeolocationPermissionRequest& permissionRequest);
virtual void cancelPermissionRequest(
const WebKit::WebGeolocationPermissionRequest& permissionRequest);
// Called to continue processing on the IO thread.
void OnStartUpdating(bool enable_high_accuracy);
void OnStopUpdating();
// GeolocationObserver methods.
virtual void OnLocationUpdate(const Geoposition& position);
// Permission for using geolocation has been set.
void OnPermissionSet(int bridge_id, bool is_allowed);
// We have an updated geolocation position or error code.
void OnPositionUpdated(const Geoposition& geoposition);
// The following members are only accessed on the UI thread.
// The |browser_| pointer is guaranteed to outlive this object.
CefBrowserImpl* browser_;
// The controller_ is valid for the lifetime of the underlying
// WebCore::GeolocationController. geolocationDestroyed() is
// invoked when the underlying object is destroyed.
scoped_ptr<WebKit::WebGeolocationController> controller_;
scoped_ptr<WebKit::WebGeolocationPermissionRequestManager>
pending_permissions_;
bool enable_high_accuracy_;
bool updating_;
// The following members are only accessed on the IO thread.
// Only set whilst we are registered with the arbitrator.
GeolocationProvider* location_provider_;
DISALLOW_COPY_AND_ASSIGN(CefGeolocationClient);
};
#endif // CEF_LIBCEF_GEOLOCATION_CLIENT_H_

View File

@ -15,6 +15,7 @@
#include "libcef_dll/cpptoc/drag_handler_cpptoc.h"
#include "libcef_dll/cpptoc/find_handler_cpptoc.h"
#include "libcef_dll/cpptoc/focus_handler_cpptoc.h"
#include "libcef_dll/cpptoc/geolocation_handler_cpptoc.h"
#include "libcef_dll/cpptoc/jsdialog_handler_cpptoc.h"
#include "libcef_dll/cpptoc/keyboard_handler_cpptoc.h"
#include "libcef_dll/cpptoc/life_span_handler_cpptoc.h"
@ -281,6 +282,24 @@ cef_drag_handler_t* CEF_CALLBACK client_get_drag_handler(
}
cef_geolocation_handler_t* CEF_CALLBACK client_get_geolocation_handler(
struct _cef_client_t* self)
{
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Execute
CefRefPtr<CefGeolocationHandler> _retval = CefClientCppToC::Get(
self)->GetGeolocationHandler();
// Return type: refptr_same
return CefGeolocationHandlerCppToC::Wrap(_retval);
}
// CONSTRUCTOR - Do not edit by hand.
@ -301,6 +320,7 @@ CefClientCppToC::CefClientCppToC(CefClient* cls)
struct_.struct_.get_v8context_handler = client_get_v8context_handler;
struct_.struct_.get_render_handler = client_get_render_handler;
struct_.struct_.get_drag_handler = client_get_drag_handler;
struct_.struct_.get_geolocation_handler = client_get_geolocation_handler;
}
#ifndef NDEBUG

View File

@ -0,0 +1,48 @@
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
#include "libcef_dll/cpptoc/geolocation_callback_cpptoc.h"
// MEMBER FUNCTIONS - Body may be edited by hand.
void CEF_CALLBACK geolocation_callback_cont(
struct _cef_geolocation_callback_t* self, int allow)
{
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Execute
CefGeolocationCallbackCppToC::Get(self)->Continue(
allow?true:false);
}
// CONSTRUCTOR - Do not edit by hand.
CefGeolocationCallbackCppToC::CefGeolocationCallbackCppToC(
CefGeolocationCallback* cls)
: CefCppToC<CefGeolocationCallbackCppToC, CefGeolocationCallback,
cef_geolocation_callback_t>(cls)
{
struct_.struct_.cont = geolocation_callback_cont;
}
#ifndef NDEBUG
template<> long CefCppToC<CefGeolocationCallbackCppToC, CefGeolocationCallback,
cef_geolocation_callback_t>::DebugObjCt = 0;
#endif

View File

@ -0,0 +1,37 @@
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
#ifndef _GEOLOCATIONCALLBACK_CPPTOC_H
#define _GEOLOCATIONCALLBACK_CPPTOC_H
#ifndef BUILDING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed DLL-side only")
#else // BUILDING_CEF_SHARED
#include "include/cef.h"
#include "include/cef_capi.h"
#include "libcef_dll/cpptoc/cpptoc.h"
// Wrap a C++ class with a C structure.
// This class may be instantiated and accessed DLL-side only.
class CefGeolocationCallbackCppToC
: public CefCppToC<CefGeolocationCallbackCppToC, CefGeolocationCallback,
cef_geolocation_callback_t>
{
public:
CefGeolocationCallbackCppToC(CefGeolocationCallback* cls);
virtual ~CefGeolocationCallbackCppToC() {}
};
#endif // BUILDING_CEF_SHARED
#endif // _GEOLOCATIONCALLBACK_CPPTOC_H

View File

@ -0,0 +1,96 @@
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
#include "libcef_dll/cpptoc/geolocation_handler_cpptoc.h"
#include "libcef_dll/ctocpp/browser_ctocpp.h"
#include "libcef_dll/ctocpp/geolocation_callback_ctocpp.h"
// MEMBER FUNCTIONS - Body may be edited by hand.
void CEF_CALLBACK geolocation_handler_on_request_geolocation_permission(
struct _cef_geolocation_handler_t* self, cef_browser_t* browser,
const cef_string_t* requesting_url, int request_id,
cef_geolocation_callback_t* callback)
{
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Verify param: browser; type: refptr_diff
DCHECK(browser);
if (!browser)
return;
// Verify param: requesting_url; type: string_byref_const
DCHECK(requesting_url);
if (!requesting_url)
return;
// Verify param: callback; type: refptr_diff
DCHECK(callback);
if (!callback)
return;
// Execute
CefGeolocationHandlerCppToC::Get(self)->OnRequestGeolocationPermission(
CefBrowserCToCpp::Wrap(browser),
CefString(requesting_url),
request_id,
CefGeolocationCallbackCToCpp::Wrap(callback));
}
void CEF_CALLBACK geolocation_handler_on_cancel_geolocation_permission(
struct _cef_geolocation_handler_t* self, cef_browser_t* browser,
const cef_string_t* requesting_url, int request_id)
{
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Verify param: browser; type: refptr_diff
DCHECK(browser);
if (!browser)
return;
// Verify param: requesting_url; type: string_byref_const
DCHECK(requesting_url);
if (!requesting_url)
return;
// Execute
CefGeolocationHandlerCppToC::Get(self)->OnCancelGeolocationPermission(
CefBrowserCToCpp::Wrap(browser),
CefString(requesting_url),
request_id);
}
// CONSTRUCTOR - Do not edit by hand.
CefGeolocationHandlerCppToC::CefGeolocationHandlerCppToC(
CefGeolocationHandler* cls)
: CefCppToC<CefGeolocationHandlerCppToC, CefGeolocationHandler,
cef_geolocation_handler_t>(cls)
{
struct_.struct_.on_request_geolocation_permission =
geolocation_handler_on_request_geolocation_permission;
struct_.struct_.on_cancel_geolocation_permission =
geolocation_handler_on_cancel_geolocation_permission;
}
#ifndef NDEBUG
template<> long CefCppToC<CefGeolocationHandlerCppToC, CefGeolocationHandler,
cef_geolocation_handler_t>::DebugObjCt = 0;
#endif

View File

@ -0,0 +1,37 @@
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
#ifndef _GEOLOCATIONHANDLER_CPPTOC_H
#define _GEOLOCATIONHANDLER_CPPTOC_H
#ifndef USING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
#else // USING_CEF_SHARED
#include "include/cef.h"
#include "include/cef_capi.h"
#include "libcef_dll/cpptoc/cpptoc.h"
// Wrap a C++ class with a C structure.
// This class may be instantiated and accessed wrapper-side only.
class CefGeolocationHandlerCppToC
: public CefCppToC<CefGeolocationHandlerCppToC, CefGeolocationHandler,
cef_geolocation_handler_t>
{
public:
CefGeolocationHandlerCppToC(CefGeolocationHandler* cls);
virtual ~CefGeolocationHandlerCppToC() {}
};
#endif // USING_CEF_SHARED
#endif // _GEOLOCATIONHANDLER_CPPTOC_H

View File

@ -15,6 +15,7 @@
#include "libcef_dll/ctocpp/drag_handler_ctocpp.h"
#include "libcef_dll/ctocpp/find_handler_ctocpp.h"
#include "libcef_dll/ctocpp/focus_handler_ctocpp.h"
#include "libcef_dll/ctocpp/geolocation_handler_ctocpp.h"
#include "libcef_dll/ctocpp/jsdialog_handler_ctocpp.h"
#include "libcef_dll/ctocpp/keyboard_handler_ctocpp.h"
#include "libcef_dll/ctocpp/life_span_handler_ctocpp.h"
@ -239,6 +240,22 @@ CefRefPtr<CefDragHandler> CefClientCToCpp::GetDragHandler()
}
CefRefPtr<CefGeolocationHandler> CefClientCToCpp::GetGeolocationHandler()
{
if (CEF_MEMBER_MISSING(struct_, get_geolocation_handler))
return NULL;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_geolocation_handler_t* _retval = struct_->get_geolocation_handler(
struct_);
// Return type: refptr_same
return CefGeolocationHandlerCToCpp::Wrap(_retval);
}
#ifndef NDEBUG
template<> long CefCToCpp<CefClientCToCpp, CefClient,

View File

@ -46,6 +46,7 @@ public:
virtual CefRefPtr<CefV8ContextHandler> GetV8ContextHandler() OVERRIDE;
virtual CefRefPtr<CefRenderHandler> GetRenderHandler() OVERRIDE;
virtual CefRefPtr<CefDragHandler> GetDragHandler() OVERRIDE;
virtual CefRefPtr<CefGeolocationHandler> GetGeolocationHandler() OVERRIDE;
};
#endif // BUILDING_CEF_SHARED

View File

@ -0,0 +1,36 @@
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
#include "libcef_dll/ctocpp/geolocation_callback_ctocpp.h"
// VIRTUAL METHODS - Body may be edited by hand.
void CefGeolocationCallbackCToCpp::Continue(bool allow)
{
if (CEF_MEMBER_MISSING(struct_, cont))
return;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
struct_->cont(struct_,
allow);
}
#ifndef NDEBUG
template<> long CefCToCpp<CefGeolocationCallbackCToCpp, CefGeolocationCallback,
cef_geolocation_callback_t>::DebugObjCt = 0;
#endif

View File

@ -0,0 +1,42 @@
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
#ifndef _GEOLOCATIONCALLBACK_CTOCPP_H
#define _GEOLOCATIONCALLBACK_CTOCPP_H
#ifndef USING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
#else // USING_CEF_SHARED
#include "include/cef.h"
#include "include/cef_capi.h"
#include "libcef_dll/ctocpp/ctocpp.h"
// Wrap a C structure with a C++ class.
// This class may be instantiated and accessed wrapper-side only.
class CefGeolocationCallbackCToCpp
: public CefCToCpp<CefGeolocationCallbackCToCpp, CefGeolocationCallback,
cef_geolocation_callback_t>
{
public:
CefGeolocationCallbackCToCpp(cef_geolocation_callback_t* str)
: CefCToCpp<CefGeolocationCallbackCToCpp, CefGeolocationCallback,
cef_geolocation_callback_t>(str) {}
virtual ~CefGeolocationCallbackCToCpp() {}
// CefGeolocationCallback methods
virtual void Continue(bool allow) OVERRIDE;
};
#endif // USING_CEF_SHARED
#endif // _GEOLOCATIONCALLBACK_CTOCPP_H

View File

@ -0,0 +1,82 @@
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
#include "libcef_dll/cpptoc/browser_cpptoc.h"
#include "libcef_dll/cpptoc/geolocation_callback_cpptoc.h"
#include "libcef_dll/ctocpp/geolocation_handler_ctocpp.h"
// VIRTUAL METHODS - Body may be edited by hand.
void CefGeolocationHandlerCToCpp::OnRequestGeolocationPermission(
CefRefPtr<CefBrowser> browser, const CefString& requesting_url,
int request_id, CefRefPtr<CefGeolocationCallback> callback)
{
if (CEF_MEMBER_MISSING(struct_, on_request_geolocation_permission))
return;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: browser; type: refptr_diff
DCHECK(browser.get());
if (!browser.get())
return;
// Verify param: requesting_url; type: string_byref_const
DCHECK(!requesting_url.empty());
if (requesting_url.empty())
return;
// Verify param: callback; type: refptr_diff
DCHECK(callback.get());
if (!callback.get())
return;
// Execute
struct_->on_request_geolocation_permission(struct_,
CefBrowserCppToC::Wrap(browser),
requesting_url.GetStruct(),
request_id,
CefGeolocationCallbackCppToC::Wrap(callback));
}
void CefGeolocationHandlerCToCpp::OnCancelGeolocationPermission(
CefRefPtr<CefBrowser> browser, const CefString& requesting_url,
int request_id)
{
if (CEF_MEMBER_MISSING(struct_, on_cancel_geolocation_permission))
return;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: browser; type: refptr_diff
DCHECK(browser.get());
if (!browser.get())
return;
// Verify param: requesting_url; type: string_byref_const
DCHECK(!requesting_url.empty());
if (requesting_url.empty())
return;
// Execute
struct_->on_cancel_geolocation_permission(struct_,
CefBrowserCppToC::Wrap(browser),
requesting_url.GetStruct(),
request_id);
}
#ifndef NDEBUG
template<> long CefCToCpp<CefGeolocationHandlerCToCpp, CefGeolocationHandler,
cef_geolocation_handler_t>::DebugObjCt = 0;
#endif

View File

@ -0,0 +1,46 @@
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
#ifndef _GEOLOCATIONHANDLER_CTOCPP_H
#define _GEOLOCATIONHANDLER_CTOCPP_H
#ifndef BUILDING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed DLL-side only")
#else // BUILDING_CEF_SHARED
#include "include/cef.h"
#include "include/cef_capi.h"
#include "libcef_dll/ctocpp/ctocpp.h"
// Wrap a C structure with a C++ class.
// This class may be instantiated and accessed DLL-side only.
class CefGeolocationHandlerCToCpp
: public CefCToCpp<CefGeolocationHandlerCToCpp, CefGeolocationHandler,
cef_geolocation_handler_t>
{
public:
CefGeolocationHandlerCToCpp(cef_geolocation_handler_t* str)
: CefCToCpp<CefGeolocationHandlerCToCpp, CefGeolocationHandler,
cef_geolocation_handler_t>(str) {}
virtual ~CefGeolocationHandlerCToCpp() {}
// CefGeolocationHandler methods
virtual void OnRequestGeolocationPermission(CefRefPtr<CefBrowser> browser,
const CefString& requesting_url, int request_id,
CefRefPtr<CefGeolocationCallback> callback) OVERRIDE;
virtual void OnCancelGeolocationPermission(CefRefPtr<CefBrowser> browser,
const CefString& requesting_url, int request_id) OVERRIDE;
};
#endif // BUILDING_CEF_SHARED
#endif // _GEOLOCATIONHANDLER_CTOCPP_H

View File

@ -17,6 +17,7 @@
#include "libcef_dll/cpptoc/domnode_cpptoc.h"
#include "libcef_dll/cpptoc/drag_data_cpptoc.h"
#include "libcef_dll/cpptoc/frame_cpptoc.h"
#include "libcef_dll/cpptoc/geolocation_callback_cpptoc.h"
#include "libcef_dll/cpptoc/post_data_cpptoc.h"
#include "libcef_dll/cpptoc/post_data_element_cpptoc.h"
#include "libcef_dll/cpptoc/request_cpptoc.h"
@ -41,6 +42,7 @@
#include "libcef_dll/ctocpp/drag_handler_ctocpp.h"
#include "libcef_dll/ctocpp/find_handler_ctocpp.h"
#include "libcef_dll/ctocpp/focus_handler_ctocpp.h"
#include "libcef_dll/ctocpp/geolocation_handler_ctocpp.h"
#include "libcef_dll/ctocpp/jsdialog_handler_ctocpp.h"
#include "libcef_dll/ctocpp/keyboard_handler_ctocpp.h"
#include "libcef_dll/ctocpp/life_span_handler_ctocpp.h"
@ -116,6 +118,8 @@ CEF_EXPORT void cef_shutdown()
DCHECK(CefFindHandlerCToCpp::DebugObjCt == 0);
DCHECK(CefFocusHandlerCToCpp::DebugObjCt == 0);
DCHECK(CefFrameCppToC::DebugObjCt == 0);
DCHECK(CefGeolocationCallbackCppToC::DebugObjCt == 0);
DCHECK(CefGeolocationHandlerCToCpp::DebugObjCt == 0);
DCHECK(CefJSDialogHandlerCToCpp::DebugObjCt == 0);
DCHECK(CefKeyboardHandlerCToCpp::DebugObjCt == 0);
DCHECK(CefLifeSpanHandlerCToCpp::DebugObjCt == 0);

View File

@ -21,6 +21,7 @@
#include "libcef_dll/cpptoc/drag_handler_cpptoc.h"
#include "libcef_dll/cpptoc/find_handler_cpptoc.h"
#include "libcef_dll/cpptoc/focus_handler_cpptoc.h"
#include "libcef_dll/cpptoc/geolocation_handler_cpptoc.h"
#include "libcef_dll/cpptoc/jsdialog_handler_cpptoc.h"
#include "libcef_dll/cpptoc/keyboard_handler_cpptoc.h"
#include "libcef_dll/cpptoc/life_span_handler_cpptoc.h"
@ -48,6 +49,7 @@
#include "libcef_dll/ctocpp/domnode_ctocpp.h"
#include "libcef_dll/ctocpp/drag_data_ctocpp.h"
#include "libcef_dll/ctocpp/frame_ctocpp.h"
#include "libcef_dll/ctocpp/geolocation_callback_ctocpp.h"
#include "libcef_dll/ctocpp/post_data_ctocpp.h"
#include "libcef_dll/ctocpp/post_data_element_ctocpp.h"
#include "libcef_dll/ctocpp/request_ctocpp.h"
@ -118,6 +120,8 @@ CEF_GLOBAL void CefShutdown()
DCHECK(CefFindHandlerCppToC::DebugObjCt == 0);
DCHECK(CefFocusHandlerCppToC::DebugObjCt == 0);
DCHECK(CefFrameCToCpp::DebugObjCt == 0);
DCHECK(CefGeolocationCallbackCToCpp::DebugObjCt == 0);
DCHECK(CefGeolocationHandlerCppToC::DebugObjCt == 0);
DCHECK(CefJSDialogHandlerCppToC::DebugObjCt == 0);
DCHECK(CefKeyboardHandlerCppToC::DebugObjCt == 0);
DCHECK(CefLifeSpanHandlerCppToC::DebugObjCt == 0);

View File

@ -16,6 +16,11 @@ patches = [
'name': 'base',
'path': '../base/',
},
{
# Avoid compile error on OS-X and Linux.
'name': 'base_bind',
'path': '../base/',
},
{
# http://code.google.com/p/gyp/issues/detail?id=223
'name': 'tools_gyp',

View File

@ -0,0 +1,15 @@
Index: bind.h
===================================================================
--- bind.h (revision 114933)
+++ bind.h (working copy)
@@ -149,8 +149,8 @@
COMPILE_ASSERT(!internal::HasIsMethodTag<RunnableType>::value ||
!is_array<P1>::value,
first_bound_argument_to_method_cannot_be_array);
- COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P2>::value,
- p2_is_refcounted_type_and_needs_scoped_refptr);
+ //COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P2>::value,
+ // p2_is_refcounted_type_and_needs_scoped_refptr);
return internal::MakeBindStateHolder(
new internal::BindState<RunnableType, RunType,

View File

@ -302,6 +302,15 @@ bool ClientHandler::OnDragEnter(CefRefPtr<CefBrowser> browser,
return false;
}
void ClientHandler::OnRequestGeolocationPermission(
CefRefPtr<CefBrowser> browser,
const CefString& requesting_url,
int request_id,
CefRefPtr<CefGeolocationCallback> callback) {
// Allow geolocation access from all websites.
callback->Continue(true);
}
void ClientHandler::NotifyDownloadComplete(const CefString& fileName)
{
SetLastDownloadFile(fileName);

View File

@ -26,6 +26,7 @@ class ClientHandler : public CefClient,
public CefPrintHandler,
public CefV8ContextHandler,
public CefDragHandler,
public CefGeolocationHandler,
public DownloadListener
{
public:
@ -51,6 +52,8 @@ public:
{ return this; }
virtual CefRefPtr<CefDragHandler> GetDragHandler() OVERRIDE
{ return this; }
virtual CefRefPtr<CefGeolocationHandler> GetGeolocationHandler() OVERRIDE
{ return this; }
// CefLifeSpanHandler methods
virtual bool OnBeforePopup(CefRefPtr<CefBrowser> parentBrowser,
@ -144,6 +147,13 @@ public:
CefRefPtr<CefDragData> dragData,
DragOperationsMask mask) OVERRIDE;
// CefGeolocationHandler methods.
virtual void OnRequestGeolocationPermission(
CefRefPtr<CefBrowser> browser,
const CefString& requesting_url,
int request_id,
CefRefPtr<CefGeolocationCallback> callback) OVERRIDE;
// DownloadListener methods
virtual void NotifyDownloadComplete(const CefString& fileName) OVERRIDE;
virtual void NotifyDownloadError(const CefString& fileName) OVERRIDE;