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

Side by Side Diff: Source/modules/geolocation/Geolocation.cpp

Issue 256843004: Get the WebGeolocationClient from WebFrameClient instead of WebViewClient. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: fix linking errors Created 6 years, 6 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008, 2009, 2010, 2011 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008, 2009, 2010, 2011 Apple Inc. All Rights Reserved.
3 * Copyright (C) 2009 Torch Mobile, Inc. 3 * Copyright (C) 2009 Torch Mobile, Inc.
4 * Copyright 2010, The Android Open Source Project 4 * Copyright 2010, The Android Open Source Project
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 Document* Geolocation::document() const 274 Document* Geolocation::document() const
275 { 275 {
276 return toDocument(executionContext()); 276 return toDocument(executionContext());
277 } 277 }
278 278
279 LocalFrame* Geolocation::frame() const 279 LocalFrame* Geolocation::frame() const
280 { 280 {
281 return document() ? document()->frame() : 0; 281 return document() ? document()->frame() : 0;
282 } 282 }
283 283
284 Page* Geolocation::page() const
285 {
286 return document() ? document()->page() : 0;
287 }
288
289 void Geolocation::stop() 284 void Geolocation::stop()
290 { 285 {
291 Page* page = this->page(); 286 LocalFrame* frame = this->frame();
292 if (page && m_allowGeolocation == InProgress) 287 if (frame && m_allowGeolocation == InProgress)
293 GeolocationController::from(page)->cancelPermissionRequest(this); 288 GeolocationController::from(frame)->cancelPermissionRequest(this);
294 // The frame may be moving to a new page and we want to get the permissions from the new page's client. 289 // The frame may be moving to a new page and we want to get the permissions from the new page's client.
295 m_allowGeolocation = Unknown; 290 m_allowGeolocation = Unknown;
296 cancelAllRequests(); 291 cancelAllRequests();
297 stopUpdating(); 292 stopUpdating();
298 m_pendingForPermissionNotifiers.clear(); 293 m_pendingForPermissionNotifiers.clear();
299 } 294 }
300 295
301 Geoposition* Geolocation::lastPosition() 296 Geoposition* Geolocation::lastPosition()
302 { 297 {
303 Page* page = this->page(); 298 LocalFrame* frame = this->frame();
304 if (!page) 299 if (!frame)
305 return 0; 300 return 0;
306 301
307 m_lastPosition = createGeoposition(GeolocationController::from(page)->lastPo sition()); 302 m_lastPosition = createGeoposition(GeolocationController::from(frame)->lastP osition());
308 303
309 return m_lastPosition.get(); 304 return m_lastPosition.get();
310 } 305 }
311 306
312 void Geolocation::getCurrentPosition(PassOwnPtr<PositionCallback> successCallbac k, PassOwnPtr<PositionErrorCallback> errorCallback, PassRefPtrWillBeRawPtr<Posit ionOptions> options) 307 void Geolocation::getCurrentPosition(PassOwnPtr<PositionCallback> successCallbac k, PassOwnPtr<PositionErrorCallback> errorCallback, PassRefPtrWillBeRawPtr<Posit ionOptions> options)
313 { 308 {
314 if (!frame()) 309 if (!frame())
315 return; 310 return;
316 311
317 RefPtrWillBeRawPtr<GeoNotifier> notifier = GeoNotifier::create(this, success Callback, errorCallback, options); 312 RefPtrWillBeRawPtr<GeoNotifier> notifier = GeoNotifier::create(this, success Callback, errorCallback, options);
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 593
599 // Maintain a reference to the cached notifiers until their timer fires. 594 // Maintain a reference to the cached notifiers until their timer fires.
600 copyToSet(oneShotsWithCachedPosition, m_oneShots); 595 copyToSet(oneShotsWithCachedPosition, m_oneShots);
601 } 596 }
602 597
603 void Geolocation::requestPermission() 598 void Geolocation::requestPermission()
604 { 599 {
605 if (m_allowGeolocation > Unknown) 600 if (m_allowGeolocation > Unknown)
606 return; 601 return;
607 602
608 Page* page = this->page(); 603 LocalFrame* frame = this->frame();
609 if (!page) 604 if (!frame)
610 return; 605 return;
611 606
612 m_allowGeolocation = InProgress; 607 m_allowGeolocation = InProgress;
613 608
614 // Ask the embedder: it maintains the geolocation challenge policy itself. 609 // Ask the embedder: it maintains the geolocation challenge policy itself.
615 GeolocationController::from(page)->requestPermission(this); 610 GeolocationController::from(frame)->requestPermission(this);
616 } 611 }
617 612
618 void Geolocation::makeSuccessCallbacks() 613 void Geolocation::makeSuccessCallbacks()
619 { 614 {
620 ASSERT(lastPosition()); 615 ASSERT(lastPosition());
621 ASSERT(isAllowed()); 616 ASSERT(isAllowed());
622 617
623 GeoNotifierVector oneShotsCopy; 618 GeoNotifierVector oneShotsCopy;
624 copyToVector(m_oneShots, oneShotsCopy); 619 copyToVector(m_oneShots, oneShotsCopy);
625 620
(...skipping 28 matching lines...) Expand all
654 } 649 }
655 650
656 void Geolocation::setError(GeolocationError* error) 651 void Geolocation::setError(GeolocationError* error)
657 { 652 {
658 RefPtrWillBeRawPtr<PositionError> positionError = createPositionError(error) ; 653 RefPtrWillBeRawPtr<PositionError> positionError = createPositionError(error) ;
659 handleError(positionError.get()); 654 handleError(positionError.get());
660 } 655 }
661 656
662 bool Geolocation::startUpdating(GeoNotifier* notifier) 657 bool Geolocation::startUpdating(GeoNotifier* notifier)
663 { 658 {
664 Page* page = this->page(); 659 LocalFrame* frame = this->frame();
665 if (!page) 660 if (!frame)
666 return false; 661 return false;
667 662
668 GeolocationController::from(page)->addObserver(this, notifier->options()->en ableHighAccuracy()); 663 GeolocationController::from(frame)->addObserver(this, notifier->options()->e nableHighAccuracy());
669 return true; 664 return true;
670 } 665 }
671 666
672 void Geolocation::stopUpdating() 667 void Geolocation::stopUpdating()
673 { 668 {
674 Page* page = this->page(); 669 LocalFrame* frame = this->frame();
675 if (!page) 670 if (!frame)
676 return; 671 return;
677 672
678 GeolocationController::from(page)->removeObserver(this); 673 GeolocationController::from(frame)->removeObserver(this);
679 } 674 }
680 675
681 void Geolocation::handlePendingPermissionNotifiers() 676 void Geolocation::handlePendingPermissionNotifiers()
682 { 677 {
683 // While we iterate through the list, we need not worry about list being mod ified as the permission 678 // While we iterate through the list, we need not worry about list being mod ified as the permission
684 // is already set to Yes/No and no new listeners will be added to the pendin g list 679 // is already set to Yes/No and no new listeners will be added to the pendin g list
685 GeoNotifierSet::const_iterator end = m_pendingForPermissionNotifiers.end(); 680 GeoNotifierSet::const_iterator end = m_pendingForPermissionNotifiers.end();
686 for (GeoNotifierSet::const_iterator iter = m_pendingForPermissionNotifiers.b egin(); iter != end; ++iter) { 681 for (GeoNotifierSet::const_iterator iter = m_pendingForPermissionNotifiers.b egin(); iter != end; ++iter) {
687 GeoNotifier* notifier = iter->get(); 682 GeoNotifier* notifier = iter->get();
688 683
689 if (isAllowed()) { 684 if (isAllowed()) {
690 // start all pending notification requests as permission granted. 685 // start all pending notification requests as permission granted.
691 // The notifier is always ref'ed by m_oneShots or m_watchers. 686 // The notifier is always ref'ed by m_oneShots or m_watchers.
692 if (startUpdating(notifier)) 687 if (startUpdating(notifier))
693 notifier->startTimer(); 688 notifier->startTimer();
694 else 689 else
695 notifier->setFatalError(PositionError::create(PositionError::POS ITION_UNAVAILABLE, failedToStartServiceErrorMessage)); 690 notifier->setFatalError(PositionError::create(PositionError::POS ITION_UNAVAILABLE, failedToStartServiceErrorMessage));
696 } else { 691 } else {
697 notifier->setFatalError(PositionError::create(PositionError::PERMISS ION_DENIED, permissionDeniedErrorMessage)); 692 notifier->setFatalError(PositionError::create(PositionError::PERMISS ION_DENIED, permissionDeniedErrorMessage));
698 } 693 }
699 } 694 }
700 } 695 }
701 696
702 } // namespace WebCore 697 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698