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 "chrome/renderer/extensions/automation_internal_custom_bindings.h" | 5 #include "chrome/renderer/extensions/automation_internal_custom_bindings.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/thread_task_runner_handle.h" | 9 #include "base/thread_task_runner_handle.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 127 ROUTE_FUNCTION(GetBoolAttribute); | 127 ROUTE_FUNCTION(GetBoolAttribute); |
| 128 ROUTE_FUNCTION(GetIntAttribute); | 128 ROUTE_FUNCTION(GetIntAttribute); |
| 129 ROUTE_FUNCTION(GetFloatAttribute); | 129 ROUTE_FUNCTION(GetFloatAttribute); |
| 130 ROUTE_FUNCTION(GetIntListAttribute); | 130 ROUTE_FUNCTION(GetIntListAttribute); |
| 131 ROUTE_FUNCTION(GetHtmlAttribute); | 131 ROUTE_FUNCTION(GetHtmlAttribute); |
| 132 | 132 |
| 133 #undef ROUTE_FUNCTION | 133 #undef ROUTE_FUNCTION |
| 134 } | 134 } |
| 135 | 135 |
| 136 AutomationInternalCustomBindings::~AutomationInternalCustomBindings() { | 136 AutomationInternalCustomBindings::~AutomationInternalCustomBindings() { |
| 137 if (message_filter_) | 137 if (message_filter_) |
|
David Tseng
2015/11/03 18:37:44
Perhaps this class needs to override Invalidate (a
dmazzoni
2015/11/06 22:49:58
Good catch. Done, that seems to work.
| |
| 138 message_filter_->Detach(); | 138 message_filter_->Detach(); |
| 139 STLDeleteContainerPairSecondPointers(tree_id_to_tree_cache_map_.begin(), | 139 |
| 140 tree_id_to_tree_cache_map_.end()); | 140 // Delete the TreeCaches quickly by first clearing their delegates so |
| 141 // we don't get a callback for every node being deleted. | |
| 142 for (auto iter : tree_id_to_tree_cache_map_) { | |
| 143 TreeCache* cache = iter.second; | |
| 144 cache->tree.SetDelegate(nullptr); | |
| 145 delete cache; | |
| 146 } | |
| 141 } | 147 } |
| 142 | 148 |
| 143 void AutomationInternalCustomBindings::OnMessageReceived( | 149 void AutomationInternalCustomBindings::OnMessageReceived( |
| 144 const IPC::Message& message) { | 150 const IPC::Message& message) { |
| 145 IPC_BEGIN_MESSAGE_MAP(AutomationInternalCustomBindings, message) | 151 IPC_BEGIN_MESSAGE_MAP(AutomationInternalCustomBindings, message) |
| 146 IPC_MESSAGE_HANDLER(ExtensionMsg_AccessibilityEvent, OnAccessibilityEvent) | 152 IPC_MESSAGE_HANDLER(ExtensionMsg_AccessibilityEvent, OnAccessibilityEvent) |
| 147 IPC_END_MESSAGE_MAP() | 153 IPC_END_MESSAGE_MAP() |
| 148 } | 154 } |
| 149 | 155 |
| 150 void AutomationInternalCustomBindings::IsInteractPermitted( | 156 void AutomationInternalCustomBindings::IsInteractPermitted( |
| (...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 621 } | 627 } |
| 622 | 628 |
| 623 void AutomationInternalCustomBindings::SendTreeChangeEvent( | 629 void AutomationInternalCustomBindings::SendTreeChangeEvent( |
| 624 api::automation::TreeChangeType change_type, | 630 api::automation::TreeChangeType change_type, |
| 625 ui::AXTree* tree, | 631 ui::AXTree* tree, |
| 626 ui::AXNode* node) { | 632 ui::AXNode* node) { |
| 627 // Don't send tree change events when it's not the active profile. | 633 // Don't send tree change events when it's not the active profile. |
| 628 if (!is_active_profile_) | 634 if (!is_active_profile_) |
| 629 return; | 635 return; |
| 630 | 636 |
| 637 if (!GetIsolate() || !context()) | |
|
David Tseng
2015/11/03 18:37:44
Do you need to do this if teardown occurs in Inval
dmazzoni
2015/11/06 22:49:58
Probably not.
| |
| 638 return; | |
| 639 | |
| 631 auto iter = axtree_to_tree_cache_map_.find(tree); | 640 auto iter = axtree_to_tree_cache_map_.find(tree); |
| 632 if (iter == axtree_to_tree_cache_map_.end()) | 641 if (iter == axtree_to_tree_cache_map_.end()) |
| 633 return; | 642 return; |
| 634 | 643 |
| 635 int tree_id = iter->second->tree_id; | 644 int tree_id = iter->second->tree_id; |
| 636 | 645 |
| 637 v8::HandleScope handle_scope(GetIsolate()); | 646 v8::HandleScope handle_scope(GetIsolate()); |
| 638 v8::Context::Scope context_scope(context()->v8_context()); | 647 v8::Context::Scope context_scope(context()->v8_context()); |
| 639 v8::Local<v8::Array> args(v8::Array::New(GetIsolate(), 3U)); | 648 v8::Local<v8::Array> args(v8::Array::New(GetIsolate(), 3U)); |
| 640 args->Set(0U, v8::Integer::New(GetIsolate(), tree_id)); | 649 args->Set(0U, v8::Integer::New(GetIsolate(), tree_id)); |
| 641 args->Set(1U, v8::Integer::New(GetIsolate(), node->id())); | 650 args->Set(1U, v8::Integer::New(GetIsolate(), node->id())); |
| 642 args->Set(2U, CreateV8String(ToString(change_type))); | 651 args->Set(2U, CreateV8String(ToString(change_type))); |
| 643 context()->DispatchEvent("automationInternal.onTreeChange", args); | 652 context()->DispatchEvent("automationInternal.onTreeChange", args); |
| 644 } | 653 } |
| 645 | 654 |
| 646 } // namespace extensions | 655 } // namespace extensions |
| OLD | NEW |