Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2010 Apple Inc. All rights reserved. |
|
Rick Byers
2016/10/17 17:02:46
New files should get the new license: https://www.
Nate Chapin
2016/10/18 23:26:33
Done.
| |
| 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 |
| 11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
| 12 * | 12 * |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' | 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' |
| 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
| 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS |
| 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
| 23 * THE POSSIBILITY OF SUCH DAMAGE. | 23 * THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "platform/ContextMenu.h" | 26 #ifndef DocumentUserGestureToken_h |
| 27 #define DocumentUserGestureToken_h | |
| 28 | |
| 29 #include "core/dom/Document.h" | |
| 30 #include "platform/UserGestureIndicator.h" | |
| 27 | 31 |
| 28 namespace blink { | 32 namespace blink { |
| 29 | 33 |
| 30 static const ContextMenuItem* findItemWithAction( | 34 class DocumentUserGestureToken final : public UserGestureToken { |
|
Rick Byers
2016/10/17 17:02:46
Add a short comment describing the purpose of the
Nate Chapin
2016/10/18 23:26:33
Done.
| |
| 31 unsigned action, | 35 WTF_MAKE_NONCOPYABLE(DocumentUserGestureToken); |
| 32 const Vector<ContextMenuItem>& items) { | 36 |
| 33 for (size_t i = 0; i < items.size(); ++i) { | 37 public: |
| 34 const ContextMenuItem& item = items[i]; | 38 static PassRefPtr<UserGestureToken> create( |
| 35 if (item.action() == static_cast<ContextMenuAction>(action)) | 39 Document* document, |
| 36 return &item; | 40 Status status = PossiblyExistingGesture) { |
| 37 if (item.type() != SubmenuType) | 41 return adoptRef(new DocumentUserGestureToken(document, status)); |
| 38 continue; | |
| 39 if (const ContextMenuItem* subMenuItem = | |
| 40 findItemWithAction(action, item.subMenuItems())) | |
| 41 return subMenuItem; | |
| 42 } | 42 } |
| 43 | 43 |
| 44 return 0; | 44 ~DocumentUserGestureToken() final {} |
| 45 } | |
| 46 | 45 |
| 47 const ContextMenuItem* ContextMenu::itemWithAction(unsigned action) const { | 46 private: |
| 48 return findItemWithAction(action, m_items); | 47 DocumentUserGestureToken(Document* document, Status status) |
| 49 } | 48 : UserGestureToken(status) { |
| 49 if (document) | |
| 50 document->setHasReceivedUserGesture(); | |
| 51 } | |
| 52 }; | |
| 50 | 53 |
| 51 } // namespace blink | 54 } // namespace blink |
| 55 | |
| 56 #endif // DocumentUserGestureToken_h | |
| OLD | NEW |