OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008, 2009, 2010, 2011 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008, 2009, 2010, 2011 Apple Inc. All Rights Reserved. |
3 * Copyright (C) 2009 Torch Mobile, Inc. | 3 * Copyright (C) 2009 Torch Mobile, Inc. |
4 * Copyright 2010, The Android Open Source Project | 4 * Copyright 2010, The Android Open Source Project |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 code = PositionError::PERMISSION_DENIED; | 72 code = PositionError::PERMISSION_DENIED; |
73 break; | 73 break; |
74 case GeolocationError::PositionUnavailable: | 74 case GeolocationError::PositionUnavailable: |
75 code = PositionError::POSITION_UNAVAILABLE; | 75 code = PositionError::POSITION_UNAVAILABLE; |
76 break; | 76 break; |
77 } | 77 } |
78 | 78 |
79 return PositionError::create(code, error->message()); | 79 return PositionError::create(code, error->message()); |
80 } | 80 } |
81 | 81 |
82 void Geolocation::Watchers::trace(Visitor* visitor) | |
83 { | |
84 visitor->trace(m_idToNotifierMap); | |
85 visitor->trace(m_notifierToIdMap); | |
86 } | |
87 | |
88 bool Geolocation::Watchers::add(int id, GeoNotifier* notifier) | |
89 { | |
90 ASSERT(id > 0); | |
91 if (!m_idToNotifierMap.add(id, notifier).isNewEntry) | |
92 return false; | |
93 m_notifierToIdMap.set(notifier, id); | |
94 return true; | |
95 } | |
96 | |
97 GeoNotifier* Geolocation::Watchers::find(int id) | |
98 { | |
99 ASSERT(id > 0); | |
100 IdToNotifierMap::iterator iter = m_idToNotifierMap.find(id); | |
101 if (iter == m_idToNotifierMap.end()) | |
102 return 0; | |
103 return iter->value.get(); | |
104 } | |
105 | |
106 void Geolocation::Watchers::remove(int id) | |
107 { | |
108 ASSERT(id > 0); | |
109 IdToNotifierMap::iterator iter = m_idToNotifierMap.find(id); | |
110 if (iter == m_idToNotifierMap.end()) | |
111 return; | |
112 m_notifierToIdMap.remove(iter->value); | |
113 m_idToNotifierMap.remove(iter); | |
114 } | |
115 | |
116 void Geolocation::Watchers::remove(GeoNotifier* notifier) | |
117 { | |
118 NotifierToIdMap::iterator iter = m_notifierToIdMap.find(notifier); | |
119 if (iter == m_notifierToIdMap.end()) | |
120 return; | |
121 m_idToNotifierMap.remove(iter->value); | |
122 m_notifierToIdMap.remove(iter); | |
123 } | |
124 | |
125 bool Geolocation::Watchers::contains(GeoNotifier* notifier) const | |
126 { | |
127 return m_notifierToIdMap.contains(notifier); | |
128 } | |
129 | |
130 void Geolocation::Watchers::clear() | |
131 { | |
132 m_idToNotifierMap.clear(); | |
133 m_notifierToIdMap.clear(); | |
134 } | |
135 | |
136 bool Geolocation::Watchers::isEmpty() const | |
137 { | |
138 return m_idToNotifierMap.isEmpty(); | |
139 } | |
140 | |
141 void Geolocation::Watchers::getNotifiersVector(GeoNotifierVector& copy) const | |
142 { | |
143 copyValuesToVector(m_idToNotifierMap, copy); | |
144 } | |
145 | |
146 Geolocation* Geolocation::create(ExecutionContext* context) | 82 Geolocation* Geolocation::create(ExecutionContext* context) |
147 { | 83 { |
148 Geolocation* geolocation = new Geolocation(context); | 84 Geolocation* geolocation = new Geolocation(context); |
149 geolocation->suspendIfNeeded(); | 85 geolocation->suspendIfNeeded(); |
150 return geolocation; | 86 return geolocation; |
151 } | 87 } |
152 | 88 |
153 Geolocation::Geolocation(ExecutionContext* context) | 89 Geolocation::Geolocation(ExecutionContext* context) |
154 : ActiveDOMObject(context) | 90 : ActiveDOMObject(context) |
155 , m_geolocationPermission(PermissionUnknown) | 91 , m_geolocationPermission(PermissionUnknown) |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
599 { | 535 { |
600 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::crea
te(NotSupportedError)); | 536 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::crea
te(NotSupportedError)); |
601 } | 537 } |
602 | 538 |
603 ScriptPromise Geolocation::getRegisteredRegions(ScriptState* scriptState) const | 539 ScriptPromise Geolocation::getRegisteredRegions(ScriptState* scriptState) const |
604 { | 540 { |
605 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::crea
te(NotSupportedError)); | 541 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::crea
te(NotSupportedError)); |
606 } | 542 } |
607 | 543 |
608 } // namespace blink | 544 } // namespace blink |
OLD | NEW |