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

Side by Side Diff: Source/core/inspector/InspectorFrontendHost.cpp

Issue 293963003: Remove ScriptObject (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 7 months 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 | Annotate | Revision Log
OLDNEW
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 13 matching lines...) Expand all
24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */ 28 */
29 29
30 #include "config.h" 30 #include "config.h"
31 #include "core/inspector/InspectorFrontendHost.h" 31 #include "core/inspector/InspectorFrontendHost.h"
32 32
33 #include "bindings/v8/ScriptFunctionCall.h" 33 #include "bindings/v8/ScriptFunctionCall.h"
34 #include "bindings/v8/ScriptObject.h"
34 #include "bindings/v8/ScriptState.h" 35 #include "bindings/v8/ScriptState.h"
35 #include "core/clipboard/Pasteboard.h" 36 #include "core/clipboard/Pasteboard.h"
36 #include "core/fetch/ResourceFetcher.h" 37 #include "core/fetch/ResourceFetcher.h"
37 #include "core/frame/LocalFrame.h" 38 #include "core/frame/LocalFrame.h"
38 #include "core/html/parser/TextResourceDecoder.h" 39 #include "core/html/parser/TextResourceDecoder.h"
39 #include "core/inspector/InspectorController.h" 40 #include "core/inspector/InspectorController.h"
40 #include "core/inspector/InspectorFrontendClient.h" 41 #include "core/inspector/InspectorFrontendClient.h"
41 #include "core/loader/FrameLoader.h" 42 #include "core/loader/FrameLoader.h"
42 #include "core/page/ContextMenuController.h" 43 #include "core/page/ContextMenuController.h"
43 #include "core/page/ContextMenuProvider.h" 44 #include "core/page/ContextMenuProvider.h"
44 #include "core/page/Page.h" 45 #include "core/page/Page.h"
45 #include "core/rendering/RenderTheme.h" 46 #include "core/rendering/RenderTheme.h"
46 #include "platform/ContextMenu.h" 47 #include "platform/ContextMenu.h"
47 #include "platform/ContextMenuItem.h" 48 #include "platform/ContextMenuItem.h"
48 #include "platform/SharedBuffer.h" 49 #include "platform/SharedBuffer.h"
49 #include "platform/UserGestureIndicator.h" 50 #include "platform/UserGestureIndicator.h"
50 #include "platform/network/ResourceError.h" 51 #include "platform/network/ResourceError.h"
51 #include "platform/network/ResourceRequest.h" 52 #include "platform/network/ResourceRequest.h"
52 #include "platform/network/ResourceResponse.h" 53 #include "platform/network/ResourceResponse.h"
53 54
54 namespace WebCore { 55 namespace WebCore {
55 56
56 class FrontendMenuProvider FINAL : public ContextMenuProvider { 57 class FrontendMenuProvider FINAL : public ContextMenuProvider {
57 public: 58 public:
58 static PassRefPtr<FrontendMenuProvider> create(InspectorFrontendHost* fronte ndHost, ScriptObject frontendApiObject, const Vector<ContextMenuItem>& items) 59 static PassRefPtr<FrontendMenuProvider> create(InspectorFrontendHost* fronte ndHost, ScriptValue frontendApiObject, const Vector<ContextMenuItem>& items)
59 { 60 {
60 return adoptRef(new FrontendMenuProvider(frontendHost, frontendApiObject , items)); 61 return adoptRef(new FrontendMenuProvider(frontendHost, frontendApiObject , items));
61 } 62 }
62 63
63 void disconnect() 64 void disconnect()
64 { 65 {
65 m_frontendApiObject = ScriptObject(); 66 m_frontendApiObject = ScriptValue();
66 m_frontendHost = 0; 67 m_frontendHost = 0;
67 } 68 }
68 69
69 private: 70 private:
70 FrontendMenuProvider(InspectorFrontendHost* frontendHost, ScriptObject front endApiObject, const Vector<ContextMenuItem>& items) 71 FrontendMenuProvider(InspectorFrontendHost* frontendHost, ScriptValue fronte ndApiObject, const Vector<ContextMenuItem>& items)
71 : m_frontendHost(frontendHost) 72 : m_frontendHost(frontendHost)
72 , m_frontendApiObject(frontendApiObject) 73 , m_frontendApiObject(frontendApiObject)
73 , m_items(items) 74 , m_items(items)
74 { 75 {
75 } 76 }
76 77
77 virtual ~FrontendMenuProvider() 78 virtual ~FrontendMenuProvider()
78 { 79 {
79 contextMenuCleared(); 80 contextMenuCleared();
80 } 81 }
(...skipping 21 matching lines...) Expand all
102 if (m_frontendHost) { 103 if (m_frontendHost) {
103 ScriptFunctionCall function(m_frontendApiObject, "contextMenuCleared "); 104 ScriptFunctionCall function(m_frontendApiObject, "contextMenuCleared ");
104 function.call(); 105 function.call();
105 106
106 m_frontendHost->m_menuProvider = 0; 107 m_frontendHost->m_menuProvider = 0;
107 } 108 }
108 m_items.clear(); 109 m_items.clear();
109 } 110 }
110 111
111 InspectorFrontendHost* m_frontendHost; 112 InspectorFrontendHost* m_frontendHost;
112 ScriptObject m_frontendApiObject; 113 ScriptValue m_frontendApiObject;
113 Vector<ContextMenuItem> m_items; 114 Vector<ContextMenuItem> m_items;
114 }; 115 };
115 116
116 InspectorFrontendHost::InspectorFrontendHost(InspectorFrontendClient* client, Pa ge* frontendPage) 117 InspectorFrontendHost::InspectorFrontendHost(InspectorFrontendClient* client, Pa ge* frontendPage)
117 : m_client(client) 118 : m_client(client)
118 , m_frontendPage(frontendPage) 119 , m_frontendPage(frontendPage)
119 , m_menuProvider(0) 120 , m_menuProvider(0)
120 { 121 {
121 ScriptWrappable::init(this); 122 ScriptWrappable::init(this);
122 } 123 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 m_client->sendMessageToEmbedder(escapeUnicodeNonCharacters(message)); 184 m_client->sendMessageToEmbedder(escapeUnicodeNonCharacters(message));
184 } 185 }
185 186
186 void InspectorFrontendHost::showContextMenu(Event* event, const Vector<ContextMe nuItem>& items) 187 void InspectorFrontendHost::showContextMenu(Event* event, const Vector<ContextMe nuItem>& items)
187 { 188 {
188 if (!event) 189 if (!event)
189 return; 190 return;
190 191
191 ASSERT(m_frontendPage); 192 ASSERT(m_frontendPage);
192 ScriptState* frontendScriptState = ScriptState::forMainWorld(m_frontendPage- >mainFrame()); 193 ScriptState* frontendScriptState = ScriptState::forMainWorld(m_frontendPage- >mainFrame());
193 ScriptObject frontendApiObject; 194 ScriptValue frontendApiObject;
194 if (!ScriptGlobalObject::get(frontendScriptState, "InspectorFrontendAPI", fr ontendApiObject)) { 195 if (!ScriptGlobalObject::get(frontendScriptState, "InspectorFrontendAPI", fr ontendApiObject)) {
195 ASSERT_NOT_REACHED(); 196 ASSERT_NOT_REACHED();
196 return; 197 return;
197 } 198 }
198 RefPtr<FrontendMenuProvider> menuProvider = FrontendMenuProvider::create(thi s, frontendApiObject, items); 199 RefPtr<FrontendMenuProvider> menuProvider = FrontendMenuProvider::create(thi s, frontendApiObject, items);
199 m_frontendPage->contextMenuController().showContextMenu(event, menuProvider) ; 200 m_frontendPage->contextMenuController().showContextMenu(event, menuProvider) ;
200 m_menuProvider = menuProvider.get(); 201 m_menuProvider = menuProvider.get();
201 } 202 }
202 203
203 String InspectorFrontendHost::getSelectionBackgroundColor() 204 String InspectorFrontendHost::getSelectionBackgroundColor()
204 { 205 {
205 return RenderTheme::theme().activeSelectionBackgroundColor().serialized(); 206 return RenderTheme::theme().activeSelectionBackgroundColor().serialized();
206 } 207 }
207 208
208 String InspectorFrontendHost::getSelectionForegroundColor() 209 String InspectorFrontendHost::getSelectionForegroundColor()
209 { 210 {
210 return RenderTheme::theme().activeSelectionForegroundColor().serialized(); 211 return RenderTheme::theme().activeSelectionForegroundColor().serialized();
211 } 212 }
212 213
213 bool InspectorFrontendHost::isUnderTest() 214 bool InspectorFrontendHost::isUnderTest()
214 { 215 {
215 return m_client && m_client->isUnderTest(); 216 return m_client && m_client->isUnderTest();
216 } 217 }
217 218
218 } // namespace WebCore 219 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/inspector/InspectorDebuggerAgent.cpp ('k') | Source/core/inspector/InspectorHeapProfilerAgent.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698