OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 Google 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 27 matching lines...) Expand all Loading... |
38 #include "modules/geolocation/GeolocationError.h" | 38 #include "modules/geolocation/GeolocationError.h" |
39 #include "modules/geolocation/GeolocationPosition.h" | 39 #include "modules/geolocation/GeolocationPosition.h" |
40 #include "modules/geolocation/testing/GeolocationClientMock.h" | 40 #include "modules/geolocation/testing/GeolocationClientMock.h" |
41 #include "wtf/CurrentTime.h" | 41 #include "wtf/CurrentTime.h" |
42 | 42 |
43 namespace blink { | 43 namespace blink { |
44 | 44 |
45 void InternalsGeolocation::setGeolocationClientMock(Internals&, Document* docume
nt) | 45 void InternalsGeolocation::setGeolocationClientMock(Internals&, Document* docume
nt) |
46 { | 46 { |
47 ASSERT(document); | 47 ASSERT(document); |
48 if (!document->frame()) | 48 GeolocationClientMock::from(document); |
49 return; | |
50 | |
51 GeolocationClientMock* client = new GeolocationClientMock(); | |
52 for (Frame* childFrame = document->page()->mainFrame(); childFrame; childFra
me = childFrame->tree().traverseNext()) { | |
53 if (childFrame->isLocalFrame()) | |
54 GeolocationController::from(toLocalFrame(childFrame))->setClientForT
est(client); | |
55 } | |
56 } | 49 } |
57 | 50 |
58 void InternalsGeolocation::setGeolocationPosition(Internals&, Document* document
, double latitude, double longitude, double accuracy) | 51 void InternalsGeolocation::setGeolocationPosition(Internals&, Document* document
, double latitude, double longitude, double accuracy) |
59 { | 52 { |
60 ASSERT(document); | 53 ASSERT(document); |
61 if (!document->frame()) | 54 if (!document->frame()) |
62 return; | 55 return; |
63 | 56 |
64 GeolocationClientMock* client = geolocationClient(document); | 57 GeolocationClientMock* client = geolocationClient(document); |
65 if (!client) | 58 if (!client) |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 | 92 |
100 GeolocationClientMock* client = geolocationClient(document); | 93 GeolocationClientMock* client = geolocationClient(document); |
101 if (!client) | 94 if (!client) |
102 return -1; | 95 return -1; |
103 return client->numberOfPendingPermissionRequests(); | 96 return client->numberOfPendingPermissionRequests(); |
104 } | 97 } |
105 | 98 |
106 GeolocationClientMock* InternalsGeolocation::geolocationClient(Document* documen
t) | 99 GeolocationClientMock* InternalsGeolocation::geolocationClient(Document* documen
t) |
107 { | 100 { |
108 ASSERT(document); | 101 ASSERT(document); |
109 if (!document->frame()) | 102 return GeolocationClientMock::from(document); |
110 return nullptr; | |
111 | |
112 GeolocationController* controller = GeolocationController::from(document->fr
ame()); | |
113 if (!controller->hasClientForTest()) | |
114 return nullptr; | |
115 return static_cast<GeolocationClientMock*>(controller->client()); | |
116 } | 103 } |
117 | 104 |
118 } // namespace blink | 105 } // namespace blink |
OLD | NEW |