OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef PluginScriptForbiddenScope_h | 5 #ifndef PluginScriptForbiddenScope_h |
6 #define PluginScriptForbiddenScope_h | 6 #define PluginScriptForbiddenScope_h |
7 | 7 |
8 #include "platform/PlatformExport.h" | 8 #include "platform/PlatformExport.h" |
9 #include "platform/wtf/Allocator.h" | 9 #include "platform/wtf/Allocator.h" |
10 #include "platform/wtf/Noncopyable.h" | 10 #include "platform/wtf/Noncopyable.h" |
11 | 11 |
12 namespace blink { | 12 namespace blink { |
13 | 13 |
14 // Similar to ScriptForbiddenScope, but more selective. This is intended to help | 14 // Similar to ScriptForbiddenScope, but more selective. This is intended to help |
15 // reduce the number of places where Flash can run a nested message loop as its | 15 // reduce the number of places where Flash can run a nested run loop as its |
16 // plugin element is being destroyed. One of the reasons that Flash runs this | 16 // plugin element is being destroyed. One of the reasons that Flash runs this |
17 // nested message loop is to allow Flash content to synchronously script the | 17 // nested run loop is to allow Flash content to synchronously script the |
18 // page when the plugin element is destroyed. | 18 // page when the plugin element is destroyed. |
19 // | 19 // |
20 // This is problematic for many reasons: the DOM may not be in a consistent | 20 // This is problematic for many reasons: the DOM may not be in a consistent |
21 // state, since Blink is in the middle of detaching nodes, nested message loops | 21 // state, since Blink is in the middle of detaching nodes, nested run loops |
22 // can cause normally impossible conditions to occur (https://crbug.com/367210), | 22 // can cause normally impossible conditions to occur (https://crbug.com/367210), |
23 // etc. | 23 // etc. |
24 // | 24 // |
25 // When this object is instantiated on the stack, it allows execution of event | 25 // When this object is instantiated on the stack, it allows execution of event |
26 // handlers, etc but blocks attempts by plugins to call back into Blink to | 26 // handlers, etc but blocks attempts by plugins to call back into Blink to |
27 // execute script. | 27 // execute script. |
28 // | 28 // |
29 // Background: | 29 // Background: |
30 // For historical reasons, Flash has allowed synchronous scripting during | 30 // For historical reasons, Flash has allowed synchronous scripting during |
31 // teardown of the plugin. This is generally problematic, but sites apparently | 31 // teardown of the plugin. This is generally problematic, but sites apparently |
32 // rely on this behavior. Over time, Blink has added restrictions on this | 32 // rely on this behavior. Over time, Blink has added restrictions on this |
33 // synchronous scripting: for example, past a certain point in Frame detach, | 33 // synchronous scripting: for example, past a certain point in Frame detach, |
34 // script execution by Flash is ignored: https://crbug.com/371084. | 34 // script execution by Flash is ignored: https://crbug.com/371084. |
35 // | 35 // |
36 // Unfortunately, there are still ways for plugins to synchronously script | 36 // Unfortunately, there are still ways for plugins to synchronously script |
37 // during Document detach: if an unload handler removes a Flash plugin element, | 37 // during Document detach: if an unload handler removes a Flash plugin element, |
38 // that will run the nested message loop, etc. This scoper is intended to block | 38 // that will run the nested run loop, etc. This scoper is intended to block |
39 // those usages, with the eventual goal that Frame detach will never have to run | 39 // those usages, with the eventual goal that Frame detach will never have to run |
40 // a nested message loop. | 40 // a nested run loop. |
41 class PLATFORM_EXPORT PluginScriptForbiddenScope final { | 41 class PLATFORM_EXPORT PluginScriptForbiddenScope final { |
42 STACK_ALLOCATED(); | 42 STACK_ALLOCATED(); |
43 WTF_MAKE_NONCOPYABLE(PluginScriptForbiddenScope); | 43 WTF_MAKE_NONCOPYABLE(PluginScriptForbiddenScope); |
44 | 44 |
45 public: | 45 public: |
46 PluginScriptForbiddenScope(); | 46 PluginScriptForbiddenScope(); |
47 ~PluginScriptForbiddenScope(); | 47 ~PluginScriptForbiddenScope(); |
48 | 48 |
49 static bool IsForbidden(); | 49 static bool IsForbidden(); |
50 }; | 50 }; |
51 | 51 |
52 } // namespace blink | 52 } // namespace blink |
53 | 53 |
54 #endif // PluginScriptForbiddenScope_h | 54 #endif // PluginScriptForbiddenScope_h |
OLD | NEW |