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

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

Issue 10536017: Refactoring CookiesTreeModel to support multiple data sources. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixes for commes by James and Evan. Created 8 years, 6 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/local_data_container.h"
6
7 #include "base/bind.h"
8 #include "base/memory/linked_ptr.h"
9 #include "chrome/browser/browsing_data_cookie_helper.h"
10 #include "chrome/browser/browsing_data_server_bound_cert_helper.h"
11 #include "chrome/browser/content_settings/cookie_settings.h"
12 #include "chrome/browser/cookies_tree_model.h"
13
14
15 ///////////////////////////////////////////////////////////////////////////////
16 // LocalDataContainer, public:
17
18 LocalDataContainer::LocalDataContainer(
19 const std::string& app_name,
20 const std::string& app_id,
21 BrowsingDataCookieHelper* cookie_helper,
22 BrowsingDataDatabaseHelper* database_helper,
23 BrowsingDataLocalStorageHelper* local_storage_helper,
24 BrowsingDataLocalStorageHelper* session_storage_helper,
25 BrowsingDataAppCacheHelper* appcache_helper,
26 BrowsingDataIndexedDBHelper* indexed_db_helper,
27 BrowsingDataFileSystemHelper* file_system_helper,
28 BrowsingDataQuotaHelper* quota_helper,
29 BrowsingDataServerBoundCertHelper* server_bound_cert_helper)
30 : app_name_(app_name),
31 app_id_(app_id),
32 appcache_helper_(appcache_helper),
33 cookie_helper_(cookie_helper),
34 database_helper_(database_helper),
35 local_storage_helper_(local_storage_helper),
36 session_storage_helper_(session_storage_helper),
37 indexed_db_helper_(indexed_db_helper),
38 file_system_helper_(file_system_helper),
39 quota_helper_(quota_helper),
40 server_bound_cert_helper_(server_bound_cert_helper),
41 delegate_(NULL),
42 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {}
43
44 LocalDataContainer::~LocalDataContainer() {}
45
46 void LocalDataContainer::Init(CookiesTreeModelDelegate* delegate) {
47 DCHECK(!delegate_);
48 delegate_ = delegate;
49
50 DCHECK(cookie_helper_);
51 cookie_helper_->StartFetching(
52 base::Bind(&LocalDataContainer::OnCookiesModelInfoLoaded,
53 weak_ptr_factory_.GetWeakPtr()));
54 DCHECK(database_helper_);
55 database_helper_->StartFetching(
56 base::Bind(&LocalDataContainer::OnDatabaseModelInfoLoaded,
57 weak_ptr_factory_.GetWeakPtr()));
58 DCHECK(local_storage_helper_);
59 local_storage_helper_->StartFetching(
60 base::Bind(&LocalDataContainer::OnLocalStorageModelInfoLoaded,
61 weak_ptr_factory_.GetWeakPtr()));
62 if (session_storage_helper_) {
63 session_storage_helper_->StartFetching(
64 base::Bind(&LocalDataContainer::OnSessionStorageModelInfoLoaded,
65 weak_ptr_factory_.GetWeakPtr()));
66 }
67
68 // TODO(michaeln): When all of the UI implementations have been updated, make
69 // this a required parameter.
70 if (appcache_helper_) {
71 appcache_helper_->StartFetching(
72 base::Bind(&LocalDataContainer::OnAppCacheModelInfoLoaded,
73 weak_ptr_factory_.GetWeakPtr()));
74 }
75
76 if (indexed_db_helper_) {
77 indexed_db_helper_->StartFetching(
78 base::Bind(&LocalDataContainer::OnIndexedDBModelInfoLoaded,
79 weak_ptr_factory_.GetWeakPtr()));
80 }
81
82 if (file_system_helper_) {
83 file_system_helper_->StartFetching(
84 base::Bind(&LocalDataContainer::OnFileSystemModelInfoLoaded,
85 weak_ptr_factory_.GetWeakPtr()));
86 }
87
88 if (quota_helper_) {
89 quota_helper_->StartFetching(
90 base::Bind(&LocalDataContainer::OnQuotaModelInfoLoaded,
91 weak_ptr_factory_.GetWeakPtr()));
92 }
93
94 if (server_bound_cert_helper_) {
95 server_bound_cert_helper_->StartFetching(
96 base::Bind(&LocalDataContainer::OnServerBoundCertModelInfoLoaded,
97 weak_ptr_factory_.GetWeakPtr()));
98 }
99 }
100
101 void LocalDataContainer::OnAppCacheModelInfoLoaded() {
102 using appcache::AppCacheInfo;
103 using appcache::AppCacheInfoCollection;
104 using appcache::AppCacheInfoVector;
105 typedef std::map<GURL, AppCacheInfoVector> InfoByOrigin;
106
107 scoped_refptr<AppCacheInfoCollection> appcache_info =
108 appcache_helper_->info_collection();
109 if (!appcache_info || appcache_info->infos_by_origin.empty())
110 return;
111
112 for (InfoByOrigin::const_iterator origin =
113 appcache_info->infos_by_origin.begin();
114 origin != appcache_info->infos_by_origin.end(); ++origin) {
115 std::list<AppCacheInfo>& info_list = appcache_info_[origin->first];
116 info_list.insert(
117 info_list.begin(), origin->second.begin(), origin->second.end());
118 }
119
120 delegate_->PopulateAppCacheInfoWithFilter(&app_name_, string16());
121 }
122
123 void LocalDataContainer::OnCookiesModelInfoLoaded(
124 const net::CookieList& cookie_list) {
125 cookie_list_.insert(cookie_list_.begin(),
126 cookie_list.begin(),
127 cookie_list.end());
128 DCHECK(delegate_);
129 delegate_->PopulateCookieInfoWithFilter(&app_id_, string16());
130 }
131
132 void LocalDataContainer::OnDatabaseModelInfoLoaded(
133 const DatabaseInfoList& database_info) {
134 database_info_list_ = database_info;
135 DCHECK(delegate_);
136 delegate_->PopulateDatabaseInfoWithFilter(&app_id_, string16());
137 }
138
139 void LocalDataContainer::OnLocalStorageModelInfoLoaded(
140 const LocalStorageInfoList& local_storage_info) {
141 local_storage_info_list_ = local_storage_info;
142 DCHECK(delegate_);
143 delegate_->PopulateLocalStorageInfoWithFilter(&app_id_, string16());
144 }
145
146 void LocalDataContainer::OnSessionStorageModelInfoLoaded(
147 const LocalStorageInfoList& session_storage_info) {
148 session_storage_info_list_ = session_storage_info;
149 DCHECK(delegate_);
150 delegate_->PopulateSessionStorageInfoWithFilter(&app_id_, string16());
151 }
152
153 void LocalDataContainer::OnIndexedDBModelInfoLoaded(
154 const IndexedDBInfoList& indexed_db_info) {
155 indexed_db_info_list_ = indexed_db_info;
156 DCHECK(delegate_);
157 delegate_->PopulateIndexedDBInfoWithFilter(&app_id_, string16());
158 }
159
160 void LocalDataContainer::OnFileSystemModelInfoLoaded(
161 const FileSystemInfoList& file_system_info) {
162 file_system_info_list_ = file_system_info;
163 DCHECK(delegate_);
164 delegate_->PopulateFileSystemInfoWithFilter(&app_id_, string16());
165 }
166
167 void LocalDataContainer::OnQuotaModelInfoLoaded(
168 const QuotaInfoList& quota_info) {
169 quota_info_list_ = quota_info;
170 DCHECK(delegate_);
171 delegate_->PopulateQuotaInfoWithFilter(&app_id_, string16());
172 }
173
174 void LocalDataContainer::OnServerBoundCertModelInfoLoaded(
175 const ServerBoundCertList& cert_list) {
176 server_bound_cert_list_ = cert_list;
177 DCHECK(delegate_);
178 delegate_->PopulateServerBoundCertInfoWithFilter(&app_id_, string16());
179 }
OLDNEW
« no previous file with comments | « chrome/browser/local_data_container.h ('k') | chrome/browser/resources/options2/cookies_list.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698