| OLD | NEW |
| 1 // Copyright (c) 2008, Google Inc. | 1 // Copyright (c) 2008, Google Inc. |
| 2 // All rights reserved. | 2 // All rights reserved. |
| 3 // | 3 // |
| 4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
| 5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
| 6 // met: | 6 // met: |
| 7 // | 7 // |
| 8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
| 9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
| 10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 | 37 |
| 38 #include "v8_proxy.h" | 38 #include "v8_proxy.h" |
| 39 #include "v8_index.h" | 39 #include "v8_index.h" |
| 40 #include "v8_binding.h" | 40 #include "v8_binding.h" |
| 41 #include "v8_custom.h" | 41 #include "v8_custom.h" |
| 42 #include "V8Collection.h" | 42 #include "V8Collection.h" |
| 43 #include "V8DOMWindow.h" | 43 #include "V8DOMWindow.h" |
| 44 | 44 |
| 45 #include "ChromiumBridge.h" | 45 #include "ChromiumBridge.h" |
| 46 #include "DOMObjectsInclude.h" | 46 #include "DOMObjectsInclude.h" |
| 47 | 47 #include "DocumentLoader.h" |
| 48 #include "ScriptController.h" | 48 #include "ScriptController.h" |
| 49 #include "V8DOMMap.h" | 49 #include "V8DOMMap.h" |
| 50 | 50 |
| 51 namespace WebCore { | 51 namespace WebCore { |
| 52 | 52 |
| 53 // Static utility context. | 53 // Static utility context. |
| 54 v8::Persistent<v8::Context> V8Proxy::m_utilityContext; | 54 v8::Persistent<v8::Context> V8Proxy::m_utilityContext; |
| 55 | 55 |
| 56 // Static list of registered extensions | 56 // Static list of registered extensions |
| 57 V8ExtensionList V8Proxy::m_extensions; | 57 V8ExtensionList V8Proxy::m_extensions; |
| (...skipping 1897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1955 V8Custom::v8DOMWindowNamedSecurityCheck, | 1955 V8Custom::v8DOMWindowNamedSecurityCheck, |
| 1956 V8Custom::v8DOMWindowIndexedSecurityCheck, | 1956 V8Custom::v8DOMWindowIndexedSecurityCheck, |
| 1957 v8::Integer::New(V8ClassIndex::DOMWINDOW)); | 1957 v8::Integer::New(V8ClassIndex::DOMWINDOW)); |
| 1958 | 1958 |
| 1959 // Dynamically tell v8 about our extensions now. | 1959 // Dynamically tell v8 about our extensions now. |
| 1960 const char** extensionNames = new const char*[m_extensions.size()]; | 1960 const char** extensionNames = new const char*[m_extensions.size()]; |
| 1961 int index = 0; | 1961 int index = 0; |
| 1962 for (V8ExtensionList::iterator it = m_extensions.begin(); | 1962 for (V8ExtensionList::iterator it = m_extensions.begin(); |
| 1963 it != m_extensions.end(); ++it) { | 1963 it != m_extensions.end(); ++it) { |
| 1964 if (it->scheme.length() > 0 && | 1964 if (it->scheme.length() > 0 && |
| 1965 it->scheme != m_frame->document()->url().protocol()) | 1965 it->scheme != m_frame->loader()->activeDocumentLoader()->url().proto
col()) |
| 1966 continue; | 1966 continue; |
| 1967 | 1967 |
| 1968 extensionNames[index++] = it->extension->name(); | 1968 extensionNames[index++] = it->extension->name(); |
| 1969 } | 1969 } |
| 1970 v8::ExtensionConfiguration extensions(index, extensionNames); | 1970 v8::ExtensionConfiguration extensions(index, extensionNames); |
| 1971 result = v8::Context::New(&extensions, globalTemplate, global); | 1971 result = v8::Context::New(&extensions, globalTemplate, global); |
| 1972 delete [] extensionNames; | 1972 delete [] extensionNames; |
| 1973 extensionNames = 0; | 1973 extensionNames = 0; |
| 1974 | 1974 |
| 1975 return result; | 1975 return result; |
| (...skipping 1182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3158 v8::Handle<v8::Value> V8Proxy::WindowToV8Object(DOMWindow* window) | 3158 v8::Handle<v8::Value> V8Proxy::WindowToV8Object(DOMWindow* window) |
| 3159 { | 3159 { |
| 3160 if (!window) return v8::Null(); | 3160 if (!window) return v8::Null(); |
| 3161 // Initializes environment of a frame, and return the global object | 3161 // Initializes environment of a frame, and return the global object |
| 3162 // of the frame. | 3162 // of the frame. |
| 3163 Frame* frame = window->frame(); | 3163 Frame* frame = window->frame(); |
| 3164 if (!frame) | 3164 if (!frame) |
| 3165 return v8::Handle<v8::Object>(); | 3165 return v8::Handle<v8::Object>(); |
| 3166 | 3166 |
| 3167 // Special case: Because of evaluateInNewContext() one DOMWindow can have | 3167 // Special case: Because of evaluateInNewContext() one DOMWindow can have |
| 3168 // multipe contexts and multiple global objects associated with it. When | 3168 // multiple contexts and multiple global objects associated with it. When |
| 3169 // code running in one of those contexts accesses the window object, we | 3169 // code running in one of those contexts accesses the window object, we |
| 3170 // want to return the global object associated with that context, not | 3170 // want to return the global object associated with that context, not |
| 3171 // necessarily the first global object associated with that DOMWindow. | 3171 // necessarily the first global object associated with that DOMWindow. |
| 3172 v8::Handle<v8::Context> current_context = v8::Context::GetCurrent(); | 3172 v8::Handle<v8::Context> current_context = v8::Context::GetCurrent(); |
| 3173 v8::Handle<v8::Object> current_global = current_context->Global(); | 3173 v8::Handle<v8::Object> current_global = current_context->Global(); |
| 3174 v8::Handle<v8::Object> windowWrapper = | 3174 v8::Handle<v8::Object> windowWrapper = |
| 3175 LookupDOMWrapper(V8ClassIndex::DOMWINDOW, current_global); | 3175 LookupDOMWrapper(V8ClassIndex::DOMWINDOW, current_global); |
| 3176 if (!windowWrapper.IsEmpty()) | 3176 if (!windowWrapper.IsEmpty()) |
| 3177 if (DOMWrapperToNative<DOMWindow>(windowWrapper) == window) | 3177 if (DOMWrapperToNative<DOMWindow>(windowWrapper) == window) |
| 3178 return current_global; | 3178 return current_global; |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3283 } | 3283 } |
| 3284 | 3284 |
| 3285 void V8Proxy::RegisterExtension(v8::Extension* extension, | 3285 void V8Proxy::RegisterExtension(v8::Extension* extension, |
| 3286 const String& schemeRestriction) { | 3286 const String& schemeRestriction) { |
| 3287 v8::RegisterExtension(extension); | 3287 v8::RegisterExtension(extension); |
| 3288 V8ExtensionInfo info = {schemeRestriction, extension}; | 3288 V8ExtensionInfo info = {schemeRestriction, extension}; |
| 3289 m_extensions.push_back(info); | 3289 m_extensions.push_back(info); |
| 3290 } | 3290 } |
| 3291 | 3291 |
| 3292 } // namespace WebCore | 3292 } // namespace WebCore |
| OLD | NEW |