chromeos: bluetooth: tie Proxy lifetime to object, not observer
[chromium-blink-merge.git] / chrome / browser / mock_browsing_data_cookie_helper.cc
blobbe897b52b36ea972e0185f609d79c0bfdf885787
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/mock_browsing_data_cookie_helper.h"
7 #include "base/logging.h"
9 MockBrowsingDataCookieHelper::MockBrowsingDataCookieHelper(Profile* profile)
10 : BrowsingDataCookieHelper(profile),
11 profile_(profile) {
14 MockBrowsingDataCookieHelper::~MockBrowsingDataCookieHelper() {
17 void MockBrowsingDataCookieHelper::StartFetching(
18 const net::CookieMonster::GetCookieListCallback &callback) {
19 callback_ = callback;
22 void MockBrowsingDataCookieHelper::CancelNotification() {
23 callback_.Reset();
26 void MockBrowsingDataCookieHelper::DeleteCookie(
27 const net::CookieMonster::CanonicalCookie& cookie) {
28 std::string key = cookie.Name() + "=" + cookie.Value();
29 CHECK(cookies_.find(key) != cookies_.end());
30 cookies_[key] = false;
33 void MockBrowsingDataCookieHelper::AddCookieSamples(
34 const GURL& url, const std::string& cookie_line) {
35 typedef net::CookieList::const_iterator cookie_iterator;
36 net::CookieMonster::ParsedCookie pc(cookie_line);
37 scoped_ptr<net::CookieMonster::CanonicalCookie> cc;
38 cc.reset(new net::CookieMonster::CanonicalCookie(url, pc));
40 if (cc.get()) {
41 for (cookie_iterator cookie = cookie_list_.begin();
42 cookie != cookie_list_.end(); ++cookie) {
43 if (cookie->Name() == cc->Name() &&
44 cookie->Domain() == cc->Domain()&&
45 cookie->Path() == cc->Path()) {
46 return;
49 cookie_list_.push_back(*cc);
50 cookies_[cookie_line] = true;
54 void MockBrowsingDataCookieHelper::Notify() {
55 if (!callback_.is_null())
56 callback_.Run(cookie_list_);
59 void MockBrowsingDataCookieHelper::Reset() {
60 for (std::map<const std::string, bool>::iterator i = cookies_.begin();
61 i != cookies_.end(); ++i)
62 i->second = true;
65 bool MockBrowsingDataCookieHelper::AllDeleted() {
66 for (std::map<const std::string, bool>::const_iterator i = cookies_.begin();
67 i != cookies_.end(); ++i)
68 if (i->second)
69 return false;
70 return true;