| 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/public/common/geoposition.h" | 7 #include "content/public/common/geoposition.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/WebGeolocationClient.h" |
| 11 #include "third_party/WebKit/public/web/WebGeolocationError.h" |
| 10 #include "third_party/WebKit/public/web/WebGeolocationPermissionRequest.h" | 12 #include "third_party/WebKit/public/web/WebGeolocationPermissionRequest.h" |
| 11 #include "third_party/WebKit/public/web/WebGeolocationPermissionRequestManager.h
" | 13 #include "third_party/WebKit/public/web/WebGeolocationPermissionRequestManager.h
" |
| 12 #include "third_party/WebKit/public/web/WebGeolocationClient.h" | |
| 13 #include "third_party/WebKit/public/web/WebGeolocationPosition.h" | 14 #include "third_party/WebKit/public/web/WebGeolocationPosition.h" |
| 14 #include "third_party/WebKit/public/web/WebGeolocationError.h" | |
| 15 | 15 |
| 16 using blink::WebGeolocationController; | 16 using blink::WebGeolocationController; |
| 17 using blink::WebGeolocationError; | 17 using blink::WebGeolocationError; |
| 18 using blink::WebGeolocationPermissionRequest; | 18 using blink::WebGeolocationPermissionRequest; |
| 19 using blink::WebGeolocationPermissionRequestManager; | 19 using blink::WebGeolocationPermissionRequestManager; |
| 20 using blink::WebGeolocationPosition; | 20 using blink::WebGeolocationPosition; |
| 21 | 21 |
| 22 namespace content { | 22 namespace content { |
| 23 | 23 |
| 24 GeolocationDispatcher::GeolocationDispatcher(RenderFrame* render_frame) | 24 GeolocationDispatcher::GeolocationDispatcher(RenderFrame* render_frame) |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 void GeolocationDispatcher::requestPermission( | 73 void GeolocationDispatcher::requestPermission( |
| 74 const WebGeolocationPermissionRequest& permissionRequest) { | 74 const WebGeolocationPermissionRequest& permissionRequest) { |
| 75 if (!permission_service_.get()) { | 75 if (!permission_service_.get()) { |
| 76 render_frame()->GetServiceRegistry()->ConnectToRemoteService( | 76 render_frame()->GetServiceRegistry()->ConnectToRemoteService( |
| 77 mojo::GetProxy(&permission_service_)); | 77 mojo::GetProxy(&permission_service_)); |
| 78 } | 78 } |
| 79 | 79 |
| 80 int permission_request_id = pending_permissions_->add(permissionRequest); | 80 int permission_request_id = pending_permissions_->add(permissionRequest); |
| 81 | 81 |
| 82 permission_service_->RequestPermission( | 82 permission_service_->RequestPermission( |
| 83 blink::mojom::PermissionName::GEOLOCATION, | 83 permissions::mojom::PermissionName::GEOLOCATION, |
| 84 permissionRequest.getSecurityOrigin().toString().utf8(), | 84 permissionRequest.getSecurityOrigin().toString().utf8(), |
| 85 base::Bind(&GeolocationDispatcher::OnPermissionSet, | 85 base::Bind(&GeolocationDispatcher::OnPermissionSet, |
| 86 base::Unretained(this), permission_request_id)); | 86 base::Unretained(this), permission_request_id)); |
| 87 } | 87 } |
| 88 | 88 |
| 89 void GeolocationDispatcher::cancelPermissionRequest( | 89 void GeolocationDispatcher::cancelPermissionRequest( |
| 90 const blink::WebGeolocationPermissionRequest& permissionRequest) { | 90 const blink::WebGeolocationPermissionRequest& permissionRequest) { |
| 91 int permission_request_id; | 91 int permission_request_id; |
| 92 pending_permissions_->remove(permissionRequest, permission_request_id); | 92 pending_permissions_->remove(permissionRequest, permission_request_id); |
| 93 } | 93 } |
| 94 | 94 |
| 95 // Permission for using geolocation has been set. | 95 // Permission for using geolocation has been set. |
| 96 void GeolocationDispatcher::OnPermissionSet( | 96 void GeolocationDispatcher::OnPermissionSet( |
| 97 int permission_request_id, | 97 int permission_request_id, |
| 98 blink::mojom::PermissionStatus status) { | 98 permissions::mojom::PermissionStatus status) { |
| 99 WebGeolocationPermissionRequest permissionRequest; | 99 WebGeolocationPermissionRequest permissionRequest; |
| 100 if (!pending_permissions_->remove(permission_request_id, permissionRequest)) | 100 if (!pending_permissions_->remove(permission_request_id, permissionRequest)) |
| 101 return; | 101 return; |
| 102 | 102 |
| 103 permissionRequest.setIsAllowed(status == | 103 permissionRequest.setIsAllowed(status == |
| 104 blink::mojom::PermissionStatus::GRANTED); | 104 permissions::mojom::PermissionStatus::GRANTED); |
| 105 } | 105 } |
| 106 | 106 |
| 107 void GeolocationDispatcher::QueryNextPosition() { | 107 void GeolocationDispatcher::QueryNextPosition() { |
| 108 DCHECK(geolocation_service_); | 108 DCHECK(geolocation_service_); |
| 109 geolocation_service_->QueryNextPosition( | 109 geolocation_service_->QueryNextPosition( |
| 110 base::Bind(&GeolocationDispatcher::OnPositionUpdate, | 110 base::Bind(&GeolocationDispatcher::OnPositionUpdate, |
| 111 base::Unretained(this))); | 111 base::Unretained(this))); |
| 112 } | 112 } |
| 113 | 113 |
| 114 void GeolocationDispatcher::OnPositionUpdate( | 114 void GeolocationDispatcher::OnPositionUpdate( |
| (...skipping 27 matching lines...) Expand all Loading... |
| 142 default: | 142 default: |
| 143 NOTREACHED() << geoposition->error_code; | 143 NOTREACHED() << geoposition->error_code; |
| 144 return; | 144 return; |
| 145 } | 145 } |
| 146 controller_->errorOccurred(WebGeolocationError( | 146 controller_->errorOccurred(WebGeolocationError( |
| 147 code, blink::WebString::fromUTF8(geoposition->error_message))); | 147 code, blink::WebString::fromUTF8(geoposition->error_message))); |
| 148 } | 148 } |
| 149 } | 149 } |
| 150 | 150 |
| 151 } // namespace content | 151 } // namespace content |
| OLD | NEW |