OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/browser/devtools/protocol/page_handler.h" | 5 #include "content/browser/devtools/protocol/page_handler.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "content/browser/devtools/protocol/color_picker.h" | 13 #include "content/browser/devtools/protocol/color_picker.h" |
14 #include "content/browser/devtools/protocol/usage_and_quota_query.h" | 14 #include "content/browser/devtools/protocol/usage_and_quota_query.h" |
15 #include "content/browser/geolocation/geolocation_service_context.h" | 15 #include "content/browser/geolocation/geolocation_dispatcher_host.h" |
16 #include "content/browser/renderer_host/render_view_host_impl.h" | 16 #include "content/browser/renderer_host/render_view_host_impl.h" |
17 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 17 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
18 #include "content/browser/web_contents/web_contents_impl.h" | 18 #include "content/browser/web_contents/web_contents_impl.h" |
19 #include "content/common/view_messages.h" | 19 #include "content/common/view_messages.h" |
20 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
21 #include "content/public/browser/javascript_dialog_manager.h" | 21 #include "content/public/browser/javascript_dialog_manager.h" |
22 #include "content/public/browser/navigation_controller.h" | 22 #include "content/public/browser/navigation_controller.h" |
23 #include "content/public/browser/navigation_entry.h" | 23 #include "content/public/browser/navigation_entry.h" |
24 #include "content/public/browser/storage_partition.h" | 24 #include "content/public/browser/storage_partition.h" |
25 #include "content/public/browser/web_contents_delegate.h" | 25 #include "content/public/browser/web_contents_delegate.h" |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 double* longitude, | 230 double* longitude, |
231 double* accuracy) { | 231 double* accuracy) { |
232 if (!host_) | 232 if (!host_) |
233 return Response::InternalError("Could not connect to view"); | 233 return Response::InternalError("Could not connect to view"); |
234 | 234 |
235 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>( | 235 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>( |
236 WebContents::FromRenderViewHost(host_)); | 236 WebContents::FromRenderViewHost(host_)); |
237 if (!web_contents) | 237 if (!web_contents) |
238 return Response::InternalError("No WebContents to override"); | 238 return Response::InternalError("No WebContents to override"); |
239 | 239 |
240 GeolocationServiceContext* geolocation_context = | 240 GeolocationDispatcherHost* geolocation_host = |
241 web_contents->GetGeolocationServiceContext(); | 241 web_contents->geolocation_dispatcher_host(); |
242 scoped_ptr<Geoposition> geoposition(new Geoposition()); | 242 scoped_ptr<Geoposition> geoposition(new Geoposition()); |
243 if (latitude && longitude && accuracy) { | 243 if (latitude && longitude && accuracy) { |
244 geoposition->latitude = *latitude; | 244 geoposition->latitude = *latitude; |
245 geoposition->longitude = *longitude; | 245 geoposition->longitude = *longitude; |
246 geoposition->accuracy = *accuracy; | 246 geoposition->accuracy = *accuracy; |
247 geoposition->timestamp = base::Time::Now(); | 247 geoposition->timestamp = base::Time::Now(); |
248 if (!geoposition->Validate()) { | 248 if (!geoposition->Validate()) { |
249 return Response::InternalError("Invalid geolocation"); | 249 return Response::InternalError("Invalid geolocation"); |
250 } | 250 } |
251 } else { | 251 } else { |
252 geoposition->error_code = Geoposition::ERROR_CODE_POSITION_UNAVAILABLE; | 252 geoposition->error_code = Geoposition::ERROR_CODE_POSITION_UNAVAILABLE; |
253 } | 253 } |
254 geolocation_context->SetOverride(geoposition.Pass()); | 254 geolocation_host->SetOverride(geoposition.Pass()); |
255 return Response::OK(); | 255 return Response::OK(); |
256 } | 256 } |
257 | 257 |
258 Response PageHandler::ClearGeolocationOverride() { | 258 Response PageHandler::ClearGeolocationOverride() { |
259 if (!host_) | 259 if (!host_) |
260 return Response::InternalError("Could not connect to view"); | 260 return Response::InternalError("Could not connect to view"); |
261 | 261 |
262 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>( | 262 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>( |
263 WebContents::FromRenderViewHost(host_)); | 263 WebContents::FromRenderViewHost(host_)); |
264 if (!web_contents) | 264 if (!web_contents) |
265 return Response::InternalError("No WebContents to override"); | 265 return Response::InternalError("No WebContents to override"); |
266 | 266 |
267 GeolocationServiceContext* geolocation_context = | 267 GeolocationDispatcherHost* geolocation_host = |
268 web_contents->GetGeolocationServiceContext(); | 268 web_contents->geolocation_dispatcher_host(); |
269 geolocation_context->ClearOverride(); | 269 geolocation_host->ClearOverride(); |
270 return Response::OK(); | 270 return Response::OK(); |
271 } | 271 } |
272 | 272 |
273 | 273 |
274 Response PageHandler::SetTouchEmulationEnabled(bool enabled) { | 274 Response PageHandler::SetTouchEmulationEnabled(bool enabled) { |
275 touch_emulation_enabled_ = enabled; | 275 touch_emulation_enabled_ = enabled; |
276 UpdateTouchEventEmulationState(); | 276 UpdateTouchEventEmulationState(); |
277 return Response::FallThrough(); | 277 return Response::FallThrough(); |
278 } | 278 } |
279 | 279 |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 | 597 |
598 void PageHandler::QueryUsageAndQuotaCompleted( | 598 void PageHandler::QueryUsageAndQuotaCompleted( |
599 scoped_refptr<DevToolsProtocol::Command> command, | 599 scoped_refptr<DevToolsProtocol::Command> command, |
600 scoped_ptr<QueryUsageAndQuotaResponse> response_data) { | 600 scoped_ptr<QueryUsageAndQuotaResponse> response_data) { |
601 client_->SendQueryUsageAndQuotaResponse(command, *response_data); | 601 client_->SendQueryUsageAndQuotaResponse(command, *response_data); |
602 } | 602 } |
603 | 603 |
604 } // namespace page | 604 } // namespace page |
605 } // namespace devtools | 605 } // namespace devtools |
606 } // namespace content | 606 } // namespace content |
OLD | NEW |