| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/emulation_handler.h" | 5 #include "content/browser/devtools/protocol/emulation_handler.h" |
| 6 | 6 |
| 7 #include <utility> |
| 8 |
| 7 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 8 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| 9 #include "content/browser/frame_host/render_frame_host_impl.h" | 11 #include "content/browser/frame_host/render_frame_host_impl.h" |
| 10 #include "content/browser/geolocation/geolocation_service_context.h" | 12 #include "content/browser/geolocation/geolocation_service_context.h" |
| 11 #include "content/browser/renderer_host/render_widget_host_impl.h" | 13 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 12 #include "content/browser/web_contents/web_contents_impl.h" | 14 #include "content/browser/web_contents/web_contents_impl.h" |
| 13 #include "content/common/view_messages.h" | 15 #include "content/common/view_messages.h" |
| 14 #include "content/public/common/url_constants.h" | 16 #include "content/public/common/url_constants.h" |
| 15 | 17 |
| 16 namespace content { | 18 namespace content { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 geoposition->latitude = *latitude; | 77 geoposition->latitude = *latitude; |
| 76 geoposition->longitude = *longitude; | 78 geoposition->longitude = *longitude; |
| 77 geoposition->accuracy = *accuracy; | 79 geoposition->accuracy = *accuracy; |
| 78 geoposition->timestamp = base::Time::Now(); | 80 geoposition->timestamp = base::Time::Now(); |
| 79 if (!geoposition->Validate()) { | 81 if (!geoposition->Validate()) { |
| 80 return Response::InternalError("Invalid geolocation"); | 82 return Response::InternalError("Invalid geolocation"); |
| 81 } | 83 } |
| 82 } else { | 84 } else { |
| 83 geoposition->error_code = Geoposition::ERROR_CODE_POSITION_UNAVAILABLE; | 85 geoposition->error_code = Geoposition::ERROR_CODE_POSITION_UNAVAILABLE; |
| 84 } | 86 } |
| 85 geolocation_context->SetOverride(geoposition.Pass()); | 87 geolocation_context->SetOverride(std::move(geoposition)); |
| 86 return Response::OK(); | 88 return Response::OK(); |
| 87 } | 89 } |
| 88 | 90 |
| 89 Response EmulationHandler::ClearGeolocationOverride() { | 91 Response EmulationHandler::ClearGeolocationOverride() { |
| 90 if (!GetWebContents()) | 92 if (!GetWebContents()) |
| 91 return Response::InternalError("Could not connect to view"); | 93 return Response::InternalError("Could not connect to view"); |
| 92 | 94 |
| 93 GeolocationServiceContext* geolocation_context = | 95 GeolocationServiceContext* geolocation_context = |
| 94 GetWebContents()->GetGeolocationServiceContext(); | 96 GetWebContents()->GetGeolocationServiceContext(); |
| 95 geolocation_context->ClearOverride(); | 97 geolocation_context->ClearOverride(); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 widget_host->GetRoutingID(), device_emulation_params_)); | 230 widget_host->GetRoutingID(), device_emulation_params_)); |
| 229 } else { | 231 } else { |
| 230 widget_host->Send(new ViewMsg_DisableDeviceEmulation( | 232 widget_host->Send(new ViewMsg_DisableDeviceEmulation( |
| 231 widget_host->GetRoutingID())); | 233 widget_host->GetRoutingID())); |
| 232 } | 234 } |
| 233 } | 235 } |
| 234 | 236 |
| 235 } // namespace emulation | 237 } // namespace emulation |
| 236 } // namespace devtools | 238 } // namespace devtools |
| 237 } // namespace content | 239 } // namespace content |
| OLD | NEW |