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

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

Powered by Google App Engine
This is Rietveld 408576698