| OLD | NEW |
| 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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 if (!bindings_registered) | 213 if (!bindings_registered) |
| 214 return; | 214 return; |
| 215 | 215 |
| 216 v8::HandleScope handle_scope; | 216 v8::HandleScope handle_scope; |
| 217 ContextList& contexts = GetContexts(); | 217 ContextList& contexts = GetContexts(); |
| 218 v8::Local<v8::Context> frame_context = frame->mainWorldScriptContext(); | 218 v8::Local<v8::Context> frame_context = frame->mainWorldScriptContext(); |
| 219 v8::Local<v8::Context> context = v8::Context::GetCurrent(); | 219 v8::Local<v8::Context> context = v8::Context::GetCurrent(); |
| 220 DCHECK(!context.IsEmpty()); | 220 DCHECK(!context.IsEmpty()); |
| 221 DCHECK(bindings_utils::FindContext(context) == contexts.end()); | 221 DCHECK(bindings_utils::FindContext(context) == contexts.end()); |
| 222 | 222 |
| 223 // Figure out the URL for the toplevel frame. If the top frame is loading, | 223 // Figure out the frame's URL. If the frame is loading, use its provisional |
| 224 // use its provisional URL, since we get this notification before commit. | 224 // URL, since we get this notification before commit. |
| 225 WebFrame* main_frame = frame->view()->GetMainFrame(); | 225 WebKit::WebDataSource* ds = frame->provisionalDataSource(); |
| 226 WebKit::WebDataSource* ds = main_frame->provisionalDataSource(); | |
| 227 if (!ds) | 226 if (!ds) |
| 228 ds = main_frame->dataSource(); | 227 ds = frame->dataSource(); |
| 229 GURL url = ds->request().url(); | 228 GURL url = ds->request().url(); |
| 230 std::string extension_id; | 229 std::string extension_id; |
| 231 if (url.SchemeIs(chrome::kExtensionScheme)) { | 230 if (url.SchemeIs(chrome::kExtensionScheme)) { |
| 232 extension_id = url.host(); | 231 extension_id = url.host(); |
| 233 } else if (!content_script) { | 232 } else if (!content_script) { |
| 234 // This context is a regular non-extension web page. Ignore it. We only | 233 // This context is a regular non-extension web page. Ignore it. We only |
| 235 // care about content scripts and extension frames. | 234 // care about content scripts and extension frames. |
| 236 // (Unless we're in unit tests, in which case we don't care what the URL | 235 // (Unless we're in unit tests, in which case we don't care what the URL |
| 237 // is). | 236 // is). |
| 238 DCHECK(frame_context == context); | 237 DCHECK(frame_context == context); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 // TODO(rafaelw): Consider only doing this check if function_name == | 303 // TODO(rafaelw): Consider only doing this check if function_name == |
| 305 // "Event.dispatchJSON". | 304 // "Event.dispatchJSON". |
| 306 #ifdef _DEBUG | 305 #ifdef _DEBUG |
| 307 if (!retval.IsEmpty() && !retval->IsUndefined()) { | 306 if (!retval.IsEmpty() && !retval->IsUndefined()) { |
| 308 std::string error = *v8::String::AsciiValue(retval); | 307 std::string error = *v8::String::AsciiValue(retval); |
| 309 DCHECK(false) << error; | 308 DCHECK(false) << error; |
| 310 } | 309 } |
| 311 #endif | 310 #endif |
| 312 } | 311 } |
| 313 } | 312 } |
| OLD | NEW |