| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "web/SuspendableScriptExecutor.h" | 5 #include "web/SuspendableScriptExecutor.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ScriptController.h" | 7 #include "bindings/core/v8/ScriptController.h" |
| 8 #include "bindings/core/v8/ScriptSourceCode.h" | 8 #include "bindings/core/v8/ScriptSourceCode.h" |
| 9 #include "bindings/core/v8/V8PersistentValueVector.h" | 9 #include "bindings/core/v8/V8PersistentValueVector.h" |
| 10 #include "bindings/core/v8/WindowProxy.h" | 10 #include "bindings/core/v8/WindowProxy.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 int extensionGroup, | 49 int extensionGroup, |
| 50 bool userGesture) | 50 bool userGesture) |
| 51 : m_sources(sources), | 51 : m_sources(sources), |
| 52 m_worldID(worldID), | 52 m_worldID(worldID), |
| 53 m_extensionGroup(extensionGroup), | 53 m_extensionGroup(extensionGroup), |
| 54 m_userGesture(userGesture) {} | 54 m_userGesture(userGesture) {} |
| 55 | 55 |
| 56 Vector<v8::Local<v8::Value>> WebScriptExecutor::execute(LocalFrame* frame) { | 56 Vector<v8::Local<v8::Value>> WebScriptExecutor::execute(LocalFrame* frame) { |
| 57 std::unique_ptr<UserGestureIndicator> indicator; | 57 std::unique_ptr<UserGestureIndicator> indicator; |
| 58 if (m_userGesture) { | 58 if (m_userGesture) { |
| 59 indicator = | 59 indicator = WTF::wrapUnique( |
| 60 wrapUnique(new UserGestureIndicator(DocumentUserGestureToken::create( | 60 new UserGestureIndicator(DocumentUserGestureToken::create( |
| 61 frame->document(), UserGestureToken::NewGesture))); | 61 frame->document(), UserGestureToken::NewGesture))); |
| 62 } | 62 } |
| 63 | 63 |
| 64 Vector<v8::Local<v8::Value>> results; | 64 Vector<v8::Local<v8::Value>> results; |
| 65 if (m_worldID) { | 65 if (m_worldID) { |
| 66 frame->script().executeScriptInIsolatedWorld(m_worldID, m_sources, | 66 frame->script().executeScriptInIsolatedWorld(m_worldID, m_sources, |
| 67 m_extensionGroup, &results); | 67 m_extensionGroup, &results); |
| 68 } else { | 68 } else { |
| 69 v8::Local<v8::Value> scriptValue = | 69 v8::Local<v8::Value> scriptValue = |
| 70 frame->script().executeScriptInMainWorldAndReturnValue( | 70 frame->script().executeScriptInMainWorldAndReturnValue( |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 Vector<v8::Local<v8::Value>> results; | 111 Vector<v8::Local<v8::Value>> results; |
| 112 v8::Local<v8::Value> singleResult; | 112 v8::Local<v8::Value> singleResult; |
| 113 Vector<v8::Local<v8::Value>> args; | 113 Vector<v8::Local<v8::Value>> args; |
| 114 args.reserveCapacity(m_args.Size()); | 114 args.reserveCapacity(m_args.Size()); |
| 115 for (size_t i = 0; i < m_args.Size(); ++i) | 115 for (size_t i = 0; i < m_args.Size(); ++i) |
| 116 args.append(m_args.Get(i)); | 116 args.append(m_args.Get(i)); |
| 117 { | 117 { |
| 118 std::unique_ptr<UserGestureIndicator> gestureIndicator; | 118 std::unique_ptr<UserGestureIndicator> gestureIndicator; |
| 119 if (m_gestureToken) { | 119 if (m_gestureToken) { |
| 120 gestureIndicator = | 120 gestureIndicator = |
| 121 wrapUnique(new UserGestureIndicator(m_gestureToken.release())); | 121 WTF::wrapUnique(new UserGestureIndicator(m_gestureToken.release())); |
| 122 } | 122 } |
| 123 if (V8ScriptRunner::callFunction(m_function.newLocal(isolate), | 123 if (V8ScriptRunner::callFunction(m_function.newLocal(isolate), |
| 124 frame->document(), | 124 frame->document(), |
| 125 m_receiver.newLocal(isolate), args.size(), | 125 m_receiver.newLocal(isolate), args.size(), |
| 126 args.data(), toIsolate(frame)) | 126 args.data(), toIsolate(frame)) |
| 127 .ToLocal(&singleResult)) | 127 .ToLocal(&singleResult)) |
| 128 results.append(singleResult); | 128 results.append(singleResult); |
| 129 } | 129 } |
| 130 return results; | 130 return results; |
| 131 } | 131 } |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 m_keepAlive.clear(); | 231 m_keepAlive.clear(); |
| 232 stop(); | 232 stop(); |
| 233 } | 233 } |
| 234 | 234 |
| 235 DEFINE_TRACE(SuspendableScriptExecutor) { | 235 DEFINE_TRACE(SuspendableScriptExecutor) { |
| 236 visitor->trace(m_executor); | 236 visitor->trace(m_executor); |
| 237 SuspendableTimer::trace(visitor); | 237 SuspendableTimer::trace(visitor); |
| 238 } | 238 } |
| 239 | 239 |
| 240 } // namespace blink | 240 } // namespace blink |
| OLD | NEW |