Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Side by Side Diff: content/shell/renderer/test_runner/event_sender.cc

Issue 1113783002: Use Local instead of Handle in src/content/* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/shell/renderer/test_runner/event_sender.h" 5 #include "content/shell/renderer/test_runner/event_sender.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 110
111 int GetKeyModifiers(const std::vector<std::string>& modifier_names) { 111 int GetKeyModifiers(const std::vector<std::string>& modifier_names) {
112 int modifiers = 0; 112 int modifiers = 0;
113 for (std::vector<std::string>::const_iterator it = modifier_names.begin(); 113 for (std::vector<std::string>::const_iterator it = modifier_names.begin();
114 it != modifier_names.end(); ++it) { 114 it != modifier_names.end(); ++it) {
115 modifiers |= GetKeyModifier(*it); 115 modifiers |= GetKeyModifier(*it);
116 } 116 }
117 return modifiers; 117 return modifiers;
118 } 118 }
119 119
120 int GetKeyModifiersFromV8(v8::Handle<v8::Value> value) { 120 int GetKeyModifiersFromV8(v8::Local<v8::Value> value) {
121 std::vector<std::string> modifier_names; 121 std::vector<std::string> modifier_names;
122 if (value->IsString()) { 122 if (value->IsString()) {
123 modifier_names.push_back(gin::V8ToString(value)); 123 modifier_names.push_back(gin::V8ToString(value));
124 } else if (value->IsArray()) { 124 } else if (value->IsArray()) {
125 gin::Converter<std::vector<std::string> >::FromV8( 125 gin::Converter<std::vector<std::string> >::FromV8(
126 NULL, value, &modifier_names); 126 NULL, value, &modifier_names);
127 } 127 }
128 return GetKeyModifiers(modifier_names); 128 return GetKeyModifiers(modifier_names);
129 } 129 }
130 130
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 : sender_(sender) { 476 : sender_(sender) {
477 } 477 }
478 478
479 EventSenderBindings::~EventSenderBindings() {} 479 EventSenderBindings::~EventSenderBindings() {}
480 480
481 // static 481 // static
482 void EventSenderBindings::Install(base::WeakPtr<EventSender> sender, 482 void EventSenderBindings::Install(base::WeakPtr<EventSender> sender,
483 WebFrame* frame) { 483 WebFrame* frame) {
484 v8::Isolate* isolate = blink::mainThreadIsolate(); 484 v8::Isolate* isolate = blink::mainThreadIsolate();
485 v8::HandleScope handle_scope(isolate); 485 v8::HandleScope handle_scope(isolate);
486 v8::Handle<v8::Context> context = frame->mainWorldScriptContext(); 486 v8::Local<v8::Context> context = frame->mainWorldScriptContext();
487 if (context.IsEmpty()) 487 if (context.IsEmpty())
488 return; 488 return;
489 489
490 v8::Context::Scope context_scope(context); 490 v8::Context::Scope context_scope(context);
491 491
492 gin::Handle<EventSenderBindings> bindings = 492 gin::Handle<EventSenderBindings> bindings =
493 gin::CreateHandle(isolate, new EventSenderBindings(sender)); 493 gin::CreateHandle(isolate, new EventSenderBindings(sender));
494 if (bindings.IsEmpty()) 494 if (bindings.IsEmpty())
495 return; 495 return;
496 v8::Handle<v8::Object> global = context->Global(); 496 v8::Local<v8::Object> global = context->Global();
497 global->Set(gin::StringToV8(isolate, "eventSender"), bindings.ToV8()); 497 global->Set(gin::StringToV8(isolate, "eventSender"), bindings.ToV8());
498 } 498 }
499 499
500 gin::ObjectTemplateBuilder 500 gin::ObjectTemplateBuilder
501 EventSenderBindings::GetObjectTemplateBuilder(v8::Isolate* isolate) { 501 EventSenderBindings::GetObjectTemplateBuilder(v8::Isolate* isolate) {
502 return gin::Wrappable<EventSenderBindings>::GetObjectTemplateBuilder(isolate) 502 return gin::Wrappable<EventSenderBindings>::GetObjectTemplateBuilder(isolate)
503 .SetMethod("enableDOMUIEventLogging", 503 .SetMethod("enableDOMUIEventLogging",
504 &EventSenderBindings::EnableDOMUIEventLogging) 504 &EventSenderBindings::EnableDOMUIEventLogging)
505 .SetMethod("fireKeyboardEventsToElement", 505 .SetMethod("fireKeyboardEventsToElement",
506 &EventSenderBindings::FireKeyboardEventsToElement) 506 &EventSenderBindings::FireKeyboardEventsToElement)
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
924 924
925 void EventSenderBindings::ScheduleAsynchronousKeyDown(gin::Arguments* args) { 925 void EventSenderBindings::ScheduleAsynchronousKeyDown(gin::Arguments* args) {
926 if (!sender_) 926 if (!sender_)
927 return; 927 return;
928 928
929 std::string code_str; 929 std::string code_str;
930 int modifiers = 0; 930 int modifiers = 0;
931 int location = DOMKeyLocationStandard; 931 int location = DOMKeyLocationStandard;
932 args->GetNext(&code_str); 932 args->GetNext(&code_str);
933 if (!args->PeekNext().IsEmpty()) { 933 if (!args->PeekNext().IsEmpty()) {
934 v8::Handle<v8::Value> value; 934 v8::Local<v8::Value> value;
935 args->GetNext(&value); 935 args->GetNext(&value);
936 modifiers = GetKeyModifiersFromV8(value); 936 modifiers = GetKeyModifiersFromV8(value);
937 if (!args->PeekNext().IsEmpty()) 937 if (!args->PeekNext().IsEmpty())
938 args->GetNext(&location); 938 args->GetNext(&location);
939 } 939 }
940 sender_->ScheduleAsynchronousKeyDown(code_str, modifiers, 940 sender_->ScheduleAsynchronousKeyDown(code_str, modifiers,
941 static_cast<KeyLocationCode>(location)); 941 static_cast<KeyLocationCode>(location));
942 } 942 }
943 943
944 void EventSenderBindings::MouseDown(gin::Arguments* args) { 944 void EventSenderBindings::MouseDown(gin::Arguments* args) {
(...skipping 26 matching lines...) Expand all
971 971
972 void EventSenderBindings::KeyDown(gin::Arguments* args) { 972 void EventSenderBindings::KeyDown(gin::Arguments* args) {
973 if (!sender_) 973 if (!sender_)
974 return; 974 return;
975 975
976 std::string code_str; 976 std::string code_str;
977 int modifiers = 0; 977 int modifiers = 0;
978 int location = DOMKeyLocationStandard; 978 int location = DOMKeyLocationStandard;
979 args->GetNext(&code_str); 979 args->GetNext(&code_str);
980 if (!args->PeekNext().IsEmpty()) { 980 if (!args->PeekNext().IsEmpty()) {
981 v8::Handle<v8::Value> value; 981 v8::Local<v8::Value> value;
982 args->GetNext(&value); 982 args->GetNext(&value);
983 modifiers = GetKeyModifiersFromV8(value); 983 modifiers = GetKeyModifiersFromV8(value);
984 if (!args->PeekNext().IsEmpty()) 984 if (!args->PeekNext().IsEmpty())
985 args->GetNext(&location); 985 args->GetNext(&location);
986 } 986 }
987 sender_->KeyDown(code_str, modifiers, static_cast<KeyLocationCode>(location)); 987 sender_->KeyDown(code_str, modifiers, static_cast<KeyLocationCode>(location));
988 } 988 }
989 989
990 bool EventSenderBindings::ForceLayoutOnEvents() const { 990 bool EventSenderBindings::ForceLayoutOnEvents() const {
991 if (sender_) 991 if (sender_)
(...skipping 1382 matching lines...) Expand 10 before | Expand all | Expand 10 after
2374 2374
2375 bool paged = false; 2375 bool paged = false;
2376 bool has_precise_scrolling_deltas = false; 2376 bool has_precise_scrolling_deltas = false;
2377 int modifiers = 0; 2377 int modifiers = 0;
2378 bool can_scroll = true; 2378 bool can_scroll = true;
2379 if (!args->PeekNext().IsEmpty()) { 2379 if (!args->PeekNext().IsEmpty()) {
2380 args->GetNext(&paged); 2380 args->GetNext(&paged);
2381 if (!args->PeekNext().IsEmpty()) { 2381 if (!args->PeekNext().IsEmpty()) {
2382 args->GetNext(&has_precise_scrolling_deltas); 2382 args->GetNext(&has_precise_scrolling_deltas);
2383 if (!args->PeekNext().IsEmpty()) { 2383 if (!args->PeekNext().IsEmpty()) {
2384 v8::Handle<v8::Value> value; 2384 v8::Local<v8::Value> value;
2385 args->GetNext(&value); 2385 args->GetNext(&value);
2386 modifiers = GetKeyModifiersFromV8(value); 2386 modifiers = GetKeyModifiersFromV8(value);
2387 if (!args->PeekNext().IsEmpty()) 2387 if (!args->PeekNext().IsEmpty())
2388 args->GetNext(&can_scroll); 2388 args->GetNext(&can_scroll);
2389 } 2389 }
2390 } 2390 }
2391 } 2391 }
2392 2392
2393 InitMouseEvent(WebInputEvent::MouseWheel, 2393 InitMouseEvent(WebInputEvent::MouseWheel,
2394 pressed_button_, 2394 pressed_button_,
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
2513 2513
2514 bool EventSender::HandleInputEventOnViewOrPopup(const WebInputEvent& event) { 2514 bool EventSender::HandleInputEventOnViewOrPopup(const WebInputEvent& event) {
2515 if (WebPagePopup* popup = view_->pagePopup()) { 2515 if (WebPagePopup* popup = view_->pagePopup()) {
2516 if (!WebInputEvent::isKeyboardEventType(event.type)) 2516 if (!WebInputEvent::isKeyboardEventType(event.type))
2517 return popup->handleInputEvent(event); 2517 return popup->handleInputEvent(event);
2518 } 2518 }
2519 return view_->handleInputEvent(event); 2519 return view_->handleInputEvent(event);
2520 } 2520 }
2521 2521
2522 } // namespace content 2522 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698