| 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 28 matching lines...) Expand all Loading... |
| 39 { | 39 { |
| 40 return adoptPtr(new GeolocationInspectorAgent()); | 40 return adoptPtr(new GeolocationInspectorAgent()); |
| 41 } | 41 } |
| 42 | 42 |
| 43 GeolocationInspectorAgent::~GeolocationInspectorAgent() | 43 GeolocationInspectorAgent::~GeolocationInspectorAgent() |
| 44 { | 44 { |
| 45 } | 45 } |
| 46 | 46 |
| 47 GeolocationInspectorAgent::GeolocationInspectorAgent() | 47 GeolocationInspectorAgent::GeolocationInspectorAgent() |
| 48 : InspectorBaseAgent<GeolocationInspectorAgent>("Geolocation") | 48 : InspectorBaseAgent<GeolocationInspectorAgent>("Geolocation") |
| 49 , m_controllers(new GeolocationControllers()) |
| 49 , m_geolocationOverridden(false) | 50 , m_geolocationOverridden(false) |
| 50 { | 51 { |
| 51 } | 52 } |
| 52 | 53 |
| 53 void GeolocationInspectorAgent::setGeolocationOverride(ErrorString* error, const
double* latitude, const double* longitude, const double* accuracy) | 54 void GeolocationInspectorAgent::setGeolocationOverride(ErrorString* error, const
double* latitude, const double* longitude, const double* accuracy) |
| 54 { | 55 { |
| 55 GeolocationPosition* position = (*m_controllers.begin())->lastPosition(); | 56 GeolocationPosition* position = (*m_controllers->begin())->lastPosition(); |
| 56 if (!m_geolocationOverridden && position) | 57 if (!m_geolocationOverridden && position) |
| 57 m_platformGeolocationPosition = position; | 58 m_platformGeolocationPosition = position; |
| 58 | 59 |
| 59 m_geolocationOverridden = true; | 60 m_geolocationOverridden = true; |
| 60 if (latitude && longitude && accuracy) | 61 if (latitude && longitude && accuracy) |
| 61 m_geolocationPosition = GeolocationPosition::create(currentTime(), *lati
tude, *longitude, *accuracy); | 62 m_geolocationPosition = GeolocationPosition::create(currentTime(), *lati
tude, *longitude, *accuracy); |
| 62 else | 63 else |
| 63 m_geolocationPosition.clear(); | 64 m_geolocationPosition.clear(); |
| 64 | 65 |
| 65 for (WTF::HashSet<GeolocationController*>::iterator it = m_controllers.begin
(); it != m_controllers.end(); ++it) | 66 for (GeolocationControllers::iterator it = m_controllers->begin(); it != m_c
ontrollers->end(); ++it) |
| 66 (*it)->positionChanged(0); // Kick location update. | 67 (*it)->positionChanged(0); // Kick location update. |
| 67 } | 68 } |
| 68 | 69 |
| 69 void GeolocationInspectorAgent::clearGeolocationOverride(ErrorString*) | 70 void GeolocationInspectorAgent::clearGeolocationOverride(ErrorString*) |
| 70 { | 71 { |
| 71 if (!m_geolocationOverridden) | 72 if (!m_geolocationOverridden) |
| 72 return; | 73 return; |
| 73 m_geolocationOverridden = false; | 74 m_geolocationOverridden = false; |
| 74 m_geolocationPosition.clear(); | 75 m_geolocationPosition.clear(); |
| 75 | 76 |
| 76 if (m_platformGeolocationPosition.get()) { | 77 if (GeolocationPosition* platformPosition = m_platformGeolocationPosition.ge
t()) { |
| 77 for (WTF::HashSet<GeolocationController*>::iterator it = m_controllers.b
egin(); it != m_controllers.end(); ++it) | 78 for (GeolocationControllers::iterator it = m_controllers->begin(); it !=
m_controllers->end(); ++it) |
| 78 (*it)->positionChanged(m_platformGeolocationPosition.get()); | 79 (*it)->positionChanged(platformPosition); |
| 79 } | 80 } |
| 80 } | 81 } |
| 81 | 82 |
| 82 GeolocationPosition* GeolocationInspectorAgent::overrideGeolocationPosition(Geol
ocationPosition* position) | 83 GeolocationPosition* GeolocationInspectorAgent::overrideGeolocationPosition(Geol
ocationPosition* position) |
| 83 { | 84 { |
| 84 if (m_geolocationOverridden) { | 85 if (m_geolocationOverridden) { |
| 85 if (position) | 86 if (position) |
| 86 m_platformGeolocationPosition = position; | 87 m_platformGeolocationPosition = position; |
| 87 return m_geolocationPosition.get(); | 88 return m_geolocationPosition.get(); |
| 88 } | 89 } |
| 89 return position; | 90 return position; |
| 90 } | 91 } |
| 91 | 92 |
| 92 void GeolocationInspectorAgent::AddController(GeolocationController* controller) | 93 void GeolocationInspectorAgent::AddController(GeolocationController* controller) |
| 93 { | 94 { |
| 94 m_controllers.add(controller); | 95 m_controllers->add(controller); |
| 95 } | 96 } |
| 96 | 97 |
| 97 void GeolocationInspectorAgent::RemoveController(GeolocationController* controll
er) | 98 void GeolocationInspectorAgent::RemoveController(GeolocationController* controll
er) |
| 98 { | 99 { |
| 99 m_controllers.remove(controller); | 100 m_controllers->remove(controller); |
| 100 } | 101 } |
| 101 | 102 |
| 102 } // namespace WebCore | 103 } // namespace WebCore |
| OLD | NEW |