Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Side by Side Diff: third_party/WebKit/Source/modules/geolocation/testing/GeolocationClientMock.h

Issue 1367853002: Move GeolocationDispatcher into blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix layout tests Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 14 matching lines...) Expand all
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32 #ifndef GeolocationClientMock_h 32 #ifndef GeolocationClientMock_h
33 #define GeolocationClientMock_h 33 #define GeolocationClientMock_h
34 34
35 #include "modules/geolocation/GeolocationClient.h" 35 #include "content/common/geolocation_service.mojom.h"
36 #include "platform/Timer.h" 36 #include "content/common/permission_service.mojom.h"
37 #include "modules/geolocation/GeolocationController.h"
38 #include "mojo/application/public/interfaces/service_provider.mojom.h"
37 #include "platform/heap/Handle.h" 39 #include "platform/heap/Handle.h"
40 #include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h"
38 #include "wtf/HashSet.h" 41 #include "wtf/HashSet.h"
42 #include "wtf/Vector.h"
39 #include "wtf/text/WTFString.h" 43 #include "wtf/text/WTFString.h"
40 44
41 namespace blink { 45 namespace blink {
42 46
43 class GeolocationController; 47 class GeolocationController;
44 class GeolocationPosition; 48 class GeolocationPosition;
45 49
46 // Provides a mock object for the geolocation client. 50 // Provides a mock object for the geolocation client.
47 class GeolocationClientMock final : public GeolocationClient { 51 // FIXME: Rename this to GeolocationServiceMock.
52 class GeolocationClientMock : public content::GeolocationService, public content ::PermissionService, public mojo::ServiceProvider, public NoBaseWillBeGarbageCol lectedFinalized<GeolocationClientMock>, public WillBeHeapSupplement<Document> {
48 public: 53 public:
49 GeolocationClientMock(); 54 ~GeolocationClientMock();
50 ~GeolocationClientMock() override; 55
56 static GeolocationClientMock* from(Document*);
51 57
52 void setPosition(GeolocationPosition*); 58 void setPosition(GeolocationPosition*);
53 void setPositionUnavailableError(const String& errorMessage); 59 void setPositionUnavailableError(const String& errorMessage);
54 void setPermission(bool allowed); 60 void setPermission(bool allowed);
55 int numberOfPendingPermissionRequests() const; 61 int numberOfPendingPermissionRequests() const;
56 62
57 // GeolocationClient 63 // content::GeolocationService
58 void startUpdating() override; 64 void SetHighAccuracy(bool highAccuracy) override;
59 void stopUpdating() override; 65 void QueryNextPosition(const QueryNextPositionCallback&) override;
60 void setEnableHighAccuracy(bool) override; 66
61 GeolocationPosition* lastPosition() override; 67 // content::PermissionService
62 void requestPermission(Geolocation*) override; 68 void HasPermission(content::PermissionName, const mojo::String& origin, cons t HasPermissionCallback&) override;
63 void cancelPermissionRequest(Geolocation*) override; 69 void RequestPermission(content::PermissionName, const mojo::String& origin, bool userGesture, const RequestPermissionCallback&) override;
64 void controllerForTestAdded(GeolocationController*) override; 70 void RequestPermissions(mojo::Array<content::PermissionName> permissions, co nst mojo::String& origin, bool userGesture, const RequestPermissionsCallback&) o verride;
65 void controllerForTestRemoved(GeolocationController*) override; 71 void RevokePermission(content::PermissionName, const mojo::String& origin, c onst RevokePermissionCallback&) override;
72 void GetNextPermissionChange(content::PermissionName, const mojo::String& or igin, content::PermissionStatus lastKnownStatus, const GetNextPermissionChangeCa llback&) override;
73
74 void ConnectToService(const mojo::String& interfaceName, mojo::ScopedMessage PipeHandle) override;
75
76 static const char* supplementName() { return "GeolocationClientMock"; }
66 77
67 DECLARE_VIRTUAL_TRACE(); 78 DECLARE_VIRTUAL_TRACE();
68 79
69 private: 80 private:
70 void asyncUpdateController(); 81 GeolocationClientMock(Document*);
71 void controllerTimerFired(Timer<GeolocationClientMock>*); 82 void runGeolocationCallbacks();
83 void runPermissionCallbacks();
72 84
73 void asyncUpdatePermission(); 85 Document* m_document;
74 void permissionTimerFired(Timer<GeolocationClientMock>*);
75 86
76 void clearError(); 87 content::MojoGeopositionPtr m_lastPosition;
77 88
78 typedef WillBeHeapHashSet<RawPtrWillBeWeakMember<GeolocationController>> Geo locationControllers; 89 Vector<QueryNextPositionCallback> m_pendingGeolocations;
79 GeolocationControllers m_controllers;
80 90
81 PersistentWillBeMember<GeolocationPosition> m_lastPosition; 91 content::PermissionStatus m_permissionState;
82 bool m_hasError; 92 Vector<RequestPermissionCallback> m_pendingPermissions;
83 String m_errorMessage;
84 Timer<GeolocationClientMock> m_controllerTimer;
85 Timer<GeolocationClientMock> m_permissionTimer;
86 bool m_isActive;
87 93
88 enum PermissionState { 94 mojo::Binding<content::GeolocationService> m_geolocationBinding;
89 PermissionStateUnset, 95 mojo::Binding<content::PermissionService> m_permissionBinding;
90 PermissionStateAllowed,
91 PermissionStateDenied
92 };
93
94 PermissionState m_permissionState;
95
96 typedef PersistentHeapHashSetWillBeHeapHashSet<Member<Geolocation>> Geolocat ionSet;
97 GeolocationSet m_pendingPermissions;
98 }; 96 };
99 97
100 } 98 }
101 99
102 #endif 100 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698