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

Side by Side Diff: Source/WebCore/inspector/InspectorPageAgent.cpp

Issue 7608014: Merge 92672 - Web Inspector: Resources panel does not show main resource cookies. (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/835/
Patch Set: Created 9 years, 4 months 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
« no previous file with comments | « Source/WebCore/ChangeLog ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 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 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 Vector<CachedResource*> result; 353 Vector<CachedResource*> result;
354 354
355 const CachedResourceLoader::DocumentResourceMap& allResources = frame->docum ent()->cachedResourceLoader()->allCachedResources(); 355 const CachedResourceLoader::DocumentResourceMap& allResources = frame->docum ent()->cachedResourceLoader()->allCachedResources();
356 CachedResourceLoader::DocumentResourceMap::const_iterator end = allResources .end(); 356 CachedResourceLoader::DocumentResourceMap::const_iterator end = allResources .end();
357 for (CachedResourceLoader::DocumentResourceMap::const_iterator it = allResou rces.begin(); it != end; ++it) 357 for (CachedResourceLoader::DocumentResourceMap::const_iterator it = allResou rces.begin(); it != end; ++it)
358 result.append(it->second.get()); 358 result.append(it->second.get());
359 359
360 return result; 360 return result;
361 } 361 }
362 362
363 static Vector<KURL> allResourcesURLsForFrame(Frame* frame)
364 {
365 Vector<KURL> result;
366
367 result.append(frame->loader()->documentLoader()->url());
368
369 Vector<CachedResource*> allResources = cachedResourcesForFrame(frame);
370 for (Vector<CachedResource*>::const_iterator it = allResources.begin(); it ! = allResources.end(); ++it)
371 result.append((*it)->url());
372
373 return result;
374 }
375
363 void InspectorPageAgent::getCookies(ErrorString*, RefPtr<InspectorArray>* cookie s, WTF::String* cookiesString) 376 void InspectorPageAgent::getCookies(ErrorString*, RefPtr<InspectorArray>* cookie s, WTF::String* cookiesString)
364 { 377 {
365 // If we can get raw cookies. 378 // If we can get raw cookies.
366 ListHashSet<Cookie> rawCookiesList; 379 ListHashSet<Cookie> rawCookiesList;
367 380
368 // If we can't get raw cookies - fall back to String representation 381 // If we can't get raw cookies - fall back to String representation
369 String stringCookiesList; 382 String stringCookiesList;
370 383
371 // Return value to getRawCookies should be the same for every call because 384 // Return value to getRawCookies should be the same for every call because
372 // the return value is platform/network backend specific, and the call will 385 // the return value is platform/network backend specific, and the call will
373 // always return the same true/false value. 386 // always return the same true/false value.
374 bool rawCookiesImplemented = false; 387 bool rawCookiesImplemented = false;
375 388
376 for (Frame* frame = mainFrame(); frame; frame = frame->tree()->traverseNext( mainFrame())) { 389 for (Frame* frame = mainFrame(); frame; frame = frame->tree()->traverseNext( mainFrame())) {
377 Document* document = frame->document(); 390 Document* document = frame->document();
378 Vector<CachedResource*> allResources = cachedResourcesForFrame(frame); 391 Vector<KURL> allURLs = allResourcesURLsForFrame(frame);
379 for (Vector<CachedResource*>::const_iterator it = allResources.begin(); it != allResources.end(); ++it) { 392 for (Vector<KURL>::const_iterator it = allURLs.begin(); it != allURLs.en d(); ++it) {
380 Vector<Cookie> docCookiesList; 393 Vector<Cookie> docCookiesList;
381 rawCookiesImplemented = getRawCookies(document, KURL(ParsedURLString , (*it)->url()), docCookiesList); 394 rawCookiesImplemented = getRawCookies(document, KURL(ParsedURLString , *it), docCookiesList);
382
383 if (!rawCookiesImplemented) { 395 if (!rawCookiesImplemented) {
384 // FIXME: We need duplication checking for the String representa tion of cookies. 396 // FIXME: We need duplication checking for the String representa tion of cookies.
385 ExceptionCode ec = 0; 397 ExceptionCode ec = 0;
386 stringCookiesList += document->cookie(ec); 398 stringCookiesList += document->cookie(ec);
387 // Exceptions are thrown by cookie() in sandboxed frames. That w on't happen here 399 // Exceptions are thrown by cookie() in sandboxed frames. That w on't happen here
388 // because "document" is the document of the main frame of the p age. 400 // because "document" is the document of the main frame of the p age.
389 ASSERT(!ec); 401 ASSERT(!ec);
390 } else { 402 } else {
391 int cookiesSize = docCookiesList.size(); 403 int cookiesSize = docCookiesList.size();
392 for (int i = 0; i < cookiesSize; i++) { 404 for (int i = 0; i < cookiesSize; i++) {
(...skipping 10 matching lines...) Expand all
403 *cookiesString = stringCookiesList; 415 *cookiesString = stringCookiesList;
404 } 416 }
405 417
406 void InspectorPageAgent::deleteCookie(ErrorString*, const String& cookieName, co nst String& domain) 418 void InspectorPageAgent::deleteCookie(ErrorString*, const String& cookieName, co nst String& domain)
407 { 419 {
408 for (Frame* frame = m_page->mainFrame(); frame; frame = frame->tree()->trave rseNext(m_page->mainFrame())) { 420 for (Frame* frame = m_page->mainFrame(); frame; frame = frame->tree()->trave rseNext(m_page->mainFrame())) {
409 Document* document = frame->document(); 421 Document* document = frame->document();
410 if (document->url().host() != domain) 422 if (document->url().host() != domain)
411 continue; 423 continue;
412 424
413 Vector<CachedResource*> allResources = cachedResourcesForFrame(frame); 425 Vector<KURL> allURLs = allResourcesURLsForFrame(frame);
414 for (Vector<CachedResource*>::const_iterator it = allResources.begin(); it != allResources.end(); ++it) 426 for (Vector<KURL>::const_iterator it = allURLs.begin(); it != allURLs.en d(); ++it)
415 WebCore::deleteCookie(document, KURL(ParsedURLString, (*it)->url()), cookieName); 427 WebCore::deleteCookie(document, KURL(ParsedURLString, *it), cookieNa me);
416 } 428 }
417 } 429 }
418 430
419 void InspectorPageAgent::getResourceTree(ErrorString*, RefPtr<InspectorObject>* object) 431 void InspectorPageAgent::getResourceTree(ErrorString*, RefPtr<InspectorObject>* object)
420 { 432 {
421 *object = buildObjectForFrameTree(m_page->mainFrame()); 433 *object = buildObjectForFrameTree(m_page->mainFrame());
422 } 434 }
423 435
424 void InspectorPageAgent::getResourceContent(ErrorString* errorString, const Stri ng& frameId, const String& url, String* content, bool* base64Encoded) 436 void InspectorPageAgent::getResourceContent(ErrorString* errorString, const Stri ng& frameId, const String& url, String* content, bool* base64Encoded)
425 { 437 {
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 result->setArray("childFrames", childrenArray); 657 result->setArray("childFrames", childrenArray);
646 } 658 }
647 childrenArray->pushObject(buildObjectForFrameTree(child)); 659 childrenArray->pushObject(buildObjectForFrameTree(child));
648 } 660 }
649 return result; 661 return result;
650 } 662 }
651 663
652 } // namespace WebCore 664 } // namespace WebCore
653 665
654 #endif // ENABLE(INSPECTOR) 666 #endif // ENABLE(INSPECTOR)
OLDNEW
« no previous file with comments | « Source/WebCore/ChangeLog ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698