| Index: third_party/WebKit/WebCore/page/Geolocation.cpp
|
| ===================================================================
|
| --- third_party/WebKit/WebCore/page/Geolocation.cpp (revision 11711)
|
| +++ third_party/WebKit/WebCore/page/Geolocation.cpp (working copy)
|
| @@ -57,7 +57,10 @@
|
| : m_frame(frame)
|
| , m_service(GeolocationService::create(this))
|
| , m_allowGeolocation(Unknown)
|
| + , m_shouldClearCache(false)
|
| {
|
| + if (!m_frame)
|
| + return;
|
| ASSERT(m_frame->document());
|
| m_frame->document()->setUsingGeolocation(true);
|
| }
|
| @@ -72,14 +75,6 @@
|
| {
|
| RefPtr<GeoNotifier> notifier = GeoNotifier::create(successCallback, errorCallback, options);
|
|
|
| - if (!shouldAllowGeolocation()) {
|
| - if (notifier->m_errorCallback) {
|
| - RefPtr<PositionError> error = WebCore::PositionError::create(PositionError::PERMISSION_DENIED, "Disallowed Geolocation");
|
| - notifier->m_errorCallback->handleEvent(error.get());
|
| - }
|
| - return;
|
| - }
|
| -
|
| if (!m_service->startUpdating(options)) {
|
| if (notifier->m_errorCallback) {
|
| RefPtr<PositionError> error = PositionError::create(PositionError::PERMISSION_DENIED, "Unable to Start");
|
| @@ -95,14 +90,6 @@
|
| {
|
| RefPtr<GeoNotifier> notifier = GeoNotifier::create(successCallback, errorCallback, options);
|
|
|
| - if (!shouldAllowGeolocation()) {
|
| - if (notifier->m_errorCallback) {
|
| - RefPtr<PositionError> error = WebCore::PositionError::create(PositionError::PERMISSION_DENIED, "Disallowed Geolocation");
|
| - notifier->m_errorCallback->handleEvent(error.get());
|
| - }
|
| - return 0;
|
| - }
|
| -
|
| if (!m_service->startUpdating(options)) {
|
| if (notifier->m_errorCallback) {
|
| RefPtr<PositionError> error = PositionError::create(PositionError::PERMISSION_DENIED, "Unable to Start");
|
| @@ -138,6 +125,18 @@
|
| m_service->resume();
|
| }
|
|
|
| +void Geolocation::setIsAllowed(bool allowed)
|
| +{
|
| + m_allowGeolocation = allowed ? Yes : No;
|
| +
|
| + if (isAllowed())
|
| + geolocationServicePositionChanged(m_service.get());
|
| + else {
|
| + WTF::RefPtr<WebCore::PositionError> error = WebCore::PositionError::create(PositionError::PERMISSION_DENIED, "User disallowed GeoLocation");
|
| + handleError(error.get());
|
| + }
|
| +}
|
| +
|
| void Geolocation::sendErrorToOneShots(PositionError* error)
|
| {
|
| Vector<RefPtr<GeoNotifier> > copy;
|
| @@ -216,10 +215,32 @@
|
| m_oneShots.clear();
|
| }
|
|
|
| +void Geolocation::requestPermission()
|
| +{
|
| + if (m_allowGeolocation > Unknown)
|
| + return;
|
| +
|
| + if (!m_frame)
|
| + return;
|
| +
|
| + Page* page = m_frame->page();
|
| + if (!page)
|
| + return;
|
| +
|
| + // Ask the chrome: it maintains the geolocation challenge policy itself.
|
| + page->chrome()->requestGeolocationPermissionForFrame(m_frame, this);
|
| +
|
| + m_allowGeolocation = InProgress;
|
| +}
|
| +
|
| void Geolocation::geolocationServicePositionChanged(GeolocationService* service)
|
| {
|
| ASSERT(service->lastPosition());
|
|
|
| + requestPermission();
|
| + if (!isAllowed())
|
| + return;
|
| +
|
| sendPositionToOneShots(service->lastPosition());
|
| sendPositionToWatchers(service->lastPosition());
|
|
|
| @@ -236,18 +257,4 @@
|
| handleError(service->lastError());
|
| }
|
|
|
| -bool Geolocation::shouldAllowGeolocation()
|
| -{
|
| - if (!m_frame)
|
| - return false;
|
| -
|
| - Page* page = m_frame->page();
|
| - if (!page)
|
| - return false;
|
| -
|
| - if (m_allowGeolocation == Unknown)
|
| - m_allowGeolocation = page->chrome()->shouldAllowGeolocationForFrame(m_frame) ? Yes : No;
|
| - return m_allowGeolocation == Yes;
|
| -}
|
| -
|
| } // namespace WebCore
|
|
|