OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 17 matching lines...) Expand all Loading... |
28 #include "modules/geolocation/GeolocationController.h" | 28 #include "modules/geolocation/GeolocationController.h" |
29 | 29 |
30 #include "core/inspector/InspectorController.h" | 30 #include "core/inspector/InspectorController.h" |
31 #include "modules/geolocation/GeolocationClient.h" | 31 #include "modules/geolocation/GeolocationClient.h" |
32 #include "modules/geolocation/GeolocationError.h" | 32 #include "modules/geolocation/GeolocationError.h" |
33 #include "modules/geolocation/GeolocationInspectorAgent.h" | 33 #include "modules/geolocation/GeolocationInspectorAgent.h" |
34 #include "modules/geolocation/GeolocationPosition.h" | 34 #include "modules/geolocation/GeolocationPosition.h" |
35 | 35 |
36 namespace WebCore { | 36 namespace WebCore { |
37 | 37 |
38 GeolocationController::GeolocationController(Page* page, GeolocationClient* clie
nt) | 38 GeolocationController::GeolocationController(Page& page, GeolocationClient* clie
nt) |
39 : PageLifecycleObserver(page) | 39 : PageLifecycleObserver(&page) |
40 , m_client(client) | 40 , m_client(client) |
41 , m_hasClientForTest(false) | 41 , m_hasClientForTest(false) |
42 , m_isClientUpdating(false) | 42 , m_isClientUpdating(false) |
43 , m_inspectorAgent() | 43 , m_inspectorAgent() |
44 { | 44 { |
45 OwnPtr<GeolocationInspectorAgent> geolocationAgent(GeolocationInspectorAgent
::create(this)); | 45 OwnPtr<GeolocationInspectorAgent> geolocationAgent(GeolocationInspectorAgent
::create(this)); |
46 m_inspectorAgent = geolocationAgent.get(); | 46 m_inspectorAgent = geolocationAgent.get(); |
47 page->inspectorController().registerModuleAgent(geolocationAgent.release()); | 47 page.inspectorController().registerModuleAgent(geolocationAgent.release()); |
48 } | 48 } |
49 | 49 |
50 void GeolocationController::startUpdatingIfNeeded() | 50 void GeolocationController::startUpdatingIfNeeded() |
51 { | 51 { |
52 if (m_isClientUpdating) | 52 if (m_isClientUpdating) |
53 return; | 53 return; |
54 m_isClientUpdating = true; | 54 m_isClientUpdating = true; |
55 m_client->startUpdating(); | 55 m_client->startUpdating(); |
56 } | 56 } |
57 | 57 |
58 void GeolocationController::stopUpdatingIfNeeded() | 58 void GeolocationController::stopUpdatingIfNeeded() |
59 { | 59 { |
60 if (!m_isClientUpdating) | 60 if (!m_isClientUpdating) |
61 return; | 61 return; |
62 m_isClientUpdating = false; | 62 m_isClientUpdating = false; |
63 m_client->stopUpdating(); | 63 m_client->stopUpdating(); |
64 } | 64 } |
65 | 65 |
66 GeolocationController::~GeolocationController() | 66 GeolocationController::~GeolocationController() |
67 { | 67 { |
68 ASSERT(m_observers.isEmpty()); | 68 ASSERT(m_observers.isEmpty()); |
69 | 69 |
70 if (m_client) | 70 if (m_client) |
71 m_client->geolocationDestroyed(); | 71 m_client->geolocationDestroyed(); |
72 } | 72 } |
73 | 73 |
74 PassOwnPtr<GeolocationController> GeolocationController::create(Page* page, Geol
ocationClient* client) | 74 PassOwnPtr<GeolocationController> GeolocationController::create(Page& page, Geol
ocationClient* client) |
75 { | 75 { |
76 return adoptPtr(new GeolocationController(page, client)); | 76 return adoptPtr(new GeolocationController(page, client)); |
77 } | 77 } |
78 | 78 |
79 void GeolocationController::addObserver(Geolocation* observer, bool enableHighAc
curacy) | 79 void GeolocationController::addObserver(Geolocation* observer, bool enableHighAc
curacy) |
80 { | 80 { |
81 // This may be called multiple times with the same observer, though removeOb
server() | 81 // This may be called multiple times with the same observer, though removeOb
server() |
82 // is called only once with each. | 82 // is called only once with each. |
83 bool wasEmpty = m_observers.isEmpty(); | 83 bool wasEmpty = m_observers.isEmpty(); |
84 m_observers.add(observer); | 84 m_observers.add(observer); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 startUpdatingIfNeeded(); | 169 startUpdatingIfNeeded(); |
170 else | 170 else |
171 stopUpdatingIfNeeded(); | 171 stopUpdatingIfNeeded(); |
172 } | 172 } |
173 | 173 |
174 const char* GeolocationController::supplementName() | 174 const char* GeolocationController::supplementName() |
175 { | 175 { |
176 return "GeolocationController"; | 176 return "GeolocationController"; |
177 } | 177 } |
178 | 178 |
179 void provideGeolocationTo(Page* page, GeolocationClient* client) | 179 void provideGeolocationTo(Page& page, GeolocationClient* client) |
180 { | 180 { |
181 Supplement<Page>::provideTo(page, GeolocationController::supplementName(), G
eolocationController::create(page, client)); | 181 Supplement<Page>::provideTo(page, GeolocationController::supplementName(), G
eolocationController::create(page, client)); |
182 } | 182 } |
183 | 183 |
184 } // namespace WebCore | 184 } // namespace WebCore |
OLD | NEW |