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

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

Issue 1413033012: Fix crashes in AutomationInternalCustomBindings due to no v8 context. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Call inherited method from AutomationInternalCustomBindings::Invalidate Created 5 years, 1 month 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
« no previous file with comments | « chrome/renderer/extensions/automation_internal_custom_bindings.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 [](v8::Isolate* isolate, v8::ReturnValue<v8::Value> result, 466 [](v8::Isolate* isolate, v8::ReturnValue<v8::Value> result,
467 ui::AXNode* node, const std::string& attribute_name) { 467 ui::AXNode* node, const std::string& attribute_name) {
468 std::string attr_value; 468 std::string attr_value;
469 if (!node->data().GetHtmlAttribute(attribute_name.c_str(), &attr_value)) 469 if (!node->data().GetHtmlAttribute(attribute_name.c_str(), &attr_value))
470 return; 470 return;
471 471
472 result.Set(v8::String::NewFromUtf8(isolate, attr_value.c_str())); 472 result.Set(v8::String::NewFromUtf8(isolate, attr_value.c_str()));
473 }); 473 });
474 } 474 }
475 475
476 AutomationInternalCustomBindings::~AutomationInternalCustomBindings() { 476 AutomationInternalCustomBindings::~AutomationInternalCustomBindings() {}
477
478 void AutomationInternalCustomBindings::Invalidate() {
479 ObjectBackedNativeHandler::Invalidate();
480
477 if (message_filter_) 481 if (message_filter_)
478 message_filter_->Detach(); 482 message_filter_->Detach();
479 STLDeleteContainerPairSecondPointers(tree_id_to_tree_cache_map_.begin(), 483
480 tree_id_to_tree_cache_map_.end()); 484 // Delete the TreeCaches quickly by first clearing their delegates so
485 // we don't get a callback for every node being deleted.
486 for (auto iter : tree_id_to_tree_cache_map_) {
487 TreeCache* cache = iter.second;
488 cache->tree.SetDelegate(nullptr);
489 delete cache;
490 }
491 tree_id_to_tree_cache_map_.clear();
481 } 492 }
482 493
483 void AutomationInternalCustomBindings::OnMessageReceived( 494 void AutomationInternalCustomBindings::OnMessageReceived(
484 const IPC::Message& message) { 495 const IPC::Message& message) {
485 IPC_BEGIN_MESSAGE_MAP(AutomationInternalCustomBindings, message) 496 IPC_BEGIN_MESSAGE_MAP(AutomationInternalCustomBindings, message)
486 IPC_MESSAGE_HANDLER(ExtensionMsg_AccessibilityEvent, OnAccessibilityEvent) 497 IPC_MESSAGE_HANDLER(ExtensionMsg_AccessibilityEvent, OnAccessibilityEvent)
487 IPC_END_MESSAGE_MAP() 498 IPC_END_MESSAGE_MAP()
488 } 499 }
489 500
490 TreeCache* AutomationInternalCustomBindings::GetTreeCacheFromTreeID( 501 TreeCache* AutomationInternalCustomBindings::GetTreeCacheFromTreeID(
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 v8::HandleScope handle_scope(isolate); 749 v8::HandleScope handle_scope(isolate);
739 v8::Context::Scope context_scope(context()->v8_context()); 750 v8::Context::Scope context_scope(context()->v8_context());
740 v8::Local<v8::Array> args(v8::Array::New(GetIsolate(), 3U)); 751 v8::Local<v8::Array> args(v8::Array::New(GetIsolate(), 3U));
741 args->Set(0U, v8::Integer::New(GetIsolate(), tree_id)); 752 args->Set(0U, v8::Integer::New(GetIsolate(), tree_id));
742 args->Set(1U, v8::Integer::New(GetIsolate(), node->id())); 753 args->Set(1U, v8::Integer::New(GetIsolate(), node->id()));
743 args->Set(2U, CreateV8String(isolate, ToString(change_type))); 754 args->Set(2U, CreateV8String(isolate, ToString(change_type)));
744 context()->DispatchEvent("automationInternal.onTreeChange", args); 755 context()->DispatchEvent("automationInternal.onTreeChange", args);
745 } 756 }
746 757
747 } // namespace extensions 758 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/automation_internal_custom_bindings.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698