| OLD | NEW |
| 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 double m_timestamp; | 87 double m_timestamp; |
| 88 TimeoutPolicy m_timeoutPolicy; | 88 TimeoutPolicy m_timeoutPolicy; |
| 89 UserGestureUtilizedCallback* m_usageCallback; | 89 UserGestureUtilizedCallback* m_usageCallback; |
| 90 }; | 90 }; |
| 91 | 91 |
| 92 class PLATFORM_EXPORT UserGestureIndicator final { | 92 class PLATFORM_EXPORT UserGestureIndicator final { |
| 93 USING_FAST_MALLOC(UserGestureIndicator); | 93 USING_FAST_MALLOC(UserGestureIndicator); |
| 94 WTF_MAKE_NONCOPYABLE(UserGestureIndicator); | 94 WTF_MAKE_NONCOPYABLE(UserGestureIndicator); |
| 95 | 95 |
| 96 public: | 96 public: |
| 97 // Note: All *ThreadSafe methods are safe to call from any thread. Their |
| 98 // non-suffixed counterparts *must* be called on the main thread. Consider |
| 99 // always using the non-suffixed one unless the code really |
| 100 // needs to be thread-safe |
| 101 |
| 97 // Returns whether a user gesture is currently in progress. | 102 // Returns whether a user gesture is currently in progress. |
| 98 // Does not invoke the UserGestureUtilizedCallback. Consider calling | 103 // Does not invoke the UserGestureUtilizedCallback. Consider calling |
| 99 // utilizeUserGesture instead if you know for sure that the return value | 104 // utilizeUserGesture instead if you know for sure that the return value |
| 100 // will have an effect. | 105 // will have an effect. |
| 101 static bool processingUserGesture(); | 106 static bool processingUserGesture(); |
| 107 static bool processingUserGestureThreadSafe(); |
| 102 | 108 |
| 103 // Indicates that a user gesture (if any) is being used, without preventing it | 109 // Indicates that a user gesture (if any) is being used, without preventing it |
| 104 // from being used again. Returns whether a user gesture is currently in | 110 // from being used again. Returns whether a user gesture is currently in |
| 105 // progress. If true, invokes (and then clears) any | 111 // progress. If true, invokes (and then clears) any |
| 106 // UserGestureUtilizedCallback. | 112 // UserGestureUtilizedCallback. |
| 107 static bool utilizeUserGesture(); | 113 static bool utilizeUserGesture(); |
| 108 | 114 |
| 109 // Mark the current user gesture (if any) as having been used, such that | 115 // Mark the current user gesture (if any) as having been used, such that |
| 110 // it cannot be used again. This is done only for very security-sensitive | 116 // it cannot be used again. This is done only for very security-sensitive |
| 111 // operations like creating a new process. | 117 // operations like creating a new process. |
| 112 // Like utilizeUserGesture, may invoke/clear any UserGestureUtilizedCallback. | 118 // Like utilizeUserGesture, may invoke/clear any UserGestureUtilizedCallback. |
| 113 static bool consumeUserGesture(); | 119 static bool consumeUserGesture(); |
| 120 static bool consumeUserGestureThreadSafe(); |
| 114 | 121 |
| 115 static UserGestureToken* currentToken(); | 122 static UserGestureToken* currentToken(); |
| 123 static UserGestureToken* currentTokenThreadSafe(); |
| 116 | 124 |
| 117 explicit UserGestureIndicator(PassRefPtr<UserGestureToken>); | 125 explicit UserGestureIndicator(PassRefPtr<UserGestureToken>); |
| 118 ~UserGestureIndicator(); | 126 ~UserGestureIndicator(); |
| 119 | 127 |
| 120 private: | 128 private: |
| 121 static UserGestureToken* s_rootToken; | 129 static UserGestureToken* s_rootToken; |
| 122 | 130 |
| 123 RefPtr<UserGestureToken> m_token; | 131 RefPtr<UserGestureToken> m_token; |
| 124 }; | 132 }; |
| 125 | 133 |
| 126 } // namespace blink | 134 } // namespace blink |
| 127 | 135 |
| 128 #endif | 136 #endif |
| OLD | NEW |