OLD | NEW |
---|---|
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/ui/webui/options2/cookies_view_handler2.h" | 5 #include "chrome/browser/ui/webui/options2/cookies_view_handler2.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
11 #include "chrome/common/extensions/extension.h" | |
12 #include "chrome/common/extensions/extension_set.h" | |
11 #include "chrome/browser/browsing_data_appcache_helper.h" | 13 #include "chrome/browser/browsing_data_appcache_helper.h" |
12 #include "chrome/browser/browsing_data_cookie_helper.h" | 14 #include "chrome/browser/browsing_data_cookie_helper.h" |
13 #include "chrome/browser/browsing_data_database_helper.h" | 15 #include "chrome/browser/browsing_data_database_helper.h" |
14 #include "chrome/browser/browsing_data_file_system_helper.h" | 16 #include "chrome/browser/browsing_data_file_system_helper.h" |
15 #include "chrome/browser/browsing_data_indexed_db_helper.h" | 17 #include "chrome/browser/browsing_data_indexed_db_helper.h" |
16 #include "chrome/browser/browsing_data_local_storage_helper.h" | 18 #include "chrome/browser/browsing_data_local_storage_helper.h" |
17 #include "chrome/browser/browsing_data_quota_helper.h" | 19 #include "chrome/browser/browsing_data_quota_helper.h" |
18 #include "chrome/browser/browsing_data_server_bound_cert_helper.h" | 20 #include "chrome/browser/browsing_data_server_bound_cert_helper.h" |
21 #include "chrome/browser/extensions/extension_service.h" | |
19 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
20 #include "chrome/browser/ui/webui/cookies_tree_model_util.h" | 23 #include "chrome/browser/ui/webui/cookies_tree_model_util.h" |
21 #include "content/public/browser/web_ui.h" | 24 #include "content/public/browser/web_ui.h" |
22 #include "grit/generated_resources.h" | 25 #include "grit/generated_resources.h" |
23 #include "ui/base/l10n/l10n_util.h" | 26 #include "ui/base/l10n/l10n_util.h" |
24 | 27 |
25 namespace options2 { | 28 namespace options2 { |
26 | 29 |
27 CookiesViewHandler::CookiesViewHandler() : batch_update_(false) { | 30 CookiesViewHandler::CookiesViewHandler() : batch_update_(false) { |
28 } | 31 } |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
155 void CookiesViewHandler::TreeModelEndBatch(CookiesTreeModel* model) { | 158 void CookiesViewHandler::TreeModelEndBatch(CookiesTreeModel* model) { |
156 DCHECK(batch_update_); | 159 DCHECK(batch_update_); |
157 batch_update_ = false; | 160 batch_update_ = false; |
158 | 161 |
159 SendChildren(cookies_tree_model_->GetRoot()); | 162 SendChildren(cookies_tree_model_->GetRoot()); |
160 } | 163 } |
161 | 164 |
162 void CookiesViewHandler::EnsureCookiesTreeModelCreated() { | 165 void CookiesViewHandler::EnsureCookiesTreeModelCreated() { |
163 if (!cookies_tree_model_.get()) { | 166 if (!cookies_tree_model_.get()) { |
164 Profile* profile = Profile::FromWebUI(web_ui()); | 167 Profile* profile = Profile::FromWebUI(web_ui()); |
165 cookies_tree_model_.reset(new CookiesTreeModel( | 168 string16 name = ASCIIToUTF16("Site Data"); |
169 string16 browser_id; | |
Evan Stade
2012/06/20 21:06:30
this is still here
nasko
2012/06/20 22:32:32
Done.
| |
170 ContainerMap apps_map; | |
171 | |
172 apps_map[browser_id] = new LocalDataContainer( | |
173 name, browser_id, | |
166 new BrowsingDataCookieHelper(profile->GetRequestContext()), | 174 new BrowsingDataCookieHelper(profile->GetRequestContext()), |
167 new BrowsingDataDatabaseHelper(profile), | 175 new BrowsingDataDatabaseHelper(profile), |
168 new BrowsingDataLocalStorageHelper(profile), | 176 new BrowsingDataLocalStorageHelper(profile), |
169 NULL, | 177 NULL, |
170 new BrowsingDataAppCacheHelper(profile), | 178 new BrowsingDataAppCacheHelper(profile), |
171 BrowsingDataIndexedDBHelper::Create(profile), | 179 BrowsingDataIndexedDBHelper::Create(profile), |
172 BrowsingDataFileSystemHelper::Create(profile), | 180 BrowsingDataFileSystemHelper::Create(profile), |
173 BrowsingDataQuotaHelper::Create(profile), | 181 BrowsingDataQuotaHelper::Create(profile), |
174 BrowsingDataServerBoundCertHelper::Create(profile), | 182 BrowsingDataServerBoundCertHelper::Create(profile)); |
175 false)); | 183 |
184 const ExtensionService* service = profile->GetExtensionService(); | |
185 if (service) { | |
186 string16 app_id; | |
Evan Stade
2012/06/20 21:06:30
why is this declared here
nasko
2012/06/20 22:32:32
The reason is that in the loop over all extensions
| |
187 const ExtensionSet* extensions = service->extensions(); | |
188 for (ExtensionSet::const_iterator it = extensions->begin(); | |
189 it != extensions->end(); ++it) { | |
190 if ((*it)->is_storage_isolated()) { | |
191 net::URLRequestContextGetter* context_getter = | |
192 profile->GetRequestContextForIsolatedApp((*it)->id()); | |
193 name = ASCIIToUTF16((*it)->name()); | |
194 app_id = ASCIIToUTF16((*it)->id()); | |
195 apps_map[app_id] = new LocalDataContainer( | |
196 name, app_id, | |
197 new BrowsingDataCookieHelper(context_getter), | |
198 new BrowsingDataDatabaseHelper(profile), | |
199 new BrowsingDataLocalStorageHelper(profile), | |
200 NULL, | |
201 new BrowsingDataAppCacheHelper(profile), | |
202 BrowsingDataIndexedDBHelper::Create(profile), | |
203 BrowsingDataFileSystemHelper::Create(profile), | |
204 BrowsingDataQuotaHelper::Create(profile), | |
205 BrowsingDataServerBoundCertHelper::Create(profile)); | |
206 } | |
207 } | |
208 } | |
209 cookies_tree_model_.reset(new CookiesTreeModel(apps_map, false)); | |
176 cookies_tree_model_->AddCookiesTreeObserver(this); | 210 cookies_tree_model_->AddCookiesTreeObserver(this); |
177 } | 211 } |
178 } | 212 } |
179 | 213 |
180 void CookiesViewHandler::UpdateSearchResults(const ListValue* args) { | 214 void CookiesViewHandler::UpdateSearchResults(const ListValue* args) { |
181 std::string query; | 215 string16 query; |
182 if (!args->GetString(0, &query)) { | 216 if (!args->GetString(0, &query)) { |
183 return; | 217 return; |
184 } | 218 } |
185 | 219 |
186 EnsureCookiesTreeModelCreated(); | 220 EnsureCookiesTreeModelCreated(); |
187 | 221 |
188 cookies_tree_model_->UpdateSearchResults(UTF8ToWide(query)); | 222 cookies_tree_model_->UpdateSearchResults(query); |
189 } | 223 } |
190 | 224 |
191 void CookiesViewHandler::RemoveAll(const ListValue* args) { | 225 void CookiesViewHandler::RemoveAll(const ListValue* args) { |
192 EnsureCookiesTreeModelCreated(); | 226 EnsureCookiesTreeModelCreated(); |
193 cookies_tree_model_->DeleteAllStoredObjects(); | 227 // TODO(nasko): This will only remove the browser stored data, not the |
228 // isolated apps data. This is fine for now, but should be changed based | |
229 // on the new isolated storage UI. | |
230 cookies_tree_model_->DeleteStoredObjectsForApp(string16()); | |
194 } | 231 } |
195 | 232 |
196 void CookiesViewHandler::Remove(const ListValue* args) { | 233 void CookiesViewHandler::Remove(const ListValue* args) { |
197 std::string node_path; | 234 std::string node_path; |
198 if (!args->GetString(0, &node_path)) { | 235 if (!args->GetString(0, &node_path)) { |
199 return; | 236 return; |
200 } | 237 } |
201 | 238 |
202 EnsureCookiesTreeModelCreated(); | 239 EnsureCookiesTreeModelCreated(); |
203 | 240 |
(...skipping 25 matching lines...) Expand all Loading... | |
229 ListValue args; | 266 ListValue args; |
230 args.Append(parent == cookies_tree_model_->GetRoot() ? | 267 args.Append(parent == cookies_tree_model_->GetRoot() ? |
231 Value::CreateNullValue() : | 268 Value::CreateNullValue() : |
232 Value::CreateStringValue(cookies_tree_model_util::GetTreeNodeId(parent))); | 269 Value::CreateStringValue(cookies_tree_model_util::GetTreeNodeId(parent))); |
233 args.Append(children); | 270 args.Append(children); |
234 | 271 |
235 web_ui()->CallJavascriptFunction("CookiesView.loadChildren", args); | 272 web_ui()->CallJavascriptFunction("CookiesView.loadChildren", args); |
236 } | 273 } |
237 | 274 |
238 } // namespace options2 | 275 } // namespace options2 |
OLD | NEW |