OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/renderer/geolocation_dispatcher.h" | 5 #include "content/renderer/geolocation_dispatcher.h" |
6 | 6 |
7 #include "content/common/geolocation_messages.h" | 7 #include "content/common/geolocation_messages.h" |
8 #include "content/renderer/render_view_impl.h" | 8 #include "content/renderer/render_view_impl.h" |
9 #include "third_party/WebKit/public/platform/WebString.h" | 9 #include "third_party/WebKit/public/platform/WebString.h" |
10 #include "third_party/WebKit/public/web/WebGeolocationPermissionRequest.h" | 10 #include "third_party/WebKit/public/web/WebGeolocationPermissionRequest.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 // conversion is necessary. | 82 // conversion is necessary. |
83 void GeolocationDispatcher::requestPermission( | 83 void GeolocationDispatcher::requestPermission( |
84 const WebGeolocationPermissionRequest& permissionRequest) { | 84 const WebGeolocationPermissionRequest& permissionRequest) { |
85 int bridge_id = pending_permissions_->add(permissionRequest); | 85 int bridge_id = pending_permissions_->add(permissionRequest); |
86 base::string16 origin = permissionRequest.securityOrigin().toString(); | 86 base::string16 origin = permissionRequest.securityOrigin().toString(); |
87 Send(new GeolocationHostMsg_RequestPermission( | 87 Send(new GeolocationHostMsg_RequestPermission( |
88 routing_id(), bridge_id, GURL(origin), | 88 routing_id(), bridge_id, GURL(origin), |
89 blink::WebUserGestureIndicator::isProcessingUserGesture())); | 89 blink::WebUserGestureIndicator::isProcessingUserGesture())); |
90 } | 90 } |
91 | 91 |
92 // TODO(jknotten): Change the messages to use a security origin, so no | |
93 // conversion is necessary. | |
94 void GeolocationDispatcher::cancelPermissionRequest( | 92 void GeolocationDispatcher::cancelPermissionRequest( |
95 const WebGeolocationPermissionRequest& permissionRequest) { | 93 const WebGeolocationPermissionRequest& permissionRequest) { |
96 int bridge_id; | 94 int bridge_id; |
97 if (!pending_permissions_->remove(permissionRequest, bridge_id)) | 95 pending_permissions_->remove(permissionRequest, bridge_id); |
98 return; | |
99 base::string16 origin = permissionRequest.securityOrigin().toString(); | |
100 Send(new GeolocationHostMsg_CancelPermissionRequest( | |
101 routing_id(), bridge_id, GURL(origin))); | |
102 } | 96 } |
103 | 97 |
104 // Permission for using geolocation has been set. | 98 // Permission for using geolocation has been set. |
105 void GeolocationDispatcher::OnPermissionSet(int bridge_id, bool is_allowed) { | 99 void GeolocationDispatcher::OnPermissionSet(int bridge_id, bool is_allowed) { |
106 WebGeolocationPermissionRequest permissionRequest; | 100 WebGeolocationPermissionRequest permissionRequest; |
107 if (!pending_permissions_->remove(bridge_id, permissionRequest)) | 101 if (!pending_permissions_->remove(bridge_id, permissionRequest)) |
108 return; | 102 return; |
109 permissionRequest.setIsAllowed(is_allowed); | 103 permissionRequest.setIsAllowed(is_allowed); |
110 } | 104 } |
111 | 105 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 NOTREACHED() << geoposition.error_code; | 139 NOTREACHED() << geoposition.error_code; |
146 return; | 140 return; |
147 } | 141 } |
148 controller_->errorOccurred( | 142 controller_->errorOccurred( |
149 WebGeolocationError( | 143 WebGeolocationError( |
150 code, blink::WebString::fromUTF8(geoposition.error_message))); | 144 code, blink::WebString::fromUTF8(geoposition.error_message))); |
151 } | 145 } |
152 } | 146 } |
153 | 147 |
154 } // namespace content | 148 } // namespace content |
OLD | NEW |