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 11 matching lines...) Expand all Loading... |
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
25 */ | 25 */ |
26 | 26 |
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/PageLifecycleObserver.h" | 32 #include "core/page/PageVisibilityObserver.h" |
33 #include "modules/ModulesExport.h" | 33 #include "modules/ModulesExport.h" |
34 #include "modules/geolocation/GeoNotifier.h" | 34 #include "modules/geolocation/GeoNotifier.h" |
35 #include "modules/geolocation/GeolocationWatchers.h" | 35 #include "modules/geolocation/GeolocationWatchers.h" |
36 #include "modules/geolocation/Geoposition.h" | 36 #include "modules/geolocation/Geoposition.h" |
37 #include "modules/geolocation/PositionCallback.h" | 37 #include "modules/geolocation/PositionCallback.h" |
38 #include "modules/geolocation/PositionError.h" | 38 #include "modules/geolocation/PositionError.h" |
39 #include "modules/geolocation/PositionErrorCallback.h" | 39 #include "modules/geolocation/PositionErrorCallback.h" |
40 #include "modules/geolocation/PositionOptions.h" | 40 #include "modules/geolocation/PositionOptions.h" |
41 #include "platform/Timer.h" | 41 #include "platform/Timer.h" |
42 #include "platform/heap/Handle.h" | 42 #include "platform/heap/Handle.h" |
43 #include "third_party/WebKit/public/platform/modules/geolocation/geolocation.moj
om-blink.h" | 43 #include "third_party/WebKit/public/platform/modules/geolocation/geolocation.moj
om-blink.h" |
44 #include "third_party/WebKit/public/platform/modules/permissions/permission.mojo
m-blink.h" | 44 #include "third_party/WebKit/public/platform/modules/permissions/permission.mojo
m-blink.h" |
45 #include "third_party/WebKit/public/platform/modules/permissions/permission_stat
us.mojom-blink.h" | 45 #include "third_party/WebKit/public/platform/modules/permissions/permission_stat
us.mojom-blink.h" |
46 | 46 |
47 namespace blink { | 47 namespace blink { |
48 | 48 |
49 class Document; | 49 class Document; |
50 class LocalFrame; | 50 class LocalFrame; |
51 class GeolocationError; | 51 class GeolocationError; |
52 class ExecutionContext; | 52 class ExecutionContext; |
53 | 53 |
54 class MODULES_EXPORT Geolocation final | 54 class MODULES_EXPORT Geolocation final |
55 : public GarbageCollectedFinalized<Geolocation> | 55 : public GarbageCollectedFinalized<Geolocation> |
56 , public ScriptWrappable | 56 , public ScriptWrappable |
57 , public ContextLifecycleObserver | 57 , public ContextLifecycleObserver |
58 , public PageLifecycleObserver { | 58 , public PageVisibilityObserver { |
59 DEFINE_WRAPPERTYPEINFO(); | 59 DEFINE_WRAPPERTYPEINFO(); |
60 USING_GARBAGE_COLLECTED_MIXIN(Geolocation); | 60 USING_GARBAGE_COLLECTED_MIXIN(Geolocation); |
61 public: | 61 public: |
62 static Geolocation* create(ExecutionContext*); | 62 static Geolocation* create(ExecutionContext*); |
63 ~Geolocation(); | 63 ~Geolocation(); |
64 DECLARE_VIRTUAL_TRACE(); | 64 DECLARE_VIRTUAL_TRACE(); |
65 | 65 |
66 // Inherited from ContextLifecycleObserver AND PageLifecycleObserver. | 66 // Inherited from ContextLifecycleObserver AND PageVisibilityObserver. |
67 void contextDestroyed() override; | 67 void contextDestroyed() override; |
68 | 68 |
69 Document* document() const; | 69 Document* document() const; |
70 LocalFrame* frame() const; | 70 LocalFrame* frame() const; |
71 | 71 |
72 // Creates a oneshot and attempts to obtain a position that meets the | 72 // Creates a oneshot and attempts to obtain a position that meets the |
73 // constraints of the options. | 73 // constraints of the options. |
74 void getCurrentPosition(PositionCallback*, PositionErrorCallback*, const Pos
itionOptions&); | 74 void getCurrentPosition(PositionCallback*, PositionErrorCallback*, const Pos
itionOptions&); |
75 | 75 |
76 // Creates a watcher that will be notified whenever a new position is | 76 // Creates a watcher that will be notified whenever a new position is |
(...skipping 13 matching lines...) Expand all Loading... |
90 void fatalErrorOccurred(GeoNotifier*); | 90 void fatalErrorOccurred(GeoNotifier*); |
91 | 91 |
92 // Adds the notifier to the set awaiting a cached position. Runs the success | 92 // Adds the notifier to the set awaiting a cached position. Runs the success |
93 // callbacks for them if permission has been granted. Requests permission if | 93 // callbacks for them if permission has been granted. Requests permission if |
94 // it is unknown. | 94 // it is unknown. |
95 void requestUsesCachedPosition(GeoNotifier*); | 95 void requestUsesCachedPosition(GeoNotifier*); |
96 | 96 |
97 // Discards the notifier if it is a oneshot because it timed it. | 97 // Discards the notifier if it is a oneshot because it timed it. |
98 void requestTimedOut(GeoNotifier*); | 98 void requestTimedOut(GeoNotifier*); |
99 | 99 |
100 // Inherited from PageLifecycleObserver. | 100 // Inherited from PageVisibilityObserver. |
101 void pageVisibilityChanged() override; | 101 void pageVisibilityChanged() override; |
102 | 102 |
103 private: | 103 private: |
104 bool isDenied() const { return m_geolocationPermission == PermissionDenied;
} | 104 bool isDenied() const { return m_geolocationPermission == PermissionDenied;
} |
105 | 105 |
106 explicit Geolocation(ExecutionContext*); | 106 explicit Geolocation(ExecutionContext*); |
107 | 107 |
108 typedef HeapVector<Member<GeoNotifier>> GeoNotifierVector; | 108 typedef HeapVector<Member<GeoNotifier>> GeoNotifierVector; |
109 typedef HeapHashSet<Member<GeoNotifier>> GeoNotifierSet; | 109 typedef HeapHashSet<Member<GeoNotifier>> GeoNotifierSet; |
110 | 110 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 | 199 |
200 // Set to true when m_geolocationService is disconnected. This is used to | 200 // Set to true when m_geolocationService is disconnected. This is used to |
201 // detect when m_geolocationService is disconnected and reconnected while | 201 // detect when m_geolocationService is disconnected and reconnected while |
202 // running callbacks in response to a call to onPositionUpdated(). | 202 // running callbacks in response to a call to onPositionUpdated(). |
203 bool m_disconnectedGeolocationService = false; | 203 bool m_disconnectedGeolocationService = false; |
204 }; | 204 }; |
205 | 205 |
206 } // namespace blink | 206 } // namespace blink |
207 | 207 |
208 #endif // Geolocation_h | 208 #endif // Geolocation_h |
OLD | NEW |