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 ContainerMap apps_map; |
169 | |
170 apps_map[""] = new LocalDataContainer( | |
James Hawkins
2012/06/21 00:04:12
s/""/string16/ (or std::string() where appropriate
nasko
2012/06/21 16:22:12
Done.
| |
171 "Site Data", "", | |
166 new BrowsingDataCookieHelper(profile->GetRequestContext()), | 172 new BrowsingDataCookieHelper(profile->GetRequestContext()), |
167 new BrowsingDataDatabaseHelper(profile), | 173 new BrowsingDataDatabaseHelper(profile), |
168 new BrowsingDataLocalStorageHelper(profile), | 174 new BrowsingDataLocalStorageHelper(profile), |
169 NULL, | 175 NULL, |
170 new BrowsingDataAppCacheHelper(profile), | 176 new BrowsingDataAppCacheHelper(profile), |
171 BrowsingDataIndexedDBHelper::Create(profile), | 177 BrowsingDataIndexedDBHelper::Create(profile), |
172 BrowsingDataFileSystemHelper::Create(profile), | 178 BrowsingDataFileSystemHelper::Create(profile), |
173 BrowsingDataQuotaHelper::Create(profile), | 179 BrowsingDataQuotaHelper::Create(profile), |
174 BrowsingDataServerBoundCertHelper::Create(profile), | 180 BrowsingDataServerBoundCertHelper::Create(profile)); |
175 false)); | 181 |
182 const ExtensionService* service = profile->GetExtensionService(); | |
183 if (service) { | |
184 const ExtensionSet* extensions = service->extensions(); | |
185 for (ExtensionSet::const_iterator it = extensions->begin(); | |
186 it != extensions->end(); ++it) { | |
187 if ((*it)->is_storage_isolated()) { | |
188 net::URLRequestContextGetter* context_getter = | |
189 profile->GetRequestContextForIsolatedApp((*it)->id()); | |
190 apps_map[(*it)->id()] = new LocalDataContainer( | |
191 (*it)->name(), (*it)->id(), | |
192 new BrowsingDataCookieHelper(context_getter), | |
193 new BrowsingDataDatabaseHelper(profile), | |
194 new BrowsingDataLocalStorageHelper(profile), | |
195 NULL, | |
196 new BrowsingDataAppCacheHelper(profile), | |
197 BrowsingDataIndexedDBHelper::Create(profile), | |
198 BrowsingDataFileSystemHelper::Create(profile), | |
199 BrowsingDataQuotaHelper::Create(profile), | |
200 BrowsingDataServerBoundCertHelper::Create(profile)); | |
201 } | |
202 } | |
203 } | |
204 cookies_tree_model_.reset(new CookiesTreeModel(apps_map, false)); | |
176 cookies_tree_model_->AddCookiesTreeObserver(this); | 205 cookies_tree_model_->AddCookiesTreeObserver(this); |
177 } | 206 } |
178 } | 207 } |
179 | 208 |
180 void CookiesViewHandler::UpdateSearchResults(const ListValue* args) { | 209 void CookiesViewHandler::UpdateSearchResults(const ListValue* args) { |
181 std::string query; | 210 string16 query; |
182 if (!args->GetString(0, &query)) { | 211 if (!args->GetString(0, &query)) { |
183 return; | 212 return; |
184 } | 213 } |
185 | 214 |
186 EnsureCookiesTreeModelCreated(); | 215 EnsureCookiesTreeModelCreated(); |
187 | 216 |
188 cookies_tree_model_->UpdateSearchResults(UTF8ToWide(query)); | 217 cookies_tree_model_->UpdateSearchResults(query); |
189 } | 218 } |
190 | 219 |
191 void CookiesViewHandler::RemoveAll(const ListValue* args) { | 220 void CookiesViewHandler::RemoveAll(const ListValue* args) { |
192 EnsureCookiesTreeModelCreated(); | 221 EnsureCookiesTreeModelCreated(); |
193 cookies_tree_model_->DeleteAllStoredObjects(); | 222 // TODO(nasko): This will only remove the browser stored data, not the |
223 // isolated apps data. This is fine for now, but should be changed based | |
224 // on the new isolated storage UI. | |
225 cookies_tree_model_->DeleteStoredObjectsForApp(""); | |
Evan Stade
2012/06/21 04:01:41
nit: pass std::string()
nasko
2012/06/21 16:22:12
Done.
| |
194 } | 226 } |
195 | 227 |
196 void CookiesViewHandler::Remove(const ListValue* args) { | 228 void CookiesViewHandler::Remove(const ListValue* args) { |
197 std::string node_path; | 229 std::string node_path; |
198 if (!args->GetString(0, &node_path)) { | 230 if (!args->GetString(0, &node_path)) { |
199 return; | 231 return; |
200 } | 232 } |
201 | 233 |
202 EnsureCookiesTreeModelCreated(); | 234 EnsureCookiesTreeModelCreated(); |
203 | 235 |
(...skipping 25 matching lines...) Expand all Loading... | |
229 ListValue args; | 261 ListValue args; |
230 args.Append(parent == cookies_tree_model_->GetRoot() ? | 262 args.Append(parent == cookies_tree_model_->GetRoot() ? |
231 Value::CreateNullValue() : | 263 Value::CreateNullValue() : |
232 Value::CreateStringValue(cookies_tree_model_util::GetTreeNodeId(parent))); | 264 Value::CreateStringValue(cookies_tree_model_util::GetTreeNodeId(parent))); |
233 args.Append(children); | 265 args.Append(children); |
234 | 266 |
235 web_ui()->CallJavascriptFunction("CookiesView.loadChildren", args); | 267 web_ui()->CallJavascriptFunction("CookiesView.loadChildren", args); |
236 } | 268 } |
237 | 269 |
238 } // namespace options2 | 270 } // namespace options2 |
OLD | NEW |