Changeset 47656 in webkit
- Timestamp:
- Aug 21, 2009 6:53:56 PM (15 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r47655 r47656 1 2009-08-19 Joseph Pecoraro <joepeck@webkit.org> 2 3 Reviewed by Timothy Hatcher. 4 5 Inspector: Improve Cookie DataGrid to Show Hidden Data 6 https://bugs.webkit.org/show_bug.cgi?id=28269 7 8 Removed Custom Bindings 9 10 * bindings/js/JSInspectorBackendCustom.cpp: 11 * bindings/v8/custom/V8CustomBinding.h: 12 * bindings/v8/custom/V8InspectorBackendCustom.cpp: 13 * inspector/InspectorBackend.cpp: 14 15 Made Non-Custom Bindings in the Backend 16 17 (WebCore::InspectorBackend::getCookies): 18 (WebCore::InspectorBackend::deleteCookie): 19 * inspector/InspectorBackend.h: 20 * inspector/InspectorBackend.idl: 21 * inspector/InspectorController.cpp: 22 (WebCore::InspectorController::deleteCookie): 23 * inspector/InspectorController.h: 24 25 Build the Cookie ScriptObjects, handles using document.cookie in 26 case the platform hasn't implemented raw cookie access. 27 28 * inspector/InspectorDOMAgent.cpp: 29 (WebCore::InspectorDOMAgent::getCookies): 30 (WebCore::InspectorDOMAgent::buildObjectForCookie): 31 (WebCore::InspectorDOMAgent::buildArrayForCookies): 32 * inspector/InspectorDOMAgent.h: 33 34 Complete the Asynchronous Calls 35 36 * inspector/InspectorFrontend.cpp: 37 (WebCore::InspectorFrontend::didGetCookies): 38 * inspector/InspectorFrontend.h: 39 40 Asynchronous Functions to get Cookie Data 41 42 * inspector/front-end/DOMAgent.js: 43 (WebInspector.Cookies.getCookiesAsync): 44 (WebInspector.Cookies.buildCookiesFromString): fallback behavior 45 46 Refactor to use the Asynchronous Functions 47 48 * inspector/front-end/CookieItemsView.js: 49 (WebInspector.CookieItemsView): 50 (WebInspector.CookieItemsView.prototype.get statusBarItems): 51 (WebInspector.CookieItemsView.prototype.update.callback): 52 (WebInspector.CookieItemsView.prototype.update): 53 (WebInspector.CookieItemsView.prototype.simpleDataGridForCookies): 54 (WebInspector.CookieItemsView.prototype._deleteButtonClicked): 55 56 Cleaned/Commented Related Code 57 58 (InspectorController.searchCanceled): 59 * inspector/front-end/InjectedScript.js: 60 * platform/Cookie.h: 61 * English.lproj/localizedStrings.js: the new strings that were supposed to have gone in last time 62 1 63 2009-08-21 Michelangelo De Simone <micdesim@gmail.com> 2 64 -
trunk/WebCore/bindings/js/JSInspectorBackendCustom.cpp
r47513 r47656 3 3 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com> 4 4 * Copyright (C) 2009 Google Inc. All rights reserved. 5 * Copyright (C) 2009 Joseph Pecoraro6 5 * 7 6 * Redistribution and use in source and binary forms, with or without … … 36 35 37 36 #include "Console.h" 38 #include "Cookie.h"39 #include "CookieJar.h"40 37 #if ENABLE(DATABASE) 41 38 #include "Database.h" … … 155 152 JSDOMWindow* inspectedWindow = toJSDOMWindow(ic->inspectedPage()->mainFrame()); 156 153 return JSInspectedObjectWrapper::wrap(inspectedWindow->globalExec(), inspectedWindow); 157 }158 159 JSValue JSInspectorBackend::cookies(ExecState* exec, const ArgList&)160 {161 InspectorController* ic = impl()->inspectorController();162 if (!ic)163 return jsUndefined();164 165 Document* document = ic->inspectedPage()->mainFrame()->document();166 Vector<Cookie> cookies;167 bool isImplemented = getRawCookies(document, document->cookieURL(), cookies);168 169 if (!isImplemented)170 return jsUndefined();171 172 MarkedArgumentBuffer result;173 Identifier nameIdentifier(exec, "name");174 Identifier valueIdentifier(exec, "value");175 Identifier domainIdentifier(exec, "domain");176 Identifier pathIdentifier(exec, "path");177 Identifier expiresIdentifier(exec, "expires");178 Identifier sizeIdentifier(exec, "size");179 Identifier httpOnlyIdentifier(exec, "httpOnly");180 Identifier secureIdentifier(exec, "secure");181 Identifier sessionIdentifier(exec, "session");182 183 unsigned length = cookies.size();184 for (unsigned i = 0; i < length; ++i) {185 const Cookie& cookie = cookies[i];186 JSObject* cookieObject = constructEmptyObject(exec);187 cookieObject->putDirect(nameIdentifier, jsString(exec, cookie.name));188 cookieObject->putDirect(valueIdentifier, jsString(exec, cookie.value));189 cookieObject->putDirect(domainIdentifier, jsString(exec, cookie.domain));190 cookieObject->putDirect(pathIdentifier, jsString(exec, cookie.path));191 cookieObject->putDirect(expiresIdentifier, jsNumber(exec, cookie.expires));192 cookieObject->putDirect(sizeIdentifier, jsNumber(exec, cookie.name.length() + cookie.value.length()));193 cookieObject->putDirect(httpOnlyIdentifier, jsBoolean(cookie.httpOnly));194 cookieObject->putDirect(secureIdentifier, jsBoolean(cookie.secure));195 cookieObject->putDirect(sessionIdentifier, jsBoolean(cookie.session));196 result.append(cookieObject);197 }198 199 return constructArray(exec, result);200 }201 202 JSValue JSInspectorBackend::deleteCookie(ExecState* exec, const ArgList& args)203 {204 if (args.size() < 1)205 return jsUndefined();206 207 InspectorController* ic = impl()->inspectorController();208 if (!ic)209 return jsUndefined();210 211 String cookieName = args.at(0).toString(exec);212 if (exec->hadException())213 return jsUndefined();214 215 Document* document = ic->inspectedPage()->mainFrame()->document();216 WebCore::deleteCookie(document, document->cookieURL(), cookieName);217 218 return jsUndefined();219 154 } 220 155 -
trunk/WebCore/bindings/v8/custom/V8CustomBinding.h
r47513 r47656 408 408 DECLARE_CALLBACK(InspectorBackendInspectedWindow); 409 409 DECLARE_CALLBACK(InspectorBackendSetSetting); 410 DECLARE_CALLBACK(InspectorBackendCookies);411 DECLARE_CALLBACK(InspectorBackendDeleteCookie);412 410 DECLARE_CALLBACK(InspectorBackendCurrentCallFrame); 413 411 DECLARE_CALLBACK(InspectorBackendDebuggerEnabled); -
trunk/WebCore/bindings/v8/custom/V8InspectorBackendCustom.cpp
r47513 r47656 205 205 } 206 206 207 CALLBACK_FUNC_DECL(InspectorBackendCookies)208 {209 INC_STATS("InspectorBackend.cookies()");210 // FIXME: Not yet implemented.211 return v8::Undefined();212 }213 214 CALLBACK_FUNC_DECL(InspectorBackendDeleteCookie)215 {216 INC_STATS("InspectorBackend.deleteCookie()");217 // FIXME: Not yet implemented. (see WebCore/bindings/js/JSInspectorBackendCustom.cpp#deleteCookie)218 return v8::Undefined();219 }220 221 207 CALLBACK_FUNC_DECL(InspectorBackendWrapCallback) 222 208 { -
trunk/WebCore/inspector/InspectorBackend.cpp
r47513 r47656 252 252 } 253 253 254 void InspectorBackend::getCookies(long callId) 255 { 256 if (!m_inspectorController) 257 return; 258 if (!m_inspectorController->m_domAgent || !m_inspectorController->m_frontend) 259 return; 260 m_inspectorController->domAgent()->getCookies(callId); 261 } 262 263 void InspectorBackend::deleteCookie(const String& cookieName) 264 { 265 if (!m_inspectorController) 266 return; 267 m_inspectorController->deleteCookie(cookieName); 268 } 269 254 270 #if ENABLE(JAVASCRIPT_DEBUGGER) 255 271 const ProfilesArray& InspectorBackend::profiles() const -
trunk/WebCore/inspector/InspectorBackend.h
r47513 r47656 96 96 const String& platform() const; 97 97 98 void getCookies(long callId); 99 void deleteCookie(const String& cookieName); 100 98 101 #if ENABLE(JAVASCRIPT_DEBUGGER) 99 102 const ProfilesArray& profiles() const; -
trunk/WebCore/inspector/InspectorBackend.idl
r47513 r47656 69 69 void storeLastActivePanel(in DOMString panelName); 70 70 71 [Custom] Array cookies();72 [Custom]void deleteCookie(in DOMString cookieName);71 void getCookies(in long callId); 72 void deleteCookie(in DOMString cookieName); 73 73 74 74 #if defined(ENABLE_JAVASCRIPT_DEBUGGER) && ENABLE_JAVASCRIPT_DEBUGGER -
trunk/WebCore/inspector/InspectorController.cpp
r47639 r47656 35 35 #include "Console.h" 36 36 #include "ConsoleMessage.h" 37 #include "CookieJar.h" 37 38 #include "Document.h" 38 39 #include "DocumentLoader.h" … … 1512 1513 } 1513 1514 1515 void InspectorController::deleteCookie(const String& cookieName) 1516 { 1517 Document* document = m_inspectedPage->mainFrame()->document(); 1518 WebCore::deleteCookie(document, document->cookieURL(), cookieName); 1519 } 1520 1514 1521 } // namespace WebCore -
trunk/WebCore/inspector/InspectorController.h
r47639 r47656 289 289 void resetInjectedScript(); 290 290 291 void deleteCookie(const String& cookieName); 292 291 293 #if ENABLE(JAVASCRIPT_DEBUGGER) 292 294 void startUserInitiatedProfilingSoon(); -
trunk/WebCore/inspector/InspectorDOMAgent.cpp
r47513 r47656 2 2 * Copyright (C) 2009 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2009 Google Inc. All rights reserved. 4 * Copyright (C) 2009 Joseph Pecoraro 4 5 * 5 6 * Redistribution and use in source and binary forms, with or without … … 33 34 #include "AtomicString.h" 34 35 #include "ContainerNode.h" 36 #include "Cookie.h" 37 #include "CookieJar.h" 35 38 #include "DOMWindow.h" 36 39 #include "Document.h" … … 359 362 } 360 363 364 void InspectorDOMAgent::getCookies(long callId) 365 { 366 Document* doc = mainFrameDocument(); 367 Vector<Cookie> cookiesList; 368 bool isImplemented = getRawCookies(doc, doc->cookieURL(), cookiesList); 369 370 if (!isImplemented) 371 m_frontend->didGetCookies(callId, m_frontend->newScriptArray(), doc->cookie()); 372 else 373 m_frontend->didGetCookies(callId, buildArrayForCookies(cookiesList), String()); 374 } 375 361 376 ScriptObject InspectorDOMAgent::buildObjectForNode(Node* node, int depth, NodeToIdMap* nodesMap) 362 377 { … … 441 456 } 442 457 458 ScriptObject InspectorDOMAgent::buildObjectForCookie(const Cookie& cookie) 459 { 460 ScriptObject value = m_frontend->newScriptObject(); 461 value.set("name", cookie.name); 462 value.set("value", cookie.value); 463 value.set("domain", cookie.domain); 464 value.set("path", cookie.path); 465 value.set("expires", cookie.expires); 466 value.set("size", static_cast<int>(cookie.name.length() + cookie.value.length())); 467 value.set("httpOnly", cookie.httpOnly); 468 value.set("secure", cookie.secure); 469 value.set("session", cookie.session); 470 return value; 471 } 472 473 ScriptArray InspectorDOMAgent::buildArrayForCookies(const Vector<Cookie>& cookiesList) 474 { 475 ScriptArray cookies = m_frontend->newScriptArray(); 476 unsigned length = cookiesList.size(); 477 for (unsigned i = 0; i < length; ++i) { 478 const Cookie& cookie = cookiesList[i]; 479 cookies.set(i, buildObjectForCookie(cookie)); 480 } 481 return cookies; 482 } 483 443 484 Node* InspectorDOMAgent::innerFirstChild(Node* node) 444 485 { -
trunk/WebCore/inspector/InspectorDOMAgent.h
r47513 r47656 52 52 class Page; 53 53 54 struct Cookie; 55 54 56 class InspectorDOMAgent : public EventListener { 55 57 public: … … 62 64 void removeAttribute(long callId, long elementId, const String& name); 63 65 void setTextNodeValue(long callId, long nodeId, const String& value); 66 void getCookies(long callId); 64 67 65 68 // Methods called from the InspectorController. … … 86 89 ScriptArray buildArrayForElementAttributes(Element* element); 87 90 ScriptArray buildArrayForContainerChildren(Node* container, int depth, NodeToIdMap* nodesMap); 91 92 ScriptObject buildObjectForCookie(const Cookie& cookie); 93 ScriptArray buildArrayForCookies(const Vector<Cookie>& cookiesList); 88 94 89 95 // We represent embedded doms as a part of the same hierarchy. Hence we treat children of frame owners differently. -
trunk/WebCore/inspector/InspectorFrontend.cpp
r47639 r47656 348 348 } 349 349 350 void InspectorFrontend::didGetCookies(int callId, const ScriptArray& cookies, const String& cookiesString) 351 { 352 OwnPtr<ScriptFunctionCall> function(newFunctionCall("didGetCookies")); 353 function->appendArgument(callId); 354 function->appendArgument(cookies); 355 function->appendArgument(cookiesString); 356 function->call(); 357 } 358 350 359 #if ENABLE(DATABASE) 351 360 void InspectorFrontend::selectDatabase(Database* database) -
trunk/WebCore/inspector/InspectorFrontend.h
r47513 r47656 113 113 void didApplyDomChange(int callId, bool success); 114 114 115 void didGetCookies(int callId, const ScriptArray& cookies, const String& cookiesString); 116 115 117 void addNodesToSearchResult(const String& nodeIds); 116 118 -
trunk/WebCore/inspector/front-end/CookieItemsView.js
r47363 r47656 32 32 WebInspector.View.call(this); 33 33 34 // Some Platforms have not yet implemented access to raw cookies35 // Those platforms will return undefined instead of an Array36 // For these platforms we:37 // - resort to document.cookie38 // - do not show the delete cookie status bar button39 this._useFallback = typeof InspectorController.cookies() === "undefined";40 41 34 this.element.addStyleClass("storage-view"); 42 35 this.element.addStyleClass("table"); … … 53 46 get statusBarItems() 54 47 { 55 if (this._useFallback) 56 return [this.refreshButton.element]; 57 else 58 return [this.refreshButton.element, this.deleteButton.element]; 48 return [this.refreshButton.element, this.deleteButton.element]; 59 49 }, 60 50 … … 73 63 update: function() 74 64 { 75 if (this._useFallback) {76 this.fallbackUpdate();77 return;78 }79 80 65 this.element.removeChildren(); 81 var dataGrid = this.dataGridForCookies(); 82 if (dataGrid) { 83 this._dataGrid = dataGrid; 84 this.element.appendChild(dataGrid.element); 85 this.deleteButton.visible = true; 86 } else { 87 var emptyMsgElement = document.createElement("div"); 88 emptyMsgElement.className = "storage-table-empty"; 89 emptyMsgElement.textContent = WebInspector.UIString("This site has no cookies."); 90 this.element.appendChild(emptyMsgElement); 91 this._dataGrid = null; 92 this.deleteButton.visible = false; 93 } 94 }, 95 96 buildCookies: function() 97 { 98 var rawCookies = InspectorController.cookies(); 99 var cookies = []; 100 for (var i = 0; i < rawCookies.length; ++i) { 101 var cookie = rawCookies[i]; 102 cookie.expires = new Date(cookie.expires); 103 cookies.push(cookie); 104 } 105 106 return cookies; 107 }, 108 109 dataGridForCookies: function() 110 { 111 var cookies = this.buildCookies(); 66 67 var self = this; 68 function callback(cookies, isAdvanced) { 69 var dataGrid = (isAdvanced ? self.dataGridForCookies(cookies) : self.simpleDataGridForCookies(cookies)); 70 if (dataGrid) { 71 self._dataGrid = dataGrid; 72 self.element.appendChild(dataGrid.element); 73 if (isAdvanced) 74 self.deleteButton.visible = true; 75 } else { 76 var emptyMsgElement = document.createElement("div"); 77 emptyMsgElement.className = "storage-table-empty"; 78 emptyMsgElement.textContent = WebInspector.UIString("This site has no cookies."); 79 self.element.appendChild(emptyMsgElement); 80 self._dataGrid = null; 81 self.deleteButton.visible = false; 82 } 83 } 84 85 WebInspector.Cookies.getCookiesAsync(callback); 86 }, 87 88 dataGridForCookies: function(cookies) 89 { 112 90 if (!cookies.length) 113 91 return null; 92 93 for (var i = 0; i < cookies.length; ++i) 94 cookies[i].expires = new Date(cookies[i].expires); 114 95 115 96 var columns = { 0: {}, 1: {}, 2: {}, 3: {}, 4: {}, 5: {}, 6: {}, 7: {} }; … … 150 131 updateDataAndColumn(2, cookie.domain); 151 132 updateDataAndColumn(3, cookie.path); 152 updateDataAndColumn(4, (cookie.session ? "Session": cookie.expires.toGMTString()));133 updateDataAndColumn(4, (cookie.session ? WebInspector.UIString("Session") : cookie.expires.toGMTString())); 153 134 updateDataAndColumn(5, Number.bytesToString(cookie.size, WebInspector.UIString)); 154 135 updateDataAndColumn(6, (cookie.httpOnly ? "\u2713" : "")); // Checkmark … … 212 193 }, 213 194 214 fallbackUpdate: function() 215 { 216 this.element.removeChildren(); 217 218 var self = this; 219 function callback(rawCookieString) { 220 var cookies = self.fallbackBuildCookiesFromString(rawCookieString); 221 var dataGrid = self.fallbackDataGridForCookies(cookies); 222 if (dataGrid) { 223 self._dataGrid = dataGrid; 224 self.element.appendChild(dataGrid.element); 225 self.deleteButton.visible = true; 226 } else { 227 var emptyMsgElement = document.createElement("div"); 228 emptyMsgElement.className = "storage-table-empty"; 229 emptyMsgElement.textContent = WebInspector.UIString("This site has no cookies."); 230 self.element.appendChild(emptyMsgElement); 231 self._dataGrid = null; 232 self.deleteButton.visible = false; 233 } 234 } 235 236 InspectorController.getCookies(callback); 237 }, 238 239 fallbackBuildCookiesFromString: function(rawCookieString) 240 { 241 var rawCookies = rawCookieString.split(/;\s*/); 242 var cookies = []; 243 244 if (!(/^\s*$/.test(rawCookieString))) { 245 for (var i = 0; i < rawCookies.length; ++i) { 246 var cookie = rawCookies[i]; 247 var delimIndex = cookie.indexOf("="); 248 var name = cookie.substring(0, delimIndex); 249 var value = cookie.substring(delimIndex + 1); 250 var size = name.length + value.length; 251 cookies.push({ name: name, value: value, size: size }); 252 } 253 } 254 255 return cookies; 256 }, 257 258 fallbackDataGridForCookies: function(cookies) 195 simpleDataGridForCookies: function(cookies) 259 196 { 260 197 if (!cookies.length) … … 313 250 _deleteButtonClicked: function(event) 314 251 { 315 if (!this._dataGrid || this._useFallback)252 if (!this._dataGrid) 316 253 return; 317 254 -
trunk/WebCore/inspector/front-end/DOMAgent.js
r47513 r47656 1 1 /* 2 2 * Copyright (C) 2009 Google Inc. All rights reserved. 3 * Copyright (C) 2009 Joseph Pecoraro 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 440 441 } 441 442 442 WebInspector.CSSStyleDeclaration = function(payload) { 443 WebInspector.Cookies = {} 444 445 WebInspector.Cookies.getCookiesAsync = function(callback) 446 { 447 function mycallback(cookies, cookiesString) { 448 if (cookiesString) 449 callback(WebInspector.Cookies.buildCookiesFromString(cookiesString), false); 450 else 451 callback(cookies, true); 452 } 453 var callId = WebInspector.Callback.wrap(mycallback); 454 InspectorController.getCookies(callId); 455 } 456 457 WebInspector.Cookies.buildCookiesFromString = function(rawCookieString) 458 { 459 var rawCookies = rawCookieString.split(/;\s*/); 460 var cookies = []; 461 462 if (!(/^\s*$/.test(rawCookieString))) { 463 for (var i = 0; i < rawCookies.length; ++i) { 464 var cookie = rawCookies[i]; 465 var delimIndex = cookie.indexOf("="); 466 var name = cookie.substring(0, delimIndex); 467 var value = cookie.substring(delimIndex + 1); 468 var size = name.length + value.length; 469 cookies.push({ name: name, value: value, size: size }); 470 } 471 } 472 473 return cookies; 474 } 475 476 WebInspector.CSSStyleDeclaration = function(payload) 477 { 443 478 this.id = payload.id; 444 479 this.width = payload.width; … … 608 643 } 609 644 645 WebInspector.didGetCookies = WebInspector.Callback.processCallback; 610 646 WebInspector.didGetChildNodes = WebInspector.Callback.processCallback; 611 647 WebInspector.didPerformSearch = WebInspector.Callback.processCallback; … … 733 769 }, 0); 734 770 } 735 736 InspectorController.getCookies = function(callback)737 {738 setTimeout(function() {739 callback(InjectedScript.getCookies());740 }, 0);741 } -
trunk/WebCore/inspector/front-end/InjectedScript.js
r47513 r47656 1 1 /* 2 2 * Copyright (C) 2007 Apple Inc. All rights reserved. 3 * Copyright (C) 2009 Joseph Pecoraro4 3 * 5 4 * Redistribution and use in source and binary forms, with or without … … 758 757 InjectedScript._searchResults = []; 759 758 return true; 760 }761 762 InjectedScript.getCookies = function()763 {764 return InjectedScript._window().document.cookie;765 759 } 766 760 -
trunk/WebCore/platform/Cookie.h
r47205 r47656 31 31 namespace WebCore { 32 32 33 // This struct is currently only used to provide more cookies information 34 // to the Web Inspector. 35 33 36 struct Cookie { 34 37 Cookie(const String& name, const String& value, const String& domain,
Note: See TracChangeset
for help on using the changeset viewer.