| Index: Source/modules/geolocation/GeolocationController.cpp
|
| diff --git a/Source/modules/geolocation/GeolocationController.cpp b/Source/modules/geolocation/GeolocationController.cpp
|
| index c5bf45367b4db0b5d8d78aaa07ca76608698a025..3a599227efb35c7f56f2c2384f285cf02a36b75a 100644
|
| --- a/Source/modules/geolocation/GeolocationController.cpp
|
| +++ b/Source/modules/geolocation/GeolocationController.cpp
|
| @@ -28,6 +28,7 @@
|
| #include "modules/geolocation/GeolocationController.h"
|
|
|
| #include "core/inspector/InspectorController.h"
|
| +#include "core/page/Page.h"
|
| #include "modules/geolocation/GeolocationClient.h"
|
| #include "modules/geolocation/GeolocationError.h"
|
| #include "modules/geolocation/GeolocationInspectorAgent.h"
|
| @@ -35,16 +36,32 @@
|
|
|
| namespace WebCore {
|
|
|
| -GeolocationController::GeolocationController(Page& page, GeolocationClient* client)
|
| - : PageLifecycleObserver(&page)
|
| +GeolocationController::GeolocationController(LocalFrame& frame, GeolocationClient* client)
|
| + : PageLifecycleObserver(frame.page())
|
| , m_client(client)
|
| , m_hasClientForTest(false)
|
| , m_isClientUpdating(false)
|
| , m_inspectorAgent()
|
| {
|
| - OwnPtr<GeolocationInspectorAgent> geolocationAgent(GeolocationInspectorAgent::create(this));
|
| - m_inspectorAgent = geolocationAgent.get();
|
| - page.inspectorController().registerModuleAgent(geolocationAgent.release());
|
| + // FIXME: Once GeolocationInspectorAgent is per frame, there will be a 1:1 relationship between
|
| + // it and this class. Until then, there's one GeolocationInspectorAgent per page that the main
|
| + // frame is responsible for creating.
|
| + if (frame.isMainFrame()) {
|
| + OwnPtr<GeolocationInspectorAgent> geolocationAgent(GeolocationInspectorAgent::create());
|
| + m_inspectorAgent = geolocationAgent.get();
|
| + frame.page()->inspectorController().registerModuleAgent(geolocationAgent.release());
|
| + } else {
|
| + m_inspectorAgent = GeolocationController::from(frame.page()->mainFrame())->m_inspectorAgent;
|
| + }
|
| +
|
| + m_inspectorAgent->AddController(this);
|
| +
|
| + if (!frame.isMainFrame()) {
|
| + // internals.setGeolocationClientMock is per page.
|
| + GeolocationController* mainController = GeolocationController::from(frame.page()->mainFrame());
|
| + if (mainController->hasClientForTest())
|
| + setClientForTest(mainController->client());
|
| + }
|
| }
|
|
|
| void GeolocationController::startUpdatingIfNeeded()
|
| @@ -66,6 +83,11 @@ void GeolocationController::stopUpdatingIfNeeded()
|
| GeolocationController::~GeolocationController()
|
| {
|
| ASSERT(m_observers.isEmpty());
|
| + if (page())
|
| + m_inspectorAgent->RemoveController(this);
|
| +
|
| + if (m_hasClientForTest)
|
| + m_client->controllerForTestRemoved(this);
|
| }
|
|
|
| void GeolocationController::willBeDestroyed()
|
| @@ -74,9 +96,9 @@ void GeolocationController::willBeDestroyed()
|
| m_client->geolocationDestroyed();
|
| }
|
|
|
| -PassOwnPtrWillBeRawPtr<GeolocationController> GeolocationController::create(Page& page, GeolocationClient* client)
|
| +PassOwnPtrWillBeRawPtr<GeolocationController> GeolocationController::create(LocalFrame& frame, GeolocationClient* client)
|
| {
|
| - return adoptPtrWillBeNoop(new GeolocationController(page, client));
|
| + return adoptPtrWillBeNoop(new GeolocationController(frame, client));
|
| }
|
|
|
| void GeolocationController::addObserver(Geolocation* observer, bool enableHighAccuracy)
|
| @@ -161,6 +183,8 @@ void GeolocationController::setClientForTest(GeolocationClient* client)
|
| {
|
| m_client = client;
|
| m_hasClientForTest = true;
|
| +
|
| + client->controllerForTestAdded(this);
|
| }
|
|
|
| void GeolocationController::pageVisibilityChanged()
|
| @@ -184,12 +208,12 @@ void GeolocationController::trace(Visitor* visitor)
|
| visitor->trace(m_lastPosition);
|
| visitor->trace(m_observers);
|
| visitor->trace(m_highAccuracyObservers);
|
| - WillBeHeapSupplement<Page>::trace(visitor);
|
| + WillBeHeapSupplement<LocalFrame>::trace(visitor);
|
| }
|
|
|
| -void provideGeolocationTo(Page& page, GeolocationClient* client)
|
| +void provideGeolocationTo(LocalFrame& frame, GeolocationClient* client)
|
| {
|
| - WillBeHeapSupplement<Page>::provideTo(page, GeolocationController::supplementName(), GeolocationController::create(page, client));
|
| + WillBeHeapSupplement<LocalFrame>::provideTo(frame, GeolocationController::supplementName(), GeolocationController::create(frame, client));
|
| }
|
|
|
| } // namespace WebCore
|
|
|