| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008, 2009, 2010, 2011 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008, 2009, 2010, 2011 Apple Inc. All Rights Reserved. |
| 3 * Copyright 2010, The Android Open Source Project | 3 * Copyright 2010, The Android Open Source Project |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #ifndef Geolocation_h | 27 #ifndef Geolocation_h |
| 28 #define Geolocation_h | 28 #define Geolocation_h |
| 29 | 29 |
| 30 #include "bindings/core/v8/ScriptWrappable.h" | 30 #include "bindings/core/v8/ScriptWrappable.h" |
| 31 #include "core/dom/ContextLifecycleObserver.h" | 31 #include "core/dom/ContextLifecycleObserver.h" |
| 32 #include "core/page/PageVisibilityObserver.h" | 32 #include "core/page/PageVisibilityObserver.h" |
| 33 #include "device/geolocation/public/interfaces/geolocation.mojom-blink.h" | 33 #include "device/geolocation/public/interfaces/geolocation.mojom-blink.h" |
| 34 #include "modules/ModulesExport.h" | 34 #include "modules/ModulesExport.h" |
| 35 #include "modules/geolocation/GeoNotifier.h" | 35 #include "modules/geolocation/GeoNotifier.h" |
| 36 #include "modules/geolocation/GeolocationWatchers.h" | 36 #include "modules/geolocation/GeolocationWatchers.h" |
| 37 #include "modules/geolocation/Geoposition.h" | 37 #include "modules/geolocation/Position.h" |
| 38 #include "modules/geolocation/PositionCallback.h" | 38 #include "modules/geolocation/PositionCallback.h" |
| 39 #include "modules/geolocation/PositionError.h" | 39 #include "modules/geolocation/PositionError.h" |
| 40 #include "modules/geolocation/PositionErrorCallback.h" | 40 #include "modules/geolocation/PositionErrorCallback.h" |
| 41 #include "modules/geolocation/PositionOptions.h" | 41 #include "modules/geolocation/PositionOptions.h" |
| 42 #include "platform/Timer.h" | 42 #include "platform/Timer.h" |
| 43 #include "platform/heap/Handle.h" | 43 #include "platform/heap/Handle.h" |
| 44 | 44 |
| 45 #include "third_party/WebKit/public/platform/modules/permissions/permission.mojo
m-blink.h" | 45 #include "third_party/WebKit/public/platform/modules/permissions/permission.mojo
m-blink.h" |
| 46 #include "third_party/WebKit/public/platform/modules/permissions/permission_stat
us.mojom-blink.h" | 46 #include "third_party/WebKit/public/platform/modules/permissions/permission_stat
us.mojom-blink.h" |
| 47 | 47 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 explicit Geolocation(ExecutionContext*); | 113 explicit Geolocation(ExecutionContext*); |
| 114 | 114 |
| 115 typedef HeapVector<Member<GeoNotifier>> GeoNotifierVector; | 115 typedef HeapVector<Member<GeoNotifier>> GeoNotifierVector; |
| 116 typedef HeapHashSet<Member<GeoNotifier>> GeoNotifierSet; | 116 typedef HeapHashSet<Member<GeoNotifier>> GeoNotifierSet; |
| 117 | 117 |
| 118 bool HasListeners() const { | 118 bool HasListeners() const { |
| 119 return !one_shots_.IsEmpty() || !watchers_.IsEmpty(); | 119 return !one_shots_.IsEmpty() || !watchers_.IsEmpty(); |
| 120 } | 120 } |
| 121 | 121 |
| 122 void SendError(GeoNotifierVector&, PositionError*); | 122 void SendError(GeoNotifierVector&, PositionError*); |
| 123 void SendPosition(GeoNotifierVector&, Geoposition*); | 123 void SendPosition(GeoNotifierVector&, Position*); |
| 124 | 124 |
| 125 // Removes notifiers that use a cached position from |notifiers| and | 125 // Removes notifiers that use a cached position from |notifiers| and |
| 126 // if |cached| is not null they are added to it. | 126 // if |cached| is not null they are added to it. |
| 127 static void ExtractNotifiersWithCachedPosition(GeoNotifierVector& notifiers, | 127 static void ExtractNotifiersWithCachedPosition(GeoNotifierVector& notifiers, |
| 128 GeoNotifierVector* cached); | 128 GeoNotifierVector* cached); |
| 129 | 129 |
| 130 // Copies notifiers from |src| vector to |dest| set. | 130 // Copies notifiers from |src| vector to |dest| set. |
| 131 static void CopyToSet(const GeoNotifierVector& src, GeoNotifierSet& dest); | 131 static void CopyToSet(const GeoNotifierVector& src, GeoNotifierSet& dest); |
| 132 | 132 |
| 133 static void StopTimer(GeoNotifierVector&); | 133 static void StopTimer(GeoNotifierVector&); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 // granted then the notifier's timers are started. Otherwise, a fatal error | 180 // granted then the notifier's timers are started. Otherwise, a fatal error |
| 181 // is set on them. | 181 // is set on them. |
| 182 void OnGeolocationPermissionUpdated(mojom::blink::PermissionStatus); | 182 void OnGeolocationPermissionUpdated(mojom::blink::PermissionStatus); |
| 183 | 183 |
| 184 void OnGeolocationConnectionError(); | 184 void OnGeolocationConnectionError(); |
| 185 void OnPermissionConnectionError(); | 185 void OnPermissionConnectionError(); |
| 186 | 186 |
| 187 GeoNotifierSet one_shots_; | 187 GeoNotifierSet one_shots_; |
| 188 GeolocationWatchers watchers_; | 188 GeolocationWatchers watchers_; |
| 189 GeoNotifierSet pending_for_permission_notifiers_; | 189 GeoNotifierSet pending_for_permission_notifiers_; |
| 190 Member<Geoposition> last_position_; | 190 Member<Position> last_position_; |
| 191 | 191 |
| 192 // States of Geolocation permission as granted by the embedder. Unknown | 192 // States of Geolocation permission as granted by the embedder. Unknown |
| 193 // means that the embedder still has to be asked for the current permission | 193 // means that the embedder still has to be asked for the current permission |
| 194 // level; Requested means that the user has yet to make a decision. | 194 // level; Requested means that the user has yet to make a decision. |
| 195 enum Permission { | 195 enum Permission { |
| 196 kPermissionUnknown, | 196 kPermissionUnknown, |
| 197 kPermissionRequested, | 197 kPermissionRequested, |
| 198 kPermissionAllowed, | 198 kPermissionAllowed, |
| 199 kPermissionDenied | 199 kPermissionDenied |
| 200 }; | 200 }; |
| 201 | 201 |
| 202 Permission geolocation_permission_; | 202 Permission geolocation_permission_; |
| 203 device::mojom::blink::GeolocationServicePtr geolocation_service_; | 203 device::mojom::blink::GeolocationServicePtr geolocation_service_; |
| 204 bool enable_high_accuracy_ = false; | 204 bool enable_high_accuracy_ = false; |
| 205 mojom::blink::PermissionServicePtr permission_service_; | 205 mojom::blink::PermissionServicePtr permission_service_; |
| 206 | 206 |
| 207 // Whether a GeoNotifier is waiting for a position update. | 207 // Whether a GeoNotifier is waiting for a position update. |
| 208 bool updating_ = false; | 208 bool updating_ = false; |
| 209 | 209 |
| 210 // Set to true when m_geolocationService is disconnected. This is used to | 210 // Set to true when m_geolocationService is disconnected. This is used to |
| 211 // detect when m_geolocationService is disconnected and reconnected while | 211 // detect when m_geolocationService is disconnected and reconnected while |
| 212 // running callbacks in response to a call to onPositionUpdated(). | 212 // running callbacks in response to a call to onPositionUpdated(). |
| 213 bool disconnected_geolocation_service_ = false; | 213 bool disconnected_geolocation_service_ = false; |
| 214 }; | 214 }; |
| 215 | 215 |
| 216 } // namespace blink | 216 } // namespace blink |
| 217 | 217 |
| 218 #endif // Geolocation_h | 218 #endif // Geolocation_h |
| OLD | NEW |