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

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

Issue 2068053002: Rename Blink constants generated from IDL files. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 4 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) 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 position.altitude_accuracy, 59 position.altitude_accuracy,
60 position.heading >= 0. && position.heading <= 360., 60 position.heading >= 0. && position.heading <= 360.,
61 position.heading, 61 position.heading,
62 position.speed >= 0., 62 position.speed >= 0.,
63 position.speed); 63 position.speed);
64 return Geoposition::create(coordinates, convertSecondsToDOMTimeStamp(positio n.timestamp)); 64 return Geoposition::create(coordinates, convertSecondsToDOMTimeStamp(positio n.timestamp));
65 } 65 }
66 66
67 static PositionError* createPositionError(mojom::blink::Geoposition::ErrorCode m ojomErrorCode, const String& error) 67 static PositionError* createPositionError(mojom::blink::Geoposition::ErrorCode m ojomErrorCode, const String& error)
68 { 68 {
69 PositionError::ErrorCode errorCode = PositionError::POSITION_UNAVAILABLE; 69 PositionError::ErrorCode errorCode = PositionError::kPositionUnavailable;
70 switch (mojomErrorCode) { 70 switch (mojomErrorCode) {
71 case mojom::blink::Geoposition::ErrorCode::PERMISSION_DENIED: 71 case mojom::blink::Geoposition::ErrorCode::PERMISSION_DENIED:
72 errorCode = PositionError::PERMISSION_DENIED; 72 errorCode = PositionError::kPermissionDenied;
73 break; 73 break;
74 case mojom::blink::Geoposition::ErrorCode::POSITION_UNAVAILABLE: 74 case mojom::blink::Geoposition::ErrorCode::POSITION_UNAVAILABLE:
75 errorCode = PositionError::POSITION_UNAVAILABLE; 75 errorCode = PositionError::kPositionUnavailable;
76 break; 76 break;
77 case mojom::blink::Geoposition::ErrorCode::NONE: 77 case mojom::blink::Geoposition::ErrorCode::NONE:
78 case mojom::blink::Geoposition::ErrorCode::TIMEOUT: 78 case mojom::blink::Geoposition::ErrorCode::TIMEOUT:
79 NOTREACHED(); 79 NOTREACHED();
80 break; 80 break;
81 } 81 }
82 return PositionError::create(errorCode, error); 82 return PositionError::create(errorCode, error);
83 } 83 }
84 84
85 } // namespace 85 } // namespace
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 watchID = getExecutionContext()->circularSequentialID(); 188 watchID = getExecutionContext()->circularSequentialID();
189 } while (!m_watchers.add(watchID, notifier)); 189 } while (!m_watchers.add(watchID, notifier));
190 return watchID; 190 return watchID;
191 } 191 }
192 192
193 void Geolocation::startRequest(GeoNotifier *notifier) 193 void Geolocation::startRequest(GeoNotifier *notifier)
194 { 194 {
195 recordOriginTypeAccess(); 195 recordOriginTypeAccess();
196 String errorMessage; 196 String errorMessage;
197 if (!frame()->settings()->allowGeolocationOnInsecureOrigins() && !getExecuti onContext()->isSecureContext(errorMessage)) { 197 if (!frame()->settings()->allowGeolocationOnInsecureOrigins() && !getExecuti onContext()->isSecureContext(errorMessage)) {
198 notifier->setFatalError(PositionError::create(PositionError::PERMISSION_ DENIED, errorMessage)); 198 notifier->setFatalError(PositionError::create(PositionError::kPermission Denied, errorMessage));
199 return; 199 return;
200 } 200 }
201 201
202 // Check whether permissions have already been denied. Note that if this is the case, 202 // Check whether permissions have already been denied. Note that if this is the case,
203 // the permission state can not change again in the lifetime of this page. 203 // the permission state can not change again in the lifetime of this page.
204 if (isDenied()) 204 if (isDenied())
205 notifier->setFatalError(PositionError::create(PositionError::PERMISSION_ DENIED, permissionDeniedErrorMessage)); 205 notifier->setFatalError(PositionError::create(PositionError::kPermission Denied, permissionDeniedErrorMessage));
206 else if (haveSuitableCachedPosition(notifier->options())) 206 else if (haveSuitableCachedPosition(notifier->options()))
207 notifier->setUseCachedPosition(); 207 notifier->setUseCachedPosition();
208 else if (!notifier->options().timeout()) 208 else if (!notifier->options().timeout())
209 notifier->startTimer(); 209 notifier->startTimer();
210 else if (!isAllowed()) { 210 else if (!isAllowed()) {
211 // if we don't yet have permission, request for permission before callin g startUpdating() 211 // if we don't yet have permission, request for permission before callin g startUpdating()
212 m_pendingForPermissionNotifiers.add(notifier); 212 m_pendingForPermissionNotifiers.add(notifier);
213 requestPermission(); 213 requestPermission();
214 } else { 214 } else {
215 startUpdating(notifier); 215 startUpdating(notifier);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 288
289 // While we iterate through the list, we need not worry about the list being modified as the permission 289 // While we iterate through the list, we need not worry about the list being modified as the permission
290 // is already set to Yes/No and no new listeners will be added to the pendin g list. 290 // is already set to Yes/No and no new listeners will be added to the pendin g list.
291 for (GeoNotifier* notifier : m_pendingForPermissionNotifiers) { 291 for (GeoNotifier* notifier : m_pendingForPermissionNotifiers) {
292 if (isAllowed()) { 292 if (isAllowed()) {
293 // Start all pending notification requests as permission granted. 293 // Start all pending notification requests as permission granted.
294 // The notifier is always ref'ed by m_oneShots or m_watchers. 294 // The notifier is always ref'ed by m_oneShots or m_watchers.
295 startUpdating(notifier); 295 startUpdating(notifier);
296 notifier->startTimer(); 296 notifier->startTimer();
297 } else { 297 } else {
298 notifier->setFatalError(PositionError::create(PositionError::PERMISS ION_DENIED, permissionDeniedErrorMessage)); 298 notifier->setFatalError(PositionError::create(PositionError::kPermis sionDenied, permissionDeniedErrorMessage));
299 } 299 }
300 } 300 }
301 m_pendingForPermissionNotifiers.clear(); 301 m_pendingForPermissionNotifiers.clear();
302 } 302 }
303 303
304 void Geolocation::sendError(GeoNotifierVector& notifiers, PositionError* error) 304 void Geolocation::sendError(GeoNotifierVector& notifiers, PositionError* error)
305 { 305 {
306 for (GeoNotifier* notifier : notifiers) 306 for (GeoNotifier* notifier : notifiers)
307 notifier->runErrorCallback(error); 307 notifier->runErrorCallback(error);
308 } 308 }
(...skipping 28 matching lines...) Expand all
337 337
338 void Geolocation::stopTimers() 338 void Geolocation::stopTimers()
339 { 339 {
340 stopTimersForOneShots(); 340 stopTimersForOneShots();
341 stopTimersForWatchers(); 341 stopTimersForWatchers();
342 } 342 }
343 343
344 void Geolocation::cancelRequests(GeoNotifierVector& notifiers) 344 void Geolocation::cancelRequests(GeoNotifierVector& notifiers)
345 { 345 {
346 for (GeoNotifier* notifier : notifiers) 346 for (GeoNotifier* notifier : notifiers)
347 notifier->setFatalError(PositionError::create(PositionError::POSITION_UN AVAILABLE, framelessDocumentErrorMessage)); 347 notifier->setFatalError(PositionError::create(PositionError::kPositionUn available, framelessDocumentErrorMessage));
348 } 348 }
349 349
350 void Geolocation::cancelAllRequests() 350 void Geolocation::cancelAllRequests()
351 { 351 {
352 GeoNotifierVector copy; 352 GeoNotifierVector copy;
353 copyToVector(m_oneShots, copy); 353 copyToVector(m_oneShots, copy);
354 cancelRequests(copy); 354 cancelRequests(copy);
355 m_watchers.getNotifiersVector(copy); 355 m_watchers.getNotifiersVector(copy);
356 cancelRequests(copy); 356 cancelRequests(copy);
357 } 357 }
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 queryNextPosition(); 518 queryNextPosition();
519 } 519 }
520 520
521 void Geolocation::pageVisibilityChanged() 521 void Geolocation::pageVisibilityChanged()
522 { 522 {
523 updateGeolocationServiceConnection(); 523 updateGeolocationServiceConnection();
524 } 524 }
525 525
526 void Geolocation::onGeolocationConnectionError() 526 void Geolocation::onGeolocationConnectionError()
527 { 527 {
528 PositionError* error = PositionError::create(PositionError::POSITION_UNAVAIL ABLE, failedToStartServiceErrorMessage); 528 PositionError* error = PositionError::create(PositionError::kPositionUnavail able, failedToStartServiceErrorMessage);
529 error->setIsFatal(true); 529 error->setIsFatal(true);
530 handleError(error); 530 handleError(error);
531 } 531 }
532 532
533 void Geolocation::onPermissionConnectionError() 533 void Geolocation::onPermissionConnectionError()
534 { 534 {
535 onGeolocationPermissionUpdated(mojom::blink::PermissionStatus::DENIED); 535 onGeolocationPermissionUpdated(mojom::blink::PermissionStatus::DENIED);
536 } 536 }
537 537
538 } // namespace blink 538 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698