Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1444)

Unified Diff: third_party/WebKit/WebCore/page/Geolocation.cpp

Issue 46097: WebKit merge 41660:41709 (WebKit side).... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/WebCore/page/Geolocation.h ('k') | third_party/WebKit/WebCore/page/Geoposition.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « third_party/WebKit/WebCore/page/Geolocation.h ('k') | third_party/WebKit/WebCore/page/Geoposition.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698