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