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

Side by Side Diff: third_party/WebKit/Source/modules/geolocation/testing/InternalsGeolocation.cpp

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) 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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698