| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2012 Apple Inc. All Rights Reserved. | 3 * Copyright (C) 2012 Apple Inc. All Rights Reserved. |
| 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 are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 #define GeolocationClientMock_h | 33 #define GeolocationClientMock_h |
| 34 | 34 |
| 35 #include "modules/geolocation/GeolocationClient.h" | 35 #include "modules/geolocation/GeolocationClient.h" |
| 36 #include "platform/Timer.h" | 36 #include "platform/Timer.h" |
| 37 #include "wtf/HashSet.h" | 37 #include "wtf/HashSet.h" |
| 38 #include "wtf/PassRefPtr.h" | 38 #include "wtf/PassRefPtr.h" |
| 39 #include "wtf/RefPtr.h" | 39 #include "wtf/RefPtr.h" |
| 40 #include "wtf/text/WTFString.h" | 40 #include "wtf/text/WTFString.h" |
| 41 | 41 |
| 42 namespace WebCore { | 42 namespace WebCore { |
| 43 | |
| 44 class GeolocationController; | 43 class GeolocationController; |
| 45 class GeolocationPosition; | 44 class GeolocationPosition; |
| 45 } |
| 46 | 46 |
| 47 // FIXME: this should not be in WebCore. It should be moved to WebKit. | 47 namespace blink { |
| 48 |
| 48 // Provides a mock object for the geolocation client. | 49 // Provides a mock object for the geolocation client. |
| 49 class GeolocationClientMock : public GeolocationClient { | 50 class GeolocationClientMock : public WebCore::GeolocationClient { |
| 50 public: | 51 public: |
| 51 GeolocationClientMock(); | 52 GeolocationClientMock(); |
| 52 virtual ~GeolocationClientMock(); | 53 virtual ~GeolocationClientMock(); |
| 53 | 54 |
| 54 void reset(); | 55 void reset(); |
| 55 void setController(GeolocationController*); | 56 void setController(WebCore::GeolocationController*); |
| 56 | 57 |
| 57 void setPosition(PassRefPtr<GeolocationPosition>); | 58 void setPosition(PassRefPtr<WebCore::GeolocationPosition>); |
| 58 void setPositionUnavailableError(const String& errorMessage); | 59 void setPositionUnavailableError(const String& errorMessage); |
| 59 void setPermission(bool allowed); | 60 void setPermission(bool allowed); |
| 60 int numberOfPendingPermissionRequests() const; | 61 int numberOfPendingPermissionRequests() const; |
| 61 | 62 |
| 62 // GeolocationClient | 63 // GeolocationClient |
| 63 virtual void geolocationDestroyed() OVERRIDE; | 64 virtual void geolocationDestroyed() OVERRIDE; |
| 64 virtual void startUpdating() OVERRIDE; | 65 virtual void startUpdating() OVERRIDE; |
| 65 virtual void stopUpdating() OVERRIDE; | 66 virtual void stopUpdating() OVERRIDE; |
| 66 virtual void setEnableHighAccuracy(bool) OVERRIDE; | 67 virtual void setEnableHighAccuracy(bool) OVERRIDE; |
| 67 virtual GeolocationPosition* lastPosition() OVERRIDE; | 68 virtual WebCore::GeolocationPosition* lastPosition() OVERRIDE; |
| 68 virtual void requestPermission(Geolocation*) OVERRIDE; | 69 virtual void requestPermission(WebCore::Geolocation*) OVERRIDE; |
| 69 virtual void cancelPermissionRequest(Geolocation*) OVERRIDE; | 70 virtual void cancelPermissionRequest(WebCore::Geolocation*) OVERRIDE; |
| 70 | 71 |
| 71 private: | 72 private: |
| 72 void asyncUpdateController(); | 73 void asyncUpdateController(); |
| 73 void controllerTimerFired(Timer<GeolocationClientMock>*); | 74 void controllerTimerFired(WebCore::Timer<GeolocationClientMock>*); |
| 74 | 75 |
| 75 void asyncUpdatePermission(); | 76 void asyncUpdatePermission(); |
| 76 void permissionTimerFired(Timer<GeolocationClientMock>*); | 77 void permissionTimerFired(WebCore::Timer<GeolocationClientMock>*); |
| 77 | 78 |
| 78 void clearError(); | 79 void clearError(); |
| 79 | 80 |
| 80 GeolocationController* m_controller; | 81 WebCore::GeolocationController* m_controller; |
| 81 RefPtr<GeolocationPosition> m_lastPosition; | 82 RefPtr<WebCore::GeolocationPosition> m_lastPosition; |
| 82 bool m_hasError; | 83 bool m_hasError; |
| 83 String m_errorMessage; | 84 String m_errorMessage; |
| 84 Timer<GeolocationClientMock> m_controllerTimer; | 85 WebCore::Timer<GeolocationClientMock> m_controllerTimer; |
| 85 Timer<GeolocationClientMock> m_permissionTimer; | 86 WebCore::Timer<GeolocationClientMock> m_permissionTimer; |
| 86 bool m_isActive; | 87 bool m_isActive; |
| 87 | 88 |
| 88 enum PermissionState { | 89 enum PermissionState { |
| 89 PermissionStateUnset, | 90 PermissionStateUnset, |
| 90 PermissionStateAllowed, | 91 PermissionStateAllowed, |
| 91 PermissionStateDenied, | 92 PermissionStateDenied, |
| 92 } m_permissionState; | 93 } m_permissionState; |
| 93 typedef WTF::HashSet<RefPtr<Geolocation> > GeolocationSet; | 94 typedef WTF::HashSet<RefPtr<WebCore::Geolocation> > GeolocationSet; |
| 94 GeolocationSet m_pendingPermission; | 95 GeolocationSet m_pendingPermission; |
| 95 }; | 96 }; |
| 96 | 97 |
| 97 } | 98 } |
| 98 | 99 |
| 99 #endif | 100 #endif |
| OLD | NEW |