OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 DocumentUserGestureToken_h | 5 #ifndef DocumentUserGestureToken_h |
6 #define DocumentUserGestureToken_h | 6 #define DocumentUserGestureToken_h |
7 | 7 |
8 #include "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
9 #include "core/frame/LocalFrame.h" | 9 #include "core/frame/LocalFrame.h" |
10 #include "platform/UserGestureIndicator.h" | 10 #include "platform/UserGestureIndicator.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 Document* document, | 21 Document* document, |
22 Status status = PossiblyExistingGesture) { | 22 Status status = PossiblyExistingGesture) { |
23 return adoptRef(new DocumentUserGestureToken(document, status)); | 23 return adoptRef(new DocumentUserGestureToken(document, status)); |
24 } | 24 } |
25 | 25 |
26 ~DocumentUserGestureToken() final {} | 26 ~DocumentUserGestureToken() final {} |
27 | 27 |
28 private: | 28 private: |
29 DocumentUserGestureToken(Document* document, Status status) | 29 DocumentUserGestureToken(Document* document, Status status) |
30 : UserGestureToken(status) { | 30 : UserGestureToken(status) { |
31 if (!document) | 31 if (!document || document->hasReceivedUserGesture()) |
32 return; | 32 return; |
33 document->setHasReceivedUserGesture(); | 33 document->setHasReceivedUserGesture(); |
34 for (Frame* frame = document->frame()->tree().parent(); frame; | 34 for (Frame* frame = document->frame()->tree().parent(); frame; |
35 frame = frame->tree().parent()) { | 35 frame = frame->tree().parent()) { |
36 // TODO(japhet): Make this work for RemoteFrames: http://crbug.com/658800 | 36 frame->setDocumentHasReceivedUserGesture(); |
37 if (frame->isLocalFrame()) | |
38 toLocalFrame(frame)->document()->setHasReceivedUserGesture(); | |
39 } | 37 } |
40 } | 38 } |
41 }; | 39 }; |
42 | 40 |
43 } // namespace blink | 41 } // namespace blink |
44 | 42 |
45 #endif // DocumentUserGestureToken_h | 43 #endif // DocumentUserGestureToken_h |
OLD | NEW |