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