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 |
34 const char kKeyAppsProtectingThis[] = "appsProtectingThis"; | 37 const char kKeyAppsProtectingThis[] = "appsProtectingThis"; |
35 const char kKeyName[] = "name"; | 38 const char kKeyName[] = "name"; |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 | 265 |
263 dict->SetString(kKeyDomain, node.GetDetailedInfo().flash_lso_domain); | 266 dict->SetString(kKeyDomain, node.GetDetailedInfo().flash_lso_domain); |
264 } | 267 } |
265 default: | 268 default: |
266 #if defined(OS_MACOSX) | 269 #if defined(OS_MACOSX) |
267 dict->SetString(kKeyIcon, "chrome://theme/IDR_BOOKMARK_BAR_FOLDER"); | 270 dict->SetString(kKeyIcon, "chrome://theme/IDR_BOOKMARK_BAR_FOLDER"); |
268 #endif | 271 #endif |
269 break; | 272 break; |
270 } | 273 } |
271 | 274 |
| 275 #if defined(ENABLE_EXTENSIONS) |
272 const extensions::ExtensionSet* protecting_apps = | 276 const extensions::ExtensionSet* protecting_apps = |
273 node.GetModel()->ExtensionsProtectingNode(node); | 277 node.GetModel()->ExtensionsProtectingNode(node); |
274 if (protecting_apps && !protecting_apps->is_empty()) { | 278 if (protecting_apps && !protecting_apps->is_empty()) { |
275 base::ListValue* app_infos = new base::ListValue; | 279 base::ListValue* app_infos = new base::ListValue; |
276 for (extensions::ExtensionSet::const_iterator it = protecting_apps->begin(); | 280 for (extensions::ExtensionSet::const_iterator it = protecting_apps->begin(); |
277 it != protecting_apps->end(); ++it) { | 281 it != protecting_apps->end(); ++it) { |
278 base::DictionaryValue* app_info = new base::DictionaryValue(); | 282 base::DictionaryValue* app_info = new base::DictionaryValue(); |
279 app_info->SetString(kKeyId, (*it)->id()); | 283 app_info->SetString(kKeyId, (*it)->id()); |
280 app_info->SetString(kKeyName, (*it)->name()); | 284 app_info->SetString(kKeyName, (*it)->name()); |
281 app_infos->Append(app_info); | 285 app_infos->Append(app_info); |
282 } | 286 } |
283 dict->Set(kKeyAppsProtectingThis, app_infos); | 287 dict->Set(kKeyAppsProtectingThis, app_infos); |
284 } | 288 } |
| 289 #endif |
285 | 290 |
286 return true; | 291 return true; |
287 } | 292 } |
288 | 293 |
289 void CookiesTreeModelUtil::GetChildNodeList(const CookieTreeNode* parent, | 294 void CookiesTreeModelUtil::GetChildNodeList(const CookieTreeNode* parent, |
290 int start, | 295 int start, |
291 int count, | 296 int count, |
292 base::ListValue* nodes) { | 297 base::ListValue* nodes) { |
293 for (int i = 0; i < count; ++i) { | 298 for (int i = 0; i < count; ++i) { |
294 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue); | 299 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue); |
(...skipping 22 matching lines...) Expand all Loading... |
317 child = id_map_.Lookup(node_id); | 322 child = id_map_.Lookup(node_id); |
318 child_index = parent->GetIndexOf(child); | 323 child_index = parent->GetIndexOf(child); |
319 if (child_index == -1) | 324 if (child_index == -1) |
320 break; | 325 break; |
321 | 326 |
322 parent = child; | 327 parent = child; |
323 } | 328 } |
324 | 329 |
325 return child_index >= 0 ? child : NULL; | 330 return child_index >= 0 ? child : NULL; |
326 } | 331 } |
OLD | NEW |