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

Side by Side Diff: chrome/browser/browsing_data_cookie_helper.h

Issue 10092013: Display third party cookies and site data counts in the WebsiteSettings UI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: "Fix CannedBrowsingDataDatabaseHelperTest.*" Created 8 years, 7 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 #ifndef CHROME_BROWSER_BROWSING_DATA_COOKIE_HELPER_H_ 5 #ifndef CHROME_BROWSER_BROWSING_DATA_COOKIE_HELPER_H_
6 #define CHROME_BROWSER_BROWSING_DATA_COOKIE_HELPER_H_ 6 #define CHROME_BROWSER_BROWSING_DATA_COOKIE_HELPER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map>
9 #include <string> 10 #include <string>
10 11
11 #include "base/basictypes.h" 12 #include "base/basictypes.h"
12 #include "base/callback.h" 13 #include "base/callback.h"
13 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
14 #include "net/cookies/cookie_monster.h" 15 #include "net/cookies/cookie_monster.h"
15 16
16 class GURL; 17 class GURL;
17 class Profile; 18 class Profile;
18 19
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 base::Callback<void(const net::CookieList& cookies)> completion_callback_; 74 base::Callback<void(const net::CookieList& cookies)> completion_callback_;
74 75
75 DISALLOW_COPY_AND_ASSIGN(BrowsingDataCookieHelper); 76 DISALLOW_COPY_AND_ASSIGN(BrowsingDataCookieHelper);
76 }; 77 };
77 78
78 // This class is a thin wrapper around BrowsingDataCookieHelper that does not 79 // This class is a thin wrapper around BrowsingDataCookieHelper that does not
79 // fetch its information from the persistent cookie store, but gets them passed 80 // fetch its information from the persistent cookie store, but gets them passed
80 // as a parameter during construction. 81 // as a parameter during construction.
81 class CannedBrowsingDataCookieHelper : public BrowsingDataCookieHelper { 82 class CannedBrowsingDataCookieHelper : public BrowsingDataCookieHelper {
82 public: 83 public:
84 typedef std::map<GURL, net::CookieList*> OriginCookieListMap;
85
83 explicit CannedBrowsingDataCookieHelper(Profile* profile); 86 explicit CannedBrowsingDataCookieHelper(Profile* profile);
84 87
85 // Return a copy of the cookie helper. Only one consumer can use the 88 // Return a copy of the cookie helper. Only one consumer can use the
86 // StartFetching method at a time, so we need to create a copy of the helper 89 // StartFetching method at a time, so we need to create a copy of the helper
87 // everytime we instantiate a cookies tree model for it. 90 // everytime we instantiate a cookies tree model for it.
88 CannedBrowsingDataCookieHelper* Clone(); 91 CannedBrowsingDataCookieHelper* Clone();
89 92
90 // Adds cookies and delete the current cookies with the same Name, Domain, 93 // Adds cookies and delete the current cookies with the same Name, Domain,
91 // and Path as the newly created ones. 94 // and Path as the newly created ones.
92 void AddReadCookies(const GURL& url, 95 void AddReadCookies(const GURL& frame_url,
96 const GURL& request_url,
93 const net::CookieList& cookie_list); 97 const net::CookieList& cookie_list);
94 98
95 // Adds cookies that will be stored by the CookieMonster. Designed to mirror 99 // Adds cookies that will be stored by the CookieMonster. Designed to mirror
96 // the logic of SetCookieWithOptions. 100 // the logic of SetCookieWithOptions.
97 void AddChangedCookie(const GURL& url, 101 void AddChangedCookie(const GURL& frame_url,
102 const GURL& request_url,
98 const std::string& cookie_line, 103 const std::string& cookie_line,
99 const net::CookieOptions& options); 104 const net::CookieOptions& options);
100 105
101 // Clears the list of canned cookies. 106 // Clears the list of canned cookies.
102 void Reset(); 107 void Reset();
103 108
104 // True if no cookie are currently stored. 109 // True if no cookie are currently stored.
105 bool empty() const; 110 bool empty() const;
106 111
107 // BrowsingDataCookieHelper methods. 112 // BrowsingDataCookieHelper methods.
108 virtual void StartFetching( 113 virtual void StartFetching(
109 const net::CookieMonster::GetCookieListCallback& callback) OVERRIDE; 114 const net::CookieMonster::GetCookieListCallback& callback) OVERRIDE;
110 115
111 // Returns the currently stored number of cookies. 116 // Returns the number of stored cookies.
112 size_t GetCookieCount() const; 117 size_t GetCookieCount() const;
113 118
119 // Returns the map that contains the cookie lists for all frame urls.
120 const OriginCookieListMap& origin_cookie_list_map() {
121 return origin_cookie_list_map_;
122 }
123
114 private: 124 private:
115 // Check if the cookie list contains a cookie with the same name, 125 // Check if the cookie list contains a cookie with the same name,
116 // domain, and path as the newly created cookie. Delete the old cookie 126 // domain, and path as the newly created cookie. Delete the old cookie
117 // if does. 127 // if does.
118 bool DeleteMetchingCookie( 128 bool DeleteMatchingCookie(
119 const net::CookieMonster::CanonicalCookie& add_cookie); 129 const net::CookieMonster::CanonicalCookie& add_cookie,
130 net::CookieList* cookie_list);
120 131
121 virtual ~CannedBrowsingDataCookieHelper(); 132 virtual ~CannedBrowsingDataCookieHelper();
122 133
123 net::CookieList cookie_list_; 134 // Returns the |CookieList| for the given |origin|.
135 net::CookieList* GetCookiesFor(const GURL& origin);
136
137 // Adds the |cookie| to the cookie list for the given |frame_url|.
138 void AddCookie(
139 const GURL& frame_url,
140 const net::CookieMonster::CanonicalCookie& cookie);
141
142 // Map that contains the cookie lists for all frame origins.
143 OriginCookieListMap origin_cookie_list_map_;
124 144
125 DISALLOW_COPY_AND_ASSIGN(CannedBrowsingDataCookieHelper); 145 DISALLOW_COPY_AND_ASSIGN(CannedBrowsingDataCookieHelper);
126 }; 146 };
127 147
128 #endif // CHROME_BROWSER_BROWSING_DATA_COOKIE_HELPER_H_ 148 #endif // CHROME_BROWSER_BROWSING_DATA_COOKIE_HELPER_H_
OLDNEW
« no previous file with comments | « chrome/browser/browsing_data_appcache_helper.cc ('k') | chrome/browser/browsing_data_cookie_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698