| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 | 77 |
| 78 ScriptController* scriptController = m_frontendPage->mainFrame() ? m_fronten
dPage->mainFrame()->script() : 0; | 78 ScriptController* scriptController = m_frontendPage->mainFrame() ? m_fronten
dPage->mainFrame()->script() : 0; |
| 79 if (scriptController) { | 79 if (scriptController) { |
| 80 String installLegacyOverrides = | 80 String installLegacyOverrides = |
| 81 "(function(host) {" | 81 "(function(host) {" |
| 82 " function dispatch(oldImpl, methodName) {" | 82 " function dispatch(methodName) {" |
| 83 " var argsArray = Array.prototype.slice.call(arguments, 2);" | 83 " var argsArray = Array.prototype.slice.call(arguments, 1);" |
| 84 " var message = {'method': methodName};" | 84 " var message = {'method': methodName};" |
| 85 " if (argsArray.length)" | 85 " if (argsArray.length)" |
| 86 " message.params = argsArray;" | 86 " message.params = argsArray;" |
| 87 " this.sendMessageToFrontendHost(JSON.stringify(message));" | 87 " this.sendMessageToFrontendHost(JSON.stringify(message));" |
| 88 " oldImpl.apply(this, argsArray);" | |
| 89 " };" | 88 " };" |
| 90 " var legacyMethods = ['requestSetDockSide', 'closeWindow', 'bringT
oFront', 'setAttachedWindowHeight', 'moveWindowBy', 'openInNewTab'," | 89 " var legacyMethods = ['requestSetDockSide', 'closeWindow', 'bringT
oFront', 'setAttachedWindowHeight', 'moveWindowBy', 'openInNewTab'," |
| 91 " 'save', 'append', 'requestFileSystems', 'add
FileSystem', 'removeFileSystem', 'indexPath', 'stopIndexing', 'searchInPath' ];" | 90 " 'save', 'append', 'requestFileSystems', 'add
FileSystem', 'removeFileSystem', 'indexPath', 'stopIndexing', 'searchInPath' ];" |
| 92 " legacyMethods.forEach(function(methodName) {" | 91 " legacyMethods.forEach(function(methodName) {" |
| 93 " host[methodName] = dispatch.bind(host, host[method], methodNa
me);" | 92 " host[methodName] = dispatch.bind(host, methodName);" |
| 94 " });" | 93 " });" |
| 95 "})(InspectorFrontendHost);"; | 94 "})(InspectorFrontendHost);"; |
| 96 scriptController->executeScriptInMainWorld(ScriptSourceCode(installLegac
yOverrides)); | 95 scriptController->executeScriptInMainWorld(ScriptSourceCode(installLegac
yOverrides)); |
| 97 } | 96 } |
| 98 } | 97 } |
| 99 | 98 |
| 100 void InspectorFrontendClientImpl::moveWindowBy(float x, float y) | |
| 101 { | |
| 102 m_client->moveWindowBy(WebFloatPoint(x, y)); | |
| 103 } | |
| 104 | |
| 105 void InspectorFrontendClientImpl::bringToFront() | |
| 106 { | |
| 107 m_client->activateWindow(); | |
| 108 } | |
| 109 | |
| 110 void InspectorFrontendClientImpl::closeWindow() | |
| 111 { | |
| 112 m_client->closeWindow(); | |
| 113 } | |
| 114 | |
| 115 void InspectorFrontendClientImpl::requestSetDockSide(DockSide side) | |
| 116 { | |
| 117 String sideString = "undocked"; | |
| 118 switch (side) { | |
| 119 case DockedToRight: sideString = "right"; break; | |
| 120 case DockedToBottom: sideString = "bottom"; break; | |
| 121 case Undocked: sideString = "undocked"; break; | |
| 122 } | |
| 123 m_client->requestSetDockSide(sideString); | |
| 124 } | |
| 125 | |
| 126 void InspectorFrontendClientImpl::changeAttachedWindowHeight(unsigned height) | |
| 127 { | |
| 128 m_client->changeAttachedWindowHeight(height); | |
| 129 } | |
| 130 | |
| 131 void InspectorFrontendClientImpl::openInNewTab(const String& url) | |
| 132 { | |
| 133 m_client->openInNewTab(url); | |
| 134 } | |
| 135 | |
| 136 void InspectorFrontendClientImpl::save(const String& url, const String& content,
bool forceSaveAs) | |
| 137 { | |
| 138 m_client->save(url, content, forceSaveAs); | |
| 139 } | |
| 140 | |
| 141 void InspectorFrontendClientImpl::append(const String& url, const String& conten
t) | |
| 142 { | |
| 143 m_client->append(url, content); | |
| 144 } | |
| 145 | |
| 146 void InspectorFrontendClientImpl::inspectedURLChanged(const String& url) | 99 void InspectorFrontendClientImpl::inspectedURLChanged(const String& url) |
| 147 { | 100 { |
| 148 m_frontendPage->mainFrame()->document()->setTitle("Developer Tools - " + url
); | 101 m_frontendPage->mainFrame()->document()->setTitle("Developer Tools - " + url
); |
| 149 } | 102 } |
| 150 | 103 |
| 151 void InspectorFrontendClientImpl::sendMessageToBackend(const String& message) | 104 void InspectorFrontendClientImpl::sendMessageToBackend(const String& message) |
| 152 { | 105 { |
| 153 m_client->sendMessageToBackend(message); | 106 m_client->sendMessageToBackend(message); |
| 154 } | 107 } |
| 155 | 108 |
| 156 void InspectorFrontendClientImpl::sendMessageToFrontendHost(const String& messag
e) | 109 void InspectorFrontendClientImpl::sendMessageToFrontendHost(const String& messag
e) |
| 157 { | 110 { |
| 158 m_client->sendMessageToFrontendHost(message); | 111 m_client->sendMessageToFrontendHost(message); |
| 159 } | 112 } |
| 160 | 113 |
| 161 void InspectorFrontendClientImpl::requestFileSystems() | |
| 162 { | |
| 163 m_client->requestFileSystems(); | |
| 164 } | |
| 165 | |
| 166 void InspectorFrontendClientImpl::indexPath(int requestId, const String& fileSys
temPath) | |
| 167 { | |
| 168 m_client->indexPath(requestId, fileSystemPath); | |
| 169 } | |
| 170 | |
| 171 void InspectorFrontendClientImpl::stopIndexing(int requestId) | |
| 172 { | |
| 173 m_client->stopIndexing(requestId); | |
| 174 } | |
| 175 | |
| 176 void InspectorFrontendClientImpl::searchInPath(int requestId, const String& file
SystemPath, const String& query) | |
| 177 { | |
| 178 m_client->searchInPath(requestId, fileSystemPath, query); | |
| 179 } | |
| 180 | |
| 181 void InspectorFrontendClientImpl::addFileSystem() | |
| 182 { | |
| 183 m_client->addFileSystem(); | |
| 184 } | |
| 185 | |
| 186 void InspectorFrontendClientImpl::removeFileSystem(const String& fileSystemPath) | |
| 187 { | |
| 188 m_client->removeFileSystem(fileSystemPath); | |
| 189 } | |
| 190 | |
| 191 bool InspectorFrontendClientImpl::isUnderTest() | 114 bool InspectorFrontendClientImpl::isUnderTest() |
| 192 { | 115 { |
| 193 return m_client->isUnderTest(); | 116 return m_client->isUnderTest(); |
| 194 } | 117 } |
| 195 | 118 |
| 196 } // namespace WebKit | 119 } // namespace WebKit |
| OLD | NEW |