| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 | 43 |
| 44 class GeolocationController; | 44 class GeolocationController; |
| 45 class GeolocationPosition; | 45 class GeolocationPosition; |
| 46 | 46 |
| 47 // Provides a mock object for the geolocation client. | 47 // Provides a mock object for the geolocation client. |
| 48 class GeolocationClientMock : public GeolocationClient { | 48 class GeolocationClientMock : public GeolocationClient { |
| 49 public: | 49 public: |
| 50 GeolocationClientMock(); | 50 GeolocationClientMock(); |
| 51 virtual ~GeolocationClientMock(); | 51 virtual ~GeolocationClientMock(); |
| 52 | 52 |
| 53 void setController(GeolocationController*); | |
| 54 | |
| 55 void setPosition(PassRefPtrWillBeRawPtr<GeolocationPosition>); | 53 void setPosition(PassRefPtrWillBeRawPtr<GeolocationPosition>); |
| 56 void setPositionUnavailableError(const String& errorMessage); | 54 void setPositionUnavailableError(const String& errorMessage); |
| 57 void setPermission(bool allowed); | 55 void setPermission(bool allowed); |
| 58 int numberOfPendingPermissionRequests() const; | 56 int numberOfPendingPermissionRequests() const; |
| 59 | 57 |
| 60 // GeolocationClient | 58 // GeolocationClient |
| 61 virtual void geolocationDestroyed() OVERRIDE; | 59 virtual void geolocationDestroyed() OVERRIDE; |
| 62 virtual void startUpdating() OVERRIDE; | 60 virtual void startUpdating() OVERRIDE; |
| 63 virtual void stopUpdating() OVERRIDE; | 61 virtual void stopUpdating() OVERRIDE; |
| 64 virtual void setEnableHighAccuracy(bool) OVERRIDE; | 62 virtual void setEnableHighAccuracy(bool) OVERRIDE; |
| 65 virtual GeolocationPosition* lastPosition() OVERRIDE; | 63 virtual GeolocationPosition* lastPosition() OVERRIDE; |
| 66 virtual void requestPermission(Geolocation*) OVERRIDE; | 64 virtual void requestPermission(Geolocation*) OVERRIDE; |
| 67 virtual void cancelPermissionRequest(Geolocation*) OVERRIDE; | 65 virtual void cancelPermissionRequest(Geolocation*) OVERRIDE; |
| 66 void controllerForTestAdded(GeolocationController*) OVERRIDE; |
| 67 void controllerForTestRemoved(GeolocationController*) OVERRIDE; |
| 68 | 68 |
| 69 private: | 69 private: |
| 70 void asyncUpdateController(); | 70 void asyncUpdateController(); |
| 71 void controllerTimerFired(Timer<GeolocationClientMock>*); | 71 void controllerTimerFired(Timer<GeolocationClientMock>*); |
| 72 | 72 |
| 73 void asyncUpdatePermission(); | 73 void asyncUpdatePermission(); |
| 74 void permissionTimerFired(Timer<GeolocationClientMock>*); | 74 void permissionTimerFired(Timer<GeolocationClientMock>*); |
| 75 | 75 |
| 76 void clearError(); | 76 void clearError(); |
| 77 | 77 |
| 78 GeolocationController* m_controller; | 78 HashSet<GeolocationController*> m_controllers; |
| 79 RefPtrWillBePersistent<GeolocationPosition> m_lastPosition; | 79 RefPtrWillBePersistent<GeolocationPosition> m_lastPosition; |
| 80 bool m_hasError; | 80 bool m_hasError; |
| 81 String m_errorMessage; | 81 String m_errorMessage; |
| 82 Timer<GeolocationClientMock> m_controllerTimer; | 82 Timer<GeolocationClientMock> m_controllerTimer; |
| 83 Timer<GeolocationClientMock> m_permissionTimer; | 83 Timer<GeolocationClientMock> m_permissionTimer; |
| 84 bool m_isActive; | 84 bool m_isActive; |
| 85 | 85 |
| 86 enum PermissionState { | 86 enum PermissionState { |
| 87 PermissionStateUnset, | 87 PermissionStateUnset, |
| 88 PermissionStateAllowed, | 88 PermissionStateAllowed, |
| 89 PermissionStateDenied | 89 PermissionStateDenied |
| 90 }; | 90 }; |
| 91 | 91 |
| 92 PermissionState m_permissionState; | 92 PermissionState m_permissionState; |
| 93 typedef WillBePersistentHeapHashSet<RefPtrWillBeMember<Geolocation> > Geoloc
ationSet; | 93 typedef WillBePersistentHeapHashSet<RefPtrWillBeMember<Geolocation> > Geoloc
ationSet; |
| 94 GeolocationSet m_pendingPermissions; | 94 GeolocationSet m_pendingPermissions; |
| 95 }; | 95 }; |
| 96 | 96 |
| 97 } | 97 } |
| 98 | 98 |
| 99 #endif | 99 #endif |
| OLD | NEW |