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

Side by Side Diff: net/base/cookie_monster.cc

Issue 294025: DevTools: Implement raw cookies access for inspector. (Closed)
Patch Set: '' Created 11 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 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Portions of this code based on Mozilla: 5 // Portions of this code based on Mozilla:
6 // (netwerk/cookie/src/nsCookieService.cpp) 6 // (netwerk/cookie/src/nsCookieService.cpp)
7 /* ***** BEGIN LICENSE BLOCK ***** 7 /* ***** BEGIN LICENSE BLOCK *****
8 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 8 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
9 * 9 *
10 * The contents of this file are subject to the Mozilla Public License Version 10 * The contents of this file are subject to the Mozilla Public License Version
(...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 if (!(*it)->Name().empty()) 762 if (!(*it)->Name().empty())
763 cookie_line += (*it)->Name() + "="; 763 cookie_line += (*it)->Name() + "=";
764 cookie_line += (*it)->Value(); 764 cookie_line += (*it)->Value();
765 } 765 }
766 766
767 COOKIE_DLOG(INFO) << "GetCookies() result: " << cookie_line; 767 COOKIE_DLOG(INFO) << "GetCookies() result: " << cookie_line;
768 768
769 return cookie_line; 769 return cookie_line;
770 } 770 }
771 771
772 void CookieMonster::GetRawCookies(const GURL& url,
773 std::vector<CanonicalCookie>* raw_cookies) {
774 raw_cookies->clear();
775 if (!HasCookieableScheme(url))
776 return;
777
778 CookieOptions options;
779 options.set_include_httponly();
780 // Get the cookies for this host and its domain(s).
781 std::vector<CanonicalCookie*> cookies;
782 FindCookiesForHostAndDomain(url, options, &cookies);
783 std::sort(cookies.begin(), cookies.end(), CookieSorter);
784
785 for (std::vector<CanonicalCookie*>::const_iterator it = cookies.begin();
786 it != cookies.end(); ++it)
787 raw_cookies->push_back(*(*it));
788 }
789
790 void CookieMonster::DeleteCookie(const GURL& url,
791 const std::string& cookie_name) {
792 if (!HasCookieableScheme(url))
793 return;
794
795 for (CookieMapItPair its = cookies_.equal_range(url.host());
796 its.first != its.second; ++its.first) {
797 if (its.first->second->Name() == cookie_name) {
798 InternalDeleteCookie(its.first, true);
799 return;
800 }
801 }
802 }
803
772 CookieMonster::CookieList CookieMonster::GetAllCookies() { 804 CookieMonster::CookieList CookieMonster::GetAllCookies() {
773 AutoLock autolock(lock_); 805 AutoLock autolock(lock_);
774 InitIfNecessary(); 806 InitIfNecessary();
775 807
776 // This function is being called to scrape the cookie list for management UI 808 // This function is being called to scrape the cookie list for management UI
777 // or similar. We shouldn't show expired cookies in this list since it will 809 // or similar. We shouldn't show expired cookies in this list since it will
778 // just be confusing to users, and this function is called rarely enough (and 810 // just be confusing to users, and this function is called rarely enough (and
779 // is already slow enough) that it's OK to take the time to garbage collect 811 // is already slow enough) that it's OK to take the time to garbage collect
780 // the expired cookies now. 812 // the expired cookies now.
781 // 813 //
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
1124 return true; 1156 return true;
1125 } 1157 }
1126 1158
1127 std::string CookieMonster::CanonicalCookie::DebugString() const { 1159 std::string CookieMonster::CanonicalCookie::DebugString() const {
1128 return StringPrintf("name: %s value: %s path: %s creation: %llu", 1160 return StringPrintf("name: %s value: %s path: %s creation: %llu",
1129 name_.c_str(), value_.c_str(), path_.c_str(), 1161 name_.c_str(), value_.c_str(), path_.c_str(),
1130 creation_date_.ToTimeT()); 1162 creation_date_.ToTimeT());
1131 } 1163 }
1132 1164
1133 } // namespace 1165 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698