| 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 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 718 { | 718 { |
| 719 if (!frame() || !frame()->script().canExecuteScripts(NotAboutToExecuteScript
)) | 719 if (!frame() || !frame()->script().canExecuteScripts(NotAboutToExecuteScript
)) |
| 720 return; | 720 return; |
| 721 frame()->script().bindToWindowObject(frame(), String(name), object); | 721 frame()->script().bindToWindowObject(frame(), String(name), object); |
| 722 } | 722 } |
| 723 | 723 |
| 724 void WebLocalFrameImpl::executeScript(const WebScriptSource& source) | 724 void WebLocalFrameImpl::executeScript(const WebScriptSource& source) |
| 725 { | 725 { |
| 726 ASSERT(frame()); | 726 ASSERT(frame()); |
| 727 TextPosition position(OrdinalNumber::fromOneBasedInt(source.startLine), Ordi
nalNumber::first()); | 727 TextPosition position(OrdinalNumber::fromOneBasedInt(source.startLine), Ordi
nalNumber::first()); |
| 728 v8::HandleScope handleScope(toIsolate(frame())); | |
| 729 frame()->script().executeScriptInMainWorld(ScriptSourceCode(source.code, sou
rce.url, position)); | 728 frame()->script().executeScriptInMainWorld(ScriptSourceCode(source.code, sou
rce.url, position)); |
| 730 } | 729 } |
| 731 | 730 |
| 732 void WebLocalFrameImpl::executeScriptInIsolatedWorld(int worldID, const WebScrip
tSource* sourcesIn, unsigned numSources, int extensionGroup) | 731 void WebLocalFrameImpl::executeScriptInIsolatedWorld(int worldID, const WebScrip
tSource* sourcesIn, unsigned numSources, int extensionGroup) |
| 733 { | 732 { |
| 734 ASSERT(frame()); | 733 ASSERT(frame()); |
| 735 RELEASE_ASSERT(worldID > 0); | 734 RELEASE_ASSERT(worldID > 0); |
| 736 RELEASE_ASSERT(worldID < EmbedderWorldIdLimit); | 735 RELEASE_ASSERT(worldID < EmbedderWorldIdLimit); |
| 737 | 736 |
| 738 Vector<ScriptSourceCode> sources; | 737 Vector<ScriptSourceCode> sources; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 801 { | 800 { |
| 802 ASSERT(frame()); | 801 ASSERT(frame()); |
| 803 | 802 |
| 804 // FIXME: This fake user gesture is required to make a bunch of pyauto | 803 // FIXME: This fake user gesture is required to make a bunch of pyauto |
| 805 // tests pass. If this isn't needed in non-test situations, we should | 804 // tests pass. If this isn't needed in non-test situations, we should |
| 806 // consider removing this code and changing the tests. | 805 // consider removing this code and changing the tests. |
| 807 // http://code.google.com/p/chromium/issues/detail?id=86397 | 806 // http://code.google.com/p/chromium/issues/detail?id=86397 |
| 808 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); | 807 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); |
| 809 | 808 |
| 810 TextPosition position(OrdinalNumber::fromOneBasedInt(source.startLine), Ordi
nalNumber::first()); | 809 TextPosition position(OrdinalNumber::fromOneBasedInt(source.startLine), Ordi
nalNumber::first()); |
| 811 return frame()->script().executeScriptInMainWorldAndReturnValue(ScriptSource
Code(source.code, source.url, position)); | 810 return frame()->script().executeScriptInMainWorldAndReturnValue(ScriptSource
Code(source.code, source.url, position)).v8Value(); |
| 812 } | 811 } |
| 813 | 812 |
| 814 void WebLocalFrameImpl::executeScriptInIsolatedWorld(int worldID, const WebScrip
tSource* sourcesIn, unsigned numSources, int extensionGroup, WebVector<v8::Local
<v8::Value> >* results) | 813 void WebLocalFrameImpl::executeScriptInIsolatedWorld(int worldID, const WebScrip
tSource* sourcesIn, unsigned numSources, int extensionGroup, WebVector<v8::Local
<v8::Value> >* results) |
| 815 { | 814 { |
| 816 ASSERT(frame()); | 815 ASSERT(frame()); |
| 817 RELEASE_ASSERT(worldID > 0); | 816 RELEASE_ASSERT(worldID > 0); |
| 818 RELEASE_ASSERT(worldID < EmbedderWorldIdLimit); | 817 RELEASE_ASSERT(worldID < EmbedderWorldIdLimit); |
| 819 | 818 |
| 820 Vector<ScriptSourceCode> sources; | 819 Vector<ScriptSourceCode> sources; |
| 821 | 820 |
| 822 for (unsigned i = 0; i < numSources; ++i) { | 821 for (unsigned i = 0; i < numSources; ++i) { |
| 823 TextPosition position(OrdinalNumber::fromOneBasedInt(sourcesIn[i].startL
ine), OrdinalNumber::first()); | 822 TextPosition position(OrdinalNumber::fromOneBasedInt(sourcesIn[i].startL
ine), OrdinalNumber::first()); |
| 824 sources.append(ScriptSourceCode(sourcesIn[i].code, sourcesIn[i].url, pos
ition)); | 823 sources.append(ScriptSourceCode(sourcesIn[i].code, sourcesIn[i].url, pos
ition)); |
| 825 } | 824 } |
| 826 | 825 |
| 827 if (results) { | 826 if (results) { |
| 828 Vector<v8::Local<v8::Value> > scriptResults; | 827 Vector<ScriptValue> scriptResults; |
| 829 frame()->script().executeScriptInIsolatedWorld(worldID, sources, extensi
onGroup, &scriptResults); | 828 frame()->script().executeScriptInIsolatedWorld(worldID, sources, extensi
onGroup, &scriptResults); |
| 830 WebVector<v8::Local<v8::Value> > v8Results(scriptResults.size()); | 829 WebVector<v8::Local<v8::Value> > v8Results(scriptResults.size()); |
| 831 for (unsigned i = 0; i < scriptResults.size(); i++) | 830 for (unsigned i = 0; i < scriptResults.size(); i++) |
| 832 v8Results[i] = v8::Local<v8::Value>::New(toIsolate(frame()), scriptR
esults[i]); | 831 v8Results[i] = v8::Local<v8::Value>::New(toIsolate(frame()), scriptR
esults[i].v8Value()); |
| 833 results->swap(v8Results); | 832 results->swap(v8Results); |
| 834 } else { | 833 } else { |
| 835 frame()->script().executeScriptInIsolatedWorld(worldID, sources, extensi
onGroup, 0); | 834 frame()->script().executeScriptInIsolatedWorld(worldID, sources, extensi
onGroup, 0); |
| 836 } | 835 } |
| 837 } | 836 } |
| 838 | 837 |
| 839 v8::Handle<v8::Value> WebLocalFrameImpl::callFunctionEvenIfScriptDisabled(v8::Ha
ndle<v8::Function> function, v8::Handle<v8::Value> receiver, int argc, v8::Handl
e<v8::Value> argv[]) | 838 v8::Handle<v8::Value> WebLocalFrameImpl::callFunctionEvenIfScriptDisabled(v8::Ha
ndle<v8::Function> function, v8::Handle<v8::Value> receiver, int argc, v8::Handl
e<v8::Value> argv[]) |
| 840 { | 839 { |
| 841 ASSERT(frame()); | 840 ASSERT(frame()); |
| 842 return frame()->script().callFunction(function, receiver, argc, argv); | 841 return frame()->script().callFunction(function, receiver, argc, argv); |
| (...skipping 1011 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1854 return; | 1853 return; |
| 1855 | 1854 |
| 1856 RefPtrWillBeRawPtr<Document> ownerDocument(frame()->document()); | 1855 RefPtrWillBeRawPtr<Document> ownerDocument(frame()->document()); |
| 1857 | 1856 |
| 1858 // Protect privileged pages against bookmarklets and other javascript manipu
lations. | 1857 // Protect privileged pages against bookmarklets and other javascript manipu
lations. |
| 1859 if (SchemeRegistry::shouldTreatURLSchemeAsNotAllowingJavascriptURLs(frame()-
>document()->url().protocol())) | 1858 if (SchemeRegistry::shouldTreatURLSchemeAsNotAllowingJavascriptURLs(frame()-
>document()->url().protocol())) |
| 1860 return; | 1859 return; |
| 1861 | 1860 |
| 1862 String script = decodeURLEscapeSequences(url.string().substring(strlen("java
script:"))); | 1861 String script = decodeURLEscapeSequences(url.string().substring(strlen("java
script:"))); |
| 1863 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); | 1862 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); |
| 1864 v8::HandleScope handleScope(toIsolate(frame())); | 1863 ScriptValue result = frame()->script().executeScriptInMainWorldAndReturnValu
e(ScriptSourceCode(script)); |
| 1865 v8::Local<v8::Value> result = frame()->script().executeScriptInMainWorldAndR
eturnValue(ScriptSourceCode(script)); | 1864 |
| 1866 if (result.IsEmpty() || !result->IsString()) | 1865 String scriptResult; |
| 1866 if (!result.toString(scriptResult)) |
| 1867 return; | 1867 return; |
| 1868 String scriptResult = toCoreString(v8::Handle<v8::String>::Cast(result)); | 1868 |
| 1869 if (!frame()->navigationScheduler().locationChangePending()) | 1869 if (!frame()->navigationScheduler().locationChangePending()) |
| 1870 frame()->document()->loader()->replaceDocument(scriptResult, ownerDocume
nt.get()); | 1870 frame()->document()->loader()->replaceDocument(scriptResult, ownerDocume
nt.get()); |
| 1871 } | 1871 } |
| 1872 | 1872 |
| 1873 void WebLocalFrameImpl::willDetachParent() | 1873 void WebLocalFrameImpl::willDetachParent() |
| 1874 { | 1874 { |
| 1875 // Do not expect string scoping results from any frames that got detached | 1875 // Do not expect string scoping results from any frames that got detached |
| 1876 // in the middle of the operation. | 1876 // in the middle of the operation. |
| 1877 if (m_textFinder && m_textFinder->scopingInProgress()) { | 1877 if (m_textFinder && m_textFinder->scopingInProgress()) { |
| 1878 | 1878 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1920 | 1920 |
| 1921 void WebLocalFrameImpl::invalidateAll() const | 1921 void WebLocalFrameImpl::invalidateAll() const |
| 1922 { | 1922 { |
| 1923 ASSERT(frame() && frame()->view()); | 1923 ASSERT(frame() && frame()->view()); |
| 1924 FrameView* view = frame()->view(); | 1924 FrameView* view = frame()->view(); |
| 1925 view->invalidateRect(view->frameRect()); | 1925 view->invalidateRect(view->frameRect()); |
| 1926 invalidateScrollbar(); | 1926 invalidateScrollbar(); |
| 1927 } | 1927 } |
| 1928 | 1928 |
| 1929 } // namespace blink | 1929 } // namespace blink |
| OLD | NEW |