Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(451)

Side by Side Diff: Source/bindings/v8/custom/V8InspectorFrontendHostCustom.cpp

Issue 74133005: Remove several uses of toWebCoreStringWithNullCheck(v8::Handle<v8::Value>) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 v8SetReturnValue(info, v8::String::NewSymbol("windows")); 49 v8SetReturnValue(info, v8::String::NewSymbol("windows"));
50 #else // Unix-like systems 50 #else // Unix-like systems
51 v8SetReturnValue(info, v8::String::NewSymbol("linux")); 51 v8SetReturnValue(info, v8::String::NewSymbol("linux"));
52 #endif 52 #endif
53 } 53 }
54 54
55 void V8InspectorFrontendHost::portMethodCustom(const v8::FunctionCallbackInfo<v8 ::Value>&) 55 void V8InspectorFrontendHost::portMethodCustom(const v8::FunctionCallbackInfo<v8 ::Value>&)
56 { 56 {
57 } 57 }
58 58
59 static void populateContextMenuItems(v8::Local<v8::Array>& itemArray, ContextMen u& menu) 59 static bool populateContextMenuItems(v8::Local<v8::Array>& itemArray, ContextMen u& menu)
60 { 60 {
61 for (size_t i = 0; i < itemArray->Length(); ++i) { 61 for (size_t i = 0; i < itemArray->Length(); ++i) {
62 v8::Local<v8::Object> item = v8::Local<v8::Object>::Cast(itemArray->Get( i)); 62 v8::Local<v8::Object> item = v8::Local<v8::Object>::Cast(itemArray->Get( i));
63 v8::Local<v8::Value> type = item->Get(v8::String::NewSymbol("type")); 63 v8::Local<v8::Value> type = item->Get(v8::String::NewSymbol("type"));
64 v8::Local<v8::Value> id = item->Get(v8::String::NewSymbol("id")); 64 v8::Local<v8::Value> id = item->Get(v8::String::NewSymbol("id"));
65 v8::Local<v8::Value> label = item->Get(v8::String::NewSymbol("label")); 65 v8::Local<v8::Value> label = item->Get(v8::String::NewSymbol("label"));
66 v8::Local<v8::Value> enabled = item->Get(v8::String::NewSymbol("enabled" )); 66 v8::Local<v8::Value> enabled = item->Get(v8::String::NewSymbol("enabled" ));
67 v8::Local<v8::Value> checked = item->Get(v8::String::NewSymbol("checked" )); 67 v8::Local<v8::Value> checked = item->Get(v8::String::NewSymbol("checked" ));
68 v8::Local<v8::Value> subItems = item->Get(v8::String::NewSymbol("subItem s")); 68 v8::Local<v8::Value> subItems = item->Get(v8::String::NewSymbol("subItem s"));
69 if (!type->IsString()) 69 if (!type->IsString())
70 continue; 70 continue;
71 String typeString = toWebCoreStringWithNullCheck(type.As<v8::String>()); 71 String typeString = toWebCoreStringWithNullCheck(type.As<v8::String>());
72 if (typeString == "separator") { 72 if (typeString == "separator") {
73 ContextMenuItem item(ContextMenuItem(SeparatorType, 73 ContextMenuItem item(ContextMenuItem(SeparatorType,
74 ContextMenuItemCustomTagNoAction, 74 ContextMenuItemCustomTagNoAction,
75 String())); 75 String()));
76 menu.appendItem(item); 76 menu.appendItem(item);
77 } else if (typeString == "subMenu" && subItems->IsArray()) { 77 } else if (typeString == "subMenu" && subItems->IsArray()) {
78 ContextMenu subMenu; 78 ContextMenu subMenu;
79 v8::Local<v8::Array> subItemsArray = v8::Local<v8::Array>::Cast(subI tems); 79 v8::Local<v8::Array> subItemsArray = v8::Local<v8::Array>::Cast(subI tems);
80 populateContextMenuItems(subItemsArray, subMenu); 80 if (!populateContextMenuItems(subItemsArray, subMenu))
81 return false;
82 V8TRYCATCH_FOR_V8STRINGRESOURCE_RETURN(V8StringResource<WithNullChec k>, labelString, label, false);
81 ContextMenuItem item(SubmenuType, 83 ContextMenuItem item(SubmenuType,
82 ContextMenuItemCustomTagNoAction, 84 ContextMenuItemCustomTagNoAction,
83 toWebCoreStringWithNullCheck(label), 85 labelString,
84 &subMenu); 86 &subMenu);
85 menu.appendItem(item); 87 menu.appendItem(item);
86 } else { 88 } else {
87 ContextMenuAction typedId = static_cast<ContextMenuAction>(ContextMe nuItemBaseCustomTag + id->ToInt32()->Value()); 89 ContextMenuAction typedId = static_cast<ContextMenuAction>(ContextMe nuItemBaseCustomTag + id->ToInt32()->Value());
88 ContextMenuItem menuItem((typeString == "checkbox" ? CheckableAction Type : ActionType), typedId, toWebCoreStringWithNullCheck(label)); 90 ContextMenuItem menuItem((typeString == "checkbox" ? CheckableAction Type : ActionType), typedId, toWebCoreStringWithNullCheck(label));
89 if (checked->IsBoolean()) 91 if (checked->IsBoolean())
90 menuItem.setChecked(checked->ToBoolean()->Value()); 92 menuItem.setChecked(checked->ToBoolean()->Value());
91 if (enabled->IsBoolean()) 93 if (enabled->IsBoolean())
92 menuItem.setEnabled(enabled->ToBoolean()->Value()); 94 menuItem.setEnabled(enabled->ToBoolean()->Value());
93 menu.appendItem(menuItem); 95 menu.appendItem(menuItem);
94 } 96 }
95 } 97 }
98 return true;
96 } 99 }
97 100
98 void V8InspectorFrontendHost::showContextMenuMethodCustom(const v8::FunctionCall backInfo<v8::Value>& info) 101 void V8InspectorFrontendHost::showContextMenuMethodCustom(const v8::FunctionCall backInfo<v8::Value>& info)
99 { 102 {
100 if (info.Length() < 2) 103 if (info.Length() < 2)
101 return; 104 return;
102 105
103 v8::Local<v8::Object> eventWrapper = v8::Local<v8::Object>::Cast(info[0]); 106 v8::Local<v8::Object> eventWrapper = v8::Local<v8::Object>::Cast(info[0]);
104 if (!V8MouseEvent::wrapperTypeInfo.equals(toWrapperTypeInfo(eventWrapper))) 107 if (!V8MouseEvent::wrapperTypeInfo.equals(toWrapperTypeInfo(eventWrapper)))
105 return; 108 return;
106 109
107 Event* event = V8Event::toNative(eventWrapper); 110 Event* event = V8Event::toNative(eventWrapper);
108 if (!info[1]->IsArray()) 111 if (!info[1]->IsArray())
109 return; 112 return;
110 113
111 v8::Local<v8::Array> array = v8::Local<v8::Array>::Cast(info[1]); 114 v8::Local<v8::Array> array = v8::Local<v8::Array>::Cast(info[1]);
112 ContextMenu menu; 115 ContextMenu menu;
113 populateContextMenuItems(array, menu); 116 if (!populateContextMenuItems(array, menu))
117 return;
114 118
115 InspectorFrontendHost* frontendHost = V8InspectorFrontendHost::toNative(info .Holder()); 119 InspectorFrontendHost* frontendHost = V8InspectorFrontendHost::toNative(info .Holder());
116 Vector<ContextMenuItem> items = menu.items(); 120 Vector<ContextMenuItem> items = menu.items();
117 frontendHost->showContextMenu(event, items); 121 frontendHost->showContextMenu(event, items);
118 } 122 }
119 123
120 static void histogramEnumeration(const char* name, const v8::FunctionCallbackInf o<v8::Value>& info, int boundaryValue) 124 static void histogramEnumeration(const char* name, const v8::FunctionCallbackInf o<v8::Value>& info, int boundaryValue)
121 { 125 {
122 if (info.Length() < 1 || !info[0]->IsInt32()) 126 if (info.Length() < 1 || !info[0]->IsInt32())
123 return; 127 return;
(...skipping 13 matching lines...) Expand all
137 histogramEnumeration("DevTools.PanelShown", info, 20); 141 histogramEnumeration("DevTools.PanelShown", info, 20);
138 } 142 }
139 143
140 void V8InspectorFrontendHost::recordSettingChangedMethodCustom(const v8::Functio nCallbackInfo<v8::Value>& info) 144 void V8InspectorFrontendHost::recordSettingChangedMethodCustom(const v8::Functio nCallbackInfo<v8::Value>& info)
141 { 145 {
142 histogramEnumeration("DevTools.SettingChanged", info, 100); 146 histogramEnumeration("DevTools.SettingChanged", info, 100);
143 } 147 }
144 148
145 } // namespace WebCore 149 } // namespace WebCore
146 150
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698