| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/dom_ui/options/cookies_view_handler.h" | 5 #include "chrome/browser/dom_ui/options/cookies_view_handler.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "base/i18n/time_formatting.h" | 8 #include "base/i18n/time_formatting.h" |
| 9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
| 10 #include "base/string_split.h" | 10 #include "base/string_split.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 void GetCookieTreeNodeDictionary(const CookieTreeNode& node, | 62 void GetCookieTreeNodeDictionary(const CookieTreeNode& node, |
| 63 DictionaryValue* dict) { | 63 DictionaryValue* dict) { |
| 64 // Use node's address as an id for DOMUI to look it up. | 64 // Use node's address as an id for DOMUI to look it up. |
| 65 dict->SetString(kKeyId, PointerToHexString(&node)); | 65 dict->SetString(kKeyId, PointerToHexString(&node)); |
| 66 dict->SetString(kKeyTitle, node.GetTitle()); | 66 dict->SetString(kKeyTitle, node.GetTitle()); |
| 67 dict->SetBoolean(kKeyHasChildren, !!node.GetChildCount()); | 67 dict->SetBoolean(kKeyHasChildren, !!node.GetChildCount()); |
| 68 | 68 |
| 69 switch (node.GetDetailedInfo().node_type) { | 69 switch (node.GetDetailedInfo().node_type) { |
| 70 case CookieTreeNode::DetailedInfo::TYPE_ORIGIN: { | 70 case CookieTreeNode::DetailedInfo::TYPE_ORIGIN: { |
| 71 dict->SetString(kKeyType, "origin"); | 71 dict->SetString(kKeyType, "origin"); |
| 72 #if defined(OS_MAC) |
| 73 dict->SetString(kKeyIcon, "chrome://theme/IDR_BOOKMARK_BAR_FOLDER"); |
| 74 #endif |
| 72 break; | 75 break; |
| 73 } | 76 } |
| 74 case CookieTreeNode::DetailedInfo::TYPE_COOKIE: { | 77 case CookieTreeNode::DetailedInfo::TYPE_COOKIE: { |
| 75 dict->SetString(kKeyType, "cookie"); | 78 dict->SetString(kKeyType, "cookie"); |
| 76 dict->SetString(kKeyIcon, "chrome://theme/IDR_COOKIE_ICON"); | 79 dict->SetString(kKeyIcon, "chrome://theme/IDR_COOKIE_ICON"); |
| 77 | 80 |
| 78 const net::CookieMonster::CanonicalCookie& cookie = | 81 const net::CookieMonster::CanonicalCookie& cookie = |
| 79 *node.GetDetailedInfo().cookie; | 82 *node.GetDetailedInfo().cookie; |
| 80 | 83 |
| 81 dict->SetString(kKeyName, cookie.Name()); | 84 dict->SetString(kKeyName, cookie.Name()); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 dict->SetString(kKeySize, | 164 dict->SetString(kKeySize, |
| 162 FormatBytes(indexed_db_info.size, | 165 FormatBytes(indexed_db_info.size, |
| 163 GetByteDisplayUnits(indexed_db_info.size), | 166 GetByteDisplayUnits(indexed_db_info.size), |
| 164 true)); | 167 true)); |
| 165 dict->SetString(kKeyModified, UTF16ToUTF8( | 168 dict->SetString(kKeyModified, UTF16ToUTF8( |
| 166 base::TimeFormatFriendlyDateAndTime(indexed_db_info.last_modified))); | 169 base::TimeFormatFriendlyDateAndTime(indexed_db_info.last_modified))); |
| 167 | 170 |
| 168 break; | 171 break; |
| 169 } | 172 } |
| 170 default: | 173 default: |
| 174 #if defined(OS_MAC) |
| 175 dict->SetString(kKeyIcon, "chrome://theme/IDR_BOOKMARK_BAR_FOLDER"); |
| 176 #endif |
| 171 break; | 177 break; |
| 172 } | 178 } |
| 173 } | 179 } |
| 174 | 180 |
| 175 // Append the children nodes of |parent| in specified range to |nodes| list. | 181 // Append the children nodes of |parent| in specified range to |nodes| list. |
| 176 void GetChildNodeList(CookieTreeNode* parent, int start, int count, | 182 void GetChildNodeList(CookieTreeNode* parent, int start, int count, |
| 177 ListValue* nodes) { | 183 ListValue* nodes) { |
| 178 for (int i = 0; i < count; ++i) { | 184 for (int i = 0; i < count; ++i) { |
| 179 DictionaryValue* dict = new DictionaryValue; | 185 DictionaryValue* dict = new DictionaryValue; |
| 180 CookieTreeNode* child = parent->GetChild(start + i); | 186 CookieTreeNode* child = parent->GetChild(start + i); |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 GetChildNodeList(parent, 0, parent->GetChildCount(), children); | 397 GetChildNodeList(parent, 0, parent->GetChildCount(), children); |
| 392 | 398 |
| 393 ListValue args; | 399 ListValue args; |
| 394 args.Append(parent == cookies_tree_model_->GetRoot() ? | 400 args.Append(parent == cookies_tree_model_->GetRoot() ? |
| 395 Value::CreateNullValue() : | 401 Value::CreateNullValue() : |
| 396 Value::CreateStringValue(PointerToHexString(parent))); | 402 Value::CreateStringValue(PointerToHexString(parent))); |
| 397 args.Append(children); | 403 args.Append(children); |
| 398 | 404 |
| 399 dom_ui_->CallJavascriptFunction(L"CookiesView.loadChildren", args); | 405 dom_ui_->CallJavascriptFunction(L"CookiesView.loadChildren", args); |
| 400 } | 406 } |
| OLD | NEW |