Chromium Code Reviews| 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 "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "content/browser/geolocation/geolocation_dispatcher_host.h" | |
| 8 #include "content/browser/renderer_host/render_view_host_impl.h" | 9 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 10 #include "content/browser/web_contents/web_contents_impl.h" | |
| 9 | 11 |
| 10 namespace content { | 12 namespace content { |
| 11 namespace devtools { | 13 namespace devtools { |
| 12 namespace page { | 14 namespace page { |
| 13 | 15 |
| 14 typedef DevToolsProtocolClient::Response Response; | 16 typedef DevToolsProtocolClient::Response Response; |
| 15 | 17 |
| 16 PageHandler::PageHandler() | 18 PageHandler::PageHandler() |
| 17 : weak_factory_(this) { | 19 : weak_factory_(this) { |
| 18 } | 20 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 50 Response PageHandler::GetNavigationHistory( | 52 Response PageHandler::GetNavigationHistory( |
| 51 int* current_index, | 53 int* current_index, |
| 52 std::vector<NavigationEntry>* entries) { | 54 std::vector<NavigationEntry>* entries) { |
| 53 return Response::FallThrough(); | 55 return Response::FallThrough(); |
| 54 } | 56 } |
| 55 | 57 |
| 56 Response PageHandler::NavigateToHistoryEntry(int entry_id) { | 58 Response PageHandler::NavigateToHistoryEntry(int entry_id) { |
| 57 return Response::FallThrough(); | 59 return Response::FallThrough(); |
| 58 } | 60 } |
| 59 | 61 |
| 62 Response PageHandler::SetGeolocationOverride(double* latitude, | |
| 63 double* longitude, | |
| 64 double* accuracy) { | |
| 65 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>( | |
| 66 WebContents::FromRenderViewHost(host_)); | |
| 67 GeolocationDispatcherHost* geolocation_host = | |
|
dgozman
2014/10/06 11:03:26
if (!web_contents)
return Response::InternalErro
vkuzkokov
2014/10/06 13:48:20
Done.
| |
| 68 web_contents->geolocation_dispatcher_host(); | |
| 69 scoped_ptr<Geoposition> geoposition(new Geoposition()); | |
| 70 if (latitude && longitude && accuracy) { | |
| 71 geoposition->latitude = *latitude; | |
| 72 geoposition->longitude = *longitude; | |
| 73 geoposition->accuracy = *accuracy; | |
| 74 geoposition->timestamp = base::Time::Now(); | |
| 75 } else { | |
| 76 geoposition->error_code = Geoposition::ERROR_CODE_POSITION_UNAVAILABLE; | |
| 77 } | |
| 78 geolocation_host->SetOverride(geoposition.Pass()); | |
|
dgozman
2014/10/06 11:03:26
Could |geolocation_host| be NULL?
Michael van Ouwerkerk
2014/10/06 13:38:23
It should really never be, it is instantiated in W
| |
| 79 return Response::OK(); | |
| 80 } | |
| 81 | |
| 82 Response PageHandler::ClearGeolocationOverride() { | |
| 83 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>( | |
|
dgozman
2014/10/06 11:03:26
Check |web_contents| and maybe |geolocation_host|.
vkuzkokov
2014/10/06 13:48:20
Done.
| |
| 84 WebContents::FromRenderViewHost(host_)); | |
| 85 GeolocationDispatcherHost* geolocation_host = | |
| 86 web_contents->geolocation_dispatcher_host(); | |
| 87 geolocation_host->ClearOverride(); | |
| 88 return Response::OK(); | |
| 89 } | |
| 90 | |
| 91 | |
| 60 Response PageHandler::SetTouchEmulationEnabled(bool enabled) { | 92 Response PageHandler::SetTouchEmulationEnabled(bool enabled) { |
| 61 return Response::FallThrough(); | 93 return Response::FallThrough(); |
| 62 } | 94 } |
| 63 | 95 |
| 64 scoped_refptr<DevToolsProtocol::Response> PageHandler::CaptureScreenshot( | 96 scoped_refptr<DevToolsProtocol::Response> PageHandler::CaptureScreenshot( |
| 65 scoped_refptr<DevToolsProtocol::Command> command) { | 97 scoped_refptr<DevToolsProtocol::Command> command) { |
| 66 if (!host_ || !host_->GetView()) | 98 if (!host_ || !host_->GetView()) |
| 67 return command->InternalErrorResponse("Could not connect to view"); | 99 return command->InternalErrorResponse("Could not connect to view"); |
| 68 | 100 |
| 69 host_->GetSnapshotFromBrowser( | 101 host_->GetSnapshotFromBrowser( |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 122 &base_64_data); | 154 &base_64_data); |
| 123 | 155 |
| 124 CaptureScreenshotResponse response; | 156 CaptureScreenshotResponse response; |
| 125 response.set_data(base_64_data); | 157 response.set_data(base_64_data); |
| 126 client_->SendCaptureScreenshotResponse(command, response); | 158 client_->SendCaptureScreenshotResponse(command, response); |
| 127 } | 159 } |
| 128 | 160 |
| 129 } // namespace page | 161 } // namespace page |
| 130 } // namespace devtools | 162 } // namespace devtools |
| 131 } // namespace content | 163 } // namespace content |
| OLD | NEW |