| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007-2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2007-2009 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 14 matching lines...) Expand all Loading... |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "bindings/core/v8/V8InspectorFrontendHost.h" | 32 #include "bindings/core/v8/V8InspectorFrontendHost.h" |
| 33 | 33 |
| 34 #include "bindings/core/v8/V8Binding.h" | 34 #include "bindings/core/v8/V8Binding.h" |
| 35 #include "bindings/core/v8/V8Document.h" | |
| 36 #include "bindings/core/v8/V8MouseEvent.h" | 35 #include "bindings/core/v8/V8MouseEvent.h" |
| 37 #include "bindings/core/v8/V8Window.h" | 36 #include "bindings/core/v8/V8Window.h" |
| 38 #include "core/dom/Document.h" | 37 #include "core/dom/Document.h" |
| 39 #include "core/frame/LocalDOMWindow.h" | 38 #include "core/frame/LocalDOMWindow.h" |
| 40 #include "core/inspector/InspectorController.h" | 39 #include "core/inspector/InspectorController.h" |
| 41 #include "core/inspector/InspectorFrontendClient.h" | 40 #include "core/inspector/InspectorFrontendClient.h" |
| 42 #include "core/inspector/InspectorFrontendHost.h" | 41 #include "core/inspector/InspectorFrontendHost.h" |
| 43 #include "platform/ContextMenu.h" | 42 #include "platform/ContextMenu.h" |
| 44 #include "public/platform/Platform.h" | 43 #include "public/platform/Platform.h" |
| 45 #include "wtf/text/WTFString.h" | 44 #include "wtf/text/WTFString.h" |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 if (!y->IsNumber()) | 139 if (!y->IsNumber()) |
| 141 return; | 140 return; |
| 142 | 141 |
| 143 v8::Local<v8::Value> array = v8::Local<v8::Value>::Cast(info[2]); | 142 v8::Local<v8::Value> array = v8::Local<v8::Value>::Cast(info[2]); |
| 144 if (!array->IsArray()) | 143 if (!array->IsArray()) |
| 145 return; | 144 return; |
| 146 ContextMenu menu; | 145 ContextMenu menu; |
| 147 if (!populateContextMenuItems(v8::Local<v8::Array>::Cast(array), menu, info.
GetIsolate())) | 146 if (!populateContextMenuItems(v8::Local<v8::Array>::Cast(array), menu, info.
GetIsolate())) |
| 148 return; | 147 return; |
| 149 | 148 |
| 150 LocalDOMWindow* window = nullptr; | 149 v8::Isolate* isolate = info.GetIsolate(); |
| 151 if (info.Length() >= 4) { | 150 v8::Handle<v8::Object> windowWrapper = V8Window::findInstanceInPrototypeChai
n(isolate->GetEnteredContext()->Global(), isolate); |
| 152 window = toDOMWindow(info[3], info.GetIsolate()); | 151 if (windowWrapper.IsEmpty()) |
| 153 } else { | 152 return; |
| 154 v8::Isolate* isolate = info.GetIsolate(); | 153 LocalDOMWindow* window = V8Window::toImpl(windowWrapper); |
| 155 v8::Handle<v8::Object> windowWrapper = V8Window::findInstanceInPrototype
Chain(isolate->GetEnteredContext()->Global(), isolate); | 154 if (!window->document() || !window->document()->page()) |
| 156 if (windowWrapper.IsEmpty()) | |
| 157 return; | |
| 158 window = V8Window::toImpl(windowWrapper); | |
| 159 } | |
| 160 if (!window || !window->document() || !window->document()->page()) | |
| 161 return; | 155 return; |
| 162 | 156 |
| 163 InspectorFrontendHost* frontendHost = V8InspectorFrontendHost::toImpl(info.H
older()); | 157 InspectorFrontendHost* frontendHost = V8InspectorFrontendHost::toImpl(info.H
older()); |
| 164 Vector<ContextMenuItem> items = menu.items(); | 158 Vector<ContextMenuItem> items = menu.items(); |
| 165 frontendHost->showContextMenu(window->document()->page(), static_cast<float>
(x->NumberValue()), static_cast<float>(y->NumberValue()), items); | 159 frontendHost->showContextMenu(window->document()->page(), static_cast<float>
(x->NumberValue()), static_cast<float>(y->NumberValue()), items); |
| 166 } | 160 } |
| 167 | 161 |
| 168 static void histogramEnumeration(const char* name, const v8::FunctionCallbackInf
o<v8::Value>& info, int boundaryValue) | 162 static void histogramEnumeration(const char* name, const v8::FunctionCallbackInf
o<v8::Value>& info, int boundaryValue) |
| 169 { | 163 { |
| 170 if (info.Length() < 1 || !info[0]->IsInt32()) | 164 if (info.Length() < 1 || !info[0]->IsInt32()) |
| 171 return; | 165 return; |
| 172 | 166 |
| 173 int sample = info[0]->ToInt32()->Value(); | 167 int sample = info[0]->ToInt32()->Value(); |
| 174 if (sample < boundaryValue) | 168 if (sample < boundaryValue) |
| 175 blink::Platform::current()->histogramEnumeration(name, sample, boundaryV
alue); | 169 blink::Platform::current()->histogramEnumeration(name, sample, boundaryV
alue); |
| 176 } | 170 } |
| 177 | 171 |
| 178 void V8InspectorFrontendHost::recordActionTakenMethodCustom(const v8::FunctionCa
llbackInfo<v8::Value>& info) | 172 void V8InspectorFrontendHost::recordActionTakenMethodCustom(const v8::FunctionCa
llbackInfo<v8::Value>& info) |
| 179 { | 173 { |
| 180 histogramEnumeration("DevTools.ActionTaken", info, 100); | 174 histogramEnumeration("DevTools.ActionTaken", info, 100); |
| 181 } | 175 } |
| 182 | 176 |
| 183 void V8InspectorFrontendHost::recordPanelShownMethodCustom(const v8::FunctionCal
lbackInfo<v8::Value>& info) | 177 void V8InspectorFrontendHost::recordPanelShownMethodCustom(const v8::FunctionCal
lbackInfo<v8::Value>& info) |
| 184 { | 178 { |
| 185 histogramEnumeration("DevTools.PanelShown", info, 20); | 179 histogramEnumeration("DevTools.PanelShown", info, 20); |
| 186 } | 180 } |
| 187 | 181 |
| 188 } // namespace blink | 182 } // namespace blink |
| 189 | 183 |
| OLD | NEW |