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

Side by Side Diff: Source/platform/UserGestureIndicator.h

Issue 82693006: Adding handlers for user gesture callbacks. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Simplified handler implementation and added unit test Created 7 years 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) 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2010 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 24 matching lines...) Expand all
35 35
36 class UserGestureIndicator; 36 class UserGestureIndicator;
37 37
38 enum ProcessingUserGestureState { 38 enum ProcessingUserGestureState {
39 DefinitelyProcessingNewUserGesture, 39 DefinitelyProcessingNewUserGesture,
40 DefinitelyProcessingUserGesture, 40 DefinitelyProcessingUserGesture,
41 PossiblyProcessingUserGesture, 41 PossiblyProcessingUserGesture,
42 DefinitelyNotProcessingUserGesture 42 DefinitelyNotProcessingUserGesture
43 }; 43 };
44 44
45 class UserGestureHandler {
46 public:
47 virtual ~UserGestureHandler() { }
48 virtual void onGesture() = 0;
49 };
50
45 class PLATFORM_EXPORT UserGestureToken : public RefCounted<UserGestureToken> { 51 class PLATFORM_EXPORT UserGestureToken : public RefCounted<UserGestureToken> {
46 public: 52 public:
47 virtual ~UserGestureToken() { } 53 virtual ~UserGestureToken() { }
48 virtual bool hasGestures() const = 0; 54 virtual bool hasGestures() const = 0;
49 virtual void setOutOfProcess() = 0; 55 virtual void setOutOfProcess() = 0;
50 virtual void setJavascriptPrompt() = 0; 56 virtual void setJavascriptPrompt() = 0;
51 }; 57 };
52 58
53 class PLATFORM_EXPORT UserGestureIndicatorDisabler { 59 class PLATFORM_EXPORT UserGestureIndicatorDisabler {
54 WTF_MAKE_NONCOPYABLE(UserGestureIndicatorDisabler); 60 WTF_MAKE_NONCOPYABLE(UserGestureIndicatorDisabler);
55 public: 61 public:
56 UserGestureIndicatorDisabler(); 62 UserGestureIndicatorDisabler();
57 ~UserGestureIndicatorDisabler(); 63 ~UserGestureIndicatorDisabler();
58 64
59 private: 65 private:
60 ProcessingUserGestureState m_savedState; 66 ProcessingUserGestureState m_savedState;
61 UserGestureIndicator* m_savedIndicator; 67 UserGestureIndicator* m_savedIndicator;
62 }; 68 };
63 69
64 class PLATFORM_EXPORT UserGestureIndicator { 70 class PLATFORM_EXPORT UserGestureIndicator {
65 WTF_MAKE_NONCOPYABLE(UserGestureIndicator); 71 WTF_MAKE_NONCOPYABLE(UserGestureIndicator);
66 friend class UserGestureIndicatorDisabler; 72 friend class UserGestureIndicatorDisabler;
67 public: 73 public:
68 static bool processingUserGesture(); 74 static bool processingUserGesture();
69 static bool consumeUserGesture(); 75 static bool consumeUserGesture();
70 static UserGestureToken* currentToken(); 76 static UserGestureToken* currentToken();
77 static void setHandler(UserGestureHandler*);
71 78
72 explicit UserGestureIndicator(ProcessingUserGestureState); 79 explicit UserGestureIndicator(ProcessingUserGestureState);
73 explicit UserGestureIndicator(PassRefPtr<UserGestureToken>); 80 explicit UserGestureIndicator(PassRefPtr<UserGestureToken>);
74 ~UserGestureIndicator(); 81 ~UserGestureIndicator();
75 82
76 83
77 private: 84 private:
78 static ProcessingUserGestureState s_state; 85 static ProcessingUserGestureState s_state;
79 static UserGestureIndicator* s_topmostIndicator; 86 static UserGestureIndicator* s_topmostIndicator;
87 static UserGestureHandler* s_handler;
80 ProcessingUserGestureState m_previousState; 88 ProcessingUserGestureState m_previousState;
81 RefPtr<UserGestureToken> m_token; 89 RefPtr<UserGestureToken> m_token;
82 }; 90 };
83 91
84 } 92 }
85 93
86 #endif 94 #endif
OLDNEW
« no previous file with comments | « no previous file | Source/platform/UserGestureIndicator.cpp » ('j') | Source/platform/UserGestureIndicator.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698