| 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/cookies_tree_model_util.h" | 5 #include "chrome/browser/ui/webui/cookies_tree_model_util.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/i18n/time_formatting.h" | 11 #include "base/i18n/time_formatting.h" |
| 12 #include "base/memory/ptr_util.h" |
| 12 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
| 13 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 14 #include "base/strings/string_split.h" | 15 #include "base/strings/string_split.h" |
| 15 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
| 16 #include "base/values.h" | 17 #include "base/values.h" |
| 17 #include "build/build_config.h" | 18 #include "build/build_config.h" |
| 18 #include "chrome/browser/browsing_data/cookies_tree_model.h" | 19 #include "chrome/browser/browsing_data/cookies_tree_model.h" |
| 19 #include "chrome/grit/generated_resources.h" | 20 #include "chrome/grit/generated_resources.h" |
| 20 #include "content/public/browser/cache_storage_context.h" | 21 #include "content/public/browser/cache_storage_context.h" |
| 21 #include "content/public/browser/indexed_db_context.h" | 22 #include "content/public/browser/indexed_db_context.h" |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 } | 249 } |
| 249 case CookieTreeNode::DetailedInfo::TYPE_SERVICE_WORKER: { | 250 case CookieTreeNode::DetailedInfo::TYPE_SERVICE_WORKER: { |
| 250 dict->SetString(kKeyType, "service_worker"); | 251 dict->SetString(kKeyType, "service_worker"); |
| 251 | 252 |
| 252 const content::ServiceWorkerUsageInfo& service_worker_info = | 253 const content::ServiceWorkerUsageInfo& service_worker_info = |
| 253 *node.GetDetailedInfo().service_worker_info; | 254 *node.GetDetailedInfo().service_worker_info; |
| 254 | 255 |
| 255 dict->SetString(kKeyOrigin, service_worker_info.origin.spec()); | 256 dict->SetString(kKeyOrigin, service_worker_info.origin.spec()); |
| 256 dict->SetString(kKeySize, | 257 dict->SetString(kKeySize, |
| 257 ui::FormatBytes(service_worker_info.total_size_bytes)); | 258 ui::FormatBytes(service_worker_info.total_size_bytes)); |
| 258 base::ListValue* scopes = new base::ListValue; | 259 auto scopes = base::MakeUnique<base::ListValue>(); |
| 259 for (std::vector<GURL>::const_iterator it = | 260 for (std::vector<GURL>::const_iterator it = |
| 260 service_worker_info.scopes.begin(); | 261 service_worker_info.scopes.begin(); |
| 261 it != service_worker_info.scopes.end(); | 262 it != service_worker_info.scopes.end(); |
| 262 ++it) { | 263 ++it) { |
| 263 scopes->AppendString(it->spec()); | 264 scopes->AppendString(it->spec()); |
| 264 } | 265 } |
| 265 dict->Set(kKeyScopes, scopes); | 266 dict->Set(kKeyScopes, std::move(scopes)); |
| 266 break; | 267 break; |
| 267 } | 268 } |
| 268 case CookieTreeNode::DetailedInfo::TYPE_CACHE_STORAGE: { | 269 case CookieTreeNode::DetailedInfo::TYPE_CACHE_STORAGE: { |
| 269 dict->SetString(kKeyType, "cache_storage"); | 270 dict->SetString(kKeyType, "cache_storage"); |
| 270 | 271 |
| 271 const content::CacheStorageUsageInfo& cache_storage_info = | 272 const content::CacheStorageUsageInfo& cache_storage_info = |
| 272 *node.GetDetailedInfo().cache_storage_info; | 273 *node.GetDetailedInfo().cache_storage_info; |
| 273 | 274 |
| 274 dict->SetString(kKeyOrigin, cache_storage_info.origin.spec()); | 275 dict->SetString(kKeyOrigin, cache_storage_info.origin.spec()); |
| 275 dict->SetString(kKeySize, | 276 dict->SetString(kKeySize, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 298 break; | 299 break; |
| 299 } | 300 } |
| 300 default: | 301 default: |
| 301 break; | 302 break; |
| 302 } | 303 } |
| 303 | 304 |
| 304 #if BUILDFLAG(ENABLE_EXTENSIONS) | 305 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 305 const extensions::ExtensionSet* protecting_apps = | 306 const extensions::ExtensionSet* protecting_apps = |
| 306 node.GetModel()->ExtensionsProtectingNode(node); | 307 node.GetModel()->ExtensionsProtectingNode(node); |
| 307 if (protecting_apps && !protecting_apps->is_empty()) { | 308 if (protecting_apps && !protecting_apps->is_empty()) { |
| 308 base::ListValue* app_infos = new base::ListValue; | 309 auto app_infos = base::MakeUnique<base::ListValue>(); |
| 309 for (extensions::ExtensionSet::const_iterator it = protecting_apps->begin(); | 310 for (extensions::ExtensionSet::const_iterator it = protecting_apps->begin(); |
| 310 it != protecting_apps->end(); ++it) { | 311 it != protecting_apps->end(); ++it) { |
| 311 std::unique_ptr<base::DictionaryValue> app_info( | 312 std::unique_ptr<base::DictionaryValue> app_info( |
| 312 new base::DictionaryValue()); | 313 new base::DictionaryValue()); |
| 313 app_info->SetString(kKeyId, (*it)->id()); | 314 app_info->SetString(kKeyId, (*it)->id()); |
| 314 app_info->SetString(kKeyName, (*it)->name()); | 315 app_info->SetString(kKeyName, (*it)->name()); |
| 315 app_infos->Append(std::move(app_info)); | 316 app_infos->Append(std::move(app_info)); |
| 316 } | 317 } |
| 317 dict->Set(kKeyAppsProtectingThis, app_infos); | 318 dict->Set(kKeyAppsProtectingThis, std::move(app_infos)); |
| 318 } | 319 } |
| 319 #endif | 320 #endif |
| 320 | 321 |
| 321 return true; | 322 return true; |
| 322 } | 323 } |
| 323 | 324 |
| 324 void CookiesTreeModelUtil::GetChildNodeDetails(const CookieTreeNode* parent, | 325 void CookiesTreeModelUtil::GetChildNodeDetails(const CookieTreeNode* parent, |
| 325 int start, | 326 int start, |
| 326 int count, | 327 int count, |
| 327 bool include_quota_nodes, | 328 bool include_quota_nodes, |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 // lookup for O(1) space, but it could be further improved to O(1) lookup if | 392 // lookup for O(1) space, but it could be further improved to O(1) lookup if |
| 392 // desired (by trading O(n) space for the time improvement). | 393 // desired (by trading O(n) space for the time improvement). |
| 393 int site_count = root->child_count(); | 394 int site_count = root->child_count(); |
| 394 for (int i = 0; i < site_count; ++i) { | 395 for (int i = 0; i < site_count; ++i) { |
| 395 const CookieTreeNode* child = root->GetChild(i); | 396 const CookieTreeNode* child = root->GetChild(i); |
| 396 if (title == child->GetTitle()) | 397 if (title == child->GetTitle()) |
| 397 return child; | 398 return child; |
| 398 } | 399 } |
| 399 return nullptr; | 400 return nullptr; |
| 400 } | 401 } |
| OLD | NEW |