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

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

Issue 171333003: Pass implementation object to supplemental classes by reference (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 years, 10 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 | Annotate | Revision Log
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 23 matching lines...) Expand all
34 #include "core/dom/Document.h" 34 #include "core/dom/Document.h"
35 #include "core/testing/Internals.h" 35 #include "core/testing/Internals.h"
36 #include "modules/geolocation/GeolocationController.h" 36 #include "modules/geolocation/GeolocationController.h"
37 #include "modules/geolocation/GeolocationError.h" 37 #include "modules/geolocation/GeolocationError.h"
38 #include "modules/geolocation/GeolocationPosition.h" 38 #include "modules/geolocation/GeolocationPosition.h"
39 #include "modules/geolocation/testing/GeolocationClientMock.h" 39 #include "modules/geolocation/testing/GeolocationClientMock.h"
40 #include "wtf/CurrentTime.h" 40 #include "wtf/CurrentTime.h"
41 41
42 namespace WebCore { 42 namespace WebCore {
43 43
44 void InternalsGeolocation::setGeolocationClientMock(Internals* internals, Docume nt* document) 44 void InternalsGeolocation::setGeolocationClientMock(Internals&, Document* docume nt)
45 { 45 {
46 ASSERT(internals && document && document->page()); 46 ASSERT(document && document->page());
47 GeolocationController* controller = GeolocationController::from(document->pa ge()); 47 GeolocationController* controller = GeolocationController::from(document->pa ge());
48 GeolocationClientMock* client = new GeolocationClientMock(); 48 GeolocationClientMock* client = new GeolocationClientMock();
49 controller->setClientForTest(client); 49 controller->setClientForTest(client);
50 client->setController(controller); 50 client->setController(controller);
51 } 51 }
52 52
53 void InternalsGeolocation::setGeolocationPosition(Internals* internals, Document * document, double latitude, double longitude, double accuracy) 53 void InternalsGeolocation::setGeolocationPosition(Internals&, Document* document , double latitude, double longitude, double accuracy)
54 { 54 {
55 ASSERT(internals && document && document->page()); 55 ASSERT(document && document->page());
56 GeolocationClientMock* client = geolocationClient(document); 56 GeolocationClientMock* client = geolocationClient(document);
57 if (!client) 57 if (!client)
58 return; 58 return;
59 client->setPosition(GeolocationPosition::create(currentTime(), latitude, lon gitude, accuracy)); 59 client->setPosition(GeolocationPosition::create(currentTime(), latitude, lon gitude, accuracy));
60 } 60 }
61 61
62 void InternalsGeolocation::setGeolocationPositionUnavailableError(Internals* int ernals, Document* document, const String& message) 62 void InternalsGeolocation::setGeolocationPositionUnavailableError(Internals&, Do cument* document, const String& message)
63 { 63 {
64 ASSERT(internals && document && document->page()); 64 ASSERT(document && document->page());
65 GeolocationClientMock* client = geolocationClient(document); 65 GeolocationClientMock* client = geolocationClient(document);
66 if (!client) 66 if (!client)
67 return; 67 return;
68 client->setPositionUnavailableError(message); 68 client->setPositionUnavailableError(message);
69 } 69 }
70 70
71 void InternalsGeolocation::setGeolocationPermission(Internals* internals, Docume nt* document, bool allowed) 71 void InternalsGeolocation::setGeolocationPermission(Internals&, Document* docume nt, bool allowed)
72 { 72 {
73 ASSERT(internals && document && document->page()); 73 ASSERT(document && document->page());
74 GeolocationClientMock* client = geolocationClient(document); 74 GeolocationClientMock* client = geolocationClient(document);
75 if (!client) 75 if (!client)
76 return; 76 return;
77 client->setPermission(allowed); 77 client->setPermission(allowed);
78 } 78 }
79 79
80 int InternalsGeolocation::numberOfPendingGeolocationPermissionRequests(Internals * internals, Document* document) 80 int InternalsGeolocation::numberOfPendingGeolocationPermissionRequests(Internals &, Document* document)
81 { 81 {
82 ASSERT(internals && document && document->page()); 82 ASSERT(document && document->page());
83 GeolocationClientMock* client = geolocationClient(document); 83 GeolocationClientMock* client = geolocationClient(document);
84 if (!client) 84 if (!client)
85 return -1; 85 return -1;
86 return client->numberOfPendingPermissionRequests(); 86 return client->numberOfPendingPermissionRequests();
87 } 87 }
88 88
89 GeolocationClientMock* InternalsGeolocation::geolocationClient(Document* documen t) 89 GeolocationClientMock* InternalsGeolocation::geolocationClient(Document* documen t)
90 { 90 {
91 GeolocationController* controller = GeolocationController::from(document->pa ge()); 91 GeolocationController* controller = GeolocationController::from(document->pa ge());
92 if (!controller->hasClientForTest()) 92 if (!controller->hasClientForTest())
93 return 0; 93 return 0;
94 return static_cast<GeolocationClientMock*>(controller->client()); 94 return static_cast<GeolocationClientMock*>(controller->client());
95 } 95 }
96 96
97 } // namespace WebCore 97 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698