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

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

Issue 265044: Eliminate WebView::GetDelegate and replace RenderViewSet with a linked list o... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/event_bindings.h" 5 #include "chrome/renderer/extensions/event_bindings.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/singleton.h" 8 #include "base/singleton.h"
9 #include "chrome/common/render_messages.h" 9 #include "chrome/common/render_messages.h"
10 #include "chrome/common/url_constants.h" 10 #include "chrome/common/url_constants.h"
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 if (content_script) { 246 if (content_script) {
247 DCHECK(frame_context != context); 247 DCHECK(frame_context != context);
248 248
249 parent_context = v8::Persistent<v8::Context>::New(frame_context); 249 parent_context = v8::Persistent<v8::Context>::New(frame_context);
250 // Content script contexts can get GCed before their frame goes away, so 250 // Content script contexts can get GCed before their frame goes away, so
251 // set up a GC callback. 251 // set up a GC callback.
252 persistent_context.MakeWeak(NULL, &ContextWeakReferenceCallback); 252 persistent_context.MakeWeak(NULL, &ContextWeakReferenceCallback);
253 } 253 }
254 254
255 RenderView* render_view = NULL; 255 RenderView* render_view = NULL;
256 if (frame->view() && frame->view()->GetDelegate()) 256 if (frame->view())
257 render_view = static_cast<RenderView*>(frame->view()->GetDelegate()); 257 render_view = RenderView::FromWebView(frame->view());
258 258
259 contexts.push_back(linked_ptr<ContextInfo>( 259 contexts.push_back(linked_ptr<ContextInfo>(
260 new ContextInfo(persistent_context, extension_id, parent_context, 260 new ContextInfo(persistent_context, extension_id, parent_context,
261 render_view))); 261 render_view)));
262 262
263 v8::Handle<v8::Value> argv[1]; 263 v8::Handle<v8::Value> argv[1];
264 argv[0] = v8::String::New(extension_id.c_str()); 264 argv[0] = v8::String::New(extension_id.c_str());
265 CallFunctionInContext(context, "dispatchOnLoad", arraysize(argv), argv); 265 CallFunctionInContext(context, "dispatchOnLoad", arraysize(argv), argv);
266 } 266 }
267 267
(...skipping 23 matching lines...) Expand all
291 // static 291 // static
292 void EventBindings::CallFunction(const std::string& function_name, 292 void EventBindings::CallFunction(const std::string& function_name,
293 int argc, v8::Handle<v8::Value>* argv, 293 int argc, v8::Handle<v8::Value>* argv,
294 RenderView* render_view) { 294 RenderView* render_view) {
295 for (ContextList::iterator it = GetContexts().begin(); 295 for (ContextList::iterator it = GetContexts().begin();
296 it != GetContexts().end(); ++it) { 296 it != GetContexts().end(); ++it) {
297 if (render_view && render_view != (*it)->render_view) 297 if (render_view && render_view != (*it)->render_view)
298 continue; 298 continue;
299 v8::Handle<v8::Value> retval = CallFunctionInContext((*it)->context, 299 v8::Handle<v8::Value> retval = CallFunctionInContext((*it)->context,
300 function_name, argc, argv); 300 function_name, argc, argv);
301 // In debug, the js will validate the event parameters and return a 301 // In debug, the js will validate the event parameters and return a
302 // string if a validation error has occured. 302 // string if a validation error has occured.
303 // TODO(rafaelw): Consider only doing this check if function_name == 303 // TODO(rafaelw): Consider only doing this check if function_name ==
304 // "Event.dispatchJSON". 304 // "Event.dispatchJSON".
305 #ifdef _DEBUG 305 #ifdef _DEBUG
306 if (!retval.IsEmpty() && !retval->IsUndefined()) { 306 if (!retval.IsEmpty() && !retval->IsUndefined()) {
307 std::string error = *v8::String::AsciiValue(retval); 307 std::string error = *v8::String::AsciiValue(retval);
308 DCHECK(false) << error; 308 DCHECK(false) << error;
309 } 309 }
310 #endif 310 #endif
311 } 311 }
312 } 312 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698