| 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/options/cookies_view_handler.h" | 5 #include "chrome/browser/ui/webui/options/cookies_view_handler.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| 11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "chrome/common/extensions/extension.h" | 13 #include "chrome/common/extensions/extension.h" |
| 14 #include "chrome/common/extensions/extension_set.h" | 14 #include "chrome/common/extensions/extension_set.h" |
| 15 #include "chrome/browser/browsing_data/browsing_data_appcache_helper.h" | 15 #include "chrome/browser/browsing_data/browsing_data_appcache_helper.h" |
| 16 #include "chrome/browser/browsing_data/browsing_data_cookie_helper.h" | 16 #include "chrome/browser/browsing_data/browsing_data_cookie_helper.h" |
| 17 #include "chrome/browser/browsing_data/browsing_data_database_helper.h" | 17 #include "chrome/browser/browsing_data/browsing_data_database_helper.h" |
| 18 #include "chrome/browser/browsing_data/browsing_data_file_system_helper.h" | 18 #include "chrome/browser/browsing_data/browsing_data_file_system_helper.h" |
| 19 #include "chrome/browser/browsing_data/browsing_data_flash_lso_helper.h" | 19 #include "chrome/browser/browsing_data/browsing_data_flash_lso_helper.h" |
| 20 #include "chrome/browser/browsing_data/browsing_data_indexed_db_helper.h" | 20 #include "chrome/browser/browsing_data/browsing_data_indexed_db_helper.h" |
| 21 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" | 21 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" |
| 22 #include "chrome/browser/browsing_data/browsing_data_quota_helper.h" | 22 #include "chrome/browser/browsing_data/browsing_data_quota_helper.h" |
| 23 #include "chrome/browser/browsing_data/browsing_data_server_bound_cert_helper.h" | 23 #include "chrome/browser/browsing_data/browsing_data_server_bound_cert_helper.h" |
| 24 #include "chrome/browser/extensions/extension_service.h" | 24 #include "chrome/browser/extensions/extension_service.h" |
| 25 #include "chrome/browser/extensions/extension_system.h" |
| 25 #include "chrome/browser/profiles/profile.h" | 26 #include "chrome/browser/profiles/profile.h" |
| 26 #include "chrome/browser/ui/webui/cookies_tree_model_util.h" | 27 #include "chrome/browser/ui/webui/cookies_tree_model_util.h" |
| 27 #include "content/public/browser/browser_context.h" | 28 #include "content/public/browser/browser_context.h" |
| 29 #include "content/public/browser/render_process_host.h" |
| 30 #include "content/public/browser/site_instance.h" |
| 28 #include "content/public/browser/storage_partition.h" | 31 #include "content/public/browser/storage_partition.h" |
| 29 #include "content/public/browser/web_ui.h" | 32 #include "content/public/browser/web_ui.h" |
| 30 #include "grit/generated_resources.h" | 33 #include "grit/generated_resources.h" |
| 31 #include "ui/base/l10n/l10n_util.h" | 34 #include "ui/base/l10n/l10n_util.h" |
| 32 | 35 |
| 33 namespace fileapi { | 36 namespace fileapi { |
| 34 class FileSystemContext; | 37 class FileSystemContext; |
| 35 } | 38 } |
| 36 | 39 |
| 37 namespace options { | 40 namespace options { |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 new CookiesTreeModel(apps_map, | 219 new CookiesTreeModel(apps_map, |
| 217 profile->GetExtensionSpecialStoragePolicy(), | 220 profile->GetExtensionSpecialStoragePolicy(), |
| 218 false)); | 221 false)); |
| 219 cookies_tree_model_->AddCookiesTreeObserver(this); | 222 cookies_tree_model_->AddCookiesTreeObserver(this); |
| 220 } | 223 } |
| 221 | 224 |
| 222 if (app_context_ && !app_cookies_tree_model_.get()) { | 225 if (app_context_ && !app_cookies_tree_model_.get()) { |
| 223 Profile* profile = Profile::FromWebUI(web_ui()); | 226 Profile* profile = Profile::FromWebUI(web_ui()); |
| 224 ContainerMap apps_map; | 227 ContainerMap apps_map; |
| 225 const ExtensionService* service = profile->GetExtensionService(); | 228 const ExtensionService* service = profile->GetExtensionService(); |
| 226 if (service) { | 229 if (!service) |
| 227 const ExtensionSet* extensions = service->extensions(); | 230 return; |
| 228 for (ExtensionSet::const_iterator it = extensions->begin(); | 231 |
| 229 it != extensions->end(); ++it) { | 232 ExtensionProcessManager* process_manager = |
| 230 if ((*it)->is_storage_isolated()) { | 233 extensions::ExtensionSystem::Get(profile)->process_manager(); |
| 231 net::URLRequestContextGetter* context_getter = | 234 if (!process_manager) |
| 232 profile->GetRequestContextForStoragePartition((*it)->id()); | 235 return; |
| 233 // TODO(nasko): When new types of storage are isolated, add the | 236 |
| 234 // appropriate browsing data helper objects to the constructor. | 237 const ExtensionSet* extensions = service->extensions(); |
| 235 // For now, just cookies are isolated, so other parameters are NULL. | 238 for (ExtensionSet::const_iterator it = extensions->begin(); |
| 236 apps_map[(*it)->id()] = new LocalDataContainer( | 239 it != extensions->end(); ++it) { |
| 237 (*it)->name(), (*it)->id(), | 240 if ((*it)->is_storage_isolated()) { |
| 238 new BrowsingDataCookieHelper(context_getter), | 241 content::StoragePartition* storage_partition = |
| 239 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); | 242 content::BrowserContext::GetStoragePartitionForSite(profile, |
| 240 } | 243 (*it)->url()); |
| 244 net::URLRequestContextGetter* context_getter = |
| 245 storage_partition->GetURLRequestContext(); |
| 246 // TODO(nasko): When new types of storage are isolated, add the |
| 247 // appropriate browsing data helper objects to the constructor. |
| 248 // For now, just cookies are isolated, so other parameters are NULL. |
| 249 apps_map[(*it)->id()] = new LocalDataContainer( |
| 250 (*it)->name(), (*it)->id(), |
| 251 new BrowsingDataCookieHelper(context_getter), |
| 252 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); |
| 241 } | 253 } |
| 242 app_cookies_tree_model_.reset( | |
| 243 new CookiesTreeModel(apps_map, | |
| 244 profile->GetExtensionSpecialStoragePolicy(), | |
| 245 false)); | |
| 246 app_cookies_tree_model_->AddCookiesTreeObserver(this); | |
| 247 } | 254 } |
| 255 app_cookies_tree_model_.reset( |
| 256 new CookiesTreeModel(apps_map, |
| 257 profile->GetExtensionSpecialStoragePolicy(), |
| 258 false)); |
| 259 app_cookies_tree_model_->AddCookiesTreeObserver(this); |
| 248 } | 260 } |
| 249 } | 261 } |
| 250 | 262 |
| 251 void CookiesViewHandler::UpdateSearchResults(const ListValue* args) { | 263 void CookiesViewHandler::UpdateSearchResults(const ListValue* args) { |
| 252 string16 query; | 264 string16 query; |
| 253 if (!args->GetString(0, &query)) | 265 if (!args->GetString(0, &query)) |
| 254 return; | 266 return; |
| 255 | 267 |
| 256 EnsureCookiesTreeModelCreated(); | 268 EnsureCookiesTreeModelCreated(); |
| 257 | 269 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 std::string CookiesViewHandler::GetCallback( | 339 std::string CookiesViewHandler::GetCallback( |
| 328 std::string method, CookiesTreeModel* model) { | 340 std::string method, CookiesTreeModel* model) { |
| 329 std::string callback("CookiesView"); | 341 std::string callback("CookiesView"); |
| 330 | 342 |
| 331 if (model == app_cookies_tree_model_) | 343 if (model == app_cookies_tree_model_) |
| 332 callback.append("App"); | 344 callback.append("App"); |
| 333 return callback.append(".").append(method); | 345 return callback.append(".").append(method); |
| 334 } | 346 } |
| 335 | 347 |
| 336 } // namespace options | 348 } // namespace options |
| OLD | NEW |