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

Side by Side Diff: Source/web/WebDevToolsFrontendImpl.cpp

Issue 900543003: DevTools: do not abuse inspector controller for the front-end side plumbing. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed initializer. Created 5 years, 10 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
« no previous file with comments | « Source/web/WebDevToolsFrontendImpl.h ('k') | Source/web/WebLocalFrameImpl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 17 matching lines...) Expand all
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "web/WebDevToolsFrontendImpl.h" 32 #include "web/WebDevToolsFrontendImpl.h"
33 33
34 #include "bindings/core/v8/ScriptController.h" 34 #include "bindings/core/v8/ScriptController.h"
35 #include "bindings/core/v8/V8DevToolsHost.h" 35 #include "bindings/core/v8/V8DevToolsHost.h"
36 #include "core/frame/LocalFrame.h" 36 #include "core/frame/LocalFrame.h"
37 #include "core/inspector/DevToolsHost.h" 37 #include "core/inspector/DevToolsHost.h"
38 #include "core/inspector/InspectorController.h"
39 #include "core/page/Page.h"
40 #include "public/platform/WebString.h" 38 #include "public/platform/WebString.h"
41 #include "public/web/WebDevToolsFrontendClient.h" 39 #include "public/web/WebDevToolsFrontendClient.h"
40 #include "public/web/WebSecurityOrigin.h"
41 #include "web/WebLocalFrameImpl.h"
42 #include "web/WebViewImpl.h" 42 #include "web/WebViewImpl.h"
43 43
44 namespace blink { 44 namespace blink {
45 45
46 WebDevToolsFrontend* WebDevToolsFrontend::create( 46 WebDevToolsFrontend* WebDevToolsFrontend::create(
47 WebView* view, 47 WebView* view,
48 WebDevToolsFrontendClient* client, 48 WebDevToolsFrontendClient* client,
49 const WebString& applicationLocale) 49 const WebString& applicationLocale)
50 { 50 {
51 return new WebDevToolsFrontendImpl(toWebViewImpl(view), client); 51 return new WebDevToolsFrontendImpl(toWebLocalFrameImpl(view->mainFrame()), c lient);
52 }
53
54 WebDevToolsFrontend* WebDevToolsFrontend::create(
55 WebLocalFrame* frame,
56 WebDevToolsFrontendClient* client,
57 const WebString& applicationLocale)
58 {
59 return new WebDevToolsFrontendImpl(toWebLocalFrameImpl(frame), client);
52 } 60 }
53 61
54 WebDevToolsFrontendImpl::WebDevToolsFrontendImpl( 62 WebDevToolsFrontendImpl::WebDevToolsFrontendImpl(
55 WebViewImpl* webViewImpl, 63 WebLocalFrameImpl* webFrame,
56 WebDevToolsFrontendClient* client) 64 WebDevToolsFrontendClient* client)
57 : m_webViewImpl(webViewImpl) 65 : m_webFrame(webFrame)
58 , m_client(client) 66 , m_client(client)
59 { 67 {
60 m_webViewImpl->page()->inspectorController().setInspectorFrontendClient(this ); 68 m_webFrame->setDevToolsFrontend(this);
61 } 69 }
62 70
63 WebDevToolsFrontendImpl::~WebDevToolsFrontendImpl() 71 WebDevToolsFrontendImpl::~WebDevToolsFrontendImpl()
64 { 72 {
65 ASSERT(!m_devtoolsHost); 73 ASSERT(!m_devtoolsHost);
66 } 74 }
67 75
68 void WebDevToolsFrontendImpl::dispose() 76 void WebDevToolsFrontendImpl::didClearWindowObject(WebLocalFrameImpl* frame)
69 { 77 {
70 if (m_devtoolsHost) { 78 if (m_webFrame == frame) {
71 m_devtoolsHost->disconnectClient(); 79 v8::Isolate* isolate = v8::Isolate::GetCurrent();
72 m_devtoolsHost = nullptr; 80 ScriptState* scriptState = ScriptState::forMainWorld(m_webFrame->frame() );
81 ScriptState::Scope scope(scriptState);
82
83 if (m_devtoolsHost)
84 m_devtoolsHost->disconnectClient();
85 m_devtoolsHost = DevToolsHost::create(this, m_webFrame->frame());
86 v8::Handle<v8::Object> global = scriptState->context()->Global();
87 v8::Handle<v8::Value> devtoolsHostObj = toV8(m_devtoolsHost.get(), globa l, scriptState->isolate());
88 global->Set(v8::String::NewFromUtf8(isolate, "DevToolsHost"), devtoolsHo stObj);
73 } 89 }
74 m_client = 0;
75 }
76 90
77 void WebDevToolsFrontendImpl::windowObjectCleared() 91 if (m_injectedScriptForOrigin.isEmpty())
78 { 92 return;
79 v8::Isolate* isolate = v8::Isolate::GetCurrent();
80 Page* page = m_webViewImpl->page();
81 ASSERT(page->mainFrame());
82 ScriptState* scriptState = ScriptState::forMainWorld(page->deprecatedLocalMa inFrame());
83 ScriptState::Scope scope(scriptState);
84 93
85 if (m_devtoolsHost) 94 String origin = frame->securityOrigin().toString();
86 m_devtoolsHost->disconnectClient(); 95 String script = m_injectedScriptForOrigin.get(origin);
87 m_devtoolsHost = DevToolsHost::create(this, page); 96 if (!script.isEmpty())
88 v8::Handle<v8::Object> global = scriptState->context()->Global(); 97 frame->frame()->script().executeScriptInMainWorld(script + "()");
89 v8::Handle<v8::Value> devtoolsHostObj = toV8(m_devtoolsHost.get(), global, s criptState->isolate());
90 global->Set(v8::String::NewFromUtf8(isolate, "DevToolsHost"), devtoolsHostOb j);
91 } 98 }
92 99
93 void WebDevToolsFrontendImpl::sendMessageToBackend(const String& message) 100 void WebDevToolsFrontendImpl::sendMessageToBackend(const String& message)
94 { 101 {
95 if (m_client) 102 if (m_client)
96 m_client->sendMessageToBackend(message); 103 m_client->sendMessageToBackend(message);
97 } 104 }
98 105
99 void WebDevToolsFrontendImpl::sendMessageToEmbedder(const String& message) 106 void WebDevToolsFrontendImpl::sendMessageToEmbedder(const String& message)
100 { 107 {
101 if (m_client) 108 if (m_client)
102 m_client->sendMessageToEmbedder(message); 109 m_client->sendMessageToEmbedder(message);
103 } 110 }
104 111
105 bool WebDevToolsFrontendImpl::isUnderTest() 112 bool WebDevToolsFrontendImpl::isUnderTest()
106 { 113 {
107 return m_client ? m_client->isUnderTest() : false; 114 return m_client ? m_client->isUnderTest() : false;
108 } 115 }
109 116
117 void WebDevToolsFrontendImpl::showContextMenu(LocalFrame* targetFrame, float x, float y, PassRefPtrWillBeRawPtr<ContextMenuProvider> menuProvider)
118 {
119 WebLocalFrameImpl::fromFrame(targetFrame)->viewImpl()->showContextMenuAtPoin t(x, y, menuProvider);
120 }
121
122 void WebDevToolsFrontendImpl::setInjectedScriptForOrigin(const String& origin, c onst String& source)
123 {
124 m_injectedScriptForOrigin.set(origin, source);
125 }
126
110 } // namespace blink 127 } // namespace blink
OLDNEW
« no previous file with comments | « Source/web/WebDevToolsFrontendImpl.h ('k') | Source/web/WebLocalFrameImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698