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

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

Issue 200116: Fix bug where content scripts can get GC'd if they don't attach (Closed)
Patch Set: remove extra braces Created 11 years, 3 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 (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/bindings_utils.h" 5 #include "chrome/renderer/extensions/bindings_utils.h"
6 6
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "chrome/renderer/render_view.h" 8 #include "chrome/renderer/render_view.h"
9 #include "webkit/api/public/WebFrame.h" 9 #include "webkit/api/public/WebFrame.h"
10 10
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 64
65 for (ContextList::iterator it = all_contexts.begin(); 65 for (ContextList::iterator it = all_contexts.begin();
66 it != all_contexts.end(); ++it) { 66 it != all_contexts.end(); ++it) {
67 if ((*it)->extension_id == extension_id) 67 if ((*it)->extension_id == extension_id)
68 contexts.push_back(*it); 68 contexts.push_back(*it);
69 } 69 }
70 70
71 return contexts; 71 return contexts;
72 } 72 }
73 73
74 ContextInfo* GetInfoForCurrentContext() {
75 v8::Local<v8::Context> context = v8::Context::GetCurrent();
76 ContextList::iterator context_iter = FindContext(context);
77 if (context_iter == GetContexts().end())
78 return NULL;
79 else
80 return context_iter->get();
81 }
82
74 ContextList::iterator FindContext(v8::Handle<v8::Context> context) { 83 ContextList::iterator FindContext(v8::Handle<v8::Context> context) {
75 ContextList& all_contexts = GetContexts(); 84 ContextList& all_contexts = GetContexts();
76 85
77 ContextList::iterator it = all_contexts.begin(); 86 ContextList::iterator it = all_contexts.begin();
78 for (; it != all_contexts.end(); ++it) { 87 for (; it != all_contexts.end(); ++it) {
79 if ((*it)->context == context) 88 if ((*it)->context == context)
80 break; 89 break;
81 } 90 }
82 91
83 return it; 92 return it;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 } 132 }
124 133
125 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(value); 134 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(value);
126 if (!function.IsEmpty()) 135 if (!function.IsEmpty())
127 return function->Call(v8::Object::New(), argc, argv); 136 return function->Call(v8::Object::New(), argc, argv);
128 137
129 return v8::Undefined(); 138 return v8::Undefined();
130 } 139 }
131 140
132 } // namespace bindings_utils 141 } // namespace bindings_utils
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698