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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 v8::Handle<v8::Context> frameContext = m_frontendPage->mainFrame() ? m_front endPage->mainFrame()->script()->currentWorldContext() : v8::Local<v8::Context>() ; 67 v8::Handle<v8::Context> frameContext = m_frontendPage->mainFrame() ? m_front endPage->mainFrame()->script()->currentWorldContext() : v8::Local<v8::Context>() ;
68 v8::Context::Scope contextScope(frameContext); 68 v8::Context::Scope contextScope(frameContext);
69 69
70 if (m_frontendHost) 70 if (m_frontendHost)
71 m_frontendHost->disconnectClient(); 71 m_frontendHost->disconnectClient();
72 m_frontendHost = InspectorFrontendHost::create(this, m_frontendPage); 72 m_frontendHost = InspectorFrontendHost::create(this, m_frontendPage);
73 v8::Handle<v8::Value> frontendHostObj = toV8(m_frontendHost.get(), v8::Handl e<v8::Object>(), frameContext->GetIsolate()); 73 v8::Handle<v8::Value> frontendHostObj = toV8(m_frontendHost.get(), v8::Handl e<v8::Object>(), frameContext->GetIsolate());
74 v8::Handle<v8::Object> global = frameContext->Global(); 74 v8::Handle<v8::Object> global = frameContext->Global();
75 75
76 global->Set(v8::String::New("InspectorFrontendHost"), frontendHostObj); 76 global->Set(v8::String::New("InspectorFrontendHost"), frontendHostObj);
77
78 ScriptController* scriptController = m_frontendPage->mainFrame() ? m_fronten dPage->mainFrame()->script() : 0;
79 if (scriptController) {
80 String installLegacyOverrides =
81 "(function(host) {"
82 " function dispatch(oldImpl, methodName) {"
83 " var argsArray = Array.prototype.slice.call(arguments, 2);"
84 " var message = {'method': methodName};"
85 " if (argsArray.length)"
86 " message.params = argsArray;"
87 " this.sendMessageToFrontendHost(JSON.stringify(message));"
88 " oldImpl.apply(this, argsArray);"
pfeldman 2013/08/23 11:20:27 if (oldImpl)
Vladislav Kaznacheev 2013/08/23 13:05:04 Done.
89 " };"
90 " var legacyMethods = ['requestSetDockSide', 'closeWindow', 'bringT oFront', 'setAttachedWindowHeight', 'moveWindowBy', 'openInNewTab',"
pfeldman 2013/08/23 11:20:27 Lets generate this list as JSONArray of method nam
91 " 'save', 'append', 'requestFileSystems', 'add FileSystem', 'removeFileSystem', 'indexPath', 'stopIndexing', 'searchInPath' ];"
92 " legacyMethods.forEach(function(methodName) {"
93 " host[methodName] = dispatch.bind(host, host[method], methodNa me);"
pfeldman 2013/08/23 11:20:27 methodName
Vladislav Kaznacheev 2013/08/23 13:05:04 Done.
94 " });"
95 "})(InspectorFrontendHost);";
96 scriptController->executeScriptInMainWorld(ScriptSourceCode(installLegac yOverrides));
97 }
77 } 98 }
78 99
79 void InspectorFrontendClientImpl::moveWindowBy(float x, float y) 100 void InspectorFrontendClientImpl::moveWindowBy(float x, float y)
80 { 101 {
81 m_client->moveWindowBy(WebFloatPoint(x, y)); 102 m_client->moveWindowBy(WebFloatPoint(x, y));
82 } 103 }
83 104
84 void InspectorFrontendClientImpl::bringToFront() 105 void InspectorFrontendClientImpl::bringToFront()
85 { 106 {
86 m_client->activateWindow(); 107 m_client->activateWindow();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 void InspectorFrontendClientImpl::inspectedURLChanged(const String& url) 146 void InspectorFrontendClientImpl::inspectedURLChanged(const String& url)
126 { 147 {
127 m_frontendPage->mainFrame()->document()->setTitle("Developer Tools - " + url ); 148 m_frontendPage->mainFrame()->document()->setTitle("Developer Tools - " + url );
128 } 149 }
129 150
130 void InspectorFrontendClientImpl::sendMessageToBackend(const String& message) 151 void InspectorFrontendClientImpl::sendMessageToBackend(const String& message)
131 { 152 {
132 m_client->sendMessageToBackend(message); 153 m_client->sendMessageToBackend(message);
133 } 154 }
134 155
156 void InspectorFrontendClientImpl::sendMessageToFrontendHost(const String& messag e)
157 {
158 m_client->sendMessageToFrontendHost(message);
159 }
160
135 void InspectorFrontendClientImpl::requestFileSystems() 161 void InspectorFrontendClientImpl::requestFileSystems()
136 { 162 {
137 m_client->requestFileSystems(); 163 m_client->requestFileSystems();
138 } 164 }
139 165
140 void InspectorFrontendClientImpl::indexPath(int requestId, const String& fileSys temPath) 166 void InspectorFrontendClientImpl::indexPath(int requestId, const String& fileSys temPath)
141 { 167 {
142 m_client->indexPath(requestId, fileSystemPath); 168 m_client->indexPath(requestId, fileSystemPath);
143 } 169 }
144 170
(...skipping 16 matching lines...) Expand all
161 { 187 {
162 m_client->removeFileSystem(fileSystemPath); 188 m_client->removeFileSystem(fileSystemPath);
163 } 189 }
164 190
165 bool InspectorFrontendClientImpl::isUnderTest() 191 bool InspectorFrontendClientImpl::isUnderTest()
166 { 192 {
167 return m_client->isUnderTest(); 193 return m_client->isUnderTest();
168 } 194 }
169 195
170 } // namespace WebKit 196 } // namespace WebKit
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698