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

Side by Side Diff: chrome/renderer/extensions/automation_internal_custom_bindings.cc

Issue 1548153002: Switch to standard integer types in chrome/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 "chrome/renderer/extensions/automation_internal_custom_bindings.h" 5 #include "chrome/renderer/extensions/automation_internal_custom_bindings.h"
6 6
7 #include <stddef.h>
8 #include <stdint.h>
9
7 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/macros.h"
8 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
9 #include "base/thread_task_runner_handle.h" 13 #include "base/thread_task_runner_handle.h"
10 #include "base/values.h" 14 #include "base/values.h"
11 #include "chrome/common/extensions/chrome_extension_messages.h" 15 #include "chrome/common/extensions/chrome_extension_messages.h"
12 #include "chrome/common/extensions/manifest_handlers/automation.h" 16 #include "chrome/common/extensions/manifest_handlers/automation.h"
13 #include "content/public/renderer/render_frame.h" 17 #include "content/public/renderer/render_frame.h"
14 #include "content/public/renderer/render_thread.h" 18 #include "content/public/renderer/render_thread.h"
15 #include "content/public/renderer/render_view.h" 19 #include "content/public/renderer/render_view.h"
16 #include "extensions/common/extension.h" 20 #include "extensions/common/extension.h"
17 #include "extensions/common/manifest.h" 21 #include "extensions/common/manifest.h"
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 RouteNodeIDFunction( 487 RouteNodeIDFunction(
484 "GetIndexInParent", 488 "GetIndexInParent",
485 [](v8::Isolate* isolate, v8::ReturnValue<v8::Value> result, 489 [](v8::Isolate* isolate, v8::ReturnValue<v8::Value> result,
486 TreeCache* cache, ui::AXNode* node) { 490 TreeCache* cache, ui::AXNode* node) {
487 result.Set(v8::Integer::New(isolate, node->index_in_parent())); 491 result.Set(v8::Integer::New(isolate, node->index_in_parent()));
488 }); 492 });
489 RouteNodeIDFunction( 493 RouteNodeIDFunction(
490 "GetState", [](v8::Isolate* isolate, v8::ReturnValue<v8::Value> result, 494 "GetState", [](v8::Isolate* isolate, v8::ReturnValue<v8::Value> result,
491 TreeCache* cache, ui::AXNode* node) { 495 TreeCache* cache, ui::AXNode* node) {
492 v8::Local<v8::Object> state(v8::Object::New(isolate)); 496 v8::Local<v8::Object> state(v8::Object::New(isolate));
493 uint32 state_pos = 0, state_shifter = node->data().state; 497 uint32_t state_pos = 0, state_shifter = node->data().state;
494 while (state_shifter) { 498 while (state_shifter) {
495 if (state_shifter & 1) { 499 if (state_shifter & 1) {
496 std::string key = ToString(static_cast<ui::AXState>(state_pos)); 500 std::string key = ToString(static_cast<ui::AXState>(state_pos));
497 state->Set(CreateV8String(isolate, key), 501 state->Set(CreateV8String(isolate, key),
498 v8::Boolean::New(isolate, true)); 502 v8::Boolean::New(isolate, true));
499 } 503 }
500 state_shifter = state_shifter >> 1; 504 state_shifter = state_shifter >> 1;
501 state_pos++; 505 state_pos++;
502 } 506 }
503 result.Set(state); 507 result.Set(state);
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 result.Set(v8::Number::New(isolate, attr_value)); 615 result.Set(v8::Number::New(isolate, attr_value));
612 }); 616 });
613 RouteNodeIDPlusAttributeFunction( 617 RouteNodeIDPlusAttributeFunction(
614 "GetIntListAttribute", 618 "GetIntListAttribute",
615 [](v8::Isolate* isolate, v8::ReturnValue<v8::Value> result, 619 [](v8::Isolate* isolate, v8::ReturnValue<v8::Value> result,
616 ui::AXNode* node, const std::string& attribute_name) { 620 ui::AXNode* node, const std::string& attribute_name) {
617 ui::AXIntListAttribute attribute = 621 ui::AXIntListAttribute attribute =
618 ui::ParseAXIntListAttribute(attribute_name); 622 ui::ParseAXIntListAttribute(attribute_name);
619 if (!node->data().HasIntListAttribute(attribute)) 623 if (!node->data().HasIntListAttribute(attribute))
620 return; 624 return;
621 const std::vector<int32>& attr_value = 625 const std::vector<int32_t>& attr_value =
622 node->data().GetIntListAttribute(attribute); 626 node->data().GetIntListAttribute(attribute);
623 627
624 v8::Local<v8::Array> array_result( 628 v8::Local<v8::Array> array_result(
625 v8::Array::New(isolate, attr_value.size())); 629 v8::Array::New(isolate, attr_value.size()));
626 for (size_t i = 0; i < attr_value.size(); ++i) 630 for (size_t i = 0; i < attr_value.size(); ++i)
627 array_result->Set(static_cast<uint32>(i), 631 array_result->Set(static_cast<uint32_t>(i),
628 v8::Integer::New(isolate, attr_value[i])); 632 v8::Integer::New(isolate, attr_value[i]));
629 result.Set(array_result); 633 result.Set(array_result);
630 }); 634 });
631 RouteNodeIDPlusAttributeFunction( 635 RouteNodeIDPlusAttributeFunction(
632 "GetHtmlAttribute", 636 "GetHtmlAttribute",
633 [](v8::Isolate* isolate, v8::ReturnValue<v8::Value> result, 637 [](v8::Isolate* isolate, v8::ReturnValue<v8::Value> result,
634 ui::AXNode* node, const std::string& attribute_name) { 638 ui::AXNode* node, const std::string& attribute_name) {
635 std::string attr_value; 639 std::string attr_value;
636 if (!node->data().GetHtmlAttribute(attribute_name.c_str(), &attr_value)) 640 if (!node->data().GetHtmlAttribute(attribute_name.c_str(), &attr_value))
637 return; 641 return;
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
1050 v8::Local<v8::Array> args(v8::Array::New(GetIsolate(), 2U)); 1054 v8::Local<v8::Array> args(v8::Array::New(GetIsolate(), 2U));
1051 args->Set(0U, v8::Integer::New(GetIsolate(), tree_id)); 1055 args->Set(0U, v8::Integer::New(GetIsolate(), tree_id));
1052 v8::Local<v8::Array> nodes(v8::Array::New(GetIsolate(), ids.size())); 1056 v8::Local<v8::Array> nodes(v8::Array::New(GetIsolate(), ids.size()));
1053 args->Set(1U, nodes); 1057 args->Set(1U, nodes);
1054 for (size_t i = 0; i < ids.size(); ++i) 1058 for (size_t i = 0; i < ids.size(); ++i)
1055 nodes->Set(i, v8::Integer::New(GetIsolate(), ids[i])); 1059 nodes->Set(i, v8::Integer::New(GetIsolate(), ids[i]));
1056 context()->DispatchEvent("automationInternal.onNodesRemoved", args); 1060 context()->DispatchEvent("automationInternal.onNodesRemoved", args);
1057 } 1061 }
1058 1062
1059 } // namespace extensions 1063 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698