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

Unified Diff: Source/web/InspectorFrontendClientImpl.cpp

Issue 23289002: Introduce InspectorFrontendHost.sendMessageToFrontendHost. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: Source/web/InspectorFrontendClientImpl.cpp
diff --git a/Source/web/InspectorFrontendClientImpl.cpp b/Source/web/InspectorFrontendClientImpl.cpp
index c5ebdab8cd9228fbc98b564c8ff0f7f484c8d0a6..21076b4e13587d8e7598e6a9e7a1a25c15eeeb72 100644
--- a/Source/web/InspectorFrontendClientImpl.cpp
+++ b/Source/web/InspectorFrontendClientImpl.cpp
@@ -74,6 +74,27 @@ void InspectorFrontendClientImpl::windowObjectCleared()
v8::Handle<v8::Object> global = frameContext->Global();
global->Set(v8::String::New("InspectorFrontendHost"), frontendHostObj);
+
+ ScriptController* scriptController = m_frontendPage->mainFrame() ? m_frontendPage->mainFrame()->script() : 0;
+ if (scriptController) {
+ String installLegacyOverrides =
+ "(function(host) {"
+ " function dispatch(oldImpl, methodName) {"
+ " var argsArray = Array.prototype.slice.call(arguments, 2);"
+ " var message = {'method': methodName};"
+ " if (argsArray.length)"
+ " message.params = argsArray;"
+ " this.sendMessageToFrontendHost(JSON.stringify(message));"
+ " oldImpl.apply(this, argsArray);"
pfeldman 2013/08/23 11:20:27 if (oldImpl)
Vladislav Kaznacheev 2013/08/23 13:05:04 Done.
+ " };"
+ " var legacyMethods = ['requestSetDockSide', 'closeWindow', 'bringToFront', 'setAttachedWindowHeight', 'moveWindowBy', 'openInNewTab',"
pfeldman 2013/08/23 11:20:27 Lets generate this list as JSONArray of method nam
+ " 'save', 'append', 'requestFileSystems', 'addFileSystem', 'removeFileSystem', 'indexPath', 'stopIndexing', 'searchInPath' ];"
+ " legacyMethods.forEach(function(methodName) {"
+ " host[methodName] = dispatch.bind(host, host[method], methodName);"
pfeldman 2013/08/23 11:20:27 methodName
Vladislav Kaznacheev 2013/08/23 13:05:04 Done.
+ " });"
+ "})(InspectorFrontendHost);";
+ scriptController->executeScriptInMainWorld(ScriptSourceCode(installLegacyOverrides));
+ }
}
void InspectorFrontendClientImpl::moveWindowBy(float x, float y)
@@ -132,6 +153,11 @@ void InspectorFrontendClientImpl::sendMessageToBackend(const String& message)
m_client->sendMessageToBackend(message);
}
+void InspectorFrontendClientImpl::sendMessageToFrontendHost(const String& message)
+{
+ m_client->sendMessageToFrontendHost(message);
+}
+
void InspectorFrontendClientImpl::requestFileSystems()
{
m_client->requestFileSystems();

Powered by Google App Engine
This is Rietveld 408576698