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

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

Issue 10636019: Adding Application Data dialog for isolated apps (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed merge conflicts 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
« no previous file with comments | « chrome/browser/cookies_tree_model.h ('k') | chrome/browser/cookies_tree_model_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/cookies_tree_model.h" 5 #include "chrome/browser/cookies_tree_model.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 21 matching lines...) Expand all
32 32
33 struct NodeTitleComparator { 33 struct NodeTitleComparator {
34 bool operator()(const CookieTreeNode* lhs, const CookieTreeNode* rhs) { 34 bool operator()(const CookieTreeNode* lhs, const CookieTreeNode* rhs) {
35 return lhs->GetTitle() < rhs->GetTitle(); 35 return lhs->GetTitle() < rhs->GetTitle();
36 } 36 }
37 }; 37 };
38 38
39 // Comparison functor, for use in CookieTreeRootNode. 39 // Comparison functor, for use in CookieTreeRootNode.
40 struct OriginNodeComparator { 40 struct OriginNodeComparator {
41 bool operator()(const CookieTreeNode* lhs, const CookieTreeNode* rhs) { 41 bool operator()(const CookieTreeNode* lhs, const CookieTreeNode* rhs) {
42 // This comparator is only meant to compare CookieTreeOriginNode types. Make
43 // sure we check this, as the static cast below is dangerous if we get the
44 // wrong object type.
45 CHECK_EQ(lhs->GetDetailedInfo().node_type,
46 CookieTreeNode::DetailedInfo::TYPE_ORIGIN);
47 CHECK_EQ(rhs->GetDetailedInfo().node_type,
48 CookieTreeNode::DetailedInfo::TYPE_ORIGIN);
49
50 const CookieTreeOriginNode* ltn =
51 static_cast<const CookieTreeOriginNode*>(lhs);
52 const CookieTreeOriginNode* rtn =
53 static_cast<const CookieTreeOriginNode*>(rhs);
54
55 if (ltn->app_id() != rtn->app_id()) {
56 return (ltn->app_name() < rtn->app_name());
57 }
58
42 // We want to order by registry controlled domain, so we would get 59 // We want to order by registry controlled domain, so we would get
43 // google.com, ad.google.com, www.google.com, 60 // google.com, ad.google.com, www.google.com,
44 // microsoft.com, ad.microsoft.com. CanonicalizeHost transforms the origins 61 // microsoft.com, ad.microsoft.com. CanonicalizeHost transforms the origins
45 // into a form like google.com.www so that string comparisons work. 62 // into a form like google.com.www so that string comparisons work.
46 return (CanonicalizeHost(lhs->GetTitle()) < 63 return (CanonicalizeHost(ltn->GetHost()) <
47 CanonicalizeHost(rhs->GetTitle())); 64 CanonicalizeHost(rtn->GetHost()));
48 } 65 }
49 66
50 static std::string CanonicalizeHost(const string16& host16) { 67 static std::string CanonicalizeHost(const std::string& host) {
51 // The canonicalized representation makes the registry controlled domain 68 // The canonicalized representation makes the registry controlled domain
52 // come first, and then adds subdomains in reverse order, e.g. 69 // come first, and then adds subdomains in reverse order, e.g.
53 // 1.mail.google.com would become google.com.mail.1, and then a standard 70 // 1.mail.google.com would become google.com.mail.1, and then a standard
54 // string comparison works to order hosts by registry controlled domain 71 // string comparison works to order hosts by registry controlled domain
55 // first. Leading dots are ignored, ".google.com" is the same as 72 // first. Leading dots are ignored, ".google.com" is the same as
56 // "google.com". 73 // "google.com".
57 74
58 std::string host = UTF16ToUTF8(host16);
59 std::string retval = net::RegistryControlledDomainService:: 75 std::string retval = net::RegistryControlledDomainService::
60 GetDomainAndRegistry(host); 76 GetDomainAndRegistry(host);
61 if (!retval.length()) // Is an IP address or other special origin. 77 if (!retval.length()) // Is an IP address or other special origin.
62 return host; 78 return host;
63 79
64 std::string::size_type position = host.rfind(retval); 80 std::string::size_type position = host.rfind(retval);
65 81
66 // The host may be the registry controlled domain, in which case fail fast. 82 // The host may be the registry controlled domain, in which case fail fast.
67 if (position == 0 || position == std::string::npos) 83 if (position == 0 || position == std::string::npos)
68 return host; 84 return host;
(...skipping 13 matching lines...) Expand all
82 retval += host.substr(0, position); 98 retval += host.substr(0, position);
83 break; 99 break;
84 } 100 }
85 retval += host.substr(next_dot + 1, position - (next_dot + 1)); 101 retval += host.substr(next_dot + 1, position - (next_dot + 1));
86 position = next_dot; 102 position = next_dot;
87 } 103 }
88 return retval; 104 return retval;
89 } 105 }
90 }; 106 };
91 107
92 } // namespace 108 // This function returns the local data container associated with a leaf tree
109 // node. The app node is assumed to be 3 levels above the leaf because of the
110 // following structure:
111 // root -> origin -> storage type -> leaf node
112 LocalDataContainer* GetLocalDataContainerForNode(CookieTreeNode* node) {
113 CookieTreeOriginNode* origin = static_cast<CookieTreeOriginNode*>(
114 node->parent()->parent());
115 CHECK_EQ(origin->GetDetailedInfo().node_type,
116 CookieTreeNode::DetailedInfo::TYPE_ORIGIN);
117 return node->GetModel()->GetLocalDataContainer(origin->app_id());
118 }
119
120
121 } // namespace
93 122
94 /////////////////////////////////////////////////////////////////////////////// 123 ///////////////////////////////////////////////////////////////////////////////
95 // CookieTreeNode, public: 124 // CookieTreeNode, public:
96 125
97 void CookieTreeNode::DeleteStoredObjects() { 126 void CookieTreeNode::DeleteStoredObjects() {
98 std::for_each(children().begin(), 127 std::for_each(children().begin(),
99 children().end(), 128 children().end(),
100 std::mem_fun(&CookieTreeNode::DeleteStoredObjects)); 129 std::mem_fun(&CookieTreeNode::DeleteStoredObjects));
101 } 130 }
102 131
103 CookiesTreeModel* CookieTreeNode::GetModel() const { 132 CookiesTreeModel* CookieTreeNode::GetModel() const {
104 if (parent()) 133 if (parent())
105 return parent()->GetModel(); 134 return parent()->GetModel();
106 else 135 else
107 return NULL; 136 return NULL;
108 } 137 }
109 138
110 /////////////////////////////////////////////////////////////////////////////// 139 ///////////////////////////////////////////////////////////////////////////////
111 // CookieTreeCookieNode, public: 140 // CookieTreeCookieNode, public:
112 141
113 CookieTreeCookieNode::CookieTreeCookieNode( 142 CookieTreeCookieNode::CookieTreeCookieNode(
114 std::list<net::CookieMonster::CanonicalCookie>::iterator cookie) 143 std::list<net::CookieMonster::CanonicalCookie>::iterator cookie)
115 : CookieTreeNode(UTF8ToUTF16(cookie->Name())), 144 : CookieTreeNode(UTF8ToUTF16(cookie->Name())),
116 cookie_(cookie) { 145 cookie_(cookie) {
117 } 146 }
118 147
119 CookieTreeCookieNode::~CookieTreeCookieNode() {} 148 CookieTreeCookieNode::~CookieTreeCookieNode() {}
120 149
121 void CookieTreeCookieNode::DeleteStoredObjects() { 150 void CookieTreeCookieNode::DeleteStoredObjects() {
122 // notify CookieMonster that we should delete this cookie 151 LocalDataContainer* container = GetLocalDataContainerForNode(this);
123 GetModel()->cookie_helper_->DeleteCookie(*cookie_); 152 CHECK(container);
124 GetModel()->cookie_list_.erase(cookie_); 153 container->cookie_helper_->DeleteCookie(*cookie_);
154 container->cookie_list_.erase(cookie_);
125 } 155 }
126 156
127 CookieTreeNode::DetailedInfo CookieTreeCookieNode::GetDetailedInfo() const { 157 CookieTreeNode::DetailedInfo CookieTreeCookieNode::GetDetailedInfo() const {
128 return DetailedInfo(parent()->parent()->GetTitle()).InitCookie(&*cookie_); 158 return DetailedInfo(parent()->parent()->GetTitle()).InitCookie(&*cookie_);
129 } 159 }
130 160
131 /////////////////////////////////////////////////////////////////////////////// 161 ///////////////////////////////////////////////////////////////////////////////
132 // CookieTreeAppCacheNode, public: 162 // CookieTreeAppCacheNode, public:
133 163
134 CookieTreeAppCacheNode::CookieTreeAppCacheNode( 164 CookieTreeAppCacheNode::CookieTreeAppCacheNode(
135 const GURL& origin_url, 165 const GURL& origin_url,
136 std::list<appcache::AppCacheInfo>::iterator appcache_info) 166 std::list<appcache::AppCacheInfo>::iterator appcache_info)
137 : CookieTreeNode(UTF8ToUTF16(appcache_info->manifest_url.spec())), 167 : CookieTreeNode(UTF8ToUTF16(appcache_info->manifest_url.spec())),
138 origin_url_(origin_url), 168 origin_url_(origin_url),
139 appcache_info_(appcache_info) { 169 appcache_info_(appcache_info) {
140 } 170 }
141 171
142 CookieTreeAppCacheNode::~CookieTreeAppCacheNode() { 172 CookieTreeAppCacheNode::~CookieTreeAppCacheNode() {
143 } 173 }
144 174
145 void CookieTreeAppCacheNode::DeleteStoredObjects() { 175 void CookieTreeAppCacheNode::DeleteStoredObjects() {
146 DCHECK(GetModel()->appcache_helper_); 176 LocalDataContainer* container = GetLocalDataContainerForNode(this);
147 GetModel()->appcache_helper_->DeleteAppCacheGroup( 177
148 appcache_info_->manifest_url); 178 if (container) {
149 GetModel()->appcache_info_[origin_url_].erase(appcache_info_); 179 DCHECK(container->appcache_helper_);
180 container->appcache_helper_->DeleteAppCacheGroup(
181 appcache_info_->manifest_url);
182 container->appcache_info_[origin_url_].erase(appcache_info_);
183 }
150 } 184 }
151 185
152 CookieTreeNode::DetailedInfo CookieTreeAppCacheNode::GetDetailedInfo() const { 186 CookieTreeNode::DetailedInfo CookieTreeAppCacheNode::GetDetailedInfo() const {
153 return DetailedInfo(parent()->parent()->GetTitle()).InitAppCache( 187 return DetailedInfo(parent()->parent()->GetTitle()).InitAppCache(
154 &*appcache_info_); 188 &*appcache_info_);
155 } 189 }
156 190
157 /////////////////////////////////////////////////////////////////////////////// 191 ///////////////////////////////////////////////////////////////////////////////
158 // CookieTreeDatabaseNode, public: 192 // CookieTreeDatabaseNode, public:
159 193
160 CookieTreeDatabaseNode::CookieTreeDatabaseNode( 194 CookieTreeDatabaseNode::CookieTreeDatabaseNode(
161 std::list<BrowsingDataDatabaseHelper::DatabaseInfo>::iterator database_info) 195 std::list<BrowsingDataDatabaseHelper::DatabaseInfo>::iterator database_info)
162 : CookieTreeNode(database_info->database_name.empty() ? 196 : CookieTreeNode(database_info->database_name.empty() ?
163 l10n_util::GetStringUTF16(IDS_COOKIES_WEB_DATABASE_UNNAMED_NAME) : 197 l10n_util::GetStringUTF16(IDS_COOKIES_WEB_DATABASE_UNNAMED_NAME) :
164 UTF8ToUTF16(database_info->database_name)), 198 UTF8ToUTF16(database_info->database_name)),
165 database_info_(database_info) { 199 database_info_(database_info) {
166 } 200 }
167 201
168 CookieTreeDatabaseNode::~CookieTreeDatabaseNode() {} 202 CookieTreeDatabaseNode::~CookieTreeDatabaseNode() {}
169 203
170 void CookieTreeDatabaseNode::DeleteStoredObjects() { 204 void CookieTreeDatabaseNode::DeleteStoredObjects() {
171 GetModel()->database_helper_->DeleteDatabase( 205 LocalDataContainer* container = GetLocalDataContainerForNode(this);
172 database_info_->origin_identifier, database_info_->database_name); 206
173 GetModel()->database_info_list_.erase(database_info_); 207 if (container) {
208 container->database_helper_->DeleteDatabase(
209 database_info_->origin_identifier, database_info_->database_name);
210 container->database_info_list_.erase(database_info_);
211 }
174 } 212 }
175 213
176 CookieTreeNode::DetailedInfo CookieTreeDatabaseNode::GetDetailedInfo() const { 214 CookieTreeNode::DetailedInfo CookieTreeDatabaseNode::GetDetailedInfo() const {
177 return DetailedInfo(parent()->parent()->GetTitle()).InitDatabase( 215 return DetailedInfo(parent()->parent()->GetTitle()).InitDatabase(
178 &*database_info_); 216 &*database_info_);
179 } 217 }
180 218
181 /////////////////////////////////////////////////////////////////////////////// 219 ///////////////////////////////////////////////////////////////////////////////
182 // CookieTreeLocalStorageNode, public: 220 // CookieTreeLocalStorageNode, public:
183 221
184 CookieTreeLocalStorageNode::CookieTreeLocalStorageNode( 222 CookieTreeLocalStorageNode::CookieTreeLocalStorageNode(
185 std::list<BrowsingDataLocalStorageHelper::LocalStorageInfo>::iterator 223 std::list<BrowsingDataLocalStorageHelper::LocalStorageInfo>::iterator
186 local_storage_info) 224 local_storage_info)
187 : CookieTreeNode(UTF8ToUTF16(local_storage_info->origin_url.spec())), 225 : CookieTreeNode(UTF8ToUTF16(local_storage_info->origin_url.spec())),
188 local_storage_info_(local_storage_info) { 226 local_storage_info_(local_storage_info) {
189 } 227 }
190 228
191 CookieTreeLocalStorageNode::~CookieTreeLocalStorageNode() {} 229 CookieTreeLocalStorageNode::~CookieTreeLocalStorageNode() {}
192 230
193 void CookieTreeLocalStorageNode::DeleteStoredObjects() { 231 void CookieTreeLocalStorageNode::DeleteStoredObjects() {
194 GetModel()->local_storage_helper_->DeleteOrigin( 232 LocalDataContainer* container = GetLocalDataContainerForNode(this);
195 local_storage_info_->origin_url); 233
196 GetModel()->local_storage_info_list_.erase(local_storage_info_); 234 if (container) {
235 container->local_storage_helper_->DeleteOrigin(
236 local_storage_info_->origin_url);
237 container->local_storage_info_list_.erase(local_storage_info_);
238 }
197 } 239 }
198 240
199 CookieTreeNode::DetailedInfo 241 CookieTreeNode::DetailedInfo
200 CookieTreeLocalStorageNode::GetDetailedInfo() const { 242 CookieTreeLocalStorageNode::GetDetailedInfo() const {
201 return DetailedInfo(parent()->parent()->GetTitle()).InitLocalStorage( 243 return DetailedInfo(parent()->parent()->GetTitle()).InitLocalStorage(
202 &*local_storage_info_); 244 &*local_storage_info_);
203 } 245 }
204 246
205 /////////////////////////////////////////////////////////////////////////////// 247 ///////////////////////////////////////////////////////////////////////////////
206 // CookieTreeSessionStorageNode, public: 248 // CookieTreeSessionStorageNode, public:
207 249
208 CookieTreeSessionStorageNode::CookieTreeSessionStorageNode( 250 CookieTreeSessionStorageNode::CookieTreeSessionStorageNode(
209 std::list<BrowsingDataLocalStorageHelper::LocalStorageInfo>::iterator 251 std::list<BrowsingDataLocalStorageHelper::LocalStorageInfo>::iterator
210 session_storage_info) 252 session_storage_info)
211 : CookieTreeNode(UTF8ToUTF16(session_storage_info->origin_url.spec())), 253 : CookieTreeNode(UTF8ToUTF16(session_storage_info->origin_url.spec())),
212 session_storage_info_(session_storage_info) { 254 session_storage_info_(session_storage_info) {
213 } 255 }
214 256
215 CookieTreeSessionStorageNode::~CookieTreeSessionStorageNode() {} 257 CookieTreeSessionStorageNode::~CookieTreeSessionStorageNode() {}
216 258
217 void CookieTreeSessionStorageNode::DeleteStoredObjects() { 259 void CookieTreeSessionStorageNode::DeleteStoredObjects() {
218 GetModel()->session_storage_info_list_.erase(session_storage_info_); 260 LocalDataContainer* container = GetLocalDataContainerForNode(this);
261
262 if (container) {
263 container->session_storage_info_list_.erase(session_storage_info_);
264 }
219 } 265 }
220 266
221 CookieTreeNode::DetailedInfo 267 CookieTreeNode::DetailedInfo
222 CookieTreeSessionStorageNode::GetDetailedInfo() const { 268 CookieTreeSessionStorageNode::GetDetailedInfo() const {
223 return DetailedInfo(parent()->parent()->GetTitle()).InitSessionStorage( 269 return DetailedInfo(parent()->parent()->GetTitle()).InitSessionStorage(
224 &*session_storage_info_); 270 &*session_storage_info_);
225 } 271 }
226 272
227 /////////////////////////////////////////////////////////////////////////////// 273 ///////////////////////////////////////////////////////////////////////////////
228 // CookieTreeIndexedDBNode, public: 274 // CookieTreeIndexedDBNode, public:
229 275
230 CookieTreeIndexedDBNode::CookieTreeIndexedDBNode( 276 CookieTreeIndexedDBNode::CookieTreeIndexedDBNode(
231 std::list<BrowsingDataIndexedDBHelper::IndexedDBInfo>::iterator 277 std::list<BrowsingDataIndexedDBHelper::IndexedDBInfo>::iterator
232 indexed_db_info) 278 indexed_db_info)
233 : CookieTreeNode(UTF8ToUTF16( 279 : CookieTreeNode(UTF8ToUTF16(
234 indexed_db_info->origin.spec())), 280 indexed_db_info->origin.spec())),
235 indexed_db_info_(indexed_db_info) { 281 indexed_db_info_(indexed_db_info) {
236 } 282 }
237 283
238 CookieTreeIndexedDBNode::~CookieTreeIndexedDBNode() {} 284 CookieTreeIndexedDBNode::~CookieTreeIndexedDBNode() {}
239 285
240 void CookieTreeIndexedDBNode::DeleteStoredObjects() { 286 void CookieTreeIndexedDBNode::DeleteStoredObjects() {
241 GetModel()->indexed_db_helper_->DeleteIndexedDB( 287 LocalDataContainer* container = GetLocalDataContainerForNode(this);
242 indexed_db_info_->origin); 288
243 GetModel()->indexed_db_info_list_.erase(indexed_db_info_); 289 if (container) {
290 container->indexed_db_helper_->DeleteIndexedDB(
291 indexed_db_info_->origin);
292 container->indexed_db_info_list_.erase(indexed_db_info_);
293 }
244 } 294 }
245 295
246 CookieTreeNode::DetailedInfo CookieTreeIndexedDBNode::GetDetailedInfo() const { 296 CookieTreeNode::DetailedInfo CookieTreeIndexedDBNode::GetDetailedInfo() const {
247 return DetailedInfo(parent()->parent()->GetTitle()).InitIndexedDB( 297 return DetailedInfo(parent()->parent()->GetTitle()).InitIndexedDB(
248 &*indexed_db_info_); 298 &*indexed_db_info_);
249 } 299 }
250 300
251 /////////////////////////////////////////////////////////////////////////////// 301 ///////////////////////////////////////////////////////////////////////////////
252 // CookieTreeFileSystemNode, public: 302 // CookieTreeFileSystemNode, public:
253 303
254 CookieTreeFileSystemNode::CookieTreeFileSystemNode( 304 CookieTreeFileSystemNode::CookieTreeFileSystemNode(
255 std::list<BrowsingDataFileSystemHelper::FileSystemInfo>::iterator 305 std::list<BrowsingDataFileSystemHelper::FileSystemInfo>::iterator
256 file_system_info) 306 file_system_info)
257 : CookieTreeNode(UTF8ToUTF16( 307 : CookieTreeNode(UTF8ToUTF16(
258 file_system_info->origin.spec())), 308 file_system_info->origin.spec())),
259 file_system_info_(file_system_info) { 309 file_system_info_(file_system_info) {
260 } 310 }
261 311
262 CookieTreeFileSystemNode::~CookieTreeFileSystemNode() {} 312 CookieTreeFileSystemNode::~CookieTreeFileSystemNode() {}
263 313
264 void CookieTreeFileSystemNode::DeleteStoredObjects() { 314 void CookieTreeFileSystemNode::DeleteStoredObjects() {
265 GetModel()->file_system_helper_->DeleteFileSystemOrigin( 315 LocalDataContainer* container = GetLocalDataContainerForNode(this);
266 file_system_info_->origin); 316
267 GetModel()->file_system_info_list_.erase(file_system_info_); 317 if (container) {
318 container->file_system_helper_->DeleteFileSystemOrigin(
319 file_system_info_->origin);
320 container->file_system_info_list_.erase(file_system_info_);
321 }
268 } 322 }
269 323
270 CookieTreeNode::DetailedInfo CookieTreeFileSystemNode::GetDetailedInfo() const { 324 CookieTreeNode::DetailedInfo CookieTreeFileSystemNode::GetDetailedInfo() const {
271 return DetailedInfo(parent()->parent()->GetTitle()).InitFileSystem( 325 return DetailedInfo(parent()->parent()->GetTitle()).InitFileSystem(
272 &*file_system_info_); 326 &*file_system_info_);
273 } 327 }
274 328
275 /////////////////////////////////////////////////////////////////////////////// 329 ///////////////////////////////////////////////////////////////////////////////
276 // CookieTreeQuotaNode, public: 330 // CookieTreeQuotaNode, public:
277 331
278 CookieTreeQuotaNode::CookieTreeQuotaNode( 332 CookieTreeQuotaNode::CookieTreeQuotaNode(
279 std::list<BrowsingDataQuotaHelper::QuotaInfo>::iterator quota_info) 333 std::list<BrowsingDataQuotaHelper::QuotaInfo>::iterator quota_info)
280 : CookieTreeNode(UTF8ToUTF16(quota_info->host)), 334 : CookieTreeNode(UTF8ToUTF16(quota_info->host)),
281 quota_info_(quota_info) { 335 quota_info_(quota_info) {
282 } 336 }
283 337
284 CookieTreeQuotaNode::~CookieTreeQuotaNode() {} 338 CookieTreeQuotaNode::~CookieTreeQuotaNode() {}
285 339
286 void CookieTreeQuotaNode::DeleteStoredObjects() { 340 void CookieTreeQuotaNode::DeleteStoredObjects() {
287 // Calling this function may cause unexpected over-quota state of origin. 341 // Calling this function may cause unexpected over-quota state of origin.
288 // However, it'll caused no problem, just prevent usage growth of the origin. 342 // However, it'll caused no problem, just prevent usage growth of the origin.
289 GetModel()->quota_helper_->RevokeHostQuota(quota_info_->host); 343 CookieTreeOriginNode* app = static_cast<CookieTreeOriginNode*>(parent());
290 GetModel()->quota_info_list_.erase(quota_info_); 344 LocalDataContainer* container = GetModel()->GetLocalDataContainer(
345 app->app_id());
346
347 if (container) {
348 container->quota_helper_->RevokeHostQuota(quota_info_->host);
349 container->quota_info_list_.erase(quota_info_);
350 }
291 } 351 }
292 352
293 CookieTreeNode::DetailedInfo CookieTreeQuotaNode::GetDetailedInfo() const { 353 CookieTreeNode::DetailedInfo CookieTreeQuotaNode::GetDetailedInfo() const {
294 return DetailedInfo(parent()->parent()->GetTitle()).InitQuota( 354 return DetailedInfo(parent()->parent()->GetTitle()).InitQuota(
295 &*quota_info_); 355 &*quota_info_);
296 } 356 }
297 357
298 /////////////////////////////////////////////////////////////////////////////// 358 ///////////////////////////////////////////////////////////////////////////////
299 // CookieTreeServerBoundCertNode, public: 359 // CookieTreeServerBoundCertNode, public:
300 360
301 CookieTreeServerBoundCertNode::CookieTreeServerBoundCertNode( 361 CookieTreeServerBoundCertNode::CookieTreeServerBoundCertNode(
302 net::ServerBoundCertStore::ServerBoundCertList::iterator cert) 362 net::ServerBoundCertStore::ServerBoundCertList::iterator cert)
303 : CookieTreeNode(ASCIIToUTF16(cert->server_identifier())), 363 : CookieTreeNode(ASCIIToUTF16(cert->server_identifier())),
304 server_bound_cert_(cert) { 364 server_bound_cert_(cert) {
305 } 365 }
306 366
307 CookieTreeServerBoundCertNode::~CookieTreeServerBoundCertNode() {} 367 CookieTreeServerBoundCertNode::~CookieTreeServerBoundCertNode() {}
308 368
309 void CookieTreeServerBoundCertNode::DeleteStoredObjects() { 369 void CookieTreeServerBoundCertNode::DeleteStoredObjects() {
310 GetModel()->server_bound_cert_helper_->DeleteServerBoundCert( 370 LocalDataContainer* container = GetLocalDataContainerForNode(this);
311 server_bound_cert_->server_identifier()); 371
312 GetModel()->server_bound_cert_list_.erase(server_bound_cert_); 372 if (container) {
373 container->server_bound_cert_helper_->DeleteServerBoundCert(
374 server_bound_cert_->server_identifier());
375 container->server_bound_cert_list_.erase(server_bound_cert_);
376 }
313 } 377 }
314 378
315 CookieTreeNode::DetailedInfo 379 CookieTreeNode::DetailedInfo
316 CookieTreeServerBoundCertNode::GetDetailedInfo() const { 380 CookieTreeServerBoundCertNode::GetDetailedInfo() const {
317 return DetailedInfo(parent()->parent()->GetTitle()).InitServerBoundCert( 381 return DetailedInfo(parent()->parent()->GetTitle()).InitServerBoundCert(
318 &*server_bound_cert_); 382 &*server_bound_cert_);
319 } 383 }
320 384
321 /////////////////////////////////////////////////////////////////////////////// 385 ///////////////////////////////////////////////////////////////////////////////
322 // CookieTreeRootNode, public: 386 // CookieTreeRootNode, public:
323 387
324 CookieTreeRootNode::CookieTreeRootNode(CookiesTreeModel* model) 388 CookieTreeRootNode::CookieTreeRootNode(CookiesTreeModel* model)
325 : model_(model) { 389 : model_(model) {
326 } 390 }
327 391
328 CookieTreeRootNode::~CookieTreeRootNode() {} 392 CookieTreeRootNode::~CookieTreeRootNode() {}
329 393
330 CookieTreeOriginNode* CookieTreeRootNode::GetOrCreateOriginNode( 394 CookieTreeOriginNode* CookieTreeRootNode::GetOrCreateOriginNode(
331 const GURL& url) { 395 const GURL& url,
332 CookieTreeOriginNode origin_node(url); 396 const std::string& app_id,
397 const std::string& app_name) {
398 CookieTreeOriginNode origin_node(url, app_id, app_name);
333 399
334 // First see if there is an existing match. 400 // First see if there is an existing match.
335 std::vector<CookieTreeNode*>::iterator origin_node_iterator = 401 std::vector<CookieTreeNode*>::iterator origin_node_iterator =
336 std::lower_bound(children().begin(), children().end(), &origin_node, 402 std::lower_bound(children().begin(), children().end(), &origin_node,
337 OriginNodeComparator()); 403 OriginNodeComparator());
338
339 if (origin_node_iterator != children().end() && 404 if (origin_node_iterator != children().end() &&
340 WideToUTF16Hack(CookieTreeOriginNode::TitleForUrl(url)) == 405 CookieTreeOriginNode::TitleForUrl(url, app_id, app_name) ==
341 (*origin_node_iterator)->GetTitle()) 406 (*origin_node_iterator)->GetTitle())
342 return static_cast<CookieTreeOriginNode*>(*origin_node_iterator); 407 return static_cast<CookieTreeOriginNode*>(*origin_node_iterator);
343 // Node doesn't exist, create a new one and insert it into the (ordered) 408 // Node doesn't exist, create a new one and insert it into the (ordered)
344 // children. 409 // children.
345 CookieTreeOriginNode* retval = new CookieTreeOriginNode(url); 410 CookieTreeOriginNode* retval = new CookieTreeOriginNode(url, app_id,
411 app_name);
346 DCHECK(model_); 412 DCHECK(model_);
347 model_->Add(this, retval, (origin_node_iterator - children().begin())); 413 model_->Add(this, retval, (origin_node_iterator - children().begin()));
348 return retval; 414 return retval;
349 } 415 }
350 416
351 CookiesTreeModel* CookieTreeRootNode::GetModel() const { 417 CookiesTreeModel* CookieTreeRootNode::GetModel() const {
352 return model_; 418 return model_;
353 } 419 }
354 420
355 CookieTreeNode::DetailedInfo CookieTreeRootNode::GetDetailedInfo() const { 421 CookieTreeNode::DetailedInfo CookieTreeRootNode::GetDetailedInfo() const {
356 return DetailedInfo(string16()).Init(DetailedInfo::TYPE_ROOT); 422 return DetailedInfo(string16()).Init(DetailedInfo::TYPE_ROOT);
357 } 423 }
358 424
359 /////////////////////////////////////////////////////////////////////////////// 425 ///////////////////////////////////////////////////////////////////////////////
360 // CookieTreeOriginNode, public: 426 // CookieTreeOriginNode, public:
361 427
362 // static 428 // static
363 std::wstring CookieTreeOriginNode::TitleForUrl(const GURL& url) { 429 string16 CookieTreeOriginNode::TitleForUrl(
430 const GURL& url,
431 const std::string& app_id,
432 const std::string& app_name) {
433 std::string title;
364 const std::string file_origin_node_name( 434 const std::string file_origin_node_name(
365 std::string(chrome::kFileScheme) + content::kStandardSchemeSeparator); 435 std::string(chrome::kFileScheme) + content::kStandardSchemeSeparator);
366 return UTF8ToWide(url.SchemeIsFile() ? file_origin_node_name : url.host()); 436 // Only prepend the app name, if the app id is not an empty string.
437 if (!app_id.empty()) {
438 title = app_name;
439 title.append(", ");
440 }
441 title.append(url.SchemeIsFile() ? file_origin_node_name : url.host());
442 return UTF8ToUTF16(title);
367 } 443 }
368 444
369 CookieTreeOriginNode::CookieTreeOriginNode(const GURL& url) 445 CookieTreeOriginNode::CookieTreeOriginNode(const GURL& url,
370 : CookieTreeNode(WideToUTF16Hack(TitleForUrl(url))), 446 const std::string& app_id,
447 const std::string& name)
448 : CookieTreeNode(TitleForUrl(url, app_id, name)),
371 cookies_child_(NULL), 449 cookies_child_(NULL),
372 databases_child_(NULL), 450 databases_child_(NULL),
373 local_storages_child_(NULL), 451 local_storages_child_(NULL),
374 session_storages_child_(NULL), 452 session_storages_child_(NULL),
375 appcaches_child_(NULL), 453 appcaches_child_(NULL),
376 indexed_dbs_child_(NULL), 454 indexed_dbs_child_(NULL),
377 file_systems_child_(NULL), 455 file_systems_child_(NULL),
378 quota_child_(NULL), 456 quota_child_(NULL),
379 server_bound_certs_child_(NULL), 457 server_bound_certs_child_(NULL),
458 app_id_(app_id),
459 app_name_(name),
380 url_(url) {} 460 url_(url) {}
381 461
382 CookieTreeOriginNode::~CookieTreeOriginNode() {} 462 CookieTreeOriginNode::~CookieTreeOriginNode() {}
383 463
464 const std::string CookieTreeOriginNode::GetHost() const {
465 const std::string file_origin_node_name(
466 std::string(chrome::kFileScheme) + content::kStandardSchemeSeparator);
467 return url_.SchemeIsFile() ? file_origin_node_name : url_.host();
468 }
469
384 CookieTreeNode::DetailedInfo CookieTreeOriginNode::GetDetailedInfo() const { 470 CookieTreeNode::DetailedInfo CookieTreeOriginNode::GetDetailedInfo() const {
385 return DetailedInfo(GetTitle()).Init(DetailedInfo::TYPE_ORIGIN); 471 return DetailedInfo(GetTitle()).InitOrigin(app_id_, app_name_);
386 } 472 }
387 473
388 CookieTreeCookiesNode* CookieTreeOriginNode::GetOrCreateCookiesNode() { 474 CookieTreeCookiesNode* CookieTreeOriginNode::GetOrCreateCookiesNode() {
389 if (cookies_child_) 475 if (cookies_child_)
390 return cookies_child_; 476 return cookies_child_;
391 cookies_child_ = new CookieTreeCookiesNode; 477 cookies_child_ = new CookieTreeCookiesNode;
392 AddChildSortedByTitle(cookies_child_); 478 AddChildSortedByTitle(cookies_child_);
393 return cookies_child_; 479 return cookies_child_;
394 } 480 }
395 481
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 685
600 void CookieTreeNode::AddChildSortedByTitle(CookieTreeNode* new_child) { 686 void CookieTreeNode::AddChildSortedByTitle(CookieTreeNode* new_child) {
601 DCHECK(new_child); 687 DCHECK(new_child);
602 std::vector<CookieTreeNode*>::iterator iter = 688 std::vector<CookieTreeNode*>::iterator iter =
603 std::lower_bound(children().begin(), children().end(), new_child, 689 std::lower_bound(children().begin(), children().end(), new_child,
604 NodeTitleComparator()); 690 NodeTitleComparator());
605 GetModel()->Add(this, new_child, iter - children().begin()); 691 GetModel()->Add(this, new_child, iter - children().begin());
606 } 692 }
607 693
608 /////////////////////////////////////////////////////////////////////////////// 694 ///////////////////////////////////////////////////////////////////////////////
695 // ScopedBatchUpdateNotifier
696 CookiesTreeModel::ScopedBatchUpdateNotifier::ScopedBatchUpdateNotifier(
697 CookiesTreeModel* model, CookieTreeNode* node)
698 : model_(model), node_(node), batch_in_progress_(false) {
699 }
700
701 CookiesTreeModel::ScopedBatchUpdateNotifier::~ScopedBatchUpdateNotifier() {
702 if (batch_in_progress_) {
703 model_->NotifyObserverTreeNodeChanged(node_);
704 model_->NotifyObserverEndBatch();
705 }
706 }
707
708 void CookiesTreeModel::ScopedBatchUpdateNotifier::StartBatchUpdate() {
709 if (!batch_in_progress_) {
710 model_->NotifyObserverBeginBatch();
711 batch_in_progress_ = true;
712 }
713 }
714
715 ///////////////////////////////////////////////////////////////////////////////
609 // CookiesTreeModel, public: 716 // CookiesTreeModel, public:
610 717 CookiesTreeModel::CookiesTreeModel(const ContainerMap& apps_map,
611 CookiesTreeModel::CookiesTreeModel( 718 bool group_by_cookie_source)
612 BrowsingDataCookieHelper* cookie_helper,
613 BrowsingDataDatabaseHelper* database_helper,
614 BrowsingDataLocalStorageHelper* local_storage_helper,
615 BrowsingDataLocalStorageHelper* session_storage_helper,
616 BrowsingDataAppCacheHelper* appcache_helper,
617 BrowsingDataIndexedDBHelper* indexed_db_helper,
618 BrowsingDataFileSystemHelper* file_system_helper,
619 BrowsingDataQuotaHelper* quota_helper,
620 BrowsingDataServerBoundCertHelper* server_bound_cert_helper,
621 bool use_cookie_source)
622 : ALLOW_THIS_IN_INITIALIZER_LIST(ui::TreeNodeModel<CookieTreeNode>( 719 : ALLOW_THIS_IN_INITIALIZER_LIST(ui::TreeNodeModel<CookieTreeNode>(
623 new CookieTreeRootNode(this))), 720 new CookieTreeRootNode(this))),
624 appcache_helper_(appcache_helper), 721 app_data_map_(apps_map),
625 cookie_helper_(cookie_helper), 722 group_by_cookie_source_(group_by_cookie_source),
626 database_helper_(database_helper), 723 batch_update_(0) {
627 local_storage_helper_(local_storage_helper), 724 for (ContainerMap::const_iterator it = apps_map.begin();
628 session_storage_helper_(session_storage_helper), 725 it != apps_map.end(); ++it) {
629 indexed_db_helper_(indexed_db_helper), 726 it->second->Init(this);
630 file_system_helper_(file_system_helper),
631 quota_helper_(quota_helper),
632 server_bound_cert_helper_(server_bound_cert_helper),
633 batch_update_(0),
634 use_cookie_source_(use_cookie_source),
635 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
636 DCHECK(cookie_helper_);
637 cookie_helper_->StartFetching(
638 base::Bind(&CookiesTreeModel::OnCookiesModelInfoLoaded,
639 weak_ptr_factory_.GetWeakPtr()));
640 DCHECK(database_helper_);
641 database_helper_->StartFetching(
642 base::Bind(&CookiesTreeModel::OnDatabaseModelInfoLoaded,
643 weak_ptr_factory_.GetWeakPtr()));
644 DCHECK(local_storage_helper_);
645 local_storage_helper_->StartFetching(
646 base::Bind(&CookiesTreeModel::OnLocalStorageModelInfoLoaded,
647 weak_ptr_factory_.GetWeakPtr()));
648 if (session_storage_helper_) {
649 session_storage_helper_->StartFetching(
650 base::Bind(&CookiesTreeModel::OnSessionStorageModelInfoLoaded,
651 weak_ptr_factory_.GetWeakPtr()));
652 }
653
654 // TODO(michaeln): When all of the UI implementations have been updated, make
655 // this a required parameter.
656 if (appcache_helper_) {
657 appcache_helper_->StartFetching(
658 base::Bind(&CookiesTreeModel::OnAppCacheModelInfoLoaded,
659 weak_ptr_factory_.GetWeakPtr()));
660 }
661
662 if (indexed_db_helper_) {
663 indexed_db_helper_->StartFetching(
664 base::Bind(&CookiesTreeModel::OnIndexedDBModelInfoLoaded,
665 weak_ptr_factory_.GetWeakPtr()));
666 }
667
668 if (file_system_helper_) {
669 file_system_helper_->StartFetching(
670 base::Bind(&CookiesTreeModel::OnFileSystemModelInfoLoaded,
671 weak_ptr_factory_.GetWeakPtr()));
672 }
673
674 if (quota_helper_) {
675 quota_helper_->StartFetching(
676 base::Bind(&CookiesTreeModel::OnQuotaModelInfoLoaded,
677 weak_ptr_factory_.GetWeakPtr()));
678 }
679
680 if (server_bound_cert_helper_) {
681 server_bound_cert_helper_->StartFetching(
682 base::Bind(&CookiesTreeModel::OnServerBoundCertModelInfoLoaded,
683 weak_ptr_factory_.GetWeakPtr()));
684 } 727 }
685 } 728 }
686 729
687 CookiesTreeModel::~CookiesTreeModel() {} 730 CookiesTreeModel::~CookiesTreeModel() {
731 STLDeleteValues(&app_data_map_);
732 }
688 733
689 /////////////////////////////////////////////////////////////////////////////// 734 ///////////////////////////////////////////////////////////////////////////////
690 // CookiesTreeModel, TreeModel methods (public): 735 // CookiesTreeModel, TreeModel methods (public):
691 736
692 // TreeModel methods: 737 // TreeModel methods:
693 // Returns the set of icons for the nodes in the tree. You only need override 738 // Returns the set of icons for the nodes in the tree. You only need override
694 // this if you don't want to use the default folder icons. 739 // this if you don't want to use the default folder icons.
695 void CookiesTreeModel::GetIcons(std::vector<gfx::ImageSkia>* icons) { 740 void CookiesTreeModel::GetIcons(std::vector<gfx::ImageSkia>* icons) {
696 icons->push_back(*ResourceBundle::GetSharedInstance().GetImageSkiaNamed( 741 icons->push_back(*ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
697 IDR_OMNIBOX_HTTP)); 742 IDR_OMNIBOX_HTTP));
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 void CookiesTreeModel::DeleteCookieNode(CookieTreeNode* cookie_node) { 792 void CookiesTreeModel::DeleteCookieNode(CookieTreeNode* cookie_node) {
748 if (cookie_node == GetRoot()) 793 if (cookie_node == GetRoot())
749 return; 794 return;
750 cookie_node->DeleteStoredObjects(); 795 cookie_node->DeleteStoredObjects();
751 CookieTreeNode* parent_node = cookie_node->parent(); 796 CookieTreeNode* parent_node = cookie_node->parent();
752 delete Remove(parent_node, cookie_node); 797 delete Remove(parent_node, cookie_node);
753 if (parent_node->empty()) 798 if (parent_node->empty())
754 DeleteCookieNode(parent_node); 799 DeleteCookieNode(parent_node);
755 } 800 }
756 801
757 void CookiesTreeModel::UpdateSearchResults(const std::wstring& filter) { 802 void CookiesTreeModel::UpdateSearchResults(const string16& filter) {
758 CookieTreeNode* root = GetRoot(); 803 CookieTreeNode* root = GetRoot();
804 ScopedBatchUpdateNotifier notifier(this, root);
759 int num_children = root->child_count(); 805 int num_children = root->child_count();
760 NotifyObserverBeginBatch(); 806 notifier.StartBatchUpdate();
761 for (int i = num_children - 1; i >= 0; --i) 807 for (int i = num_children - 1; i >= 0; --i)
762 delete Remove(root, root->GetChild(i)); 808 delete Remove(root, root->GetChild(i));
763 PopulateCookieInfoWithFilter(filter); 809
764 PopulateDatabaseInfoWithFilter(filter); 810 for (ContainerMap::iterator app_iterator = app_data_map_.begin();
765 PopulateLocalStorageInfoWithFilter(filter); 811 app_iterator != app_data_map_.end(); ++app_iterator ) {
766 PopulateSessionStorageInfoWithFilter(filter); 812 LocalDataContainer* container = app_iterator->second;
767 PopulateAppCacheInfoWithFilter(filter); 813
768 PopulateIndexedDBInfoWithFilter(filter); 814 PopulateCookieInfoWithFilter(container, &notifier, filter);
769 PopulateFileSystemInfoWithFilter(filter); 815 PopulateDatabaseInfoWithFilter(container, &notifier, filter);
770 PopulateQuotaInfoWithFilter(filter); 816 PopulateLocalStorageInfoWithFilter(container, &notifier, filter);
771 PopulateServerBoundCertInfoWithFilter(filter); 817 PopulateSessionStorageInfoWithFilter(container, &notifier, filter);
772 NotifyObserverTreeNodeChanged(root); 818 PopulateAppCacheInfoWithFilter(container, &notifier, filter);
773 NotifyObserverEndBatch(); 819 PopulateIndexedDBInfoWithFilter(container, &notifier, filter);
820 PopulateFileSystemInfoWithFilter(container, &notifier, filter);
821 PopulateQuotaInfoWithFilter(container, &notifier, filter);
822 PopulateServerBoundCertInfoWithFilter(container, &notifier, filter);
823 }
774 } 824 }
775 825
776 void CookiesTreeModel::AddCookiesTreeObserver(Observer* observer) { 826 void CookiesTreeModel::AddCookiesTreeObserver(Observer* observer) {
777 cookies_observer_list_.AddObserver(observer); 827 cookies_observer_list_.AddObserver(observer);
778 // Call super so that TreeNodeModel can notify, too. 828 // Call super so that TreeNodeModel can notify, too.
779 ui::TreeNodeModel<CookieTreeNode>::AddObserver(observer); 829 ui::TreeNodeModel<CookieTreeNode>::AddObserver(observer);
780 } 830 }
781 831
782 void CookiesTreeModel::RemoveCookiesTreeObserver(Observer* observer) { 832 void CookiesTreeModel::RemoveCookiesTreeObserver(Observer* observer) {
783 cookies_observer_list_.RemoveObserver(observer); 833 cookies_observer_list_.RemoveObserver(observer);
784 // Call super so that TreeNodeModel doesn't have dead pointers. 834 // Call super so that TreeNodeModel doesn't have dead pointers.
785 ui::TreeNodeModel<CookieTreeNode>::RemoveObserver(observer); 835 ui::TreeNodeModel<CookieTreeNode>::RemoveObserver(observer);
786 } 836 }
787 837
788 void CookiesTreeModel::OnAppCacheModelInfoLoaded() { 838 void CookiesTreeModel::PopulateAppCacheInfo(LocalDataContainer* container) {
789 using appcache::AppCacheInfo; 839 ScopedBatchUpdateNotifier notifier(this, GetRoot());
790 using appcache::AppCacheInfoCollection; 840 PopulateAppCacheInfoWithFilter(container, &notifier, string16());
791 using appcache::AppCacheInfoVector; 841 }
792 typedef std::map<GURL, AppCacheInfoVector> InfoByOrigin;
793 842
794 scoped_refptr<AppCacheInfoCollection> appcache_info = 843 void CookiesTreeModel::PopulateCookieInfo(LocalDataContainer* container) {
795 appcache_helper_->info_collection(); 844 ScopedBatchUpdateNotifier notifier(this, GetRoot());
796 if (!appcache_info || appcache_info->infos_by_origin.empty()) 845 PopulateCookieInfoWithFilter(container, &notifier, string16());
797 return; 846 }
798 847
799 for (InfoByOrigin::const_iterator origin = 848 void CookiesTreeModel::PopulateDatabaseInfo(LocalDataContainer* container) {
800 appcache_info->infos_by_origin.begin(); 849 ScopedBatchUpdateNotifier notifier(this, GetRoot());
801 origin != appcache_info->infos_by_origin.end(); ++origin) { 850 PopulateDatabaseInfoWithFilter(container, &notifier, string16());
802 std::list<AppCacheInfo>& info_list = appcache_info_[origin->first]; 851 }
803 info_list.insert(
804 info_list.begin(), origin->second.begin(), origin->second.end());
805 }
806 852
807 PopulateAppCacheInfoWithFilter(std::wstring()); 853 void CookiesTreeModel::PopulateLocalStorageInfo(LocalDataContainer* container) {
854 ScopedBatchUpdateNotifier notifier(this, GetRoot());
855 PopulateLocalStorageInfoWithFilter(container, &notifier, string16());
856 }
857
858 void CookiesTreeModel::PopulateSessionStorageInfo(
859 LocalDataContainer* container) {
860 ScopedBatchUpdateNotifier notifier(this, GetRoot());
861 PopulateSessionStorageInfoWithFilter(container, &notifier, string16());
862 }
863
864 void CookiesTreeModel::PopulateIndexedDBInfo(LocalDataContainer* container){
865 ScopedBatchUpdateNotifier notifier(this, GetRoot());
866 PopulateIndexedDBInfoWithFilter(container, &notifier, string16());
867 }
868
869 void CookiesTreeModel::PopulateFileSystemInfo(LocalDataContainer* container) {
870 ScopedBatchUpdateNotifier notifier(this, GetRoot());
871 PopulateFileSystemInfoWithFilter(container, &notifier, string16());
872 }
873
874 void CookiesTreeModel::PopulateQuotaInfo(LocalDataContainer* container) {
875 ScopedBatchUpdateNotifier notifier(this, GetRoot());
876 PopulateQuotaInfoWithFilter(container, &notifier, string16());
877 }
878
879 void CookiesTreeModel::PopulateServerBoundCertInfo(
880 LocalDataContainer* container) {
881 ScopedBatchUpdateNotifier notifier(this, GetRoot());
882 PopulateServerBoundCertInfoWithFilter(container, &notifier, string16());
808 } 883 }
809 884
810 void CookiesTreeModel::PopulateAppCacheInfoWithFilter( 885 void CookiesTreeModel::PopulateAppCacheInfoWithFilter(
811 const std::wstring& filter) { 886 LocalDataContainer* container,
887 ScopedBatchUpdateNotifier* notifier,
888 const string16& filter) {
812 using appcache::AppCacheInfo; 889 using appcache::AppCacheInfo;
813 typedef std::map<GURL, std::list<AppCacheInfo> > InfoByOrigin; 890 typedef std::map<GURL, std::list<AppCacheInfo> > InfoByOrigin;
891 CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot());
814 892
815 if (appcache_info_.empty()) 893 if (container->appcache_info_.empty())
816 return; 894 return;
817 895
818 CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot()); 896 notifier->StartBatchUpdate();
819 NotifyObserverBeginBatch(); 897 for (InfoByOrigin::iterator origin = container->appcache_info_.begin();
820 for (InfoByOrigin::iterator origin = appcache_info_.begin(); 898 origin != container->appcache_info_.end(); ++origin) {
821 origin != appcache_info_.end(); ++origin) { 899 string16 origin_node_name = UTF8ToUTF16(origin->first.host());
822 std::wstring origin_node_name = UTF8ToWide(origin->first.host());
823 if (filter.empty() || 900 if (filter.empty() ||
824 (origin_node_name.find(filter) != std::wstring::npos)) { 901 (origin_node_name.find(filter) != string16::npos)) {
825 CookieTreeOriginNode* origin_node = 902 CookieTreeOriginNode* origin_node =
826 root->GetOrCreateOriginNode(origin->first); 903 root->GetOrCreateOriginNode(origin->first, container->app_id(),
904 container->app_name());
827 CookieTreeAppCachesNode* appcaches_node = 905 CookieTreeAppCachesNode* appcaches_node =
828 origin_node->GetOrCreateAppCachesNode(); 906 origin_node->GetOrCreateAppCachesNode();
829 907
830 for (std::list<AppCacheInfo>::iterator info = origin->second.begin(); 908 for (std::list<AppCacheInfo>::iterator info = origin->second.begin();
831 info != origin->second.end(); ++info) { 909 info != origin->second.end(); ++info) {
832 appcaches_node->AddAppCacheNode( 910 appcaches_node->AddAppCacheNode(
833 new CookieTreeAppCacheNode(origin->first, info)); 911 new CookieTreeAppCacheNode(origin->first, info));
834 } 912 }
835 } 913 }
836 } 914 }
837 NotifyObserverTreeNodeChanged(root);
838 NotifyObserverEndBatch();
839 }
840
841 void CookiesTreeModel::OnCookiesModelInfoLoaded(
842 const net::CookieList& cookie_list) {
843 cookie_list_.insert(cookie_list_.begin(),
844 cookie_list.begin(),
845 cookie_list.end());
846 PopulateCookieInfoWithFilter(std::wstring());
847 } 915 }
848 916
849 void CookiesTreeModel::PopulateCookieInfoWithFilter( 917 void CookiesTreeModel::PopulateCookieInfoWithFilter(
850 const std::wstring& filter) { 918 LocalDataContainer* container,
851 // mmargh mmargh mmargh! delicious! 919 ScopedBatchUpdateNotifier* notifier,
920 const string16& filter) {
921 CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot());
852 922
853 CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot()); 923 notifier->StartBatchUpdate();
854 NotifyObserverBeginBatch(); 924 for (CookieList::iterator it = container->cookie_list_.begin();
855 for (CookieList::iterator it = cookie_list_.begin(); 925 it != container->cookie_list_.end(); ++it) {
856 it != cookie_list_.end(); ++it) {
857 std::string source_string = it->Source(); 926 std::string source_string = it->Source();
858 if (source_string.empty() || !use_cookie_source_) { 927 if (source_string.empty() || !group_by_cookie_source_) {
859 std::string domain = it->Domain(); 928 std::string domain = it->Domain();
860 if (domain.length() > 1 && domain[0] == '.') 929 if (domain.length() > 1 && domain[0] == '.')
861 domain = domain.substr(1); 930 domain = domain.substr(1);
862 931
863 // We treat secure cookies just the same as normal ones. 932 // We treat secure cookies just the same as normal ones.
864 source_string = std::string(chrome::kHttpScheme) + 933 source_string = std::string(chrome::kHttpScheme) +
865 content::kStandardSchemeSeparator + domain + "/"; 934 content::kStandardSchemeSeparator + domain + "/";
866 } 935 }
867 936
868 GURL source(source_string); 937 GURL source(source_string);
869 if (!filter.size() || 938 if (!filter.size() ||
870 (CookieTreeOriginNode::TitleForUrl(source).find(filter) != 939 (CookieTreeOriginNode::TitleForUrl(source, container->app_id(),
871 std::string::npos)) { 940 container->app_name()).find(filter) != string16::npos)) {
872 CookieTreeOriginNode* origin_node = 941 CookieTreeOriginNode* origin_node =
873 root->GetOrCreateOriginNode(source); 942 root->GetOrCreateOriginNode(source, container->app_id(),
943 container->app_name());
874 CookieTreeCookiesNode* cookies_node = 944 CookieTreeCookiesNode* cookies_node =
875 origin_node->GetOrCreateCookiesNode(); 945 origin_node->GetOrCreateCookiesNode();
876 CookieTreeCookieNode* new_cookie = new CookieTreeCookieNode(it); 946 CookieTreeCookieNode* new_cookie = new CookieTreeCookieNode(it);
877 cookies_node->AddCookieNode(new_cookie); 947 cookies_node->AddCookieNode(new_cookie);
878 } 948 }
879 } 949 }
880 NotifyObserverTreeNodeChanged(root);
881 NotifyObserverEndBatch();
882 }
883
884 void CookiesTreeModel::OnDatabaseModelInfoLoaded(
885 const DatabaseInfoList& database_info) {
886 database_info_list_ = database_info;
887 PopulateDatabaseInfoWithFilter(std::wstring());
888 } 950 }
889 951
890 void CookiesTreeModel::PopulateDatabaseInfoWithFilter( 952 void CookiesTreeModel::PopulateDatabaseInfoWithFilter(
891 const std::wstring& filter) { 953 LocalDataContainer* container,
892 if (database_info_list_.empty()) 954 ScopedBatchUpdateNotifier* notifier,
893 return; 955 const string16& filter) {
894 CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot()); 956 CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot());
895 NotifyObserverBeginBatch(); 957
896 for (DatabaseInfoList::iterator database_info = database_info_list_.begin(); 958 if (container->database_info_list_.empty())
897 database_info != database_info_list_.end(); 959 return;
960
961 notifier->StartBatchUpdate();
962 for (DatabaseInfoList::iterator database_info =
963 container->database_info_list_.begin();
964 database_info != container->database_info_list_.end();
898 ++database_info) { 965 ++database_info) {
899 GURL origin(database_info->origin); 966 GURL origin(database_info->origin);
900 967
901 if (!filter.size() || 968 if (!filter.size() ||
902 (CookieTreeOriginNode::TitleForUrl(origin).find(filter) != 969 (CookieTreeOriginNode::TitleForUrl(origin, container->app_id(),
903 std::wstring::npos)) { 970 container->app_name()).find(filter) != string16::npos)) {
904 CookieTreeOriginNode* origin_node = 971 CookieTreeOriginNode* origin_node =
905 root->GetOrCreateOriginNode(origin); 972 root->GetOrCreateOriginNode(origin, container->app_id(),
973 container->app_name());
906 CookieTreeDatabasesNode* databases_node = 974 CookieTreeDatabasesNode* databases_node =
907 origin_node->GetOrCreateDatabasesNode(); 975 origin_node->GetOrCreateDatabasesNode();
908 databases_node->AddDatabaseNode( 976 databases_node->AddDatabaseNode(
909 new CookieTreeDatabaseNode(database_info)); 977 new CookieTreeDatabaseNode(database_info));
910 } 978 }
911 } 979 }
912 NotifyObserverTreeNodeChanged(root);
913 NotifyObserverEndBatch();
914 }
915
916 void CookiesTreeModel::OnLocalStorageModelInfoLoaded(
917 const LocalStorageInfoList& local_storage_info) {
918 local_storage_info_list_ = local_storage_info;
919 PopulateLocalStorageInfoWithFilter(std::wstring());
920 } 980 }
921 981
922 void CookiesTreeModel::PopulateLocalStorageInfoWithFilter( 982 void CookiesTreeModel::PopulateLocalStorageInfoWithFilter(
923 const std::wstring& filter) { 983 LocalDataContainer* container,
924 if (local_storage_info_list_.empty()) 984 ScopedBatchUpdateNotifier* notifier,
925 return; 985 const string16& filter) {
926 CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot()); 986 CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot());
927 NotifyObserverBeginBatch(); 987
988 if (container->local_storage_info_list_.empty())
989 return;
990
991 notifier->StartBatchUpdate();
928 for (LocalStorageInfoList::iterator local_storage_info = 992 for (LocalStorageInfoList::iterator local_storage_info =
929 local_storage_info_list_.begin(); 993 container->local_storage_info_list_.begin();
930 local_storage_info != local_storage_info_list_.end(); 994 local_storage_info != container->local_storage_info_list_.end();
931 ++local_storage_info) { 995 ++local_storage_info) {
932 const GURL& origin(local_storage_info->origin_url); 996 const GURL& origin(local_storage_info->origin_url);
933 997
934 if (!filter.size() || 998 if (!filter.size() ||
935 (CookieTreeOriginNode::TitleForUrl(origin).find(filter) != 999 (CookieTreeOriginNode::TitleForUrl(origin, container->app_id(),
936 std::wstring::npos)) { 1000 container->app_name()).find(filter) != std::string::npos)) {
937 CookieTreeOriginNode* origin_node = 1001 CookieTreeOriginNode* origin_node =
938 root->GetOrCreateOriginNode(origin); 1002 root->GetOrCreateOriginNode(origin, container->app_id(),
1003 container->app_name());
939 CookieTreeLocalStoragesNode* local_storages_node = 1004 CookieTreeLocalStoragesNode* local_storages_node =
940 origin_node->GetOrCreateLocalStoragesNode(); 1005 origin_node->GetOrCreateLocalStoragesNode();
941 local_storages_node->AddLocalStorageNode( 1006 local_storages_node->AddLocalStorageNode(
942 new CookieTreeLocalStorageNode(local_storage_info)); 1007 new CookieTreeLocalStorageNode(local_storage_info));
943 } 1008 }
944 } 1009 }
945 NotifyObserverTreeNodeChanged(root);
946 NotifyObserverEndBatch();
947 }
948
949 void CookiesTreeModel::OnSessionStorageModelInfoLoaded(
950 const LocalStorageInfoList& session_storage_info) {
951 session_storage_info_list_ = session_storage_info;
952 PopulateSessionStorageInfoWithFilter(std::wstring());
953 } 1010 }
954 1011
955 void CookiesTreeModel::PopulateSessionStorageInfoWithFilter( 1012 void CookiesTreeModel::PopulateSessionStorageInfoWithFilter(
956 const std::wstring& filter) { 1013 LocalDataContainer* container,
957 if (session_storage_info_list_.empty()) 1014 ScopedBatchUpdateNotifier* notifier,
958 return; 1015 const string16& filter) {
959 CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot()); 1016 CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot());
960 NotifyObserverBeginBatch(); 1017
1018 if (container->session_storage_info_list_.empty())
1019 return;
1020
1021 notifier->StartBatchUpdate();
961 for (LocalStorageInfoList::iterator session_storage_info = 1022 for (LocalStorageInfoList::iterator session_storage_info =
962 session_storage_info_list_.begin(); 1023 container->session_storage_info_list_.begin();
963 session_storage_info != session_storage_info_list_.end(); 1024 session_storage_info != container->session_storage_info_list_.end();
964 ++session_storage_info) { 1025 ++session_storage_info) {
965 const GURL& origin = session_storage_info->origin_url; 1026 const GURL& origin = session_storage_info->origin_url;
966 if (!filter.size() || 1027
967 (CookieTreeOriginNode::TitleForUrl(origin).find(filter) != 1028 if (!filter.size() ||
968 std::wstring::npos)) { 1029 (CookieTreeOriginNode::TitleForUrl(origin, container->app_id(),
969 CookieTreeOriginNode* origin_node = 1030 container->app_name()).find(filter) != string16::npos)) {
970 root->GetOrCreateOriginNode(origin); 1031 CookieTreeOriginNode* origin_node =
1032 root->GetOrCreateOriginNode(origin, container->app_id(),
1033 container->app_name());
971 CookieTreeSessionStoragesNode* session_storages_node = 1034 CookieTreeSessionStoragesNode* session_storages_node =
972 origin_node->GetOrCreateSessionStoragesNode(); 1035 origin_node->GetOrCreateSessionStoragesNode();
973 session_storages_node->AddSessionStorageNode( 1036 session_storages_node->AddSessionStorageNode(
974 new CookieTreeSessionStorageNode(session_storage_info)); 1037 new CookieTreeSessionStorageNode(session_storage_info));
975 } 1038 }
976 } 1039 }
977 NotifyObserverTreeNodeChanged(root);
978 NotifyObserverEndBatch();
979 }
980
981 void CookiesTreeModel::OnIndexedDBModelInfoLoaded(
982 const IndexedDBInfoList& indexed_db_info) {
983 indexed_db_info_list_ = indexed_db_info;
984 PopulateIndexedDBInfoWithFilter(std::wstring());
985 } 1040 }
986 1041
987 void CookiesTreeModel::PopulateIndexedDBInfoWithFilter( 1042 void CookiesTreeModel::PopulateIndexedDBInfoWithFilter(
988 const std::wstring& filter) { 1043 LocalDataContainer* container,
989 if (indexed_db_info_list_.empty()) 1044 ScopedBatchUpdateNotifier* notifier,
990 return; 1045 const string16& filter) {
991 CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot()); 1046 CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot());
992 NotifyObserverBeginBatch(); 1047
1048 if (container->indexed_db_info_list_.empty())
1049 return;
1050
1051 notifier->StartBatchUpdate();
993 for (IndexedDBInfoList::iterator indexed_db_info = 1052 for (IndexedDBInfoList::iterator indexed_db_info =
994 indexed_db_info_list_.begin(); 1053 container->indexed_db_info_list_.begin();
995 indexed_db_info != indexed_db_info_list_.end(); 1054 indexed_db_info != container->indexed_db_info_list_.end();
996 ++indexed_db_info) { 1055 ++indexed_db_info) {
997 const GURL& origin = indexed_db_info->origin; 1056 const GURL& origin = indexed_db_info->origin;
998 1057
999 if (!filter.size() || 1058 if (!filter.size() ||
1000 (CookieTreeOriginNode::TitleForUrl(origin).find(filter) != 1059 (CookieTreeOriginNode::TitleForUrl(origin, container->app_id(),
1001 std::wstring::npos)) { 1060 container->app_name()).find(filter) != string16::npos)) {
1002 CookieTreeOriginNode* origin_node = 1061 CookieTreeOriginNode* origin_node =
1003 root->GetOrCreateOriginNode(origin); 1062 root->GetOrCreateOriginNode(origin, container->app_id(),
1063 container->app_name());
1004 CookieTreeIndexedDBsNode* indexed_dbs_node = 1064 CookieTreeIndexedDBsNode* indexed_dbs_node =
1005 origin_node->GetOrCreateIndexedDBsNode(); 1065 origin_node->GetOrCreateIndexedDBsNode();
1006 indexed_dbs_node->AddIndexedDBNode( 1066 indexed_dbs_node->AddIndexedDBNode(
1007 new CookieTreeIndexedDBNode(indexed_db_info)); 1067 new CookieTreeIndexedDBNode(indexed_db_info));
1008 } 1068 }
1009 } 1069 }
1010 NotifyObserverTreeNodeChanged(root);
1011 NotifyObserverEndBatch();
1012 }
1013
1014 void CookiesTreeModel::OnFileSystemModelInfoLoaded(
1015 const FileSystemInfoList& file_system_info) {
1016 file_system_info_list_ = file_system_info;
1017 PopulateFileSystemInfoWithFilter(std::wstring());
1018 }
1019
1020 void CookiesTreeModel::PopulateFileSystemInfoWithFilter(
1021 const std::wstring& filter) {
1022 if (file_system_info_list_.empty())
1023 return;
1024 CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot());
1025 NotifyObserverBeginBatch();
1026 for (FileSystemInfoList::iterator file_system_info =
1027 file_system_info_list_.begin();
1028 file_system_info != file_system_info_list_.end();
1029 ++file_system_info) {
1030 GURL origin(file_system_info->origin);
1031
1032 if (!filter.size() ||
1033 (CookieTreeOriginNode::TitleForUrl(origin).find(filter) !=
1034 std::wstring::npos)) {
1035 CookieTreeOriginNode* origin_node =
1036 root->GetOrCreateOriginNode(origin);
1037 CookieTreeFileSystemsNode* file_systems_node =
1038 origin_node->GetOrCreateFileSystemsNode();
1039 file_systems_node->AddFileSystemNode(
1040 new CookieTreeFileSystemNode(file_system_info));
1041 }
1042 }
1043 NotifyObserverTreeNodeChanged(root);
1044 NotifyObserverEndBatch();
1045 }
1046
1047 void CookiesTreeModel::OnQuotaModelInfoLoaded(
1048 const QuotaInfoArray& quota_info) {
1049 quota_info_list_ = quota_info;
1050 PopulateQuotaInfoWithFilter(std::wstring());
1051 }
1052
1053 void CookiesTreeModel::PopulateQuotaInfoWithFilter(
1054 const std::wstring& filter) {
1055 if (quota_info_list_.empty())
1056 return;
1057 CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot());
1058 NotifyObserverBeginBatch();
1059 for (QuotaInfoArray::iterator quota_info = quota_info_list_.begin();
1060 quota_info != quota_info_list_.end();
1061 ++quota_info) {
1062 if (!filter.size() ||
1063 (UTF8ToWide(quota_info->host).find(filter) != std::wstring::npos)) {
1064 CookieTreeOriginNode* origin_node =
1065 root->GetOrCreateOriginNode(GURL("http://" + quota_info->host));
1066 origin_node->UpdateOrCreateQuotaNode(quota_info);
1067 }
1068 }
1069 NotifyObserverTreeNodeChanged(root);
1070 NotifyObserverEndBatch();
1071 }
1072
1073 void CookiesTreeModel::OnServerBoundCertModelInfoLoaded(
1074 const ServerBoundCertList& cert_list) {
1075 server_bound_cert_list_ = cert_list;
1076 PopulateServerBoundCertInfoWithFilter(std::wstring());
1077 } 1070 }
1078 1071
1079 void CookiesTreeModel::PopulateServerBoundCertInfoWithFilter( 1072 void CookiesTreeModel::PopulateServerBoundCertInfoWithFilter(
1080 const std::wstring& filter) { 1073 LocalDataContainer* container,
1081 if (server_bound_cert_list_.empty()) 1074 ScopedBatchUpdateNotifier* notifier,
1082 return; 1075 const string16& filter) {
1083 CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot()); 1076 CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot());
1084 NotifyObserverBeginBatch(); 1077
1078 if (container->server_bound_cert_list_.empty())
1079 return;
1080
1081 notifier->StartBatchUpdate();
1085 for (ServerBoundCertList::iterator cert_info = 1082 for (ServerBoundCertList::iterator cert_info =
1086 server_bound_cert_list_.begin(); 1083 container->server_bound_cert_list_.begin();
1087 cert_info != server_bound_cert_list_.end(); 1084 cert_info != container->server_bound_cert_list_.end();
1088 ++cert_info) { 1085 ++cert_info) {
1089 GURL origin(cert_info->server_identifier()); 1086 GURL origin(cert_info->server_identifier());
1090 if (!origin.is_valid()) { 1087 if (!origin.is_valid()) {
1091 // Domain Bound Cert. Make a valid URL to satisfy the 1088 // Domain Bound Cert. Make a valid URL to satisfy the
1092 // CookieTreeRootNode::GetOrCreateOriginNode interface. 1089 // CookieTreeRootNode::GetOrCreateOriginNode interface.
1093 origin = GURL(std::string(chrome::kHttpsScheme) + 1090 origin = GURL(std::string(chrome::kHttpsScheme) +
1094 content::kStandardSchemeSeparator + 1091 content::kStandardSchemeSeparator +
1095 cert_info->server_identifier() + "/"); 1092 cert_info->server_identifier() + "/");
1096 } 1093 }
1097 std::wstring title = CookieTreeOriginNode::TitleForUrl(origin); 1094 string16 title = CookieTreeOriginNode::TitleForUrl(origin,
1098 1095 container->app_id(),
1099 if (!filter.size() || title.find(filter) != std::wstring::npos) { 1096 container->app_name());
1100 CookieTreeOriginNode* origin_node = 1097
1101 root->GetOrCreateOriginNode(origin); 1098 if (!filter.size() || title.find(filter) != string16::npos) {
1099 CookieTreeOriginNode* origin_node =
1100 root->GetOrCreateOriginNode(origin, container->app_id(),
1101 container->app_name());
1102 CookieTreeServerBoundCertsNode* server_bound_certs_node = 1102 CookieTreeServerBoundCertsNode* server_bound_certs_node =
1103 origin_node->GetOrCreateServerBoundCertsNode(); 1103 origin_node->GetOrCreateServerBoundCertsNode();
1104 server_bound_certs_node->AddServerBoundCertNode( 1104 server_bound_certs_node->AddServerBoundCertNode(
1105 new CookieTreeServerBoundCertNode(cert_info)); 1105 new CookieTreeServerBoundCertNode(cert_info));
1106 } 1106 }
1107 } 1107 }
1108 NotifyObserverTreeNodeChanged(root); 1108 }
1109 NotifyObserverEndBatch(); 1109
1110 void CookiesTreeModel::PopulateFileSystemInfoWithFilter(
1111 LocalDataContainer* container,
1112 ScopedBatchUpdateNotifier* notifier,
1113 const string16& filter) {
1114 CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot());
1115
1116 if (container->file_system_info_list_.empty())
1117 return;
1118
1119 notifier->StartBatchUpdate();
1120 for (FileSystemInfoList::iterator file_system_info =
1121 container->file_system_info_list_.begin();
1122 file_system_info != container->file_system_info_list_.end();
1123 ++file_system_info) {
1124 GURL origin(file_system_info->origin);
1125
1126 if (!filter.size() ||
1127 (CookieTreeOriginNode::TitleForUrl(origin, container->app_id(),
1128 container->app_name()).find(filter) != string16::npos)) {
1129 CookieTreeOriginNode* origin_node =
1130 root->GetOrCreateOriginNode(origin, container->app_id(),
1131 container->app_name());
1132 CookieTreeFileSystemsNode* file_systems_node =
1133 origin_node->GetOrCreateFileSystemsNode();
1134 file_systems_node->AddFileSystemNode(
1135 new CookieTreeFileSystemNode(file_system_info));
1136 }
1137 }
1138 }
1139
1140 void CookiesTreeModel::PopulateQuotaInfoWithFilter(
1141 LocalDataContainer* container,
1142 ScopedBatchUpdateNotifier* notifier,
1143 const string16& filter) {
1144 CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot());
1145
1146 if (container->quota_info_list_.empty())
1147 return;
1148
1149 notifier->StartBatchUpdate();
1150 for (QuotaInfoList::iterator quota_info = container->quota_info_list_.begin();
1151 quota_info != container->quota_info_list_.end();
1152 ++quota_info) {
1153 if (!filter.size() ||
1154 (UTF8ToUTF16(quota_info->host).find(filter) != string16::npos)) {
1155 CookieTreeOriginNode* origin_node =
1156 root->GetOrCreateOriginNode(GURL("http://" + quota_info->host),
1157 container->app_id(),
1158 container->app_name());
1159 origin_node->UpdateOrCreateQuotaNode(quota_info);
1160 }
1161 }
1110 } 1162 }
1111 1163
1112 void CookiesTreeModel::NotifyObserverBeginBatch() { 1164 void CookiesTreeModel::NotifyObserverBeginBatch() {
1113 // Only notify the model once if we're batching in a nested manner. 1165 // Only notify the model once if we're batching in a nested manner.
1114 if (batch_update_++ == 0) { 1166 if (batch_update_++ == 0) {
1115 FOR_EACH_OBSERVER(Observer, 1167 FOR_EACH_OBSERVER(Observer,
1116 cookies_observer_list_, 1168 cookies_observer_list_,
1117 TreeModelBeginBatch(this)); 1169 TreeModelBeginBatch(this));
1118 } 1170 }
1119 } 1171 }
1120 1172
1121 void CookiesTreeModel::NotifyObserverEndBatch() { 1173 void CookiesTreeModel::NotifyObserverEndBatch() {
1122 // Only notify the observers if this is the outermost call to EndBatch() if 1174 // Only notify the observers if this is the outermost call to EndBatch() if
1123 // called in a nested manner. 1175 // called in a nested manner.
1124 if (--batch_update_ == 0) { 1176 if (--batch_update_ == 0) {
1125 FOR_EACH_OBSERVER(Observer, 1177 FOR_EACH_OBSERVER(Observer,
1126 cookies_observer_list_, 1178 cookies_observer_list_,
1127 TreeModelEndBatch(this)); 1179 TreeModelEndBatch(this));
1128 } 1180 }
1129 } 1181 }
1182
1183 LocalDataContainer* CookiesTreeModel::GetLocalDataContainer(
1184 const std::string& app_id) {
1185 LocalDataContainer* container = app_data_map_[app_id];
1186 return container;
1187 }
OLDNEW
« no previous file with comments | « chrome/browser/cookies_tree_model.h ('k') | chrome/browser/cookies_tree_model_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698