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