Update to Chromium revision 203701.

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1269 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt
2013-06-04 17:41:37 +00:00
parent 300847a38a
commit 7a71dc06de
38 changed files with 348 additions and 182 deletions

View File

@@ -7,49 +7,76 @@
#include "libcef/browser/thread_util.h"
#include "libcef/common/time_util.h"
#include "base/logging.h"
#include "content/browser/geolocation/geolocation_provider.h"
#include "content/public/browser/geolocation_provider.h"
#include "content/public/common/geoposition.h"
namespace {
void SetPosition(const content::Geoposition& source, CefGeoposition& target) {
target.latitude = source.latitude;
target.longitude = source.longitude;
target.altitude = source.altitude;
target.accuracy = source.accuracy;
target.altitude_accuracy = source.altitude_accuracy;
target.heading = source.heading;
target.speed = source.speed;
cef_time_from_basetime(source.timestamp, target.timestamp);
switch (source.error_code) {
case content::Geoposition::ERROR_CODE_NONE:
target.error_code = GEOPOSITON_ERROR_NONE;
break;
case content::Geoposition::ERROR_CODE_PERMISSION_DENIED:
target.error_code = GEOPOSITON_ERROR_PERMISSION_DENIED;
break;
case content::Geoposition::ERROR_CODE_POSITION_UNAVAILABLE:
target.error_code = GEOPOSITON_ERROR_POSITION_UNAVAILABLE;
break;
case content::Geoposition::ERROR_CODE_TIMEOUT:
target.error_code = GEOPOSITON_ERROR_TIMEOUT;
break;
class CefLocationRequest :
public base::RefCountedThreadSafe<CefLocationRequest> {
public:
explicit CefLocationRequest(CefRefPtr<CefGetGeolocationCallback> callback)
: callback_(callback) {
CEF_REQUIRE_IOT();
geo_callback_ = base::Bind(&CefLocationRequest::OnLocationUpdate, this);
content::GeolocationProvider* provider =
content::GeolocationProvider::GetInstance();
provider->AddLocationUpdateCallback(geo_callback_, true);
provider->UserDidOptIntoLocationServices();
}
CefString(&target.error_message) = source.error_message;
}
private:
void OnLocationUpdate(const content::Geoposition& position) {
if (CEF_CURRENTLY_ON_UIT()) {
if (callback_) {
CefGeoposition cef_position;
SetPosition(position, cef_position);
callback_->OnLocationUpdate(cef_position);
callback_ = NULL;
}
} else {
content::GeolocationProvider::GetInstance()->RemoveLocationUpdateCallback(
geo_callback_);
geo_callback_.Reset();
void LocationCallback(CefRefPtr<CefGetGeolocationCallback> callback,
const content::Geoposition& position) {
if (CEF_CURRENTLY_ON_UIT()) {
CefGeoposition cef_position;
SetPosition(position, cef_position);
callback->OnLocationUpdate(cef_position);
} else {
CEF_POST_TASK(CEF_UIT, base::Bind(LocationCallback, callback, position));
CEF_POST_TASK(CEF_UIT,
base::Bind(&CefLocationRequest::OnLocationUpdate, this, position));
}
}
}
void SetPosition(const content::Geoposition& source, CefGeoposition& target) {
target.latitude = source.latitude;
target.longitude = source.longitude;
target.altitude = source.altitude;
target.accuracy = source.accuracy;
target.altitude_accuracy = source.altitude_accuracy;
target.heading = source.heading;
target.speed = source.speed;
cef_time_from_basetime(source.timestamp, target.timestamp);
switch (source.error_code) {
case content::Geoposition::ERROR_CODE_NONE:
target.error_code = GEOPOSITON_ERROR_NONE;
break;
case content::Geoposition::ERROR_CODE_PERMISSION_DENIED:
target.error_code = GEOPOSITON_ERROR_PERMISSION_DENIED;
break;
case content::Geoposition::ERROR_CODE_POSITION_UNAVAILABLE:
target.error_code = GEOPOSITON_ERROR_POSITION_UNAVAILABLE;
break;
case content::Geoposition::ERROR_CODE_TIMEOUT:
target.error_code = GEOPOSITON_ERROR_TIMEOUT;
break;
}
CefString(&target.error_message) = source.error_message;
}
CefRefPtr<CefGetGeolocationCallback> callback_;
content::GeolocationProvider::LocationUpdateCallback geo_callback_;
DISALLOW_COPY_AND_ASSIGN(CefLocationRequest);
};
} // namespace
@@ -65,10 +92,9 @@ bool CefGetGeolocation(CefRefPtr<CefGetGeolocationCallback> callback) {
}
if (CEF_CURRENTLY_ON_IOT()) {
content::GeolocationProvider* provider =
content::GeolocationProvider::GetInstance();
if (provider) {
provider->RequestCallback(base::Bind(LocationCallback, callback));
if (content::GeolocationProvider::GetInstance()) {
// Will be released after the callback executes.
new CefLocationRequest(callback);
return true;
}
return false;