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 18 matching lines...) Expand all Loading... | |
29 if (!token || !token->hasGestures()) | 29 if (!token || !token->hasGestures()) |
30 return nullptr; | 30 return nullptr; |
31 setHasReceivedUserGesture(document); | 31 setHasReceivedUserGesture(document); |
32 return token; | 32 return token; |
33 } | 33 } |
34 | 34 |
35 private: | 35 private: |
36 DocumentUserGestureToken(Status status) : UserGestureToken(status) {} | 36 DocumentUserGestureToken(Status status) : UserGestureToken(status) {} |
37 | 37 |
38 static void setHasReceivedUserGesture(Document* document) { | 38 static void setHasReceivedUserGesture(Document* document) { |
39 if (!document || document->hasReceivedUserGesture()) | 39 if (!document || !document->frame() || |
40 document->frame()->hasReceivedUserGesture()) { | |
40 return; | 41 return; |
41 document->setHasReceivedUserGesture(); | 42 } |
43 | |
44 document->frame()->setDocumentHasReceivedUserGesture(); | |
dcheng
2017/01/12 10:41:00
Nit: perhaps remove 'document' from the name, sinc
| |
42 for (Frame* frame = document->frame()->tree().parent(); frame; | 45 for (Frame* frame = document->frame()->tree().parent(); frame; |
43 frame = frame->tree().parent()) { | 46 frame = frame->tree().parent()) { |
44 frame->setDocumentHasReceivedUserGesture(); | 47 frame->setDocumentHasReceivedUserGesture(); |
45 } | 48 } |
46 } | 49 } |
47 }; | 50 }; |
48 | 51 |
49 } // namespace blink | 52 } // namespace blink |
50 | 53 |
51 #endif // DocumentUserGestureToken_h | 54 #endif // DocumentUserGestureToken_h |
OLD | NEW |