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

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

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

Powered by Google App Engine
This is Rietveld 408576698