15c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)/* 25c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Copyright (C) 2009 Apple Inc. All rights reserved. 35c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 45c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Redistribution and use in source and binary forms, with or without 55c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * modification, are permitted provided that the following conditions 65c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * are met: 75c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 1. Redistributions of source code must retain the above copyright 85c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * notice, this list of conditions and the following disclaimer. 95c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 2. Redistributions in binary form must reproduce the above copyright 105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * notice, this list of conditions and the following disclaimer in the 115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * documentation and/or other materials provided with the distribution. 125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' 145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS 175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * THE POSSIBILITY OF SUCH DAMAGE. 245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) */ 255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#ifndef GeolocationController_h 275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#define GeolocationController_h 285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 29f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles)#include "core/frame/LocalFrame.h" 30bfe3590b1806e3ff18f46ee3af5d4b83078f305aTorne (Richard Coles)#include "core/page/PageLifecycleObserver.h" 3153e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "modules/geolocation/Geolocation.h" 3210f88d5669dbd969c059d61ba09fa37dd72ac559Ben Murdoch#include "platform/heap/Handle.h" 3353e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "wtf/HashSet.h" 3453e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "wtf/Noncopyable.h" 355c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 36c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)namespace blink { 375c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 3809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)class GeolocationInspectorAgent; 395c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)class GeolocationClient; 405c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)class GeolocationError; 415c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)class GeolocationPosition; 425c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 435d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)class GeolocationController FINAL : public NoBaseWillBeGarbageCollectedFinalized<GeolocationController>, public WillBeHeapSupplement<LocalFrame>, public PageLifecycleObserver { 445d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles) WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(GeolocationController); 455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) WTF_MAKE_NONCOPYABLE(GeolocationController); 465c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)public: 4709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) virtual ~GeolocationController(); 485c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 495d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles) static PassOwnPtrWillBeRawPtr<GeolocationController> create(LocalFrame&, GeolocationClient*); 505c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 515c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) void addObserver(Geolocation*, bool enableHighAccuracy); 525c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) void removeObserver(Geolocation*); 535c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 545c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) void requestPermission(Geolocation*); 555c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) void cancelPermissionRequest(Geolocation*); 565c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 575c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) void positionChanged(GeolocationPosition*); 585c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) void errorOccurred(GeolocationError*); 595c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 605c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) GeolocationPosition* lastPosition(); 615c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 6209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) void setClientForTest(GeolocationClient*); 6309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) bool hasClientForTest() { return m_hasClientForTest; } 6409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) GeolocationClient* client() { return m_client; } 6509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) 66bfe3590b1806e3ff18f46ee3af5d4b83078f305aTorne (Richard Coles) // Inherited from PageLifecycleObserver. 67bfe3590b1806e3ff18f46ee3af5d4b83078f305aTorne (Richard Coles) virtual void pageVisibilityChanged() OVERRIDE; 68bfe3590b1806e3ff18f46ee3af5d4b83078f305aTorne (Richard Coles) 69926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) static const char* supplementName(); 705d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles) static GeolocationController* from(LocalFrame* frame) { return static_cast<GeolocationController*>(WillBeHeapSupplement<LocalFrame>::from(frame, supplementName())); } 716f543c786fc42989f552b4daa774ca5ff32fa697Ben Murdoch 725d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles) // Inherited from Supplement. 735d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles) virtual void trace(Visitor*) OVERRIDE; 74a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch 755c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)private: 76f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles) GeolocationController(LocalFrame&, GeolocationClient*); 775c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 78f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) void startUpdatingIfNeeded(); 79f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) void stopUpdatingIfNeeded(); 80f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) 817242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci RawPtrWillBeMember<GeolocationClient> m_client; 8209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) bool m_hasClientForTest; 835c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 845d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles) PersistentWillBeMember<GeolocationPosition> m_lastPosition; 855d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles) typedef PersistentHeapHashSetWillBeHeapHashSet<Member<Geolocation> > ObserversSet; 865c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // All observers; both those requesting high accuracy and those not. 875c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) ObserversSet m_observers; 885c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) ObserversSet m_highAccuracyObservers; 89f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) bool m_isClientUpdating; 90c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) RawPtrWillBeMember<GeolocationInspectorAgent> m_inspectorAgent; 915c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)}; 925c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 93c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)} // namespace blink 945c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 955c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#endif // GeolocationController_h 96