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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 m_inspectorFrontendResumeObserver.clear(); | 141 m_inspectorFrontendResumeObserver.clear(); |
142 doDispatchOnInspectorFrontend(m_messages.takeFirst()); | 142 doDispatchOnInspectorFrontend(m_messages.takeFirst()); |
143 } | 143 } |
144 } | 144 } |
145 | 145 |
146 void WebDevToolsFrontendImpl::doDispatchOnInspectorFrontend(const WebString& mes
sage) | 146 void WebDevToolsFrontendImpl::doDispatchOnInspectorFrontend(const WebString& mes
sage) |
147 { | 147 { |
148 WebFrameImpl* frame = m_webViewImpl->mainFrameImpl(); | 148 WebFrameImpl* frame = m_webViewImpl->mainFrameImpl(); |
149 if (!frame->frame()) | 149 if (!frame->frame()) |
150 return; | 150 return; |
151 v8::Isolate* isolate = isolateForFrame(frame->frame()); | 151 v8::Isolate* isolate = toIsolate(frame->frame()); |
152 v8::HandleScope scope(isolate); | 152 v8::HandleScope scope(isolate); |
153 v8::Handle<v8::Context> frameContext = frame->frame()->script()->currentWorl
dContext(); | 153 v8::Handle<v8::Context> frameContext = frame->frame()->script()->currentWorl
dContext(); |
154 v8::Context::Scope contextScope(frameContext); | 154 v8::Context::Scope contextScope(frameContext); |
155 v8::Handle<v8::Value> inspectorFrontendApiValue = frameContext->Global()->Ge
t(v8::String::New("InspectorFrontendAPI")); | 155 v8::Handle<v8::Value> inspectorFrontendApiValue = frameContext->Global()->Ge
t(v8::String::New("InspectorFrontendAPI")); |
156 if (!inspectorFrontendApiValue->IsObject()) | 156 if (!inspectorFrontendApiValue->IsObject()) |
157 return; | 157 return; |
158 v8::Handle<v8::Object> dispatcherObject = v8::Handle<v8::Object>::Cast(inspe
ctorFrontendApiValue); | 158 v8::Handle<v8::Object> dispatcherObject = v8::Handle<v8::Object>::Cast(inspe
ctorFrontendApiValue); |
159 v8::Handle<v8::Value> dispatchFunction = dispatcherObject->Get(v8::String::N
ew("dispatchMessage")); | 159 v8::Handle<v8::Value> dispatchFunction = dispatcherObject->Get(v8::String::N
ew("dispatchMessage")); |
160 // The frame might have navigated away from the front-end page (which is sti
ll weird), | 160 // The frame might have navigated away from the front-end page (which is sti
ll weird), |
161 // OR the older version of frontend might have a dispatch method in a differ
ent place. | 161 // OR the older version of frontend might have a dispatch method in a differ
ent place. |
162 // FIXME(kaznacheev): Remove when Chrome for Android M18 is retired. | 162 // FIXME(kaznacheev): Remove when Chrome for Android M18 is retired. |
163 if (!dispatchFunction->IsFunction()) { | 163 if (!dispatchFunction->IsFunction()) { |
164 v8::Handle<v8::Value> inspectorBackendApiValue = frameContext->Global()-
>Get(v8::String::New("InspectorBackend")); | 164 v8::Handle<v8::Value> inspectorBackendApiValue = frameContext->Global()-
>Get(v8::String::New("InspectorBackend")); |
165 if (!inspectorBackendApiValue->IsObject()) | 165 if (!inspectorBackendApiValue->IsObject()) |
166 return; | 166 return; |
167 dispatcherObject = v8::Handle<v8::Object>::Cast(inspectorBackendApiValue
); | 167 dispatcherObject = v8::Handle<v8::Object>::Cast(inspectorBackendApiValue
); |
168 dispatchFunction = dispatcherObject->Get(v8::String::New("dispatch")); | 168 dispatchFunction = dispatcherObject->Get(v8::String::New("dispatch")); |
169 if (!dispatchFunction->IsFunction()) | 169 if (!dispatchFunction->IsFunction()) |
170 return; | 170 return; |
171 } | 171 } |
172 v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(dispatchF
unction); | 172 v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(dispatchF
unction); |
173 Vector< v8::Handle<v8::Value> > args; | 173 Vector< v8::Handle<v8::Value> > args; |
174 args.append(v8String(message, isolate)); | 174 args.append(v8String(message, isolate)); |
175 v8::TryCatch tryCatch; | 175 v8::TryCatch tryCatch; |
176 tryCatch.SetVerbose(true); | 176 tryCatch.SetVerbose(true); |
177 ScriptController::callFunctionWithInstrumentation(frame->frame() ? frame->fr
ame()->document() : 0, function, dispatcherObject, args.size(), args.data(), iso
late); | 177 ScriptController::callFunctionWithInstrumentation(frame->frame() ? frame->fr
ame()->document() : 0, function, dispatcherObject, args.size(), args.data(), iso
late); |
178 } | 178 } |
179 | 179 |
180 } // namespace WebKit | 180 } // namespace WebKit |
OLD | NEW |