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

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

Issue 2080623002: Revert "Remove OwnPtr from Blink." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 #include "core/page/CreateWindow.h" 71 #include "core/page/CreateWindow.h"
72 #include "core/page/Page.h" 72 #include "core/page/Page.h"
73 #include "core/page/WindowFeatures.h" 73 #include "core/page/WindowFeatures.h"
74 #include "core/page/scrolling/ScrollingCoordinator.h" 74 #include "core/page/scrolling/ScrollingCoordinator.h"
75 #include "platform/EventDispatchForbiddenScope.h" 75 #include "platform/EventDispatchForbiddenScope.h"
76 #include "platform/weborigin/SecurityOrigin.h" 76 #include "platform/weborigin/SecurityOrigin.h"
77 #include "platform/weborigin/Suborigin.h" 77 #include "platform/weborigin/Suborigin.h"
78 #include "public/platform/Platform.h" 78 #include "public/platform/Platform.h"
79 #include "public/platform/WebFrameScheduler.h" 79 #include "public/platform/WebFrameScheduler.h"
80 #include "public/platform/WebScreenInfo.h" 80 #include "public/platform/WebScreenInfo.h"
81 #include <memory> 81 #include "wtf/PassOwnPtr.h"
82 82
83 namespace blink { 83 namespace blink {
84 84
85 // Rather than simply inheriting LocalFrameLifecycleObserver like most other 85 // Rather than simply inheriting LocalFrameLifecycleObserver like most other
86 // classes, LocalDOMWindow hides its LocalFrameLifecycleObserver with 86 // classes, LocalDOMWindow hides its LocalFrameLifecycleObserver with
87 // composition. This prevents conflicting overloads between DOMWindow, which 87 // composition. This prevents conflicting overloads between DOMWindow, which
88 // has a frame() accessor that returns Frame* for bindings code, and 88 // has a frame() accessor that returns Frame* for bindings code, and
89 // LocalFrameLifecycleObserver, which has a frame() accessor that returns a 89 // LocalFrameLifecycleObserver, which has a frame() accessor that returns a
90 // LocalFrame*. 90 // LocalFrame*.
91 class LocalDOMWindow::WindowFrameObserver final : public GarbageCollected<LocalD OMWindow::WindowFrameObserver>, public LocalFrameLifecycleObserver { 91 class LocalDOMWindow::WindowFrameObserver final : public GarbageCollected<LocalD OMWindow::WindowFrameObserver>, public LocalFrameLifecycleObserver {
(...skipping 28 matching lines...) Expand all
120 , m_window(window) 120 , m_window(window)
121 { 121 {
122 } 122 }
123 123
124 Member<LocalDOMWindow> m_window; 124 Member<LocalDOMWindow> m_window;
125 }; 125 };
126 126
127 class PostMessageTimer final : public GarbageCollectedFinalized<PostMessageTimer >, public SuspendableTimer { 127 class PostMessageTimer final : public GarbageCollectedFinalized<PostMessageTimer >, public SuspendableTimer {
128 USING_GARBAGE_COLLECTED_MIXIN(PostMessageTimer); 128 USING_GARBAGE_COLLECTED_MIXIN(PostMessageTimer);
129 public: 129 public:
130 PostMessageTimer(LocalDOMWindow& window, MessageEvent* event, PassRefPtr<Sec urityOrigin> targetOrigin, std::unique_ptr<SourceLocation> location, UserGesture Token* userGestureToken) 130 PostMessageTimer(LocalDOMWindow& window, MessageEvent* event, PassRefPtr<Sec urityOrigin> targetOrigin, PassOwnPtr<SourceLocation> location, UserGestureToken * userGestureToken)
131 : SuspendableTimer(window.document()) 131 : SuspendableTimer(window.document())
132 , m_event(event) 132 , m_event(event)
133 , m_window(&window) 133 , m_window(&window)
134 , m_targetOrigin(targetOrigin) 134 , m_targetOrigin(targetOrigin)
135 , m_location(std::move(location)) 135 , m_location(std::move(location))
136 , m_userGestureToken(userGestureToken) 136 , m_userGestureToken(userGestureToken)
137 , m_disposalAllowed(true) 137 , m_disposalAllowed(true)
138 { 138 {
139 InspectorInstrumentation::asyncTaskScheduled(window.document(), "postMes sage", this); 139 InspectorInstrumentation::asyncTaskScheduled(window.document(), "postMes sage", this);
140 } 140 }
141 141
142 MessageEvent* event() const { return m_event; } 142 MessageEvent* event() const { return m_event; }
143 SecurityOrigin* targetOrigin() const { return m_targetOrigin.get(); } 143 SecurityOrigin* targetOrigin() const { return m_targetOrigin.get(); }
144 std::unique_ptr<SourceLocation> takeLocation() { return std::move(m_location ); } 144 PassOwnPtr<SourceLocation> takeLocation() { return std::move(m_location); }
145 UserGestureToken* userGestureToken() const { return m_userGestureToken.get() ; } 145 UserGestureToken* userGestureToken() const { return m_userGestureToken.get() ; }
146 void stop() override 146 void stop() override
147 { 147 {
148 SuspendableTimer::stop(); 148 SuspendableTimer::stop();
149 149
150 if (m_disposalAllowed) 150 if (m_disposalAllowed)
151 dispose(); 151 dispose();
152 } 152 }
153 153
154 // Eager finalization is needed to promptly stop this timer object. 154 // Eager finalization is needed to promptly stop this timer object.
(...skipping 22 matching lines...) Expand all
177 // Oilpan optimization: unregister as an observer right away. 177 // Oilpan optimization: unregister as an observer right away.
178 clearContext(); 178 clearContext();
179 // Will destroy this object, now or after the next GC depending 179 // Will destroy this object, now or after the next GC depending
180 // on whether Oilpan is disabled or not. 180 // on whether Oilpan is disabled or not.
181 m_window->removePostMessageTimer(this); 181 m_window->removePostMessageTimer(this);
182 } 182 }
183 183
184 Member<MessageEvent> m_event; 184 Member<MessageEvent> m_event;
185 Member<LocalDOMWindow> m_window; 185 Member<LocalDOMWindow> m_window;
186 RefPtr<SecurityOrigin> m_targetOrigin; 186 RefPtr<SecurityOrigin> m_targetOrigin;
187 std::unique_ptr<SourceLocation> m_location; 187 OwnPtr<SourceLocation> m_location;
188 RefPtr<UserGestureToken> m_userGestureToken; 188 RefPtr<UserGestureToken> m_userGestureToken;
189 bool m_disposalAllowed; 189 bool m_disposalAllowed;
190 }; 190 };
191 191
192 static void updateSuddenTerminationStatus(LocalDOMWindow* domWindow, bool addedL istener, FrameLoaderClient::SuddenTerminationDisablerType disablerType) 192 static void updateSuddenTerminationStatus(LocalDOMWindow* domWindow, bool addedL istener, FrameLoaderClient::SuddenTerminationDisablerType disablerType)
193 { 193 {
194 Platform::current()->suddenTerminationChanged(!addedListener); 194 Platform::current()->suddenTerminationChanged(!addedListener);
195 if (domWindow->frame() && domWindow->frame()->loader().client()) 195 if (domWindow->frame() && domWindow->frame()->loader().client())
196 domWindow->frame()->loader().client()->suddenTerminationDisablerChanged( addedListener, disablerType); 196 domWindow->frame()->loader().client()->suddenTerminationDisablerChanged( addedListener, disablerType);
197 } 197 }
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 688
689 event->entangleMessagePorts(document()); 689 event->entangleMessagePorts(document());
690 dispatchMessageEventWithOriginCheck(timer->targetOrigin(), event, timer->tak eLocation()); 690 dispatchMessageEventWithOriginCheck(timer->targetOrigin(), event, timer->tak eLocation());
691 } 691 }
692 692
693 void LocalDOMWindow::removePostMessageTimer(PostMessageTimer* timer) 693 void LocalDOMWindow::removePostMessageTimer(PostMessageTimer* timer)
694 { 694 {
695 m_postMessageTimers.remove(timer); 695 m_postMessageTimers.remove(timer);
696 } 696 }
697 697
698 void LocalDOMWindow::dispatchMessageEventWithOriginCheck(SecurityOrigin* intende dTargetOrigin, Event* event, std::unique_ptr<SourceLocation> location) 698 void LocalDOMWindow::dispatchMessageEventWithOriginCheck(SecurityOrigin* intende dTargetOrigin, Event* event, PassOwnPtr<SourceLocation> location)
699 { 699 {
700 if (intendedTargetOrigin) { 700 if (intendedTargetOrigin) {
701 // Check target origin now since the target document may have changed si nce the timer was scheduled. 701 // Check target origin now since the target document may have changed si nce the timer was scheduled.
702 SecurityOrigin* securityOrigin = document()->getSecurityOrigin(); 702 SecurityOrigin* securityOrigin = document()->getSecurityOrigin();
703 bool validTarget = intendedTargetOrigin->isSameSchemeHostPortAndSuborigi n(securityOrigin); 703 bool validTarget = intendedTargetOrigin->isSameSchemeHostPortAndSuborigi n(securityOrigin);
704 if (securityOrigin->hasSuborigin() && securityOrigin->suborigin()->polic yContains(Suborigin::SuboriginPolicyOptions::UnsafePostMessageReceive)) 704 if (securityOrigin->hasSuborigin() && securityOrigin->suborigin()->polic yContains(Suborigin::SuboriginPolicyOptions::UnsafePostMessageReceive))
705 validTarget = intendedTargetOrigin->isSameSchemeHostPort(securityOri gin); 705 validTarget = intendedTargetOrigin->isSameSchemeHostPort(securityOri gin);
706 706
707 if (!validTarget) { 707 if (!validTarget) {
708 String message = ExceptionMessages::failedToExecute("postMessage", " DOMWindow", "The target origin provided ('" + intendedTargetOrigin->toString() + "') does not match the recipient window's origin ('" + document()->getSecurityO rigin()->toString() + "')."); 708 String message = ExceptionMessages::failedToExecute("postMessage", " DOMWindow", "The target origin provided ('" + intendedTargetOrigin->toString() + "') does not match the recipient window's origin ('" + document()->getSecurityO rigin()->toString() + "').");
(...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after
1553 { 1553 {
1554 // If the LocalDOMWindow still has a frame reference, that frame must point 1554 // If the LocalDOMWindow still has a frame reference, that frame must point
1555 // back to this LocalDOMWindow: otherwise, it's easy to get into a situation 1555 // back to this LocalDOMWindow: otherwise, it's easy to get into a situation
1556 // where script execution leaks between different LocalDOMWindows. 1556 // where script execution leaks between different LocalDOMWindows.
1557 if (m_frameObserver->frame()) 1557 if (m_frameObserver->frame())
1558 ASSERT_WITH_SECURITY_IMPLICATION(m_frameObserver->frame()->domWindow() = = this); 1558 ASSERT_WITH_SECURITY_IMPLICATION(m_frameObserver->frame()->domWindow() = = this);
1559 return m_frameObserver->frame(); 1559 return m_frameObserver->frame();
1560 } 1560 }
1561 1561
1562 } // namespace blink 1562 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/LocalDOMWindow.h ('k') | third_party/WebKit/Source/core/frame/LocalFrame.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698