Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: third_party/WebKit/Source/core/frame/DOMWindowTimers.cpp

Issue 2711163003: Revert of Add security checks to scheduled actions (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
4 * Copyright (C) 2013 Samsung Electronics. All rights reserved. 4 * Copyright (C) 2013 Samsung Electronics. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are 7 * modification, are permitted provided that the following conditions are
8 * met: 8 * met:
9 * 9 *
10 * * Redistributions of source code must retain the above copyright 10 * * Redistributions of source code must retain the above copyright
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 int timeout, 78 int timeout,
79 const Vector<ScriptValue>& arguments) { 79 const Vector<ScriptValue>& arguments) {
80 ExecutionContext* executionContext = eventTarget.getExecutionContext(); 80 ExecutionContext* executionContext = eventTarget.getExecutionContext();
81 if (!isAllowed(scriptState, executionContext, false)) 81 if (!isAllowed(scriptState, executionContext, false))
82 return 0; 82 return 0;
83 if (timeout >= 0 && executionContext->isDocument()) { 83 if (timeout >= 0 && executionContext->isDocument()) {
84 // FIXME: Crude hack that attempts to pass idle time to V8. This should 84 // FIXME: Crude hack that attempts to pass idle time to V8. This should
85 // be done using the scheduler instead. 85 // be done using the scheduler instead.
86 V8GCForContextDispose::instance().notifyIdle(); 86 V8GCForContextDispose::instance().notifyIdle();
87 } 87 }
88 ScheduledAction* action = ScheduledAction::create( 88 ScheduledAction* action =
89 scriptState, executionContext, handler, arguments); 89 ScheduledAction::create(scriptState, handler, arguments);
90 return DOMTimer::install(executionContext, action, timeout, true); 90 return DOMTimer::install(executionContext, action, timeout, true);
91 } 91 }
92 92
93 int setTimeout(ScriptState* scriptState, 93 int setTimeout(ScriptState* scriptState,
94 EventTarget& eventTarget, 94 EventTarget& eventTarget,
95 const String& handler, 95 const String& handler,
96 int timeout, 96 int timeout,
97 const Vector<ScriptValue>&) { 97 const Vector<ScriptValue>&) {
98 ExecutionContext* executionContext = eventTarget.getExecutionContext(); 98 ExecutionContext* executionContext = eventTarget.getExecutionContext();
99 if (!isAllowed(scriptState, executionContext, true)) 99 if (!isAllowed(scriptState, executionContext, true))
100 return 0; 100 return 0;
101 // Don't allow setting timeouts to run empty functions. Was historically a 101 // Don't allow setting timeouts to run empty functions. Was historically a
102 // perfomance issue. 102 // perfomance issue.
103 if (handler.isEmpty()) 103 if (handler.isEmpty())
104 return 0; 104 return 0;
105 if (timeout >= 0 && executionContext->isDocument()) { 105 if (timeout >= 0 && executionContext->isDocument()) {
106 // FIXME: Crude hack that attempts to pass idle time to V8. This should 106 // FIXME: Crude hack that attempts to pass idle time to V8. This should
107 // be done using the scheduler instead. 107 // be done using the scheduler instead.
108 V8GCForContextDispose::instance().notifyIdle(); 108 V8GCForContextDispose::instance().notifyIdle();
109 } 109 }
110 ScheduledAction* action = 110 ScheduledAction* action = ScheduledAction::create(scriptState, handler);
111 ScheduledAction::create(scriptState, executionContext, handler);
112 return DOMTimer::install(executionContext, action, timeout, true); 111 return DOMTimer::install(executionContext, action, timeout, true);
113 } 112 }
114 113
115 int setInterval(ScriptState* scriptState, 114 int setInterval(ScriptState* scriptState,
116 EventTarget& eventTarget, 115 EventTarget& eventTarget,
117 const ScriptValue& handler, 116 const ScriptValue& handler,
118 int timeout, 117 int timeout,
119 const Vector<ScriptValue>& arguments) { 118 const Vector<ScriptValue>& arguments) {
120 ExecutionContext* executionContext = eventTarget.getExecutionContext(); 119 ExecutionContext* executionContext = eventTarget.getExecutionContext();
121 if (!isAllowed(scriptState, executionContext, false)) 120 if (!isAllowed(scriptState, executionContext, false))
122 return 0; 121 return 0;
123 ScheduledAction* action = ScheduledAction::create( 122 ScheduledAction* action =
124 scriptState, executionContext, handler, arguments); 123 ScheduledAction::create(scriptState, handler, arguments);
125 return DOMTimer::install(executionContext, action, timeout, false); 124 return DOMTimer::install(executionContext, action, timeout, false);
126 } 125 }
127 126
128 int setInterval(ScriptState* scriptState, 127 int setInterval(ScriptState* scriptState,
129 EventTarget& eventTarget, 128 EventTarget& eventTarget,
130 const String& handler, 129 const String& handler,
131 int timeout, 130 int timeout,
132 const Vector<ScriptValue>&) { 131 const Vector<ScriptValue>&) {
133 ExecutionContext* executionContext = eventTarget.getExecutionContext(); 132 ExecutionContext* executionContext = eventTarget.getExecutionContext();
134 if (!isAllowed(scriptState, executionContext, true)) 133 if (!isAllowed(scriptState, executionContext, true))
135 return 0; 134 return 0;
136 // Don't allow setting timeouts to run empty functions. Was historically a 135 // Don't allow setting timeouts to run empty functions. Was historically a
137 // perfomance issue. 136 // perfomance issue.
138 if (handler.isEmpty()) 137 if (handler.isEmpty())
139 return 0; 138 return 0;
140 ScheduledAction* action = 139 ScheduledAction* action = ScheduledAction::create(scriptState, handler);
141 ScheduledAction::create(scriptState, executionContext, handler);
142 return DOMTimer::install(executionContext, action, timeout, false); 140 return DOMTimer::install(executionContext, action, timeout, false);
143 } 141 }
144 142
145 void clearTimeout(EventTarget& eventTarget, int timeoutID) { 143 void clearTimeout(EventTarget& eventTarget, int timeoutID) {
146 if (ExecutionContext* context = eventTarget.getExecutionContext()) 144 if (ExecutionContext* context = eventTarget.getExecutionContext())
147 DOMTimer::removeByID(context, timeoutID); 145 DOMTimer::removeByID(context, timeoutID);
148 } 146 }
149 147
150 void clearInterval(EventTarget& eventTarget, int timeoutID) { 148 void clearInterval(EventTarget& eventTarget, int timeoutID) {
151 if (ExecutionContext* context = eventTarget.getExecutionContext()) 149 if (ExecutionContext* context = eventTarget.getExecutionContext())
152 DOMTimer::removeByID(context, timeoutID); 150 DOMTimer::removeByID(context, timeoutID);
153 } 151 }
154 152
155 } // namespace DOMWindowTimers 153 } // namespace DOMWindowTimers
156 154
157 } // namespace blink 155 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/ScheduledAction.cpp ('k') | third_party/WebKit/Source/core/testing/Internals.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698