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

Side by Side Diff: third_party/WebKit/Source/core/dom/DocumentUserGestureToken.h

Issue 2408333004: Move persistent gesture state to Document, add DocumentUserGestureToken (Closed)
Patch Set: Re-add dropped null check Created 4 years, 1 month 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef DocumentUserGestureToken_h
6 #define DocumentUserGestureToken_h
7
8 #include "core/dom/Document.h"
9 #include "core/frame/LocalFrame.h"
10 #include "platform/UserGestureIndicator.h"
11
12 namespace blink {
13
14 // Associates a UserGestureToken with a Document, if a non-null Document*
15 // is provided in the constructor.
16 class DocumentUserGestureToken final : public UserGestureToken {
17 WTF_MAKE_NONCOPYABLE(DocumentUserGestureToken);
18
19 public:
20 static PassRefPtr<UserGestureToken> create(
21 Document* document,
22 Status status = PossiblyExistingGesture) {
23 return adoptRef(new DocumentUserGestureToken(document, status));
24 }
25
26 ~DocumentUserGestureToken() final {}
27
28 private:
29 DocumentUserGestureToken(Document* document, Status status)
30 : UserGestureToken(status) {
31 if (!document)
32 return;
33 document->setHasReceivedUserGesture();
34 for (Frame* frame = document->frame()->tree().parent(); frame;
35 frame = frame->tree().parent()) {
36 // TODO(japhet): Make this work for RemoteFrames: http://crbug.com/658800
37 if (frame->isLocalFrame())
38 toLocalFrame(frame)->document()->setHasReceivedUserGesture();
39 }
40 }
41 };
42
43 } // namespace blink
44
45 #endif // DocumentUserGestureToken_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Document.cpp ('k') | third_party/WebKit/Source/core/dom/DocumentUserGestureTokenTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698