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/string_number_conversions.h" | 11 #include "base/string_number_conversions.h" |
12 #include "base/string_split.h" | 12 #include "base/string_split.h" |
13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
14 #include "base/values.h" | 14 #include "base/values.h" |
15 #include "chrome/browser/cookies_tree_model.h" | 15 #include "chrome/browser/cookies_tree_model.h" |
16 #include "grit/generated_resources.h" | 16 #include "grit/generated_resources.h" |
| 17 #include "net/cookies/canonical_cookie.h" |
17 #include "ui/base/l10n/l10n_util.h" | 18 #include "ui/base/l10n/l10n_util.h" |
18 #include "ui/base/text/bytes_formatting.h" | 19 #include "ui/base/text/bytes_formatting.h" |
19 | 20 |
20 namespace { | 21 namespace { |
21 | 22 |
22 const char kKeyId[] = "id"; | 23 const char kKeyId[] = "id"; |
23 const char kKeyTitle[] = "title"; | 24 const char kKeyTitle[] = "title"; |
24 const char kKeyIcon[] = "icon"; | 25 const char kKeyIcon[] = "icon"; |
25 const char kKeyType[] = "type"; | 26 const char kKeyType[] = "type"; |
26 const char kKeyHasChildren[] = "hasChildren"; | 27 const char kKeyHasChildren[] = "hasChildren"; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 dict->SetString(kKeyAppId, node.GetDetailedInfo().app_id); | 101 dict->SetString(kKeyAppId, node.GetDetailedInfo().app_id); |
101 #if defined(OS_MACOSX) | 102 #if defined(OS_MACOSX) |
102 dict->SetString(kKeyIcon, "chrome://theme/IDR_BOOKMARK_BAR_FOLDER"); | 103 dict->SetString(kKeyIcon, "chrome://theme/IDR_BOOKMARK_BAR_FOLDER"); |
103 #endif | 104 #endif |
104 break; | 105 break; |
105 } | 106 } |
106 case CookieTreeNode::DetailedInfo::TYPE_COOKIE: { | 107 case CookieTreeNode::DetailedInfo::TYPE_COOKIE: { |
107 dict->SetString(kKeyType, "cookie"); | 108 dict->SetString(kKeyType, "cookie"); |
108 dict->SetString(kKeyIcon, "chrome://theme/IDR_COOKIE_ICON"); | 109 dict->SetString(kKeyIcon, "chrome://theme/IDR_COOKIE_ICON"); |
109 | 110 |
110 const net::CookieMonster::CanonicalCookie& cookie = | 111 const net::CanonicalCookie& cookie = *node.GetDetailedInfo().cookie; |
111 *node.GetDetailedInfo().cookie; | |
112 | 112 |
113 dict->SetString(kKeyName, cookie.Name()); | 113 dict->SetString(kKeyName, cookie.Name()); |
114 dict->SetString(kKeyContent, cookie.Value()); | 114 dict->SetString(kKeyContent, cookie.Value()); |
115 dict->SetString(kKeyDomain, cookie.Domain()); | 115 dict->SetString(kKeyDomain, cookie.Domain()); |
116 dict->SetString(kKeyPath, cookie.Path()); | 116 dict->SetString(kKeyPath, cookie.Path()); |
117 dict->SetString(kKeySendFor, cookie.IsSecure() ? | 117 dict->SetString(kKeySendFor, cookie.IsSecure() ? |
118 l10n_util::GetStringUTF8(IDS_COOKIES_COOKIE_SENDFOR_SECURE) : | 118 l10n_util::GetStringUTF8(IDS_COOKIES_COOKIE_SENDFOR_SECURE) : |
119 l10n_util::GetStringUTF8(IDS_COOKIES_COOKIE_SENDFOR_ANY)); | 119 l10n_util::GetStringUTF8(IDS_COOKIES_COOKIE_SENDFOR_ANY)); |
120 std::string accessible = cookie.IsHttpOnly() ? | 120 std::string accessible = cookie.IsHttpOnly() ? |
121 l10n_util::GetStringUTF8(IDS_COOKIES_COOKIE_ACCESSIBLE_TO_SCRIPT_NO) : | 121 l10n_util::GetStringUTF8(IDS_COOKIES_COOKIE_ACCESSIBLE_TO_SCRIPT_NO) : |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 child = id_map_.Lookup(node_id); | 309 child = id_map_.Lookup(node_id); |
310 child_index = parent->GetIndexOf(child); | 310 child_index = parent->GetIndexOf(child); |
311 if (child_index == -1) | 311 if (child_index == -1) |
312 break; | 312 break; |
313 | 313 |
314 parent = child; | 314 parent = child; |
315 } | 315 } |
316 | 316 |
317 return child_index >= 0 ? child : NULL; | 317 return child_index >= 0 ? child : NULL; |
318 } | 318 } |
OLD | NEW |