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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 // WebCore::GeolocationController already caches the last position it | 80 // WebCore::GeolocationController already caches the last position it |
81 // receives, so there is not much benefit to more position caching here. | 81 // receives, so there is not much benefit to more position caching here. |
82 return false; | 82 return false; |
83 } | 83 } |
84 | 84 |
85 // TODO(jknotten): Change the messages to use a security origin, so no | 85 // TODO(jknotten): Change the messages to use a security origin, so no |
86 // conversion is necessary. | 86 // conversion is necessary. |
87 void GeolocationDispatcher::requestPermission( | 87 void GeolocationDispatcher::requestPermission( |
88 const WebGeolocationPermissionRequest& permissionRequest) { | 88 const WebGeolocationPermissionRequest& permissionRequest) { |
89 int bridge_id = pending_permissions_->add(permissionRequest); | 89 int bridge_id = pending_permissions_->add(permissionRequest); |
90 string16 origin = permissionRequest.securityOrigin().toString(); | 90 base::string16 origin = permissionRequest.securityOrigin().toString(); |
91 Send(new GeolocationHostMsg_RequestPermission( | 91 Send(new GeolocationHostMsg_RequestPermission( |
92 routing_id(), bridge_id, GURL(origin))); | 92 routing_id(), bridge_id, GURL(origin))); |
93 } | 93 } |
94 | 94 |
95 // TODO(jknotten): Change the messages to use a security origin, so no | 95 // TODO(jknotten): Change the messages to use a security origin, so no |
96 // conversion is necessary. | 96 // conversion is necessary. |
97 void GeolocationDispatcher::cancelPermissionRequest( | 97 void GeolocationDispatcher::cancelPermissionRequest( |
98 const WebGeolocationPermissionRequest& permissionRequest) { | 98 const WebGeolocationPermissionRequest& permissionRequest) { |
99 int bridge_id; | 99 int bridge_id; |
100 if (!pending_permissions_->remove(permissionRequest, bridge_id)) | 100 if (!pending_permissions_->remove(permissionRequest, bridge_id)) |
101 return; | 101 return; |
102 string16 origin = permissionRequest.securityOrigin().toString(); | 102 base::string16 origin = permissionRequest.securityOrigin().toString(); |
103 Send(new GeolocationHostMsg_CancelPermissionRequest( | 103 Send(new GeolocationHostMsg_CancelPermissionRequest( |
104 routing_id(), bridge_id, GURL(origin))); | 104 routing_id(), bridge_id, GURL(origin))); |
105 } | 105 } |
106 | 106 |
107 // Permission for using geolocation has been set. | 107 // Permission for using geolocation has been set. |
108 void GeolocationDispatcher::OnPermissionSet(int bridge_id, bool is_allowed) { | 108 void GeolocationDispatcher::OnPermissionSet(int bridge_id, bool is_allowed) { |
109 WebGeolocationPermissionRequest permissionRequest; | 109 WebGeolocationPermissionRequest permissionRequest; |
110 if (!pending_permissions_->remove(bridge_id, permissionRequest)) | 110 if (!pending_permissions_->remove(bridge_id, permissionRequest)) |
111 return; | 111 return; |
112 permissionRequest.setIsAllowed(is_allowed); | 112 permissionRequest.setIsAllowed(is_allowed); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 NOTREACHED() << geoposition.error_code; | 148 NOTREACHED() << geoposition.error_code; |
149 return; | 149 return; |
150 } | 150 } |
151 controller_->errorOccurred( | 151 controller_->errorOccurred( |
152 WebGeolocationError( | 152 WebGeolocationError( |
153 code, blink::WebString::fromUTF8(geoposition.error_message))); | 153 code, blink::WebString::fromUTF8(geoposition.error_message))); |
154 } | 154 } |
155 } | 155 } |
156 | 156 |
157 } // namespace content | 157 } // namespace content |
OLD | NEW |