OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/renderer_overrides_handler.h" | 5 #include "content/browser/devtools/renderer_overrides_handler.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/barrier_closure.h" | 10 #include "base/barrier_closure.h" |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 screencast_command_ = NULL; | 319 screencast_command_ = NULL; |
320 return NULL; | 320 return NULL; |
321 } | 321 } |
322 | 322 |
323 scoped_refptr<DevToolsProtocol::Response> | 323 scoped_refptr<DevToolsProtocol::Response> |
324 RendererOverridesHandler::PageHandleJavaScriptDialog( | 324 RendererOverridesHandler::PageHandleJavaScriptDialog( |
325 scoped_refptr<DevToolsProtocol::Command> command) { | 325 scoped_refptr<DevToolsProtocol::Command> command) { |
326 base::DictionaryValue* params = command->params(); | 326 base::DictionaryValue* params = command->params(); |
327 const char* paramAccept = | 327 const char* paramAccept = |
328 devtools::Page::handleJavaScriptDialog::kParamAccept; | 328 devtools::Page::handleJavaScriptDialog::kParamAccept; |
329 bool accept; | 329 bool accept = false; |
330 if (!params || !params->GetBoolean(paramAccept, &accept)) | 330 if (!params || !params->GetBoolean(paramAccept, &accept)) |
331 return command->InvalidParamResponse(paramAccept); | 331 return command->InvalidParamResponse(paramAccept); |
332 base::string16 prompt_override; | 332 base::string16 prompt_override; |
333 base::string16* prompt_override_ptr = &prompt_override; | 333 base::string16* prompt_override_ptr = &prompt_override; |
334 if (!params || !params->GetString( | 334 if (!params || !params->GetString( |
335 devtools::Page::handleJavaScriptDialog::kParamPromptText, | 335 devtools::Page::handleJavaScriptDialog::kParamPromptText, |
336 prompt_override_ptr)) { | 336 prompt_override_ptr)) { |
337 prompt_override_ptr = NULL; | 337 prompt_override_ptr = NULL; |
338 } | 338 } |
339 | 339 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 entries); | 426 entries); |
427 return command->SuccessResponse(result); | 427 return command->SuccessResponse(result); |
428 } | 428 } |
429 } | 429 } |
430 return command->InternalErrorResponse("No WebContents to navigate"); | 430 return command->InternalErrorResponse("No WebContents to navigate"); |
431 } | 431 } |
432 | 432 |
433 scoped_refptr<DevToolsProtocol::Response> | 433 scoped_refptr<DevToolsProtocol::Response> |
434 RendererOverridesHandler::PageNavigateToHistoryEntry( | 434 RendererOverridesHandler::PageNavigateToHistoryEntry( |
435 scoped_refptr<DevToolsProtocol::Command> command) { | 435 scoped_refptr<DevToolsProtocol::Command> command) { |
436 int entry_id; | |
437 | |
438 base::DictionaryValue* params = command->params(); | 436 base::DictionaryValue* params = command->params(); |
439 const char* param = devtools::Page::navigateToHistoryEntry::kParamEntryId; | 437 const char* param = devtools::Page::navigateToHistoryEntry::kParamEntryId; |
| 438 int entry_id = 0; |
440 if (!params || !params->GetInteger(param, &entry_id)) { | 439 if (!params || !params->GetInteger(param, &entry_id)) { |
441 return command->InvalidParamResponse(param); | 440 return command->InvalidParamResponse(param); |
442 } | 441 } |
443 | 442 |
444 RenderViewHost* host = agent_->GetRenderViewHost(); | 443 RenderViewHost* host = agent_->GetRenderViewHost(); |
445 if (host) { | 444 if (host) { |
446 WebContents* web_contents = host->GetDelegate()->GetAsWebContents(); | 445 WebContents* web_contents = host->GetDelegate()->GetAsWebContents(); |
447 if (web_contents) { | 446 if (web_contents) { |
448 NavigationController& controller = web_contents->GetController(); | 447 NavigationController& controller = web_contents->GetController(); |
449 for (int i = 0; i != controller.GetEntryCount(); ++i) { | 448 for (int i = 0; i != controller.GetEntryCount(); ++i) { |
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
973 if (!params->GetInteger(devtools::Input::dispatchGestureEvent::kParamX, | 972 if (!params->GetInteger(devtools::Input::dispatchGestureEvent::kParamX, |
974 &event.x) || | 973 &event.x) || |
975 !params->GetInteger(devtools::Input::dispatchGestureEvent::kParamY, | 974 !params->GetInteger(devtools::Input::dispatchGestureEvent::kParamY, |
976 &event.y)) { | 975 &event.y)) { |
977 return NULL; | 976 return NULL; |
978 } | 977 } |
979 event.globalX = event.x; | 978 event.globalX = event.x; |
980 event.globalY = event.y; | 979 event.globalY = event.y; |
981 | 980 |
982 if (type == "scrollUpdate") { | 981 if (type == "scrollUpdate") { |
983 int dx; | 982 int dx = 0; |
984 int dy; | 983 int dy = 0; |
985 if (!params->GetInteger( | 984 if (!params->GetInteger( |
986 devtools::Input::dispatchGestureEvent::kParamDeltaX, &dx) || | 985 devtools::Input::dispatchGestureEvent::kParamDeltaX, &dx) || |
987 !params->GetInteger( | 986 !params->GetInteger( |
988 devtools::Input::dispatchGestureEvent::kParamDeltaY, &dy)) { | 987 devtools::Input::dispatchGestureEvent::kParamDeltaY, &dy)) { |
989 return NULL; | 988 return NULL; |
990 } | 989 } |
991 event.data.scrollUpdate.deltaX = dx; | 990 event.data.scrollUpdate.deltaX = dx; |
992 event.data.scrollUpdate.deltaY = dy; | 991 event.data.scrollUpdate.deltaY = dy; |
993 } | 992 } |
994 | 993 |
995 if (type == "pinchUpdate") { | 994 if (type == "pinchUpdate") { |
996 double scale; | 995 double scale; |
997 if (!params->GetDouble( | 996 if (!params->GetDouble( |
998 devtools::Input::dispatchGestureEvent::kParamPinchScale, | 997 devtools::Input::dispatchGestureEvent::kParamPinchScale, |
999 &scale)) { | 998 &scale)) { |
1000 return NULL; | 999 return NULL; |
1001 } | 1000 } |
1002 event.data.pinchUpdate.scale = static_cast<float>(scale); | 1001 event.data.pinchUpdate.scale = static_cast<float>(scale); |
1003 } | 1002 } |
1004 | 1003 |
1005 host->ForwardGestureEvent(event); | 1004 host->ForwardGestureEvent(event); |
1006 return command->SuccessResponse(NULL); | 1005 return command->SuccessResponse(NULL); |
1007 } | 1006 } |
1008 | 1007 |
1009 } // namespace content | 1008 } // namespace content |
OLD | NEW |