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

Side by Side Diff: chrome/browser/mock_browsing_data_cookie_helper.cc

Issue 10785017: Move CanonicalCookie into separate files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added missing include Created 8 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 #include "chrome/browser/mock_browsing_data_cookie_helper.h" 5 #include "chrome/browser/mock_browsing_data_cookie_helper.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "net/cookies/canonical_cookie.h"
8 #include "net/cookies/parsed_cookie.h" 9 #include "net/cookies/parsed_cookie.h"
9 10
10 MockBrowsingDataCookieHelper::MockBrowsingDataCookieHelper( 11 MockBrowsingDataCookieHelper::MockBrowsingDataCookieHelper(
11 net::URLRequestContextGetter* request_context_getter) 12 net::URLRequestContextGetter* request_context_getter)
12 : BrowsingDataCookieHelper(request_context_getter) { 13 : BrowsingDataCookieHelper(request_context_getter) {
13 } 14 }
14 15
15 MockBrowsingDataCookieHelper::~MockBrowsingDataCookieHelper() { 16 MockBrowsingDataCookieHelper::~MockBrowsingDataCookieHelper() {
16 } 17 }
17 18
18 void MockBrowsingDataCookieHelper::StartFetching( 19 void MockBrowsingDataCookieHelper::StartFetching(
19 const net::CookieMonster::GetCookieListCallback &callback) { 20 const net::CookieMonster::GetCookieListCallback &callback) {
20 callback_ = callback; 21 callback_ = callback;
21 } 22 }
22 23
23 void MockBrowsingDataCookieHelper::DeleteCookie( 24 void MockBrowsingDataCookieHelper::DeleteCookie(
24 const net::CookieMonster::CanonicalCookie& cookie) { 25 const net::CanonicalCookie& cookie) {
25 std::string key = cookie.Name() + "=" + cookie.Value(); 26 std::string key = cookie.Name() + "=" + cookie.Value();
26 CHECK(cookies_.find(key) != cookies_.end()); 27 CHECK(cookies_.find(key) != cookies_.end());
27 cookies_[key] = false; 28 cookies_[key] = false;
28 } 29 }
29 30
30 void MockBrowsingDataCookieHelper::AddCookieSamples( 31 void MockBrowsingDataCookieHelper::AddCookieSamples(
31 const GURL& url, const std::string& cookie_line) { 32 const GURL& url, const std::string& cookie_line) {
32 typedef net::CookieList::const_iterator cookie_iterator; 33 typedef net::CookieList::const_iterator cookie_iterator;
33 net::ParsedCookie pc(cookie_line); 34 net::ParsedCookie pc(cookie_line);
34 scoped_ptr<net::CookieMonster::CanonicalCookie> cc; 35 scoped_ptr<net::CanonicalCookie> cc(new net::CanonicalCookie(url, pc));
35 cc.reset(new net::CookieMonster::CanonicalCookie(url, pc));
36 36
37 if (cc.get()) { 37 if (cc.get()) {
38 for (cookie_iterator cookie = cookie_list_.begin(); 38 for (cookie_iterator cookie = cookie_list_.begin();
39 cookie != cookie_list_.end(); ++cookie) { 39 cookie != cookie_list_.end(); ++cookie) {
40 if (cookie->Name() == cc->Name() && 40 if (cookie->Name() == cc->Name() &&
41 cookie->Domain() == cc->Domain()&& 41 cookie->Domain() == cc->Domain()&&
42 cookie->Path() == cc->Path()) { 42 cookie->Path() == cc->Path()) {
43 return; 43 return;
44 } 44 }
45 } 45 }
(...skipping 13 matching lines...) Expand all
59 i->second = true; 59 i->second = true;
60 } 60 }
61 61
62 bool MockBrowsingDataCookieHelper::AllDeleted() { 62 bool MockBrowsingDataCookieHelper::AllDeleted() {
63 for (std::map<const std::string, bool>::const_iterator i = cookies_.begin(); 63 for (std::map<const std::string, bool>::const_iterator i = cookies_.begin();
64 i != cookies_.end(); ++i) 64 i != cookies_.end(); ++i)
65 if (i->second) 65 if (i->second)
66 return false; 66 return false;
67 return true; 67 return true;
68 } 68 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698