| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008, 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 |
| 11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
| 12 * | 12 * |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 void disconnectFrame(); | 53 void disconnectFrame(); |
| 54 | 54 |
| 55 Geoposition* lastPosition() const { return m_service->lastPosition(); } | 55 Geoposition* lastPosition() const { return m_service->lastPosition(); } |
| 56 | 56 |
| 57 void getCurrentPosition(PassRefPtr<PositionCallback>, PassRefPtr<PositionErr
orCallback>, PositionOptions*); | 57 void getCurrentPosition(PassRefPtr<PositionCallback>, PassRefPtr<PositionErr
orCallback>, PositionOptions*); |
| 58 int watchPosition(PassRefPtr<PositionCallback>, PassRefPtr<PositionErrorCall
back>, PositionOptions*); | 58 int watchPosition(PassRefPtr<PositionCallback>, PassRefPtr<PositionErrorCall
back>, PositionOptions*); |
| 59 void clearWatch(int watchId); | 59 void clearWatch(int watchId); |
| 60 | 60 |
| 61 void suspend(); | 61 void suspend(); |
| 62 void resume(); | 62 void resume(); |
| 63 |
| 64 void setIsAllowed(bool); |
| 65 bool isAllowed() const { return m_allowGeolocation == Yes; } |
| 66 |
| 67 void setShouldClearCache(bool shouldClearCache) { m_shouldClearCache = shoul
dClearCache; } |
| 68 bool shouldClearCache() const { return m_shouldClearCache; } |
| 63 | 69 |
| 64 private: | 70 private: |
| 65 Geolocation(Frame*); | 71 Geolocation(Frame*); |
| 66 | 72 |
| 67 class GeoNotifier : public RefCounted<GeoNotifier> { | 73 class GeoNotifier : public RefCounted<GeoNotifier> { |
| 68 public: | 74 public: |
| 69 static PassRefPtr<GeoNotifier> create(PassRefPtr<PositionCallback> posit
ionCallback, PassRefPtr<PositionErrorCallback> positionErrorCallback, PositionOp
tions* options) { return adoptRef(new GeoNotifier(positionCallback, positionErro
rCallback, options)); } | 75 static PassRefPtr<GeoNotifier> create(PassRefPtr<PositionCallback> posit
ionCallback, PassRefPtr<PositionErrorCallback> positionErrorCallback, PositionOp
tions* options) { return adoptRef(new GeoNotifier(positionCallback, positionErro
rCallback, options)); } |
| 70 | 76 |
| 71 void timerFired(Timer<GeoNotifier>*); | 77 void timerFired(Timer<GeoNotifier>*); |
| 72 | 78 |
| 73 RefPtr<PositionCallback> m_successCallback; | 79 RefPtr<PositionCallback> m_successCallback; |
| 74 RefPtr<PositionErrorCallback> m_errorCallback; | 80 RefPtr<PositionErrorCallback> m_errorCallback; |
| 75 Timer<GeoNotifier> m_timer; | 81 Timer<GeoNotifier> m_timer; |
| 76 | 82 |
| 77 private: | 83 private: |
| 78 GeoNotifier(PassRefPtr<PositionCallback>, PassRefPtr<PositionErrorCallba
ck>, PositionOptions*); | 84 GeoNotifier(PassRefPtr<PositionCallback>, PassRefPtr<PositionErrorCallba
ck>, PositionOptions*); |
| 79 }; | 85 }; |
| 80 | 86 |
| 81 bool hasListeners() const { return !m_oneShots.isEmpty() || !m_watchers.isEm
pty(); } | 87 bool hasListeners() const { return !m_oneShots.isEmpty() || !m_watchers.isEm
pty(); } |
| 82 | 88 |
| 83 void sendErrorToOneShots(PositionError*); | 89 void sendErrorToOneShots(PositionError*); |
| 84 void sendErrorToWatchers(PositionError*); | 90 void sendErrorToWatchers(PositionError*); |
| 85 void sendPositionToOneShots(Geoposition*); | 91 void sendPositionToOneShots(Geoposition*); |
| 86 void sendPositionToWatchers(Geoposition*); | 92 void sendPositionToWatchers(Geoposition*); |
| 87 | 93 |
| 88 void handleError(PositionError*); | 94 void handleError(PositionError*); |
| 89 | 95 |
| 96 void requestPermission(); |
| 97 |
| 90 // GeolocationServiceClient | 98 // GeolocationServiceClient |
| 91 virtual void geolocationServicePositionChanged(GeolocationService*); | 99 virtual void geolocationServicePositionChanged(GeolocationService*); |
| 92 virtual void geolocationServiceErrorOccurred(GeolocationService*); | 100 virtual void geolocationServiceErrorOccurred(GeolocationService*); |
| 93 | 101 |
| 94 bool shouldAllowGeolocation(); | |
| 95 | |
| 96 typedef HashSet<RefPtr<GeoNotifier> > GeoNotifierSet; | 102 typedef HashSet<RefPtr<GeoNotifier> > GeoNotifierSet; |
| 97 typedef HashMap<int, RefPtr<GeoNotifier> > GeoNotifierMap; | 103 typedef HashMap<int, RefPtr<GeoNotifier> > GeoNotifierMap; |
| 98 | 104 |
| 99 GeoNotifierSet m_oneShots; | 105 GeoNotifierSet m_oneShots; |
| 100 GeoNotifierMap m_watchers; | 106 GeoNotifierMap m_watchers; |
| 101 Frame* m_frame; | 107 Frame* m_frame; |
| 102 OwnPtr<GeolocationService> m_service; | 108 OwnPtr<GeolocationService> m_service; |
| 103 | 109 |
| 104 enum { | 110 enum { |
| 105 Unknown, | 111 Unknown, |
| 112 InProgress, |
| 106 Yes, | 113 Yes, |
| 107 No | 114 No |
| 108 } m_allowGeolocation; | 115 } m_allowGeolocation; |
| 116 bool m_shouldClearCache; |
| 109 }; | 117 }; |
| 110 | 118 |
| 111 } // namespace WebCore | 119 } // namespace WebCore |
| 112 | 120 |
| 113 #endif // Geolocation_h | 121 #endif // Geolocation_h |
| OLD | NEW |