| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. 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 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 719 { | 719 { |
| 720 if (!frame()) | 720 if (!frame()) |
| 721 return WebPerformance(); | 721 return WebPerformance(); |
| 722 return WebPerformance(frame()->domWindow()->performance()); | 722 return WebPerformance(frame()->domWindow()->performance()); |
| 723 } | 723 } |
| 724 | 724 |
| 725 NPObject* WebFrameImpl::windowObject() const | 725 NPObject* WebFrameImpl::windowObject() const |
| 726 { | 726 { |
| 727 if (!frame()) | 727 if (!frame()) |
| 728 return 0; | 728 return 0; |
| 729 return frame()->script()->windowScriptNPObject(); | 729 return frame()->script().windowScriptNPObject(); |
| 730 } | 730 } |
| 731 | 731 |
| 732 void WebFrameImpl::bindToWindowObject(const WebString& name, NPObject* object) | 732 void WebFrameImpl::bindToWindowObject(const WebString& name, NPObject* object) |
| 733 { | 733 { |
| 734 bindToWindowObject(name, object, 0); | 734 bindToWindowObject(name, object, 0); |
| 735 } | 735 } |
| 736 | 736 |
| 737 void WebFrameImpl::bindToWindowObject(const WebString& name, NPObject* object, v
oid*) | 737 void WebFrameImpl::bindToWindowObject(const WebString& name, NPObject* object, v
oid*) |
| 738 { | 738 { |
| 739 if (!frame() || !frame()->script()->canExecuteScripts(NotAboutToExecuteScrip
t)) | 739 if (!frame() || !frame()->script().canExecuteScripts(NotAboutToExecuteScript
)) |
| 740 return; | 740 return; |
| 741 frame()->script()->bindToWindowObject(frame(), String(name), object); | 741 frame()->script().bindToWindowObject(frame(), String(name), object); |
| 742 } | 742 } |
| 743 | 743 |
| 744 void WebFrameImpl::executeScript(const WebScriptSource& source) | 744 void WebFrameImpl::executeScript(const WebScriptSource& source) |
| 745 { | 745 { |
| 746 ASSERT(frame()); | 746 ASSERT(frame()); |
| 747 TextPosition position(OrdinalNumber::fromOneBasedInt(source.startLine), Ordi
nalNumber::first()); | 747 TextPosition position(OrdinalNumber::fromOneBasedInt(source.startLine), Ordi
nalNumber::first()); |
| 748 frame()->script()->executeScriptInMainWorld(ScriptSourceCode(source.code, so
urce.url, position)); | 748 frame()->script().executeScriptInMainWorld(ScriptSourceCode(source.code, sou
rce.url, position)); |
| 749 } | 749 } |
| 750 | 750 |
| 751 void WebFrameImpl::executeScriptInIsolatedWorld(int worldID, const WebScriptSour
ce* sourcesIn, unsigned numSources, int extensionGroup) | 751 void WebFrameImpl::executeScriptInIsolatedWorld(int worldID, const WebScriptSour
ce* sourcesIn, unsigned numSources, int extensionGroup) |
| 752 { | 752 { |
| 753 ASSERT(frame()); | 753 ASSERT(frame()); |
| 754 RELEASE_ASSERT(worldID > 0); | 754 RELEASE_ASSERT(worldID > 0); |
| 755 RELEASE_ASSERT(worldID < EmbedderWorldIdLimit); | 755 RELEASE_ASSERT(worldID < EmbedderWorldIdLimit); |
| 756 | 756 |
| 757 Vector<ScriptSourceCode> sources; | 757 Vector<ScriptSourceCode> sources; |
| 758 for (unsigned i = 0; i < numSources; ++i) { | 758 for (unsigned i = 0; i < numSources; ++i) { |
| 759 TextPosition position(OrdinalNumber::fromOneBasedInt(sourcesIn[i].startL
ine), OrdinalNumber::first()); | 759 TextPosition position(OrdinalNumber::fromOneBasedInt(sourcesIn[i].startL
ine), OrdinalNumber::first()); |
| 760 sources.append(ScriptSourceCode(sourcesIn[i].code, sourcesIn[i].url, pos
ition)); | 760 sources.append(ScriptSourceCode(sourcesIn[i].code, sourcesIn[i].url, pos
ition)); |
| 761 } | 761 } |
| 762 | 762 |
| 763 frame()->script()->executeScriptInIsolatedWorld(worldID, sources, extensionG
roup, 0); | 763 frame()->script().executeScriptInIsolatedWorld(worldID, sources, extensionGr
oup, 0); |
| 764 } | 764 } |
| 765 | 765 |
| 766 void WebFrameImpl::setIsolatedWorldSecurityOrigin(int worldID, const WebSecurity
Origin& securityOrigin) | 766 void WebFrameImpl::setIsolatedWorldSecurityOrigin(int worldID, const WebSecurity
Origin& securityOrigin) |
| 767 { | 767 { |
| 768 ASSERT(frame()); | 768 ASSERT(frame()); |
| 769 DOMWrapperWorld::setIsolatedWorldSecurityOrigin(worldID, securityOrigin.get(
)); | 769 DOMWrapperWorld::setIsolatedWorldSecurityOrigin(worldID, securityOrigin.get(
)); |
| 770 } | 770 } |
| 771 | 771 |
| 772 void WebFrameImpl::setIsolatedWorldContentSecurityPolicy(int worldID, const WebS
tring& policy) | 772 void WebFrameImpl::setIsolatedWorldContentSecurityPolicy(int worldID, const WebS
tring& policy) |
| 773 { | 773 { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 820 { | 820 { |
| 821 ASSERT(frame()); | 821 ASSERT(frame()); |
| 822 | 822 |
| 823 // FIXME: This fake user gesture is required to make a bunch of pyauto | 823 // FIXME: This fake user gesture is required to make a bunch of pyauto |
| 824 // tests pass. If this isn't needed in non-test situations, we should | 824 // tests pass. If this isn't needed in non-test situations, we should |
| 825 // consider removing this code and changing the tests. | 825 // consider removing this code and changing the tests. |
| 826 // http://code.google.com/p/chromium/issues/detail?id=86397 | 826 // http://code.google.com/p/chromium/issues/detail?id=86397 |
| 827 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); | 827 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); |
| 828 | 828 |
| 829 TextPosition position(OrdinalNumber::fromOneBasedInt(source.startLine), Ordi
nalNumber::first()); | 829 TextPosition position(OrdinalNumber::fromOneBasedInt(source.startLine), Ordi
nalNumber::first()); |
| 830 return frame()->script()->executeScriptInMainWorldAndReturnValue(ScriptSourc
eCode(source.code, source.url, position)).v8Value(); | 830 return frame()->script().executeScriptInMainWorldAndReturnValue(ScriptSource
Code(source.code, source.url, position)).v8Value(); |
| 831 } | 831 } |
| 832 | 832 |
| 833 void WebFrameImpl::executeScriptInIsolatedWorld(int worldID, const WebScriptSour
ce* sourcesIn, unsigned numSources, int extensionGroup, WebVector<v8::Local<v8::
Value> >* results) | 833 void WebFrameImpl::executeScriptInIsolatedWorld(int worldID, const WebScriptSour
ce* sourcesIn, unsigned numSources, int extensionGroup, WebVector<v8::Local<v8::
Value> >* results) |
| 834 { | 834 { |
| 835 ASSERT(frame()); | 835 ASSERT(frame()); |
| 836 RELEASE_ASSERT(worldID > 0); | 836 RELEASE_ASSERT(worldID > 0); |
| 837 RELEASE_ASSERT(worldID < EmbedderWorldIdLimit); | 837 RELEASE_ASSERT(worldID < EmbedderWorldIdLimit); |
| 838 | 838 |
| 839 Vector<ScriptSourceCode> sources; | 839 Vector<ScriptSourceCode> sources; |
| 840 | 840 |
| 841 for (unsigned i = 0; i < numSources; ++i) { | 841 for (unsigned i = 0; i < numSources; ++i) { |
| 842 TextPosition position(OrdinalNumber::fromOneBasedInt(sourcesIn[i].startL
ine), OrdinalNumber::first()); | 842 TextPosition position(OrdinalNumber::fromOneBasedInt(sourcesIn[i].startL
ine), OrdinalNumber::first()); |
| 843 sources.append(ScriptSourceCode(sourcesIn[i].code, sourcesIn[i].url, pos
ition)); | 843 sources.append(ScriptSourceCode(sourcesIn[i].code, sourcesIn[i].url, pos
ition)); |
| 844 } | 844 } |
| 845 | 845 |
| 846 if (results) { | 846 if (results) { |
| 847 Vector<ScriptValue> scriptResults; | 847 Vector<ScriptValue> scriptResults; |
| 848 frame()->script()->executeScriptInIsolatedWorld(worldID, sources, extens
ionGroup, &scriptResults); | 848 frame()->script().executeScriptInIsolatedWorld(worldID, sources, extensi
onGroup, &scriptResults); |
| 849 WebVector<v8::Local<v8::Value> > v8Results(scriptResults.size()); | 849 WebVector<v8::Local<v8::Value> > v8Results(scriptResults.size()); |
| 850 for (unsigned i = 0; i < scriptResults.size(); i++) | 850 for (unsigned i = 0; i < scriptResults.size(); i++) |
| 851 v8Results[i] = v8::Local<v8::Value>::New(toIsolate(frame()), scriptR
esults[i].v8Value()); | 851 v8Results[i] = v8::Local<v8::Value>::New(toIsolate(frame()), scriptR
esults[i].v8Value()); |
| 852 results->swap(v8Results); | 852 results->swap(v8Results); |
| 853 } else | 853 } else { |
| 854 frame()->script()->executeScriptInIsolatedWorld(worldID, sources, extens
ionGroup, 0); | 854 frame()->script().executeScriptInIsolatedWorld(worldID, sources, extensi
onGroup, 0); |
| 855 } |
| 855 } | 856 } |
| 856 | 857 |
| 857 v8::Handle<v8::Value> WebFrameImpl::callFunctionEvenIfScriptDisabled(v8::Handle<
v8::Function> function, v8::Handle<v8::Object> receiver, int argc, v8::Handle<v8
::Value> argv[]) | 858 v8::Handle<v8::Value> WebFrameImpl::callFunctionEvenIfScriptDisabled(v8::Handle<
v8::Function> function, v8::Handle<v8::Object> receiver, int argc, v8::Handle<v8
::Value> argv[]) |
| 858 { | 859 { |
| 859 ASSERT(frame()); | 860 ASSERT(frame()); |
| 860 return frame()->script()->callFunction(function, receiver, argc, argv); | 861 return frame()->script().callFunction(function, receiver, argc, argv); |
| 861 } | 862 } |
| 862 | 863 |
| 863 v8::Local<v8::Context> WebFrameImpl::mainWorldScriptContext() const | 864 v8::Local<v8::Context> WebFrameImpl::mainWorldScriptContext() const |
| 864 { | 865 { |
| 865 if (!frame()) | 866 if (!frame()) |
| 866 return v8::Local<v8::Context>(); | 867 return v8::Local<v8::Context>(); |
| 867 return ScriptController::mainWorldContext(frame()); | 868 return ScriptController::mainWorldContext(frame()); |
| 868 } | 869 } |
| 869 | 870 |
| 870 v8::Handle<v8::Value> WebFrameImpl::createFileSystem(WebFileSystemType type, con
st WebString& name, const WebString& path) | 871 v8::Handle<v8::Value> WebFrameImpl::createFileSystem(WebFileSystemType type, con
st WebString& name, const WebString& path) |
| (...skipping 1618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2489 return; | 2490 return; |
| 2490 | 2491 |
| 2491 RefPtr<Document> ownerDocument(frame()->document()); | 2492 RefPtr<Document> ownerDocument(frame()->document()); |
| 2492 | 2493 |
| 2493 // Protect privileged pages against bookmarklets and other javascript manipu
lations. | 2494 // Protect privileged pages against bookmarklets and other javascript manipu
lations. |
| 2494 if (SchemeRegistry::shouldTreatURLSchemeAsNotAllowingJavascriptURLs(frame()-
>document()->url().protocol())) | 2495 if (SchemeRegistry::shouldTreatURLSchemeAsNotAllowingJavascriptURLs(frame()-
>document()->url().protocol())) |
| 2495 return; | 2496 return; |
| 2496 | 2497 |
| 2497 String script = decodeURLEscapeSequences(url.string().substring(strlen("java
script:"))); | 2498 String script = decodeURLEscapeSequences(url.string().substring(strlen("java
script:"))); |
| 2498 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); | 2499 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); |
| 2499 ScriptValue result = frame()->script()->executeScriptInMainWorldAndReturnVal
ue(ScriptSourceCode(script)); | 2500 ScriptValue result = frame()->script().executeScriptInMainWorldAndReturnValu
e(ScriptSourceCode(script)); |
| 2500 | 2501 |
| 2501 String scriptResult; | 2502 String scriptResult; |
| 2502 if (!result.getString(scriptResult)) | 2503 if (!result.getString(scriptResult)) |
| 2503 return; | 2504 return; |
| 2504 | 2505 |
| 2505 if (!frame()->navigationScheduler()->locationChangePending()) | 2506 if (!frame()->navigationScheduler()->locationChangePending()) |
| 2506 frame()->document()->loader()->replaceDocument(scriptResult, ownerDocume
nt.get()); | 2507 frame()->document()->loader()->replaceDocument(scriptResult, ownerDocume
nt.get()); |
| 2507 } | 2508 } |
| 2508 | 2509 |
| 2509 void WebFrameImpl::willDetachPage() | 2510 void WebFrameImpl::willDetachPage() |
| 2510 { | 2511 { |
| 2511 if (!frame() || !frame()->page()) | 2512 if (!frame() || !frame()->page()) |
| 2512 return; | 2513 return; |
| 2513 | 2514 |
| 2514 // Do not expect string scoping results from any frames that got detached | 2515 // Do not expect string scoping results from any frames that got detached |
| 2515 // in the middle of the operation. | 2516 // in the middle of the operation. |
| 2516 if (m_scopingInProgress) { | 2517 if (m_scopingInProgress) { |
| 2517 | 2518 |
| 2518 // There is a possibility that the frame being detached was the only | 2519 // There is a possibility that the frame being detached was the only |
| 2519 // pending one. We need to make sure final replies can be sent. | 2520 // pending one. We need to make sure final replies can be sent. |
| 2520 flushCurrentScopingEffort(m_findRequestIdentifier); | 2521 flushCurrentScopingEffort(m_findRequestIdentifier); |
| 2521 | 2522 |
| 2522 cancelPendingScopingEffort(); | 2523 cancelPendingScopingEffort(); |
| 2523 } | 2524 } |
| 2524 } | 2525 } |
| 2525 | 2526 |
| 2526 } // namespace WebKit | 2527 } // namespace WebKit |
| OLD | NEW |