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

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

Issue 620003005: Record whether Geolocation is accessed from a secure origin. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@screen_orientation_use_counter
Patch Set: Created 6 years, 2 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 11 matching lines...) Expand all
22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28 #include "config.h" 28 #include "config.h"
29 #include "modules/geolocation/Geolocation.h" 29 #include "modules/geolocation/Geolocation.h"
30 30
31 #include "core/dom/Document.h" 31 #include "core/dom/Document.h"
32 #include "core/frame/UseCounter.h"
32 #include "modules/geolocation/Coordinates.h" 33 #include "modules/geolocation/Coordinates.h"
33 #include "modules/geolocation/GeolocationController.h" 34 #include "modules/geolocation/GeolocationController.h"
34 #include "modules/geolocation/GeolocationError.h" 35 #include "modules/geolocation/GeolocationError.h"
35 #include "modules/geolocation/GeolocationPosition.h" 36 #include "modules/geolocation/GeolocationPosition.h"
36 #include "wtf/CurrentTime.h" 37 #include "wtf/CurrentTime.h"
37 38
38 namespace blink { 39 namespace blink {
39 40
40 static const char permissionDeniedErrorMessage[] = "User denied Geolocation"; 41 static const char permissionDeniedErrorMessage[] = "User denied Geolocation";
41 static const char failedToStartServiceErrorMessage[] = "Failed to start Geolocat ion service"; 42 static const char failedToStartServiceErrorMessage[] = "Failed to start Geolocat ion service";
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 { 131 {
131 LocalFrame* frame = this->frame(); 132 LocalFrame* frame = this->frame();
132 if (!frame) 133 if (!frame)
133 return 0; 134 return 0;
134 135
135 m_lastPosition = createGeoposition(GeolocationController::from(frame)->lastP osition()); 136 m_lastPosition = createGeoposition(GeolocationController::from(frame)->lastP osition());
136 137
137 return m_lastPosition.get(); 138 return m_lastPosition.get();
138 } 139 }
139 140
141 void Geolocation::RecordOriginTypeAccess()
142 {
143 ASSERT(frame());
144
145 Document* document = frame()->document();
146 if (!document)
Peter Beverloo 2014/10/02 14:58:24 When would there not be a document if we have the
mlamouri (slow - plz ping) 2014/10/02 15:44:54 Done.
147 return;
148
149 // It is required but canAccessFeatureRequiringSecureOrigin() but isn't
150 // actually used. This could be used later if a warning is shown in the
151 // developer console.
152 String insecureOriginMsg;
153 UseCounter::Feature counter = document->securityOrigin()->canAccessFeatureRe quiringSecureOrigin(insecureOriginMsg)
154 ? UseCounter::GeolocationSecureOrigin : UseCounter::GeolocationInsecureO rigin;
155 UseCounter::count(document, counter);
Peter Beverloo 2014/10/02 14:58:24 I would much prefer this code to use SecurityOrigi
Mike West 2014/10/02 15:04:11 We're using canAccessFeature* for security checks
156 }
157
140 void Geolocation::getCurrentPosition(PositionCallback* successCallback, Position ErrorCallback* errorCallback, const Dictionary& options) 158 void Geolocation::getCurrentPosition(PositionCallback* successCallback, Position ErrorCallback* errorCallback, const Dictionary& options)
141 { 159 {
142 if (!frame()) 160 if (!frame())
143 return; 161 return;
144 162
163 RecordOriginTypeAccess();
164
145 GeoNotifier* notifier = GeoNotifier::create(this, successCallback, errorCall back, PositionOptions::create(options)); 165 GeoNotifier* notifier = GeoNotifier::create(this, successCallback, errorCall back, PositionOptions::create(options));
146 startRequest(notifier); 166 startRequest(notifier);
147 167
148 m_oneShots.add(notifier); 168 m_oneShots.add(notifier);
149 } 169 }
150 170
151 int Geolocation::watchPosition(PositionCallback* successCallback, PositionErrorC allback* errorCallback, const Dictionary& options) 171 int Geolocation::watchPosition(PositionCallback* successCallback, PositionErrorC allback* errorCallback, const Dictionary& options)
152 { 172 {
153 if (!frame()) 173 if (!frame())
154 return 0; 174 return 0;
155 175
176 RecordOriginTypeAccess();
177
156 GeoNotifier* notifier = GeoNotifier::create(this, successCallback, errorCall back, PositionOptions::create(options)); 178 GeoNotifier* notifier = GeoNotifier::create(this, successCallback, errorCall back, PositionOptions::create(options));
157 startRequest(notifier); 179 startRequest(notifier);
158 180
159 int watchID; 181 int watchID;
160 // Keep asking for the next id until we're given one that we don't already h ave. 182 // Keep asking for the next id until we're given one that we don't already h ave.
161 do { 183 do {
162 watchID = executionContext()->circularSequentialID(); 184 watchID = executionContext()->circularSequentialID();
163 } while (!m_watchers.add(watchID, notifier)); 185 } while (!m_watchers.add(watchID, notifier));
164 return watchID; 186 return watchID;
165 } 187 }
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 notifier->startTimer(); 538 notifier->startTimer();
517 else 539 else
518 notifier->setFatalError(PositionError::create(PositionError::POS ITION_UNAVAILABLE, failedToStartServiceErrorMessage)); 540 notifier->setFatalError(PositionError::create(PositionError::POS ITION_UNAVAILABLE, failedToStartServiceErrorMessage));
519 } else { 541 } else {
520 notifier->setFatalError(PositionError::create(PositionError::PERMISS ION_DENIED, permissionDeniedErrorMessage)); 542 notifier->setFatalError(PositionError::create(PositionError::PERMISS ION_DENIED, permissionDeniedErrorMessage));
521 } 543 }
522 } 544 }
523 } 545 }
524 546
525 } // namespace blink 547 } // namespace blink
OLDNEW
« Source/modules/geolocation/Geolocation.h ('K') | « Source/modules/geolocation/Geolocation.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698