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/extensions/extension_messages.h" | 9 #include "chrome/common/extensions/extension_messages.h" |
10 #include "chrome/common/extensions/extension_set.h" | 10 #include "chrome/common/extensions/extension_set.h" |
11 #include "chrome/common/url_constants.h" | 11 #include "chrome/common/url_constants.h" |
12 #include "chrome/renderer/extensions/bindings_utils.h" | 12 #include "chrome/renderer/extensions/bindings_utils.h" |
13 #include "chrome/renderer/extensions/event_bindings.h" | 13 #include "chrome/renderer/extensions/event_bindings.h" |
| 14 #include "chrome/renderer/extensions/extension_dispatcher.h" |
14 #include "chrome/renderer/extensions/extension_process_bindings.h" | 15 #include "chrome/renderer/extensions/extension_process_bindings.h" |
15 #include "chrome/renderer/extensions/js_only_v8_extensions.h" | 16 #include "chrome/renderer/extensions/js_only_v8_extensions.h" |
16 #include "chrome/renderer/render_thread.h" | 17 #include "chrome/renderer/render_thread.h" |
17 #include "content/renderer/render_view.h" | 18 #include "content/renderer/render_view.h" |
18 #include "googleurl/src/gurl.h" | 19 #include "googleurl/src/gurl.h" |
19 #include "grit/renderer_resources.h" | 20 #include "grit/renderer_resources.h" |
20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" | 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" |
21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" | 23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" |
23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h" | 24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h" |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 v8::Local<v8::Context> context = v8::Context::GetCurrent(); | 259 v8::Local<v8::Context> context = v8::Context::GetCurrent(); |
259 DCHECK(!context.IsEmpty()); | 260 DCHECK(!context.IsEmpty()); |
260 DCHECK(bindings_utils::FindContext(context) == contexts.end()); | 261 DCHECK(bindings_utils::FindContext(context) == contexts.end()); |
261 | 262 |
262 // Figure out the frame's URL. If the frame is loading, use its provisional | 263 // Figure out the frame's URL. If the frame is loading, use its provisional |
263 // URL, since we get this notification before commit. | 264 // URL, since we get this notification before commit. |
264 WebDataSource* ds = frame->provisionalDataSource(); | 265 WebDataSource* ds = frame->provisionalDataSource(); |
265 if (!ds) | 266 if (!ds) |
266 ds = frame->dataSource(); | 267 ds = frame->dataSource(); |
267 GURL url = ds->request().url(); | 268 GURL url = ds->request().url(); |
268 const ExtensionSet* extensions = GetRenderThread()->GetExtensions(); | 269 const ExtensionSet* extensions = ExtensionDispatcher::Get()->extensions(); |
269 std::string extension_id = extensions->GetIdByURL(url); | 270 std::string extension_id = extensions->GetIdByURL(url); |
270 | 271 |
271 if (!extensions->ExtensionBindingsAllowed(url) && | 272 if (!extensions->ExtensionBindingsAllowed(url) && |
272 !content_script) { | 273 !content_script) { |
273 // This context is a regular non-extension web page or an unprivileged | 274 // This context is a regular non-extension web page or an unprivileged |
274 // chrome app. Ignore it. We only care about content scripts and extension | 275 // chrome app. Ignore it. We only care about content scripts and extension |
275 // frames. | 276 // frames. |
276 // (Unless we're in unit tests, in which case we don't care what the URL | 277 // (Unless we're in unit tests, in which case we don't care what the URL |
277 // is). | 278 // is). |
278 DCHECK(frame_context.IsEmpty() || frame_context == context); | 279 DCHECK(frame_context.IsEmpty() || frame_context == context); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 // TODO(rafaelw): Consider only doing this check if function_name == | 373 // TODO(rafaelw): Consider only doing this check if function_name == |
373 // "Event.dispatchJSON". | 374 // "Event.dispatchJSON". |
374 #ifndef NDEBUG | 375 #ifndef NDEBUG |
375 if (!retval.IsEmpty() && !retval->IsUndefined()) { | 376 if (!retval.IsEmpty() && !retval->IsUndefined()) { |
376 std::string error = *v8::String::AsciiValue(retval); | 377 std::string error = *v8::String::AsciiValue(retval); |
377 DCHECK(false) << error; | 378 DCHECK(false) << error; |
378 } | 379 } |
379 #endif | 380 #endif |
380 } | 381 } |
381 } | 382 } |
OLD | NEW |