OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/lazy_instance.h" | 8 #include "base/lazy_instance.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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
258 v8::Local<v8::Context> context = v8::Context::GetCurrent(); | 258 v8::Local<v8::Context> context = v8::Context::GetCurrent(); |
259 DCHECK(!context.IsEmpty()); | 259 DCHECK(!context.IsEmpty()); |
260 DCHECK(bindings_utils::FindContext(context) == contexts.end()); | 260 DCHECK(bindings_utils::FindContext(context) == contexts.end()); |
261 | 261 |
262 // Figure out the frame's URL. If the frame is loading, use its provisional | 262 // Figure out the frame's URL. If the frame is loading, use its provisional |
263 // URL, since we get this notification before commit. | 263 // URL, since we get this notification before commit. |
264 WebDataSource* ds = frame->provisionalDataSource(); | 264 WebDataSource* ds = frame->provisionalDataSource(); |
265 if (!ds) | 265 if (!ds) |
266 ds = frame->dataSource(); | 266 ds = frame->dataSource(); |
267 GURL url = ds->request().url(); | 267 GURL url = ds->request().url(); |
268 std::string extension_id = ExtensionRendererInfo::GetIdByURL(url); | 268 ExtensionRendererInfo* extensions = RenderThread::current()->extensions(); |
Matt Perry
2011/01/24 20:08:34
use the render_thread global instead, since Render
Aaron Boodman
2011/01/25 00:27:33
Done.
| |
269 std::string extension_id = extensions->GetIdByURL(url); | |
269 | 270 |
270 if (!ExtensionRendererInfo::ExtensionBindingsAllowed(url) && | 271 if (!extensions->ExtensionBindingsAllowed(url) && |
271 !content_script) { | 272 !content_script) { |
272 // This context is a regular non-extension web page or an unprivileged | 273 // This context is a regular non-extension web page or an unprivileged |
273 // chrome app. Ignore it. We only care about content scripts and extension | 274 // chrome app. Ignore it. We only care about content scripts and extension |
274 // frames. | 275 // frames. |
275 // (Unless we're in unit tests, in which case we don't care what the URL | 276 // (Unless we're in unit tests, in which case we don't care what the URL |
276 // is). | 277 // is). |
277 DCHECK(frame_context.IsEmpty() || frame_context == context); | 278 DCHECK(frame_context.IsEmpty() || frame_context == context); |
278 if (!in_unit_tests) | 279 if (!in_unit_tests) |
279 return; | 280 return; |
280 | 281 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
371 // TODO(rafaelw): Consider only doing this check if function_name == | 372 // TODO(rafaelw): Consider only doing this check if function_name == |
372 // "Event.dispatchJSON". | 373 // "Event.dispatchJSON". |
373 #ifndef NDEBUG | 374 #ifndef NDEBUG |
374 if (!retval.IsEmpty() && !retval->IsUndefined()) { | 375 if (!retval.IsEmpty() && !retval->IsUndefined()) { |
375 std::string error = *v8::String::AsciiValue(retval); | 376 std::string error = *v8::String::AsciiValue(retval); |
376 DCHECK(false) << error; | 377 DCHECK(false) << error; |
377 } | 378 } |
378 #endif | 379 #endif |
379 } | 380 } |
380 } | 381 } |
OLD | NEW |