OLD | NEW |
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 Loading... |
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, legacyMethodNames) {" |
| 82 " function dispatch(methodName, oldImpl) {" |
| 83 " var argsArray = Array.prototype.slice.call(arguments, 2);" |
| 84 " var message = {'method': methodName};" |
| 85 " if (argsArray.length)" |
| 86 " message.params = argsArray;" |
| 87 " this.sendMessageToEmbedder(JSON.stringify(message));" |
| 88 " if (oldImpl)" |
| 89 " oldImpl.apply(this, argsArray);" |
| 90 " };" |
| 91 " legacyMethodNames.forEach(function(methodName) {" |
| 92 " host[methodName] = dispatch.bind(host, methodName, host[met
hodName]);" |
| 93 " });" |
| 94 "})(InspectorFrontendHost," |
| 95 " ['moveWindowBy'," |
| 96 " 'bringToFront'," |
| 97 " 'requestSetDockSide'," |
| 98 " 'openInNewTab'," |
| 99 " 'save'," |
| 100 " 'append'," |
| 101 " 'requestFileSystems'," |
| 102 " 'indexPath'," |
| 103 " 'stopIndexing'," |
| 104 " 'searchInPath'," |
| 105 " 'addFileSystem'," |
| 106 " 'removeFileSystem']);"; |
| 107 |
| 108 scriptController->executeScriptInMainWorld(ScriptSourceCode(installLegac
yOverrides)); |
| 109 } |
77 } | 110 } |
78 | 111 |
79 void InspectorFrontendClientImpl::moveWindowBy(float x, float y) | 112 void InspectorFrontendClientImpl::moveWindowBy(float x, float y) |
80 { | 113 { |
81 m_client->moveWindowBy(WebFloatPoint(x, y)); | 114 m_client->moveWindowBy(WebFloatPoint(x, y)); |
82 } | 115 } |
83 | 116 |
84 void InspectorFrontendClientImpl::bringToFront() | 117 void InspectorFrontendClientImpl::bringToFront() |
85 { | 118 { |
86 m_client->activateWindow(); | 119 m_client->activateWindow(); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 void InspectorFrontendClientImpl::inspectedURLChanged(const String& url) | 158 void InspectorFrontendClientImpl::inspectedURLChanged(const String& url) |
126 { | 159 { |
127 m_frontendPage->mainFrame()->document()->setTitle("Developer Tools - " + url
); | 160 m_frontendPage->mainFrame()->document()->setTitle("Developer Tools - " + url
); |
128 } | 161 } |
129 | 162 |
130 void InspectorFrontendClientImpl::sendMessageToBackend(const String& message) | 163 void InspectorFrontendClientImpl::sendMessageToBackend(const String& message) |
131 { | 164 { |
132 m_client->sendMessageToBackend(message); | 165 m_client->sendMessageToBackend(message); |
133 } | 166 } |
134 | 167 |
| 168 void InspectorFrontendClientImpl::sendMessageToEmbedder(const String& message) |
| 169 { |
| 170 m_client->sendMessageToEmbedder(message); |
| 171 } |
| 172 |
135 void InspectorFrontendClientImpl::requestFileSystems() | 173 void InspectorFrontendClientImpl::requestFileSystems() |
136 { | 174 { |
137 m_client->requestFileSystems(); | 175 m_client->requestFileSystems(); |
138 } | 176 } |
139 | 177 |
140 void InspectorFrontendClientImpl::indexPath(int requestId, const String& fileSys
temPath) | 178 void InspectorFrontendClientImpl::indexPath(int requestId, const String& fileSys
temPath) |
141 { | 179 { |
142 m_client->indexPath(requestId, fileSystemPath); | 180 m_client->indexPath(requestId, fileSystemPath); |
143 } | 181 } |
144 | 182 |
(...skipping 16 matching lines...) Expand all Loading... |
161 { | 199 { |
162 m_client->removeFileSystem(fileSystemPath); | 200 m_client->removeFileSystem(fileSystemPath); |
163 } | 201 } |
164 | 202 |
165 bool InspectorFrontendClientImpl::isUnderTest() | 203 bool InspectorFrontendClientImpl::isUnderTest() |
166 { | 204 { |
167 return m_client->isUnderTest(); | 205 return m_client->isUnderTest(); |
168 } | 206 } |
169 | 207 |
170 } // namespace WebKit | 208 } // namespace WebKit |
OLD | NEW |