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

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

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: " 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 #include "chrome/browser/browsing_data_local_storage_helper.h" 5 #include "chrome/browser/browsing_data_local_storage_helper.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "chrome/browser/browsing_data_helper.h" 12 #include "chrome/browser/browsing_data_helper.h"
13 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "content/public/browser/browser_thread.h" 14 #include "content/public/browser/browser_thread.h"
15 #include "content/public/browser/dom_storage_context.h" 15 #include "content/public/browser/dom_storage_context.h"
16 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCString.h " 16 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCString.h "
17 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" 17 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h"
19 #include "webkit/glue/webkit_glue.h" 19 #include "webkit/glue/webkit_glue.h"
20 20
21 using content::BrowserContext; 21 using content::BrowserContext;
22 using content::BrowserThread; 22 using content::BrowserThread;
23 using content::DOMStorageContext; 23 using content::DOMStorageContext;
24 using WebKit::WebSecurityOrigin; 24 using WebKit::WebSecurityOrigin;
25 25
26 BrowsingDataLocalStorageHelper::LocalStorageInfo::LocalStorageInfo()
27 : port(0),
28 size(0) {
29 }
30
31 BrowsingDataLocalStorageHelper::LocalStorageInfo::LocalStorageInfo( 26 BrowsingDataLocalStorageHelper::LocalStorageInfo::LocalStorageInfo(
32 const std::string& protocol, 27 const std::string& protocol,
33 const std::string& host, 28 const std::string& host,
34 unsigned short port, 29 unsigned short port,
35 const std::string& database_identifier, 30 const std::string& database_identifier,
36 const std::string& origin, 31 const std::string& origin,
37 const FilePath& file_path, 32 const FilePath& file_path,
38 int64 size, 33 int64 size,
39 base::Time last_modified) 34 base::Time last_modified)
40 : protocol(protocol), 35 : protocol(protocol),
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 } 156 }
162 157
163 bool CannedBrowsingDataLocalStorageHelper::empty() const { 158 bool CannedBrowsingDataLocalStorageHelper::empty() const {
164 return local_storage_info_.empty() && pending_local_storage_info_.empty(); 159 return local_storage_info_.empty() && pending_local_storage_info_.empty();
165 } 160 }
166 161
167 size_t CannedBrowsingDataLocalStorageHelper::GetLocalStorageCount() const { 162 size_t CannedBrowsingDataLocalStorageHelper::GetLocalStorageCount() const {
168 return pending_local_storage_info_.size(); 163 return pending_local_storage_info_.size();
169 } 164 }
170 165
166 const std::set<GURL>&
167 CannedBrowsingDataLocalStorageHelper::GetLocalStorageInfo() const {
168 return pending_local_storage_info_;
169 }
170
171 void CannedBrowsingDataLocalStorageHelper::StartFetching( 171 void CannedBrowsingDataLocalStorageHelper::StartFetching(
172 const base::Callback<void(const std::list<LocalStorageInfo>&)>& callback) { 172 const base::Callback<void(const std::list<LocalStorageInfo>&)>& callback) {
173 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 173 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
174 DCHECK(!is_fetching_); 174 DCHECK(!is_fetching_);
175 DCHECK_EQ(false, callback.is_null()); 175 DCHECK_EQ(false, callback.is_null());
176 176
177 is_fetching_ = true; 177 is_fetching_ = true;
178 completion_callback_ = callback; 178 completion_callback_ = callback;
179 179
180 // We post a task to emulate async fetching behavior. 180 // We post a task to emulate async fetching behavior.
181 MessageLoop::current()->PostTask( 181 MessageLoop::current()->PostTask(
182 FROM_HERE, 182 FROM_HERE,
183 base::Bind(&CannedBrowsingDataLocalStorageHelper:: 183 base::Bind(&CannedBrowsingDataLocalStorageHelper::
184 ConvertPendingInfo, this)); 184 ConvertPendingInfo, this));
185 } 185 }
186 186
187 CannedBrowsingDataLocalStorageHelper::~CannedBrowsingDataLocalStorageHelper() {} 187 CannedBrowsingDataLocalStorageHelper::~CannedBrowsingDataLocalStorageHelper() {}
188 188
189 void CannedBrowsingDataLocalStorageHelper::ConvertPendingInfo() { 189 void CannedBrowsingDataLocalStorageHelper::ConvertPendingInfo() {
190 for (std::set<GURL>::iterator info = pending_local_storage_info_.begin(); 190 for (std::set<GURL>::iterator info = pending_local_storage_info_.begin();
191 info != pending_local_storage_info_.end(); ++info) { 191 info != pending_local_storage_info_.end(); ++info) {
192 local_storage_info_.clear();
192 WebSecurityOrigin web_security_origin = 193 WebSecurityOrigin web_security_origin =
193 WebSecurityOrigin::createFromString( 194 WebSecurityOrigin::createFromString(
194 UTF8ToUTF16(info->spec())); 195 UTF8ToUTF16(info->spec()));
195 std::string security_origin(web_security_origin.toString().utf8()); 196 std::string security_origin(web_security_origin.toString().utf8());
196 197
197 bool duplicate = false;
198 for (std::list<LocalStorageInfo>::iterator
199 local_storage = local_storage_info_.begin();
200 local_storage != local_storage_info_.end(); ++local_storage) {
201 if (local_storage->origin == security_origin) {
202 duplicate = true;
203 break;
204 }
205 }
206 if (duplicate)
207 continue;
208
209 local_storage_info_.push_back(LocalStorageInfo( 198 local_storage_info_.push_back(LocalStorageInfo(
210 web_security_origin.protocol().utf8(), 199 web_security_origin.protocol().utf8(),
211 web_security_origin.host().utf8(), 200 web_security_origin.host().utf8(),
212 web_security_origin.port(), 201 web_security_origin.port(),
213 web_security_origin.databaseIdentifier().utf8(), 202 web_security_origin.databaseIdentifier().utf8(),
214 security_origin, 203 security_origin,
215 dom_storage_context_-> 204 dom_storage_context_->
216 GetFilePath(web_security_origin.databaseIdentifier()), 205 GetFilePath(web_security_origin.databaseIdentifier()),
217 0, 206 0,
218 base::Time())); 207 base::Time()));
219 } 208 }
220 pending_local_storage_info_.clear();
221 209
222 BrowserThread::PostTask( 210 BrowserThread::PostTask(
223 BrowserThread::UI, FROM_HERE, 211 BrowserThread::UI, FROM_HERE,
224 base::Bind(&CannedBrowsingDataLocalStorageHelper::NotifyInUIThread, 212 base::Bind(&CannedBrowsingDataLocalStorageHelper::NotifyInUIThread,
225 this)); 213 this));
226 } 214 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698