| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/i18n/time_formatting.h" | 9 #include "base/i18n/time_formatting.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
| 12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 13 #include "base/strings/string_split.h" | 13 #include "base/strings/string_split.h" |
| 14 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
| 15 #include "base/values.h" | 15 #include "base/values.h" |
| 16 #include "chrome/browser/browsing_data/cookies_tree_model.h" | 16 #include "chrome/browser/browsing_data/cookies_tree_model.h" |
| 17 #include "content/public/browser/indexed_db_context.h" | 17 #include "content/public/browser/indexed_db_context.h" |
| 18 #include "extensions/common/extension_set.h" | |
| 19 #include "grit/generated_resources.h" | 18 #include "grit/generated_resources.h" |
| 20 #include "net/cookies/canonical_cookie.h" | 19 #include "net/cookies/canonical_cookie.h" |
| 21 #include "net/ssl/ssl_client_cert_type.h" | 20 #include "net/ssl/ssl_client_cert_type.h" |
| 22 #include "ui/base/l10n/l10n_util.h" | 21 #include "ui/base/l10n/l10n_util.h" |
| 23 #include "ui/base/text/bytes_formatting.h" | 22 #include "ui/base/text/bytes_formatting.h" |
| 24 #include "webkit/common/fileapi/file_system_types.h" | 23 #include "webkit/common/fileapi/file_system_types.h" |
| 25 | 24 |
| 25 #if defined(ENABLE_EXTENSIONS) |
| 26 #include "extensions/common/extension_set.h" |
| 27 #endif |
| 28 |
| 26 namespace { | 29 namespace { |
| 27 | 30 |
| 28 const char kKeyId[] = "id"; | 31 const char kKeyId[] = "id"; |
| 29 const char kKeyTitle[] = "title"; | 32 const char kKeyTitle[] = "title"; |
| 30 const char kKeyIcon[] = "icon"; | 33 const char kKeyIcon[] = "icon"; |
| 31 const char kKeyType[] = "type"; | 34 const char kKeyType[] = "type"; |
| 32 const char kKeyHasChildren[] = "hasChildren"; | 35 const char kKeyHasChildren[] = "hasChildren"; |
| 33 | 36 |
| 37 #if defined(ENABLE_EXTENSIONS) |
| 34 const char kKeyAppsProtectingThis[] = "appsProtectingThis"; | 38 const char kKeyAppsProtectingThis[] = "appsProtectingThis"; |
| 39 #endif |
| 35 const char kKeyName[] = "name"; | 40 const char kKeyName[] = "name"; |
| 36 const char kKeyContent[] = "content"; | 41 const char kKeyContent[] = "content"; |
| 37 const char kKeyDomain[] = "domain"; | 42 const char kKeyDomain[] = "domain"; |
| 38 const char kKeyPath[] = "path"; | 43 const char kKeyPath[] = "path"; |
| 39 const char kKeySendFor[] = "sendfor"; | 44 const char kKeySendFor[] = "sendfor"; |
| 40 const char kKeyAccessibleToScript[] = "accessibleToScript"; | 45 const char kKeyAccessibleToScript[] = "accessibleToScript"; |
| 41 const char kKeyDesc[] = "desc"; | 46 const char kKeyDesc[] = "desc"; |
| 42 const char kKeySize[] = "size"; | 47 const char kKeySize[] = "size"; |
| 43 const char kKeyOrigin[] = "origin"; | 48 const char kKeyOrigin[] = "origin"; |
| 44 const char kKeyManifest[] = "manifest"; | 49 const char kKeyManifest[] = "manifest"; |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 | 267 |
| 263 dict->SetString(kKeyDomain, node.GetDetailedInfo().flash_lso_domain); | 268 dict->SetString(kKeyDomain, node.GetDetailedInfo().flash_lso_domain); |
| 264 } | 269 } |
| 265 default: | 270 default: |
| 266 #if defined(OS_MACOSX) | 271 #if defined(OS_MACOSX) |
| 267 dict->SetString(kKeyIcon, "chrome://theme/IDR_BOOKMARK_BAR_FOLDER"); | 272 dict->SetString(kKeyIcon, "chrome://theme/IDR_BOOKMARK_BAR_FOLDER"); |
| 268 #endif | 273 #endif |
| 269 break; | 274 break; |
| 270 } | 275 } |
| 271 | 276 |
| 277 #if defined(ENABLE_EXTENSIONS) |
| 272 const extensions::ExtensionSet* protecting_apps = | 278 const extensions::ExtensionSet* protecting_apps = |
| 273 node.GetModel()->ExtensionsProtectingNode(node); | 279 node.GetModel()->ExtensionsProtectingNode(node); |
| 274 if (protecting_apps && !protecting_apps->is_empty()) { | 280 if (protecting_apps && !protecting_apps->is_empty()) { |
| 275 base::ListValue* app_infos = new base::ListValue; | 281 base::ListValue* app_infos = new base::ListValue; |
| 276 for (extensions::ExtensionSet::const_iterator it = protecting_apps->begin(); | 282 for (extensions::ExtensionSet::const_iterator it = protecting_apps->begin(); |
| 277 it != protecting_apps->end(); ++it) { | 283 it != protecting_apps->end(); ++it) { |
| 278 base::DictionaryValue* app_info = new base::DictionaryValue(); | 284 base::DictionaryValue* app_info = new base::DictionaryValue(); |
| 279 app_info->SetString(kKeyId, (*it)->id()); | 285 app_info->SetString(kKeyId, (*it)->id()); |
| 280 app_info->SetString(kKeyName, (*it)->name()); | 286 app_info->SetString(kKeyName, (*it)->name()); |
| 281 app_infos->Append(app_info); | 287 app_infos->Append(app_info); |
| 282 } | 288 } |
| 283 dict->Set(kKeyAppsProtectingThis, app_infos); | 289 dict->Set(kKeyAppsProtectingThis, app_infos); |
| 284 } | 290 } |
| 291 #endif |
| 285 | 292 |
| 286 return true; | 293 return true; |
| 287 } | 294 } |
| 288 | 295 |
| 289 void CookiesTreeModelUtil::GetChildNodeList(const CookieTreeNode* parent, | 296 void CookiesTreeModelUtil::GetChildNodeList(const CookieTreeNode* parent, |
| 290 int start, | 297 int start, |
| 291 int count, | 298 int count, |
| 292 base::ListValue* nodes) { | 299 base::ListValue* nodes) { |
| 293 for (int i = 0; i < count; ++i) { | 300 for (int i = 0; i < count; ++i) { |
| 294 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue); | 301 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 317 child = id_map_.Lookup(node_id); | 324 child = id_map_.Lookup(node_id); |
| 318 child_index = parent->GetIndexOf(child); | 325 child_index = parent->GetIndexOf(child); |
| 319 if (child_index == -1) | 326 if (child_index == -1) |
| 320 break; | 327 break; |
| 321 | 328 |
| 322 parent = child; | 329 parent = child; |
| 323 } | 330 } |
| 324 | 331 |
| 325 return child_index >= 0 ? child : NULL; | 332 return child_index >= 0 ? child : NULL; |
| 326 } | 333 } |
| OLD | NEW |