cros: Remove default pinned apps trial.
[chromium-blink-merge.git] / chrome / browser / browsing_data / mock_browsing_data_cookie_helper.cc
blobb8511e047192bf2e316086a9115e31a3061b2b3f
1 // Copyright (c) 2012 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/browsing_data/mock_browsing_data_cookie_helper.h"
7 #include "base/logging.h"
8 #include "net/cookies/canonical_cookie.h"
9 #include "net/cookies/parsed_cookie.h"
11 MockBrowsingDataCookieHelper::MockBrowsingDataCookieHelper(
12 net::URLRequestContextGetter* request_context_getter)
13 : BrowsingDataCookieHelper(request_context_getter) {
16 MockBrowsingDataCookieHelper::~MockBrowsingDataCookieHelper() {
19 void MockBrowsingDataCookieHelper::StartFetching(
20 const net::CookieMonster::GetCookieListCallback &callback) {
21 callback_ = callback;
24 void MockBrowsingDataCookieHelper::DeleteCookie(
25 const net::CanonicalCookie& cookie) {
26 std::string key = cookie.Name() + "=" + cookie.Value();
27 CHECK(cookies_.find(key) != cookies_.end());
28 cookies_[key] = false;
31 void MockBrowsingDataCookieHelper::AddCookieSamples(
32 const GURL& url, const std::string& cookie_line) {
33 typedef net::CookieList::const_iterator cookie_iterator;
34 net::ParsedCookie pc(cookie_line);
35 scoped_ptr<net::CanonicalCookie> cc(new net::CanonicalCookie(url, pc));
37 if (cc.get()) {
38 for (cookie_iterator cookie = cookie_list_.begin();
39 cookie != cookie_list_.end(); ++cookie) {
40 if (cookie->Name() == cc->Name() &&
41 cookie->Domain() == cc->Domain()&&
42 cookie->Path() == cc->Path()) {
43 return;
46 cookie_list_.push_back(*cc);
47 cookies_[cookie_line] = true;
51 void MockBrowsingDataCookieHelper::Notify() {
52 if (!callback_.is_null())
53 callback_.Run(cookie_list_);
56 void MockBrowsingDataCookieHelper::Reset() {
57 for (std::map<const std::string, bool>::iterator i = cookies_.begin();
58 i != cookies_.end(); ++i)
59 i->second = true;
62 bool MockBrowsingDataCookieHelper::AllDeleted() {
63 for (std::map<const std::string, bool>::const_iterator i = cookies_.begin();
64 i != cookies_.end(); ++i)
65 if (i->second)
66 return false;
67 return true;