| 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 "core/dom/Document.h" | 10 #include "core/dom/Document.h" |
| 11 #include "core/dom/DocumentUserGestureToken.h" |
| 11 #include "core/frame/LocalFrame.h" | 12 #include "core/frame/LocalFrame.h" |
| 12 #include "platform/UserGestureIndicator.h" | 13 #include "platform/UserGestureIndicator.h" |
| 13 #include "public/platform/WebVector.h" | 14 #include "public/platform/WebVector.h" |
| 14 #include "public/web/WebScriptExecutionCallback.h" | 15 #include "public/web/WebScriptExecutionCallback.h" |
| 15 #include "wtf/PtrUtil.h" | 16 #include "wtf/PtrUtil.h" |
| 16 #include "wtf/Vector.h" | 17 #include "wtf/Vector.h" |
| 17 #include <memory> | 18 #include <memory> |
| 18 | 19 |
| 19 namespace blink { | 20 namespace blink { |
| 20 | 21 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 47 int extensionGroup, | 48 int extensionGroup, |
| 48 bool userGesture) | 49 bool userGesture) |
| 49 : m_sources(sources), | 50 : m_sources(sources), |
| 50 m_worldID(worldID), | 51 m_worldID(worldID), |
| 51 m_extensionGroup(extensionGroup), | 52 m_extensionGroup(extensionGroup), |
| 52 m_userGesture(userGesture) {} | 53 m_userGesture(userGesture) {} |
| 53 | 54 |
| 54 Vector<v8::Local<v8::Value>> WebScriptExecutor::execute(LocalFrame* frame) { | 55 Vector<v8::Local<v8::Value>> WebScriptExecutor::execute(LocalFrame* frame) { |
| 55 std::unique_ptr<UserGestureIndicator> indicator; | 56 std::unique_ptr<UserGestureIndicator> indicator; |
| 56 if (m_userGesture) { | 57 if (m_userGesture) { |
| 57 indicator = wrapUnique(new UserGestureIndicator( | 58 indicator = |
| 58 UserGestureToken::create(UserGestureToken::NewGesture))); | 59 wrapUnique(new UserGestureIndicator(DocumentUserGestureToken::create( |
| 60 frame->document(), UserGestureToken::NewGesture))); |
| 59 } | 61 } |
| 60 | 62 |
| 61 Vector<v8::Local<v8::Value>> results; | 63 Vector<v8::Local<v8::Value>> results; |
| 62 if (m_worldID) { | 64 if (m_worldID) { |
| 63 frame->script().executeScriptInIsolatedWorld(m_worldID, m_sources, | 65 frame->script().executeScriptInIsolatedWorld(m_worldID, m_sources, |
| 64 m_extensionGroup, &results); | 66 m_extensionGroup, &results); |
| 65 } else { | 67 } else { |
| 66 v8::Local<v8::Value> scriptValue = | 68 v8::Local<v8::Value> scriptValue = |
| 67 frame->script().executeScriptInMainWorldAndReturnValue( | 69 frame->script().executeScriptInMainWorldAndReturnValue( |
| 68 m_sources.first()); | 70 m_sources.first()); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 stop(); | 205 stop(); |
| 204 } | 206 } |
| 205 | 207 |
| 206 DEFINE_TRACE(SuspendableScriptExecutor) { | 208 DEFINE_TRACE(SuspendableScriptExecutor) { |
| 207 visitor->trace(m_frame); | 209 visitor->trace(m_frame); |
| 208 visitor->trace(m_executor); | 210 visitor->trace(m_executor); |
| 209 SuspendableTimer::trace(visitor); | 211 SuspendableTimer::trace(visitor); |
| 210 } | 212 } |
| 211 | 213 |
| 212 } // namespace blink | 214 } // namespace blink |
| OLD | NEW |