Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 | |
|
markusheintz_
2012/06/26 16:34:31
nit: I think you can remove one of the empty lines
nasko
2012/06/26 17:43:20
Done.
| |
| 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 | |
| 55 if (database_helper_) { | |
| 56 database_helper_->StartFetching( | |
| 57 base::Bind(&LocalDataContainer::OnDatabaseModelInfoLoaded, | |
| 58 weak_ptr_factory_.GetWeakPtr())); | |
| 59 } | |
| 60 | |
| 61 if (local_storage_helper_) { | |
| 62 local_storage_helper_->StartFetching( | |
| 63 base::Bind(&LocalDataContainer::OnLocalStorageModelInfoLoaded, | |
| 64 weak_ptr_factory_.GetWeakPtr())); | |
| 65 } | |
| 66 | |
| 67 if (session_storage_helper_) { | |
| 68 session_storage_helper_->StartFetching( | |
| 69 base::Bind(&LocalDataContainer::OnSessionStorageModelInfoLoaded, | |
| 70 weak_ptr_factory_.GetWeakPtr())); | |
| 71 } | |
| 72 | |
| 73 // TODO(michaeln): When all of the UI implementations have been updated, make | |
| 74 // this a required parameter. | |
| 75 if (appcache_helper_) { | |
| 76 appcache_helper_->StartFetching( | |
| 77 base::Bind(&LocalDataContainer::OnAppCacheModelInfoLoaded, | |
| 78 weak_ptr_factory_.GetWeakPtr())); | |
| 79 } | |
| 80 | |
| 81 if (indexed_db_helper_) { | |
| 82 indexed_db_helper_->StartFetching( | |
| 83 base::Bind(&LocalDataContainer::OnIndexedDBModelInfoLoaded, | |
| 84 weak_ptr_factory_.GetWeakPtr())); | |
| 85 } | |
| 86 | |
| 87 if (file_system_helper_) { | |
| 88 file_system_helper_->StartFetching( | |
| 89 base::Bind(&LocalDataContainer::OnFileSystemModelInfoLoaded, | |
| 90 weak_ptr_factory_.GetWeakPtr())); | |
| 91 } | |
| 92 | |
| 93 if (quota_helper_) { | |
| 94 quota_helper_->StartFetching( | |
| 95 base::Bind(&LocalDataContainer::OnQuotaModelInfoLoaded, | |
| 96 weak_ptr_factory_.GetWeakPtr())); | |
| 97 } | |
| 98 | |
| 99 if (server_bound_cert_helper_) { | |
| 100 server_bound_cert_helper_->StartFetching( | |
| 101 base::Bind(&LocalDataContainer::OnServerBoundCertModelInfoLoaded, | |
| 102 weak_ptr_factory_.GetWeakPtr())); | |
| 103 } | |
| 104 } | |
| 105 | |
| 106 void LocalDataContainer::OnAppCacheModelInfoLoaded() { | |
| 107 using appcache::AppCacheInfo; | |
| 108 using appcache::AppCacheInfoCollection; | |
| 109 using appcache::AppCacheInfoVector; | |
| 110 typedef std::map<GURL, AppCacheInfoVector> InfoByOrigin; | |
| 111 | |
| 112 scoped_refptr<AppCacheInfoCollection> appcache_info = | |
| 113 appcache_helper_->info_collection(); | |
| 114 if (!appcache_info || appcache_info->infos_by_origin.empty()) | |
| 115 return; | |
| 116 | |
| 117 for (InfoByOrigin::const_iterator origin = | |
| 118 appcache_info->infos_by_origin.begin(); | |
| 119 origin != appcache_info->infos_by_origin.end(); ++origin) { | |
| 120 std::list<AppCacheInfo>& info_list = appcache_info_[origin->first]; | |
| 121 info_list.insert( | |
| 122 info_list.begin(), origin->second.begin(), origin->second.end()); | |
| 123 } | |
| 124 | |
| 125 delegate_->PopulateAppCacheInfoWithFilter(&app_name_, string16()); | |
| 126 } | |
| 127 | |
| 128 void LocalDataContainer::OnCookiesModelInfoLoaded( | |
| 129 const net::CookieList& cookie_list) { | |
| 130 cookie_list_.insert(cookie_list_.begin(), | |
| 131 cookie_list.begin(), | |
| 132 cookie_list.end()); | |
| 133 DCHECK(delegate_); | |
| 134 delegate_->PopulateCookieInfoWithFilter(&app_id_, string16()); | |
| 135 } | |
| 136 | |
| 137 void LocalDataContainer::OnDatabaseModelInfoLoaded( | |
| 138 const DatabaseInfoList& database_info) { | |
| 139 database_info_list_ = database_info; | |
| 140 DCHECK(delegate_); | |
| 141 delegate_->PopulateDatabaseInfoWithFilter(&app_id_, string16()); | |
| 142 } | |
| 143 | |
| 144 void LocalDataContainer::OnLocalStorageModelInfoLoaded( | |
| 145 const LocalStorageInfoList& local_storage_info) { | |
| 146 local_storage_info_list_ = local_storage_info; | |
| 147 DCHECK(delegate_); | |
| 148 delegate_->PopulateLocalStorageInfoWithFilter(&app_id_, string16()); | |
| 149 } | |
| 150 | |
| 151 void LocalDataContainer::OnSessionStorageModelInfoLoaded( | |
| 152 const LocalStorageInfoList& session_storage_info) { | |
| 153 session_storage_info_list_ = session_storage_info; | |
| 154 DCHECK(delegate_); | |
| 155 delegate_->PopulateSessionStorageInfoWithFilter(&app_id_, string16()); | |
| 156 } | |
| 157 | |
| 158 void LocalDataContainer::OnIndexedDBModelInfoLoaded( | |
| 159 const IndexedDBInfoList& indexed_db_info) { | |
| 160 indexed_db_info_list_ = indexed_db_info; | |
| 161 DCHECK(delegate_); | |
| 162 delegate_->PopulateIndexedDBInfoWithFilter(&app_id_, string16()); | |
| 163 } | |
| 164 | |
| 165 void LocalDataContainer::OnFileSystemModelInfoLoaded( | |
| 166 const FileSystemInfoList& file_system_info) { | |
| 167 file_system_info_list_ = file_system_info; | |
| 168 DCHECK(delegate_); | |
| 169 delegate_->PopulateFileSystemInfoWithFilter(&app_id_, string16()); | |
| 170 } | |
| 171 | |
| 172 void LocalDataContainer::OnQuotaModelInfoLoaded( | |
| 173 const QuotaInfoList& quota_info) { | |
| 174 quota_info_list_ = quota_info; | |
| 175 DCHECK(delegate_); | |
| 176 delegate_->PopulateQuotaInfoWithFilter(&app_id_, string16()); | |
| 177 } | |
| 178 | |
| 179 void LocalDataContainer::OnServerBoundCertModelInfoLoaded( | |
| 180 const ServerBoundCertList& cert_list) { | |
| 181 server_bound_cert_list_ = cert_list; | |
| 182 DCHECK(delegate_); | |
| 183 delegate_->PopulateServerBoundCertInfoWithFilter(&app_id_, string16()); | |
| 184 } | |
| OLD | NEW |