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

Side by Side Diff: Source/modules/geolocation/GeolocationController.cpp

Issue 256843004: Get the WebGeolocationClient from WebFrameClient instead of WebViewClient. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: fix layouttest, fix webkit_unit_tests crash, remove obsolete layout test Created 6 years, 7 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) 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2009 Apple 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 10 matching lines...) Expand all
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE. 23 * THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #include "config.h" 26 #include "config.h"
27 27
28 #include "modules/geolocation/GeolocationController.h" 28 #include "modules/geolocation/GeolocationController.h"
29 29
30 #include "core/inspector/InspectorController.h" 30 #include "core/inspector/InspectorController.h"
31 #include "core/page/Page.h"
31 #include "modules/geolocation/GeolocationClient.h" 32 #include "modules/geolocation/GeolocationClient.h"
32 #include "modules/geolocation/GeolocationError.h" 33 #include "modules/geolocation/GeolocationError.h"
33 #include "modules/geolocation/GeolocationInspectorAgent.h" 34 #include "modules/geolocation/GeolocationInspectorAgent.h"
34 #include "modules/geolocation/GeolocationPosition.h" 35 #include "modules/geolocation/GeolocationPosition.h"
35 36
36 namespace WebCore { 37 namespace WebCore {
37 38
38 GeolocationController::GeolocationController(Page& page, GeolocationClient* clie nt) 39 GeolocationController::GeolocationController(LocalFrame& frame, GeolocationClien t* client)
39 : PageLifecycleObserver(&page) 40 : PageLifecycleObserver(frame.page())
40 , m_client(client) 41 , m_client(client)
41 , m_hasClientForTest(false) 42 , m_hasClientForTest(false)
42 , m_isClientUpdating(false) 43 , m_isClientUpdating(false)
43 , m_inspectorAgent() 44 , m_inspectorAgent()
44 { 45 {
45 OwnPtr<GeolocationInspectorAgent> geolocationAgent(GeolocationInspectorAgent ::create(this)); 46 // FIXME: Once GeolocationInspectorAgent is per frame, there will be a 1:1 r elationship between
46 m_inspectorAgent = geolocationAgent.get(); 47 // it and this class. Until then, there's one GeolocationInspectorAgent per page that the main
47 page.inspectorController().registerModuleAgent(geolocationAgent.release()); 48 // frame is responsible for creating.
49 if (frame.isMainFrame()) {
50 OwnPtr<GeolocationInspectorAgent> geolocationAgent(GeolocationInspectorA gent::create());
51 m_inspectorAgent = geolocationAgent.get();
52 frame.page()->inspectorController().registerModuleAgent(geolocationAgent .release());
53 } else {
54 m_inspectorAgent = GeolocationController::from(frame.page()->mainFrame() )->m_inspectorAgent;
55 }
56
57 m_inspectorAgent->AddController(this);
48 } 58 }
49 59
50 void GeolocationController::startUpdatingIfNeeded() 60 void GeolocationController::startUpdatingIfNeeded()
51 { 61 {
52 if (m_isClientUpdating) 62 if (m_isClientUpdating)
53 return; 63 return;
54 m_isClientUpdating = true; 64 m_isClientUpdating = true;
55 m_client->startUpdating(); 65 m_client->startUpdating();
56 } 66 }
57 67
58 void GeolocationController::stopUpdatingIfNeeded() 68 void GeolocationController::stopUpdatingIfNeeded()
59 { 69 {
60 if (!m_isClientUpdating) 70 if (!m_isClientUpdating)
61 return; 71 return;
62 m_isClientUpdating = false; 72 m_isClientUpdating = false;
63 m_client->stopUpdating(); 73 m_client->stopUpdating();
64 } 74 }
65 75
66 GeolocationController::~GeolocationController() 76 GeolocationController::~GeolocationController()
67 { 77 {
68 ASSERT(m_observers.isEmpty()); 78 ASSERT(m_observers.isEmpty());
79 if (page())
80 m_inspectorAgent->RemoveController(this);
69 } 81 }
70 82
71 void GeolocationController::willBeDestroyed() 83 void GeolocationController::willBeDestroyed()
72 { 84 {
73 if (m_client) 85 if (m_client)
74 m_client->geolocationDestroyed(); 86 m_client->geolocationDestroyed();
75 } 87 }
76 88
77 PassOwnPtr<GeolocationController> GeolocationController::create(Page& page, Geol ocationClient* client) 89 PassOwnPtr<GeolocationController> GeolocationController::create(LocalFrame& fram e, GeolocationClient* client)
78 { 90 {
79 return adoptPtr(new GeolocationController(page, client)); 91 return adoptPtr(new GeolocationController(frame, client));
80 } 92 }
81 93
82 void GeolocationController::addObserver(Geolocation* observer, bool enableHighAc curacy) 94 void GeolocationController::addObserver(Geolocation* observer, bool enableHighAc curacy)
83 { 95 {
84 // This may be called multiple times with the same observer, though removeOb server() 96 // This may be called multiple times with the same observer, though removeOb server()
85 // is called only once with each. 97 // is called only once with each.
86 bool wasEmpty = m_observers.isEmpty(); 98 bool wasEmpty = m_observers.isEmpty();
87 m_observers.add(observer); 99 m_observers.add(observer);
88 if (enableHighAccuracy) 100 if (enableHighAccuracy)
89 m_highAccuracyObservers.add(observer); 101 m_highAccuracyObservers.add(observer);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 startUpdatingIfNeeded(); 184 startUpdatingIfNeeded();
173 else 185 else
174 stopUpdatingIfNeeded(); 186 stopUpdatingIfNeeded();
175 } 187 }
176 188
177 const char* GeolocationController::supplementName() 189 const char* GeolocationController::supplementName()
178 { 190 {
179 return "GeolocationController"; 191 return "GeolocationController";
180 } 192 }
181 193
182 void provideGeolocationTo(Page& page, GeolocationClient* client) 194 void provideGeolocationTo(LocalFrame& frame, GeolocationClient* client)
183 { 195 {
184 Supplement<Page>::provideTo(page, GeolocationController::supplementName(), G eolocationController::create(page, client)); 196 Supplement<LocalFrame>::provideTo(frame, GeolocationController::supplementNa me(), GeolocationController::create(frame, client));
185 } 197 }
186 198
187 } // namespace WebCore 199 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698