| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 class Geolocation : public ScriptWrappable, public RefCounted<Geolocation>, publ
ic ActiveDOMObject | 49 class Geolocation : public ScriptWrappable, public RefCounted<Geolocation>, publ
ic ActiveDOMObject |
| 50 { | 50 { |
| 51 public: | 51 public: |
| 52 static PassRefPtr<Geolocation> create(ExecutionContext*); | 52 static PassRefPtr<Geolocation> create(ExecutionContext*); |
| 53 ~Geolocation(); | 53 ~Geolocation(); |
| 54 | 54 |
| 55 virtual void stop() OVERRIDE; | 55 virtual void stop() OVERRIDE; |
| 56 Document* document() const; | 56 Document* document() const; |
| 57 Frame* frame() const; | 57 Frame* frame() const; |
| 58 | 58 |
| 59 void getCurrentPosition(PassRefPtr<PositionCallback>, PassRefPtr<PositionErr
orCallback>, PassRefPtr<PositionOptions>); | 59 void getCurrentPosition(PassOwnPtr<PositionCallback>, PassOwnPtr<PositionErr
orCallback>, PassRefPtr<PositionOptions>); |
| 60 int watchPosition(PassRefPtr<PositionCallback>, PassRefPtr<PositionErrorCall
back>, PassRefPtr<PositionOptions>); | 60 int watchPosition(PassOwnPtr<PositionCallback>, PassOwnPtr<PositionErrorCall
back>, PassRefPtr<PositionOptions>); |
| 61 void clearWatch(int watchID); | 61 void clearWatch(int watchID); |
| 62 | 62 |
| 63 void setIsAllowed(bool); | 63 void setIsAllowed(bool); |
| 64 bool isAllowed() const { return m_allowGeolocation == Yes; } | 64 bool isAllowed() const { return m_allowGeolocation == Yes; } |
| 65 | 65 |
| 66 void positionChanged(); | 66 void positionChanged(); |
| 67 void setError(GeolocationError*); | 67 void setError(GeolocationError*); |
| 68 | 68 |
| 69 private: | 69 private: |
| 70 Geoposition* lastPosition(); | 70 Geoposition* lastPosition(); |
| 71 | 71 |
| 72 bool isDenied() const { return m_allowGeolocation == No; } | 72 bool isDenied() const { return m_allowGeolocation == No; } |
| 73 | 73 |
| 74 explicit Geolocation(ExecutionContext*); | 74 explicit Geolocation(ExecutionContext*); |
| 75 | 75 |
| 76 Page* page() const; | 76 Page* page() const; |
| 77 | 77 |
| 78 class GeoNotifier : public RefCounted<GeoNotifier> { | 78 class GeoNotifier : public RefCounted<GeoNotifier> { |
| 79 public: | 79 public: |
| 80 static PassRefPtr<GeoNotifier> create(Geolocation* geolocation, PassRefP
tr<PositionCallback> positionCallback, PassRefPtr<PositionErrorCallback> positio
nErrorCallback, PassRefPtr<PositionOptions> options) { return adoptRef(new GeoNo
tifier(geolocation, positionCallback, positionErrorCallback, options)); } | 80 static PassRefPtr<GeoNotifier> create(Geolocation* geolocation, PassOwnP
tr<PositionCallback> positionCallback, PassOwnPtr<PositionErrorCallback> positio
nErrorCallback, PassRefPtr<PositionOptions> options) { return adoptRef(new GeoNo
tifier(geolocation, positionCallback, positionErrorCallback, options)); } |
| 81 | 81 |
| 82 PositionOptions* options() const { return m_options.get(); }; | 82 PositionOptions* options() const { return m_options.get(); }; |
| 83 void setFatalError(PassRefPtr<PositionError>); | 83 void setFatalError(PassRefPtr<PositionError>); |
| 84 | 84 |
| 85 bool useCachedPosition() const { return m_useCachedPosition; } | 85 bool useCachedPosition() const { return m_useCachedPosition; } |
| 86 void setUseCachedPosition(); | 86 void setUseCachedPosition(); |
| 87 | 87 |
| 88 void runSuccessCallback(Geoposition*); | 88 void runSuccessCallback(Geoposition*); |
| 89 void runErrorCallback(PositionError*); | 89 void runErrorCallback(PositionError*); |
| 90 | 90 |
| 91 void startTimerIfNeeded(); | 91 void startTimerIfNeeded(); |
| 92 void stopTimer(); | 92 void stopTimer(); |
| 93 void timerFired(Timer<GeoNotifier>*); | 93 void timerFired(Timer<GeoNotifier>*); |
| 94 bool hasZeroTimeout() const; | 94 bool hasZeroTimeout() const; |
| 95 | 95 |
| 96 private: | 96 private: |
| 97 GeoNotifier(Geolocation*, PassRefPtr<PositionCallback>, PassRefPtr<Posit
ionErrorCallback>, PassRefPtr<PositionOptions>); | 97 GeoNotifier(Geolocation*, PassOwnPtr<PositionCallback>, PassOwnPtr<Posit
ionErrorCallback>, PassRefPtr<PositionOptions>); |
| 98 | 98 |
| 99 RefPtr<Geolocation> m_geolocation; | 99 RefPtr<Geolocation> m_geolocation; |
| 100 RefPtr<PositionCallback> m_successCallback; | 100 OwnPtr<PositionCallback> m_successCallback; |
| 101 RefPtr<PositionErrorCallback> m_errorCallback; | 101 OwnPtr<PositionErrorCallback> m_errorCallback; |
| 102 RefPtr<PositionOptions> m_options; | 102 RefPtr<PositionOptions> m_options; |
| 103 Timer<GeoNotifier> m_timer; | 103 Timer<GeoNotifier> m_timer; |
| 104 RefPtr<PositionError> m_fatalError; | 104 RefPtr<PositionError> m_fatalError; |
| 105 bool m_useCachedPosition; | 105 bool m_useCachedPosition; |
| 106 }; | 106 }; |
| 107 | 107 |
| 108 typedef Vector<RefPtr<GeoNotifier> > GeoNotifierVector; | 108 typedef Vector<RefPtr<GeoNotifier> > GeoNotifierVector; |
| 109 typedef HashSet<RefPtr<GeoNotifier> > GeoNotifierSet; | 109 typedef HashSet<RefPtr<GeoNotifier> > GeoNotifierSet; |
| 110 | 110 |
| 111 class Watchers { | 111 class Watchers { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 No | 171 No |
| 172 } m_allowGeolocation; | 172 } m_allowGeolocation; |
| 173 | 173 |
| 174 GeoNotifierSet m_requestsAwaitingCachedPosition; | 174 GeoNotifierSet m_requestsAwaitingCachedPosition; |
| 175 }; | 175 }; |
| 176 | 176 |
| 177 } // namespace WebCore | 177 } // namespace WebCore |
| 178 | 178 |
| 179 #endif // Geolocation_h | 179 #endif // Geolocation_h |
| 180 | 180 |
| OLD | NEW |