WebCore/ChangeLog

 12010-06-11 Steve Block <steveblock@google.com>
 2
 3 Reviewed by NOBODY (OOPS!).
 4
 5 Client-based Geolocation does not pass high power option to controller and client
 6 https://bugs.webkit.org/show_bug.cgi?id=40374
 7
 8 This change passes the enableHighAccuracy request option to the GeolocationController.
 9 The GeolocationController tracks whether high power should be used by the client.
 10
 11 No new tests possible as the mock provider doesn't support this feature.
 12
 13 * page/Geolocation.cpp:
 14 (WebCore::Geolocation::setIsAllowed):
 15 (WebCore::Geolocation::startUpdating):
 16 * page/GeolocationController.cpp:
 17 (WebCore::GeolocationController::addObserver):
 18 (WebCore::GeolocationController::removeObserver):
 19 (WebCore::GeolocationController::useHighPower):
 20 (WebCore::GeolocationController::positionChanged):
 21 (WebCore::GeolocationController::errorOccurred):
 22 * page/GeolocationController.h:
 23 * page/GeolocationControllerClient.h:
 24
1252010-06-11 Steve Block <steveblock@google.com>
226
327 Reviewed by Alexey Proskuryakov.
60998

WebCore/page/Geolocation.cpp

@@void Geolocation::setIsAllowed(bool allo
411411 Page* page = m_frame->page();
412412 if (!page)
413413 return;
414  page->geolocationController()->addObserver(this);
 414 page->geolocationController()->addObserver(this, m_startRequestPermissionNotifier->m_options->enableHighAccuracy());
415415 } else {
416416 m_startRequestPermissionNotifier->setFatalError(PositionError::create(PositionError::PERMISSION_DENIED, permissionDeniedErrorMessage));
417417 m_oneShots.add(m_startRequestPermissionNotifier);

@@void Geolocation::geolocationServiceErro
613613bool Geolocation::startUpdating(GeoNotifier* notifier)
614614{
615615#if ENABLE(CLIENT_BASED_GEOLOCATION)
616  // FIXME: Pass options to client.
617 
618616 if (!isAllowed()) {
619617 m_startRequestPermissionNotifier = notifier;
620618 requestPermission();

@@bool Geolocation::startUpdating(GeoNotif
628626 if (!page)
629627 return false;
630628
631  page->geolocationController()->addObserver(this);
 629 page->geolocationController()->addObserver(this, notifier->m_options->enableHighAccuracy());
632630 return true;
633631#else
634632 return m_service->startUpdating(notifier->m_options.get());
60998

WebCore/page/GeolocationController.cpp

@@GeolocationController::~GeolocationContr
4545 m_client->geolocationDestroyed();
4646}
4747
48 void GeolocationController::addObserver(Geolocation* observer)
 48void GeolocationController::addObserver(Geolocation* observer, bool highPower)
4949{
5050 // This may be called multiple times with the same observer, though removeObserver()
5151 // is called only once with each.
52  if (m_observers.contains(observer))
53  return;
54 
5552 bool wasEmpty = m_observers.isEmpty();
56  m_observers.add(observer);
57  if (wasEmpty && m_client)
58  m_client->startUpdating();
 53 bool wasUsingHighPower = useHighPower();
 54
 55 if (m_observers.contains(observer))
 56 m_observers.find(observer)->second |= highPower;
 57 else
 58 m_observers.add(observer, highPower);
 59
 60 if (m_client) {
 61 if (!wasUsingHighPower && useHighPower())
 62 m_client->setUseHighPower(true);
 63 if (wasEmpty)
 64 m_client->startUpdating();
 65 }
5966}
6067
6168void GeolocationController::removeObserver(Geolocation* observer)

@@void GeolocationController::removeObserv
6370 if (!m_observers.contains(observer))
6471 return;
6572
 73 bool wasUsingHighPower = useHighPower();
6674 m_observers.remove(observer);
67  if (m_observers.isEmpty() && m_client)
68  m_client->stopUpdating();
 75 if (m_client) {
 76 if (m_observers.isEmpty())
 77 m_client->stopUpdating();
 78 else if (wasUsingHighPower && !useHighPower())
 79 m_client->setUseHighPower(false);
 80 }
 81}
 82
 83bool GeolocationController::useHighPower() const
 84{
 85 ObserversMap::const_iterator end = m_observers.end();
 86 for (ObserversMap::const_iterator iter = m_observers.begin(); iter != end; ++iter) {
 87 if (iter->second)
 88 return true;
 89 }
 90 return false;
6991}
7092
7193void GeolocationController::positionChanged(GeolocationPosition* position)
7294{
7395 m_lastPosition = position;
7496 Vector<RefPtr<Geolocation> > observersVector;
75  copyToVector(m_observers, observersVector);
 97 copyKeysToVector(m_observers, observersVector);
7698 for (size_t i = 0; i < observersVector.size(); ++i)
7799 observersVector[i]->positionChanged();
78100}

@@void GeolocationController::positionChan
80102void GeolocationController::errorOccurred(GeolocationError* error)
81103{
82104 Vector<RefPtr<Geolocation> > observersVector;
83  copyToVector(m_observers, observersVector);
 105 copyKeysToVector(m_observers, observersVector);
84106 for (size_t i = 0; i < observersVector.size(); ++i)
85107 observersVector[i]->setError(error);
86108}
60998

WebCore/page/GeolocationController.h

2929#if ENABLE(CLIENT_BASED_GEOLOCATION)
3030
3131#include "Geolocation.h"
32 #include <wtf/HashSet.h>
 32#include <wtf/HashMap.h>
3333#include <wtf/Noncopyable.h>
3434#include <wtf/RefPtr.h>
3535

@@public:
4545 GeolocationController(Page*, GeolocationControllerClient*);
4646 ~GeolocationController();
4747
48  void addObserver(Geolocation*);
 48 void addObserver(Geolocation*, bool highPower);
4949 void removeObserver(Geolocation*);
5050
5151 void positionChanged(GeolocationPosition*);

@@public:
5454 GeolocationPosition* lastPosition();
5555
5656private:
 57 bool useHighPower() const;
 58
5759 Page* m_page;
5860 GeolocationControllerClient* m_client;
5961
6062 RefPtr<GeolocationPosition> m_lastPosition;
61  HashSet<RefPtr<Geolocation> > m_observers;
 63 typedef HashMap<RefPtr<Geolocation>, bool> ObserversMap;
 64 ObserversMap m_observers;
6265};
6366
6467} // namespace WebCore
60998

WebCore/page/GeolocationControllerClient.h

@@public:
3636
3737 virtual void startUpdating() = 0;
3838 virtual void stopUpdating() = 0;
 39 virtual void setUseHighPower(bool) = 0;
3940 virtual GeolocationPosition* lastPosition() = 0;
4041
4142protected:
60998

WebKit/mac/ChangeLog

 12010-06-09 Steve Block <steveblock@google.com>
 2
 3 Reviewed by NOBODY (OOPS!).
 4
 5 Client-based Geolocation does not pass high power option to controller and client
 6 https://bugs.webkit.org/show_bug.cgi?id=40374
 7
 8 Stub out setUseHighPower method for the Mac port.
 9
 10 * WebCoreSupport/WebGeolocationControllerClient.h:
 11 (WebGeolocationControllerClient::setUseHighPower):
 12
1132010-06-10 David Hyatt <hyatt@apple.com>
214
315 Reviewed by John Sullivan.
60998

WebKit/mac/WebCoreSupport/WebGeolocationControllerClient.h

@@public:
3939 void geolocationDestroyed();
4040 void startUpdating();
4141 void stopUpdating();
 42 void setUseHighPower(bool) { }
4243
4344 WebCore::GeolocationPosition* lastPosition();
4445
60998