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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 #include "platform/ContextMenuItem.h" | 48 #include "platform/ContextMenuItem.h" |
49 #include "platform/JSONValues.h" | 49 #include "platform/JSONValues.h" |
50 #include "platform/SharedBuffer.h" | 50 #include "platform/SharedBuffer.h" |
51 #include "platform/UserGestureIndicator.h" | 51 #include "platform/UserGestureIndicator.h" |
52 #include "platform/network/ResourceError.h" | 52 #include "platform/network/ResourceError.h" |
53 #include "platform/network/ResourceRequest.h" | 53 #include "platform/network/ResourceRequest.h" |
54 #include "platform/network/ResourceResponse.h" | 54 #include "platform/network/ResourceResponse.h" |
55 | 55 |
56 namespace WebCore { | 56 namespace WebCore { |
57 | 57 |
58 class FrontendMenuProvider : public ContextMenuProvider { | 58 class FrontendMenuProvider FINAL : public ContextMenuProvider { |
59 public: | 59 public: |
60 static PassRefPtr<FrontendMenuProvider> create(InspectorFrontendHost* fronte
ndHost, ScriptObject frontendApiObject, const Vector<ContextMenuItem>& items) | 60 static PassRefPtr<FrontendMenuProvider> create(InspectorFrontendHost* fronte
ndHost, ScriptObject frontendApiObject, const Vector<ContextMenuItem>& items) |
61 { | 61 { |
62 return adoptRef(new FrontendMenuProvider(frontendHost, frontendApiObject
, items)); | 62 return adoptRef(new FrontendMenuProvider(frontendHost, frontendApiObject
, items)); |
63 } | 63 } |
64 | 64 |
65 void disconnect() | 65 void disconnect() |
66 { | 66 { |
67 m_frontendApiObject = ScriptObject(); | 67 m_frontendApiObject = ScriptObject(); |
68 m_frontendHost = 0; | 68 m_frontendHost = 0; |
69 } | 69 } |
70 | 70 |
71 private: | 71 private: |
72 FrontendMenuProvider(InspectorFrontendHost* frontendHost, ScriptObject front
endApiObject, const Vector<ContextMenuItem>& items) | 72 FrontendMenuProvider(InspectorFrontendHost* frontendHost, ScriptObject front
endApiObject, const Vector<ContextMenuItem>& items) |
73 : m_frontendHost(frontendHost) | 73 : m_frontendHost(frontendHost) |
74 , m_frontendApiObject(frontendApiObject) | 74 , m_frontendApiObject(frontendApiObject) |
75 , m_items(items) | 75 , m_items(items) |
76 { | 76 { |
77 } | 77 } |
78 | 78 |
79 virtual ~FrontendMenuProvider() | 79 virtual ~FrontendMenuProvider() |
80 { | 80 { |
81 contextMenuCleared(); | 81 contextMenuCleared(); |
82 } | 82 } |
83 | 83 |
84 virtual void populateContextMenu(ContextMenu* menu) | 84 virtual void populateContextMenu(ContextMenu* menu) OVERRIDE |
85 { | 85 { |
86 for (size_t i = 0; i < m_items.size(); ++i) | 86 for (size_t i = 0; i < m_items.size(); ++i) |
87 menu->appendItem(m_items[i]); | 87 menu->appendItem(m_items[i]); |
88 } | 88 } |
89 | 89 |
90 virtual void contextMenuItemSelected(const ContextMenuItem* item) | 90 virtual void contextMenuItemSelected(const ContextMenuItem* item) OVERRIDE |
91 { | 91 { |
92 if (m_frontendHost) { | 92 if (m_frontendHost) { |
93 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGes
ture); | 93 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGes
ture); |
94 int itemNumber = item->action() - ContextMenuItemBaseCustomTag; | 94 int itemNumber = item->action() - ContextMenuItemBaseCustomTag; |
95 | 95 |
96 ScriptFunctionCall function(m_frontendApiObject, "contextMenuItemSel
ected"); | 96 ScriptFunctionCall function(m_frontendApiObject, "contextMenuItemSel
ected"); |
97 function.appendArgument(itemNumber); | 97 function.appendArgument(itemNumber); |
98 function.call(); | 98 function.call(); |
99 } | 99 } |
100 } | 100 } |
101 | 101 |
102 virtual void contextMenuCleared() | 102 virtual void contextMenuCleared() OVERRIDE |
103 { | 103 { |
104 if (m_frontendHost) { | 104 if (m_frontendHost) { |
105 ScriptFunctionCall function(m_frontendApiObject, "contextMenuCleared
"); | 105 ScriptFunctionCall function(m_frontendApiObject, "contextMenuCleared
"); |
106 function.call(); | 106 function.call(); |
107 | 107 |
108 m_frontendHost->m_menuProvider = 0; | 108 m_frontendHost->m_menuProvider = 0; |
109 } | 109 } |
110 m_items.clear(); | 110 m_items.clear(); |
111 } | 111 } |
112 | 112 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 params->pushString(domFileSystem->rootURL().string()); | 216 params->pushString(domFileSystem->rootURL().string()); |
217 sendMessageToEmbedder(message->toJSONString()); | 217 sendMessageToEmbedder(message->toJSONString()); |
218 } | 218 } |
219 | 219 |
220 bool InspectorFrontendHost::isUnderTest() | 220 bool InspectorFrontendHost::isUnderTest() |
221 { | 221 { |
222 return m_client && m_client->isUnderTest(); | 222 return m_client && m_client->isUnderTest(); |
223 } | 223 } |
224 | 224 |
225 } // namespace WebCore | 225 } // namespace WebCore |
OLD | NEW |