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

Unified Diff: chrome/browser/mock_browsing_data_cookie_helper.cc

Issue 7355025: Creat BrowsingDataCookieHelper and CannedBrowsingDataCookieHelper for logging cookies at UI thread. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/mock_browsing_data_cookie_helper.cc
===================================================================
--- chrome/browser/mock_browsing_data_cookie_helper.cc (revision 0)
+++ chrome/browser/mock_browsing_data_cookie_helper.cc (revision 0)
@@ -0,0 +1,69 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/mock_browsing_data_cookie_helper.h"
+
+MockBrowsingDataCookieHelper::MockBrowsingDataCookieHelper(Profile* profile)
+ : BrowsingDataCookieHelper(profile),
+ profile_(profile) {
+}
+
+MockBrowsingDataCookieHelper::~MockBrowsingDataCookieHelper() {
+}
+
+void MockBrowsingDataCookieHelper::StartFetching(
+ const net::CookieMonster::GetCookieListCallback &callback) {
+ callback_ = callback;
+}
+
+void MockBrowsingDataCookieHelper::CancelNotification() {
+ callback_.Reset();
+}
+
+void MockBrowsingDataCookieHelper::DeleteCookie(
+ const net::CookieMonster::CanonicalCookie& cookie) {
+ std::string key = cookie.Name() + "=" + cookie.Value();
+ CHECK(cookies_.find(key) != cookies_.end());
+ cookies_[key] = false;
+}
+
+void MockBrowsingDataCookieHelper::AddCookieSamples(
+ const GURL& url, const std::string& cookie_line) {
+ typedef net::CookieList::const_iterator cookie_iterator;
+ net::CookieMonster::ParsedCookie pc(cookie_line);
+ scoped_ptr<net::CookieMonster::CanonicalCookie> cc;
+ cc.reset(new net::CookieMonster::CanonicalCookie(url, pc));
+
+ if (cc.get()) {
+ for (cookie_iterator cookie = cookie_list_.begin();
+ cookie != cookie_list_.end(); ++cookie) {
+ if (cookie->Name() == cc->Name() &&
+ cookie->Domain() == cc->Domain()&&
+ cookie->Path() == cc->Path()) {
+ return;
+ }
+ }
+ cookie_list_.push_back(*cc);
+ cookies_[cookie_line] = true;
+ }
+}
+
+void MockBrowsingDataCookieHelper::Notify() {
+ if (!callback_.is_null())
+ callback_.Run(cookie_list_);
+}
+
+void MockBrowsingDataCookieHelper::Reset() {
+ for (std::map<const std::string, bool>::iterator i = cookies_.begin();
+ i != cookies_.end(); ++i)
+ i->second = true;
+}
+
+bool MockBrowsingDataCookieHelper::AllDeleted() {
+ for (std::map<const std::string, bool>::const_iterator i = cookies_.begin();
+ i != cookies_.end(); ++i)
+ if (i->second)
+ return false;
+ return true;
+}
Property changes on: chrome/browser/mock_browsing_data_cookie_helper.cc
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « chrome/browser/mock_browsing_data_cookie_helper.h ('k') | chrome/browser/safe_browsing/client_side_detection_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698