Changeset 64991 in webkit
- Timestamp:
- Aug 9, 2010 10:50:41 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r64987 r64991 1 2010-08-09 Dominic Cooney <dominicc@google.com> 2 3 Reviewed by Adam Barth. 4 5 Moves window.open logic into the generic bindings. 6 7 This patch moves window.open logic from V8 into the generic 8 bindings so it could be shared with JSC. JSC sharing is not in 9 this patch. This patch is of the same flavor/intent as 33201. 10 11 https://bugs.webkit.org/show_bug.cgi?id=41392 12 13 * bindings/generic/BindingDOMWindow.h: 14 (WebCore::::createWindow): 15 (WebCore::::open): 16 (WebCore::::completeURL): 17 * bindings/generic/BindingSecurity.h: 18 (WebCore::::allowPopUp): 19 (WebCore::::shouldAllowNavigation): 20 * bindings/v8/V8Binding.h: 21 (WebCore::V8Binding::emptyScriptValue): 22 * bindings/v8/V8Utilities.cpp: 23 (WebCore::transferHiddenDependency): 24 (WebCore::processingUserGesture): 25 (WebCore::shouldAllowNavigation): 26 (WebCore::completeURL): 27 * bindings/v8/custom/V8ArrayBufferCustom.cpp: 28 * bindings/v8/custom/V8DOMWindowCustom.cpp: 29 (WebCore::V8DOMWindow::showModalDialogCallback): 30 (WebCore::V8DOMWindow::openCallback): 31 * bindings/v8/specialization/V8BindingState.cpp: 32 (WebCore::::getActiveFrame): 33 (WebCore::::getFirstFrame): 34 (WebCore::::processingUserGesture): 35 * bindings/v8/specialization/V8BindingState.h: 36 (WebCore::): 37 1 38 2010-08-09 Marcus Bulach <bulach@chromium.org> 2 39 -
trunk/WebCore/bindings/generic/BindingDOMWindow.h
r60036 r64991 1 1 /* 2 2 * Copyright (C) 2010 Google Inc. All rights reserved. 3 * 3 * 4 4 * Redistribution and use in source and binary forms, with or without 5 5 * modification, are permitted provided that the following conditions are 6 6 * met: 7 * 7 * 8 8 * * Redistributions of source code must retain the above copyright 9 9 * notice, this list of conditions and the following disclaimer. … … 15 15 * contributors may be used to endorse or promote products derived from 16 16 * this software without specific prior written permission. 17 * 17 * 18 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT … … 32 32 #define BindingDOMWindow_h 33 33 34 #include "DOMWindow.h" 34 35 #include "Frame.h" 35 36 #include "FrameLoadRequest.h" 37 #include "FrameLoader.h" 38 #include "FrameView.h" 36 39 #include "GenericBinding.h" 37 40 #include "Page.h" 41 #include "PlatformScreen.h" 42 #include "ScriptController.h" 38 43 #include "SecurityOrigin.h" 44 #include "WindowFeatures.h" 39 45 40 46 namespace WebCore { … … 53 59 const WindowFeatures& windowFeatures, 54 60 BindingValue dialogArgs); 61 62 static WebCore::DOMWindow* open(State<Binding>*, 63 WebCore::DOMWindow* parent, 64 const String& url, 65 const String& frameName, 66 const WindowFeatures& rawFeatures); 67 68 // FIXME: There should be a place for generic binding utilities. 69 static KURL completeURL(State<Binding>*, const String& relativeURL); 70 71 private: 72 // Horizontal and vertical offset, from the parent content area, 73 // around newly opened popups that don't specify a location. 74 static const int popupTilePixels = 10; 55 75 }; 56 76 … … 104 124 if (!protocolIsJavaScript(url) || BindingSecurity<Binding>::canAccessFrame(state, newFrame, true)) { 105 125 KURL completedUrl = 106 url.isEmpty() ? KURL(ParsedURLString, "") : completeURL( url);107 bool userGesture = processingUserGesture();126 url.isEmpty() ? KURL(ParsedURLString, "") : completeURL(state, url); 127 bool userGesture = state->processingUserGesture(); 108 128 109 129 if (created) … … 116 136 } 117 137 138 template<class Binding> 139 WebCore::DOMWindow* BindingDOMWindow<Binding>::open(State<Binding>* state, 140 WebCore::DOMWindow* parent, 141 const String& urlString, 142 const String& frameName, 143 const WindowFeatures& rawFeatures) 144 { 145 Frame* frame = parent->frame(); 146 147 if (!BindingSecurity<Binding>::canAccessFrame(state, frame, true)) 148 return 0; 149 150 Frame* firstFrame = state->getFirstFrame(); 151 if (!firstFrame) 152 return 0; 153 154 Frame* activeFrame = state->getActiveFrame(); 155 // We may not have a calling context if we are invoked by a plugin 156 // via NPAPI. 157 if (!activeFrame) 158 activeFrame = firstFrame; 159 160 Page* page = frame->page(); 161 if (!page) 162 return 0; 163 164 // Because FrameTree::find() returns true for empty strings, we must check 165 // for empty framenames. Otherwise, illegitimate window.open() calls with 166 // no name will pass right through the popup blocker. 167 if (!BindingSecurity<Binding>::allowPopUp(state) 168 && (frameName.isEmpty() || !frame->tree()->find(frameName))) { 169 return 0; 170 } 171 172 // Get the target frame for the special cases of _top and _parent. 173 // In those cases, we can schedule a location change right now and 174 // return early. 175 bool topOrParent = false; 176 if (frameName == "_top") { 177 frame = frame->tree()->top(); 178 topOrParent = true; 179 } else if (frameName == "_parent") { 180 if (Frame* parent = frame->tree()->parent()) 181 frame = parent; 182 topOrParent = true; 183 } 184 if (topOrParent) { 185 if (!BindingSecurity<Binding>::shouldAllowNavigation(state, frame)) 186 return 0; 187 188 String completedUrl; 189 if (!urlString.isEmpty()) 190 completedUrl = completeURL(state, urlString); 191 192 if (!completedUrl.isEmpty() 193 && (!protocolIsJavaScript(completedUrl) 194 || BindingSecurity<Binding>::canAccessFrame(state, frame, true))) { 195 bool userGesture = state->processingUserGesture(); 196 197 // For whatever reason, Firefox uses the first frame to determine 198 // the outgoingReferrer. We replicate that behavior here. 199 String referrer = firstFrame->loader()->outgoingReferrer(); 200 201 frame->redirectScheduler()->scheduleLocationChange(completedUrl, referrer, false, false, userGesture); 202 } 203 return frame->domWindow(); 204 } 205 206 // In the case of a named frame or a new window, we'll use the 207 // createWindow() helper. 208 209 // Work with a copy of the parsed values so we can restore the 210 // values we may not want to overwrite after we do the multiple 211 // monitor fixes. 212 WindowFeatures windowFeatures(rawFeatures); 213 FloatRect screenRect = screenAvailableRect(page->mainFrame()->view()); 214 215 // Set default size and location near parent window if none were specified. 216 // These may be further modified by adjustWindowRect, below. 217 if (!windowFeatures.xSet) { 218 windowFeatures.x = parent->screenX() - screenRect.x() + popupTilePixels; 219 windowFeatures.xSet = true; 220 } 221 if (!windowFeatures.ySet) { 222 windowFeatures.y = parent->screenY() - screenRect.y() + popupTilePixels; 223 windowFeatures.ySet = true; 224 } 225 if (!windowFeatures.widthSet) { 226 windowFeatures.width = parent->innerWidth(); 227 windowFeatures.widthSet = true; 228 } 229 if (!windowFeatures.heightSet) { 230 windowFeatures.height = parent->innerHeight(); 231 windowFeatures.heightSet = true; 232 } 233 234 FloatRect windowRect(windowFeatures.x, windowFeatures.y, windowFeatures.width, windowFeatures.height); 235 236 // The new window's location is relative to its current screen, so shift 237 // it in case it's on a secondary monitor. See http://b/viewIssue?id=967905. 238 windowRect.move(screenRect.x(), screenRect.y()); 239 WebCore::DOMWindow::adjustWindowRect(screenRect, windowRect, windowRect); 240 241 windowFeatures.x = windowRect.x(); 242 windowFeatures.y = windowRect.y(); 243 windowFeatures.height = windowRect.height(); 244 windowFeatures.width = windowRect.width(); 245 246 // If either of the origin coordinates or dimensions weren't set 247 // in the original string, make sure they aren't set now. 248 if (!rawFeatures.xSet) { 249 windowFeatures.x = 0; 250 windowFeatures.xSet = false; 251 } 252 if (!rawFeatures.ySet) { 253 windowFeatures.y = 0; 254 windowFeatures.ySet = false; 255 } 256 if (!rawFeatures.widthSet) { 257 windowFeatures.width = 0; 258 windowFeatures.widthSet = false; 259 } 260 if (!rawFeatures.heightSet) { 261 windowFeatures.height = 0; 262 windowFeatures.heightSet = false; 263 } 264 265 frame = createWindow(state, activeFrame, firstFrame, frame, urlString, frameName, windowFeatures, Binding::emptyScriptValue()); 266 267 if (!frame) 268 return 0; 269 270 return frame->domWindow(); 271 } 272 273 template <class Binding> 274 KURL BindingDOMWindow<Binding>::completeURL(State<Binding>* state, 275 const String& relativeURL) 276 { 277 // For historical reasons, we need to complete the URL using the 278 // dynamic frame. 279 Frame* frame = state->getFirstFrame(); 280 if (!frame) 281 return KURL(); 282 return frame->loader()->completeURL(relativeURL); 283 } 284 118 285 } // namespace WebCore 119 286 -
trunk/WebCore/bindings/generic/BindingSecurity.h
r61094 r64991 35 35 #include "CSSHelper.h" 36 36 #include "Element.h" 37 #include "Frame.h" 37 38 #include "GenericBinding.h" 38 39 #include "HTMLFrameElementBase.h" 39 40 #include "HTMLNames.h" 41 #include "Settings.h" 40 42 41 43 namespace WebCore { 42 44 43 45 class DOMWindow; 44 class Frame;45 46 class Node; 46 47 … … 56 57 static bool checkNodeSecurity(State<Binding>*, Node* target); 57 58 59 static bool allowPopUp(State<Binding>*); 58 60 static bool allowSettingFrameSrcToJavascriptUrl(State<Binding>*, HTMLFrameElementBase*, String value); 59 61 static bool allowSettingSrcToJavascriptURL(State<Binding>*, Element*, String name, String value); 62 63 static bool shouldAllowNavigation(State<Binding>*, Frame*); 60 64 61 65 private: … … 111 115 112 116 template <class Binding> 117 bool BindingSecurity<Binding>::allowPopUp(State<Binding>* state) 118 { 119 if (state->processingUserGesture()) 120 return true; 121 122 Frame* frame = state->getFirstFrame(); 123 ASSERT(frame); 124 Settings* settings = frame->settings(); 125 return settings && settings->javaScriptCanOpenWindowsAutomatically(); 126 } 127 128 template <class Binding> 113 129 bool BindingSecurity<Binding>::allowSettingFrameSrcToJavascriptUrl(State<Binding>* state, HTMLFrameElementBase* frame, String value) 114 130 { … … 129 145 } 130 146 147 template <class Binding> 148 bool BindingSecurity<Binding>::shouldAllowNavigation(State<Binding>* state, Frame* frame) 149 { 150 Frame* activeFrame = state->getActiveFrame(); 151 return activeFrame && activeFrame->loader()->shouldAllowNavigation(frame); 152 } 153 131 154 } 132 155 -
trunk/WebCore/bindings/v8/V8Binding.h
r64840 r64991 1 1 /* 2 2 * Copyright (C) 2009 Google Inc. All rights reserved. 3 * 3 * 4 4 * Redistribution and use in source and binary forms, with or without 5 5 * modification, are permitted provided that the following conditions are 6 6 * met: 7 * 7 * 8 8 * * Redistributions of source code must retain the above copyright 9 9 * notice, this list of conditions and the following disclaimer. … … 15 15 * contributors may be used to endorse or promote products derived from 16 16 * this software without specific prior written permission. 17 * 17 * 18 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT … … 41 41 42 42 namespace WebCore { 43 43 44 44 class EventListener; 45 45 class EventTarget; … … 51 51 typedef v8::Handle<v8::Value> Value; 52 52 typedef V8BindingDOMWindow DOMWindow; 53 54 static Value emptyScriptValue() { return v8::Local<v8::Value>(); } 53 55 }; 54 56 typedef BindingSecurity<V8Binding> V8BindingSecurity; … … 153 155 return v8ValueToWebCoreString(object); 154 156 } 155 157 156 158 String toWebCoreString(const v8::Arguments&, int index); 157 159 … … 172 174 173 175 String toWebCoreStringWithNullOrUndefinedCheck(v8::Handle<v8::Value> value); 174 176 175 177 v8::Handle<v8::String> v8UndetectableString(const String& str); 176 178 … … 184 186 185 187 v8::Handle<v8::Value> v8DateOrNull(double value); 186 188 187 189 v8::Persistent<v8::FunctionTemplate> createRawTemplate(); 188 190 189 191 struct BatchedAttribute; 190 192 struct BatchedCallback; 191 193 192 194 v8::Local<v8::Signature> configureTemplate(v8::Persistent<v8::FunctionTemplate>, 193 195 const char* interfaceName, 194 196 v8::Persistent<v8::FunctionTemplate> parentClass, 195 197 int fieldCount, 196 const BatchedAttribute*, 198 const BatchedAttribute*, 197 199 size_t attributeCount, 198 200 const BatchedCallback*, 199 201 size_t callbackCount); 200 202 201 203 v8::Handle<v8::Value> getElementStringAttr(const v8::AccessorInfo&, 202 204 const QualifiedName&); … … 205 207 v8::Local<v8::Value>); 206 208 207 209 208 210 v8::Persistent<v8::String> getToStringName(); 209 211 v8::Persistent<v8::FunctionTemplate> getToStringTemplate(); 210 212 211 213 // V8Parameter is an adapter class that converts V8 values to Strings 212 214 // or AtomicStrings as appropriate, using multiple typecast operators. … … 225 227 v8::Local<v8::Value> m_v8Object; 226 228 }; 227 229 228 230 template<> inline V8Parameter<DefaultMode>::operator String() { return toWebCoreString(m_v8Object); } 229 231 template<> inline V8Parameter<WithNullCheck>::operator String() { return toWebCoreStringWithNullCheck(m_v8Object); } -
trunk/WebCore/bindings/v8/V8Utilities.cpp
r62868 r64991 39 39 #include "ScriptState.h" 40 40 #include "V8Binding.h" 41 #include "V8BindingDOMWindow.h" // FIXME: remove when completeURL moves 42 #include "V8BindingState.h" 41 43 #include "V8Proxy.h" 42 44 #include "WorkerContext.h" … … 93 95 createHiddenDependency(object, newValue, cacheIndex); 94 96 } 95 96 97 97 98 bool processingUserGesture() 98 99 { 99 Frame* frame = V8Proxy::retrieveFrameForEnteredContext(); 100 return frame && frame->script()->processingUserGesture(); 100 return V8BindingState::Only()->processingUserGesture(); 101 101 } 102 102 103 103 Frame* callingOrEnteredFrame() 104 104 { 105 Frame* frame = V8Proxy::retrieveFrameForCallingContext(); 106 if (!frame) { 107 // Unfortunately, when processing script from a plug-in, we might not 108 // have a calling context. In those cases, we fall back to the 109 // entered context for security checks. 110 // FIXME: We need a better API for retrieving frames that abstracts 111 // away this concern. 112 frame = V8Proxy::retrieveFrameForEnteredContext(); 113 } 114 return frame; 105 return V8BindingState::Only()->getActiveFrame(); 115 106 } 116 107 117 108 bool shouldAllowNavigation(Frame* frame) 118 109 { 119 Frame* callingOrEntered = callingOrEnteredFrame(); 120 return callingOrEntered && callingOrEntered->loader()->shouldAllowNavigation(frame); 110 return V8BindingSecurity::shouldAllowNavigation(V8BindingState::Only(), frame); 121 111 } 122 112 123 113 KURL completeURL(const String& relativeURL) 124 114 { 125 // For histoical reasons, we need to complete the URL using the dynamic frame. 126 Frame* frame = V8Proxy::retrieveFrameForEnteredContext(); 127 if (!frame) 128 return KURL(); 129 return frame->loader()->completeURL(relativeURL); 115 return V8BindingDOMWindow::completeURL(V8BindingState::Only(), relativeURL); 130 116 } 131 117 -
trunk/WebCore/bindings/v8/custom/V8ArrayBufferCustom.cpp
r61339 r64991 35 35 #include "ArrayBuffer.h" 36 36 37 #include "ExceptionCode.h" 37 38 #include "V8Binding.h" 38 39 #include "V8ArrayBuffer.h" -
trunk/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp
r64840 r64991 83 83 #include "WindowFeatures.h" 84 84 85 // Horizontal and vertical offset, from the parent content area, around newly86 // opened popups that don't specify a location.87 static const int popupTilePixels = 10;88 89 85 namespace WebCore { 90 86 … … 448 444 return false; 449 445 return frame->page()->chrome()->canRunModalNow(); 450 }451 452 static bool allowPopUp()453 {454 Frame* frame = V8Proxy::retrieveFrameForEnteredContext();455 456 ASSERT(frame);457 if (frame->script()->processingUserGesture())458 return true;459 Settings* settings = frame->settings();460 return settings && settings->javaScriptCanOpenWindowsAutomatically();461 446 } 462 447 … … 514 499 return v8::Undefined(); 515 500 516 if (!canShowModalDialogNow(frame) || ! allowPopUp())501 if (!canShowModalDialogNow(frame) || !V8BindingSecurity::allowPopUp(V8BindingState::Only())) 517 502 return v8::Undefined(); 518 503 … … 585 570 INC_STATS("DOM.DOMWindow.open()"); 586 571 572 DOMWindow* parent = V8DOMWindow::toNative(args.Holder()); 587 573 String urlString = toWebCoreStringWithNullOrUndefinedCheck(args[0]); 588 574 AtomicString frameName = (args[1]->IsUndefined() || args[1]->IsNull()) ? "_blank" : AtomicString(toWebCoreString(args[1])); 589 590 DOMWindow* parent = V8DOMWindow::toNative(args.Holder());591 Frame* frame = parent->frame();592 593 if (!V8BindingSecurity::canAccessFrame(V8BindingState::Only(), frame, true))594 return v8::Undefined();595 596 Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext();597 if (!enteredFrame)598 return v8::Undefined();599 600 Frame* callingFrame = V8Proxy::retrieveFrameForCallingContext();601 // We may not have a calling context if we are invoked by a plugin via NPAPI.602 if (!callingFrame)603 callingFrame = enteredFrame;604 605 Page* page = frame->page();606 if (!page)607 return v8::Undefined();608 609 // Because FrameTree::find() returns true for empty strings, we must check610 // for empty framenames. Otherwise, illegitimate window.open() calls with611 // no name will pass right through the popup blocker.612 if (!allowPopUp() &&613 (frameName.isEmpty() || !frame->tree()->find(frameName))) {614 return v8::Undefined();615 }616 617 // Get the target frame for the special cases of _top and _parent. In those618 // cases, we can schedule a location change right now and return early.619 bool topOrParent = false;620 if (frameName == "_top") {621 frame = frame->tree()->top();622 topOrParent = true;623 } else if (frameName == "_parent") {624 if (Frame* parent = frame->tree()->parent())625 frame = parent;626 topOrParent = true;627 }628 if (topOrParent) {629 if (!shouldAllowNavigation(frame))630 return v8::Undefined();631 632 String completedUrl;633 if (!urlString.isEmpty())634 completedUrl = completeURL(urlString);635 636 if (!completedUrl.isEmpty() &&637 (!protocolIsJavaScript(completedUrl) || ScriptController::isSafeScript(frame))) {638 bool userGesture = processingUserGesture();639 640 // For whatever reason, Firefox uses the entered frame to determine641 // the outgoingReferrer. We replicate that behavior here.642 String referrer = enteredFrame->loader()->outgoingReferrer();643 644 frame->redirectScheduler()->scheduleLocationChange(completedUrl, referrer, false, false, userGesture);645 }646 return toV8(frame->domWindow());647 }648 649 // In the case of a named frame or a new window, we'll use the650 // createWindow() helper.651 652 // Parse the values, and then work with a copy of the parsed values653 // so we can restore the values we may not want to overwrite after654 // we do the multiple monitor fixes.655 575 WindowFeatures rawFeatures(toWebCoreStringWithNullOrUndefinedCheck(args[2])); 656 WindowFeatures windowFeatures(rawFeatures); 657 FloatRect screenRect = screenAvailableRect(page->mainFrame()->view()); 658 659 // Set default size and location near parent window if none were specified. 660 // These may be further modified by adjustWindowRect, below. 661 if (!windowFeatures.xSet) { 662 windowFeatures.x = parent->screenX() - screenRect.x() + popupTilePixels; 663 windowFeatures.xSet = true; 664 } 665 if (!windowFeatures.ySet) { 666 windowFeatures.y = parent->screenY() - screenRect.y() + popupTilePixels; 667 windowFeatures.ySet = true; 668 } 669 if (!windowFeatures.widthSet) { 670 windowFeatures.width = parent->innerWidth(); 671 windowFeatures.widthSet = true; 672 } 673 if (!windowFeatures.heightSet) { 674 windowFeatures.height = parent->innerHeight(); 675 windowFeatures.heightSet = true; 676 } 677 678 FloatRect windowRect(windowFeatures.x, windowFeatures.y, windowFeatures.width, windowFeatures.height); 679 680 // The new window's location is relative to its current screen, so shift 681 // it in case it's on a secondary monitor. See http://b/viewIssue?id=967905. 682 windowRect.move(screenRect.x(), screenRect.y()); 683 WebCore::DOMWindow::adjustWindowRect(screenRect, windowRect, windowRect); 684 685 windowFeatures.x = windowRect.x(); 686 windowFeatures.y = windowRect.y(); 687 windowFeatures.height = windowRect.height(); 688 windowFeatures.width = windowRect.width(); 689 690 // If either of the origin coordinates or dimensions weren't set in the original 691 // string, make sure they aren't set now. 692 if (!rawFeatures.xSet) { 693 windowFeatures.x = 0; 694 windowFeatures.xSet = false; 695 } 696 if (!rawFeatures.ySet) { 697 windowFeatures.y = 0; 698 windowFeatures.ySet = false; 699 } 700 if (!rawFeatures.widthSet) { 701 windowFeatures.width = 0; 702 windowFeatures.widthSet = false; 703 } 704 if (!rawFeatures.heightSet) { 705 windowFeatures.height = 0; 706 windowFeatures.heightSet = false; 707 } 708 709 frame = V8BindingDOMWindow::createWindow(V8BindingState::Only(), callingFrame, enteredFrame, frame, urlString, frameName, windowFeatures, v8::Local<v8::Value>()); 710 711 if (!frame) 712 return v8::Undefined(); 713 714 return toV8(frame->domWindow()); 576 DOMWindow* child = V8BindingDOMWindow::open(V8BindingState::Only(), parent, urlString, frameName, rawFeatures); 577 578 if (!child) 579 return v8::Undefined(); 580 581 return toV8(child); 715 582 } 716 583 -
trunk/WebCore/bindings/v8/specialization/V8BindingState.cpp
r52810 r64991 1 1 /* 2 2 * Copyright (C) 2009 Google Inc. All rights reserved. 3 * 3 * 4 4 * Redistribution and use in source and binary forms, with or without 5 5 * modification, are permitted provided that the following conditions are 6 6 * met: 7 * 7 * 8 8 * * Redistributions of source code must retain the above copyright 9 9 * notice, this list of conditions and the following disclaimer. … … 15 15 * contributors may be used to endorse or promote products derived from 16 16 * this software without specific prior written permission. 17 * 17 * 18 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT … … 32 32 #include "V8BindingState.h" 33 33 34 #include "Frame.h" 35 #include "ScriptController.h" 34 36 #include "V8Proxy.h" 35 37 #include <wtf/StdLibExtras.h> … … 54 56 } 55 57 58 Frame* State<V8Binding>::getActiveFrame() 59 { 60 Frame* frame = V8Proxy::retrieveFrameForCallingContext(); 61 if (!frame) { 62 // Unfortunately, when processing script from a plug-in, we might not 63 // have a calling context. In those cases, we fall back to the 64 // entered context for security checks. 65 // FIXME: We need a better API for retrieving frames that abstracts 66 // away this concern. 67 frame = V8Proxy::retrieveFrameForEnteredContext(); 68 } 69 return frame; 70 } 71 72 Frame* State<V8Binding>::getFirstFrame() 73 { 74 return V8Proxy::retrieveFrameForEnteredContext(); 75 } 76 56 77 void State<V8Binding>::immediatelyReportUnsafeAccessTo(Frame* target) 57 78 { … … 59 80 } 60 81 82 bool State<V8Binding>::processingUserGesture() 83 { 84 Frame* frame = V8Proxy::retrieveFrameForEnteredContext(); 85 return frame && frame->script()->processingUserGesture(); 86 } 87 61 88 } // namespace WebCore -
trunk/WebCore/bindings/v8/specialization/V8BindingState.h
r52810 r64991 1 1 /* 2 2 * Copyright (C) 2009 Google Inc. All rights reserved. 3 * 3 * 4 4 * Redistribution and use in source and binary forms, with or without 5 5 * modification, are permitted provided that the following conditions are 6 6 * met: 7 * 7 * 8 8 * * Redistributions of source code must retain the above copyright 9 9 * notice, this list of conditions and the following disclaimer. … … 15 15 * contributors may be used to endorse or promote products derived from 16 16 * this software without specific prior written permission. 17 * 17 * 18 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT … … 37 37 namespace WebCore { 38 38 39 class Frame; 40 39 41 // Singleton implementation of State<V8Binding>. Uses V8's global data 40 42 // structures to return information about relevant execution state. … … 45 47 static State* Only(); 46 48 49 // Reports an error message (without delay) if the security check fails. 50 static void immediatelyReportUnsafeAccessTo(Frame*); 51 47 52 // The DOMWindow corresponding to the 'calling context' of execution. 48 53 DOMWindow* getActiveWindow(); 49 54 50 // Reports an error message (without delay) if the security check fails. 51 static void immediatelyReportUnsafeAccessTo(Frame*); 55 // The frame corresponding to the 'calling context' of execution. 56 Frame* getActiveFrame(); 57 58 // The first frame in which execution entered user script. 59 Frame* getFirstFrame(); 60 61 bool processingUserGesture(); 52 62 53 63 private:
Note: See TracChangeset
for help on using the changeset viewer.