OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. |
3 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com> | 3 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com> |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * | 8 * |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 #include "platform/ContextMenu.h" | 50 #include "platform/ContextMenu.h" |
51 #include "platform/ContextMenuItem.h" | 51 #include "platform/ContextMenuItem.h" |
52 #include "platform/SharedBuffer.h" | 52 #include "platform/SharedBuffer.h" |
53 #include "platform/UserGestureIndicator.h" | 53 #include "platform/UserGestureIndicator.h" |
54 #include "platform/network/ResourceError.h" | 54 #include "platform/network/ResourceError.h" |
55 #include "platform/network/ResourceRequest.h" | 55 #include "platform/network/ResourceRequest.h" |
56 #include "platform/network/ResourceResponse.h" | 56 #include "platform/network/ResourceResponse.h" |
57 | 57 |
58 namespace blink { | 58 namespace blink { |
59 | 59 |
60 class FrontendMenuProvider FINAL : public ContextMenuProvider { | 60 class FrontendMenuProvider final : public ContextMenuProvider { |
61 public: | 61 public: |
62 static PassRefPtr<FrontendMenuProvider> create(InspectorFrontendHost* fronte
ndHost, ScriptValue frontendApiObject, const Vector<ContextMenuItem>& items) | 62 static PassRefPtr<FrontendMenuProvider> create(InspectorFrontendHost* fronte
ndHost, ScriptValue frontendApiObject, const Vector<ContextMenuItem>& items) |
63 { | 63 { |
64 return adoptRef(new FrontendMenuProvider(frontendHost, frontendApiObject
, items)); | 64 return adoptRef(new FrontendMenuProvider(frontendHost, frontendApiObject
, items)); |
65 } | 65 } |
66 | 66 |
67 void disconnect() | 67 void disconnect() |
68 { | 68 { |
69 m_frontendApiObject = ScriptValue(); | 69 m_frontendApiObject = ScriptValue(); |
70 m_frontendHost = 0; | 70 m_frontendHost = 0; |
71 } | 71 } |
72 | 72 |
73 private: | 73 private: |
74 FrontendMenuProvider(InspectorFrontendHost* frontendHost, ScriptValue fronte
ndApiObject, const Vector<ContextMenuItem>& items) | 74 FrontendMenuProvider(InspectorFrontendHost* frontendHost, ScriptValue fronte
ndApiObject, const Vector<ContextMenuItem>& items) |
75 : m_frontendHost(frontendHost) | 75 : m_frontendHost(frontendHost) |
76 , m_frontendApiObject(frontendApiObject) | 76 , m_frontendApiObject(frontendApiObject) |
77 , m_items(items) | 77 , m_items(items) |
78 { | 78 { |
79 } | 79 } |
80 | 80 |
81 virtual ~FrontendMenuProvider() | 81 virtual ~FrontendMenuProvider() |
82 { | 82 { |
83 contextMenuCleared(); | 83 contextMenuCleared(); |
84 } | 84 } |
85 | 85 |
86 virtual void populateContextMenu(ContextMenu* menu) OVERRIDE | 86 virtual void populateContextMenu(ContextMenu* menu) override |
87 { | 87 { |
88 for (size_t i = 0; i < m_items.size(); ++i) | 88 for (size_t i = 0; i < m_items.size(); ++i) |
89 menu->appendItem(m_items[i]); | 89 menu->appendItem(m_items[i]); |
90 } | 90 } |
91 | 91 |
92 virtual void contextMenuItemSelected(const ContextMenuItem* item) OVERRIDE | 92 virtual void contextMenuItemSelected(const ContextMenuItem* item) override |
93 { | 93 { |
94 if (m_frontendHost) { | 94 if (m_frontendHost) { |
95 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGes
ture); | 95 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGes
ture); |
96 int itemNumber = item->action() - ContextMenuItemBaseCustomTag; | 96 int itemNumber = item->action() - ContextMenuItemBaseCustomTag; |
97 | 97 |
98 ScriptFunctionCall function(m_frontendApiObject, "contextMenuItemSel
ected"); | 98 ScriptFunctionCall function(m_frontendApiObject, "contextMenuItemSel
ected"); |
99 function.appendArgument(itemNumber); | 99 function.appendArgument(itemNumber); |
100 function.call(); | 100 function.call(); |
101 } | 101 } |
102 } | 102 } |
103 | 103 |
104 virtual void contextMenuCleared() OVERRIDE | 104 virtual void contextMenuCleared() override |
105 { | 105 { |
106 if (m_frontendHost) { | 106 if (m_frontendHost) { |
107 ScriptFunctionCall function(m_frontendApiObject, "contextMenuCleared
"); | 107 ScriptFunctionCall function(m_frontendApiObject, "contextMenuCleared
"); |
108 function.call(); | 108 function.call(); |
109 | 109 |
110 m_frontendHost->m_menuProvider = 0; | 110 m_frontendHost->m_menuProvider = 0; |
111 } | 111 } |
112 m_items.clear(); | 112 m_items.clear(); |
113 m_frontendHost = 0; | 113 m_frontendHost = 0; |
114 } | 114 } |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 { | 258 { |
259 return m_client && m_client->isUnderTest(); | 259 return m_client && m_client->isUnderTest(); |
260 } | 260 } |
261 | 261 |
262 bool InspectorFrontendHost::isHostedMode() | 262 bool InspectorFrontendHost::isHostedMode() |
263 { | 263 { |
264 return false; | 264 return false; |
265 } | 265 } |
266 | 266 |
267 } // namespace blink | 267 } // namespace blink |
OLD | NEW |