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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
57 // This may be called multiple times with the same observer, though removeOb server() | 57 // This may be called multiple times with the same observer, though removeOb server() |
58 // is called only once with each. | 58 // is called only once with each. |
59 bool wasEmpty = m_observers.isEmpty(); | 59 bool wasEmpty = m_observers.isEmpty(); |
60 m_observers.add(observer); | 60 m_observers.add(observer); |
61 if (enableHighAccuracy) | 61 if (enableHighAccuracy) |
62 m_highAccuracyObservers.add(observer); | 62 m_highAccuracyObservers.add(observer); |
63 | 63 |
64 if (m_client) { | 64 if (m_client) { |
65 if (enableHighAccuracy) | 65 if (enableHighAccuracy) |
66 m_client->setEnableHighAccuracy(true); | 66 m_client->setEnableHighAccuracy(true); |
67 if (wasEmpty && page()->visibilityState() == PageVisibilityStateVisible) | 67 if (wasEmpty && page() && page()->visibilityState() == PageVisibilitySta teVisible) |
68 m_client->startUpdating(); | 68 m_client->startUpdating(); |
69 } | 69 } |
70 } | 70 } |
71 | 71 |
72 void GeolocationController::removeObserver(Geolocation* observer) | 72 void GeolocationController::removeObserver(Geolocation* observer) |
73 { | 73 { |
74 if (!m_observers.contains(observer)) | 74 if (!m_observers.contains(observer)) |
75 return; | 75 return; |
76 | 76 |
77 m_observers.remove(observer); | 77 m_observers.remove(observer); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
128 return 0; | 128 return 0; |
129 | 129 |
130 return m_client->lastPosition(); | 130 return m_client->lastPosition(); |
131 } | 131 } |
132 | 132 |
133 void GeolocationController::pageVisibilityChanged() | 133 void GeolocationController::pageVisibilityChanged() |
134 { | 134 { |
135 if (m_observers.isEmpty() || !m_client) | 135 if (m_observers.isEmpty() || !m_client) |
136 return; | 136 return; |
137 | 137 |
138 if (page()->visibilityState() == PageVisibilityStateVisible) | 138 if (page() && page()->visibilityState() == PageVisibilityStateVisible) |
adamk
2013/10/23 15:34:38
I'd hope that page() couldn't be null here, since
| |
139 m_client->startUpdating(); | 139 m_client->startUpdating(); |
140 else | 140 else |
141 m_client->stopUpdating(); | 141 m_client->stopUpdating(); |
142 } | 142 } |
143 | 143 |
144 const char* GeolocationController::supplementName() | 144 const char* GeolocationController::supplementName() |
145 { | 145 { |
146 return "GeolocationController"; | 146 return "GeolocationController"; |
147 } | 147 } |
148 | 148 |
149 void provideGeolocationTo(Page* page, GeolocationClient* client) | 149 void provideGeolocationTo(Page* page, GeolocationClient* client) |
150 { | 150 { |
151 Supplement<Page>::provideTo(page, GeolocationController::supplementName(), G eolocationController::create(page, client)); | 151 Supplement<Page>::provideTo(page, GeolocationController::supplementName(), G eolocationController::create(page, client)); |
152 } | 152 } |
153 | 153 |
154 } // namespace WebCore | 154 } // namespace WebCore |
OLD | NEW |