Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(644)

Side by Side Diff: chrome/browser/ui/webui/cookies_tree_model_util.cc

Issue 7189076: Localize strings, speeds. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: copyright dates Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/i18n/time_formatting.h" 7 #include "base/i18n/time_formatting.h"
8 #include "base/string_number_conversions.h" 8 #include "base/string_number_conversions.h"
9 #include "base/string_split.h" 9 #include "base/string_split.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "chrome/browser/cookies_tree_model.h" 12 #include "chrome/browser/cookies_tree_model.h"
13 #include "grit/generated_resources.h" 13 #include "grit/generated_resources.h"
14 #include "ui/base/l10n/l10n_util.h" 14 #include "ui/base/l10n/l10n_util.h"
15 #include "ui/base/text/bytes_formatting.h"
15 16
16 namespace { 17 namespace {
17 18
18 static const char kKeyId[] = "id"; 19 static const char kKeyId[] = "id";
19 static const char kKeyTitle[] = "title"; 20 static const char kKeyTitle[] = "title";
20 static const char kKeyIcon[] = "icon"; 21 static const char kKeyIcon[] = "icon";
21 static const char kKeyType[] = "type"; 22 static const char kKeyType[] = "type";
22 static const char kKeyHasChildren[] = "hasChildren"; 23 static const char kKeyHasChildren[] = "hasChildren";
23 24
24 static const char kKeyName[] = "name"; 25 static const char kKeyName[] = "name";
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 dict->SetString(kKeyType, "database"); 110 dict->SetString(kKeyType, "database");
110 dict->SetString(kKeyIcon, "chrome://theme/IDR_COOKIE_STORAGE_ICON"); 111 dict->SetString(kKeyIcon, "chrome://theme/IDR_COOKIE_STORAGE_ICON");
111 112
112 const BrowsingDataDatabaseHelper::DatabaseInfo& database_info = 113 const BrowsingDataDatabaseHelper::DatabaseInfo& database_info =
113 *node.GetDetailedInfo().database_info; 114 *node.GetDetailedInfo().database_info;
114 115
115 dict->SetString(kKeyName, database_info.database_name.empty() ? 116 dict->SetString(kKeyName, database_info.database_name.empty() ?
116 l10n_util::GetStringUTF8(IDS_COOKIES_WEB_DATABASE_UNNAMED_NAME) : 117 l10n_util::GetStringUTF8(IDS_COOKIES_WEB_DATABASE_UNNAMED_NAME) :
117 database_info.database_name); 118 database_info.database_name);
118 dict->SetString(kKeyDesc, database_info.description); 119 dict->SetString(kKeyDesc, database_info.description);
119 dict->SetString(kKeySize, 120 dict->SetString(kKeySize, ui::FormatBytes(database_info.size));
120 FormatBytes(database_info.size,
121 GetByteDisplayUnits(database_info.size),
122 true));
123 dict->SetString(kKeyModified, UTF16ToUTF8( 121 dict->SetString(kKeyModified, UTF16ToUTF8(
124 base::TimeFormatFriendlyDateAndTime(database_info.last_modified))); 122 base::TimeFormatFriendlyDateAndTime(database_info.last_modified)));
125 123
126 break; 124 break;
127 } 125 }
128 case CookieTreeNode::DetailedInfo::TYPE_LOCAL_STORAGE: { 126 case CookieTreeNode::DetailedInfo::TYPE_LOCAL_STORAGE: {
129 dict->SetString(kKeyType, "local_storage"); 127 dict->SetString(kKeyType, "local_storage");
130 dict->SetString(kKeyIcon, "chrome://theme/IDR_COOKIE_STORAGE_ICON"); 128 dict->SetString(kKeyIcon, "chrome://theme/IDR_COOKIE_STORAGE_ICON");
131 129
132 const BrowsingDataLocalStorageHelper::LocalStorageInfo& 130 const BrowsingDataLocalStorageHelper::LocalStorageInfo&
133 local_storage_info = *node.GetDetailedInfo().local_storage_info; 131 local_storage_info = *node.GetDetailedInfo().local_storage_info;
134 132
135 dict->SetString(kKeyOrigin, local_storage_info.origin); 133 dict->SetString(kKeyOrigin, local_storage_info.origin);
136 dict->SetString(kKeySize, 134 dict->SetString(kKeySize, ui::FormatBytes(local_storage_info.size));
137 FormatBytes(local_storage_info.size,
138 GetByteDisplayUnits(local_storage_info.size),
139 true));
140 dict->SetString(kKeyModified, UTF16ToUTF8( 135 dict->SetString(kKeyModified, UTF16ToUTF8(
141 base::TimeFormatFriendlyDateAndTime( 136 base::TimeFormatFriendlyDateAndTime(
142 local_storage_info.last_modified))); 137 local_storage_info.last_modified)));
143 138
144 break; 139 break;
145 } 140 }
146 case CookieTreeNode::DetailedInfo::TYPE_APPCACHE: { 141 case CookieTreeNode::DetailedInfo::TYPE_APPCACHE: {
147 dict->SetString(kKeyType, "app_cache"); 142 dict->SetString(kKeyType, "app_cache");
148 dict->SetString(kKeyIcon, "chrome://theme/IDR_COOKIE_STORAGE_ICON"); 143 dict->SetString(kKeyIcon, "chrome://theme/IDR_COOKIE_STORAGE_ICON");
149 144
150 const appcache::AppCacheInfo& appcache_info = 145 const appcache::AppCacheInfo& appcache_info =
151 *node.GetDetailedInfo().appcache_info; 146 *node.GetDetailedInfo().appcache_info;
152 147
153 dict->SetString(kKeyManifest, appcache_info.manifest_url.spec()); 148 dict->SetString(kKeyManifest, appcache_info.manifest_url.spec());
154 dict->SetString(kKeySize, 149 dict->SetString(kKeySize, ui::FormatBytes(appcache_info.size));
155 FormatBytes(appcache_info.size,
156 GetByteDisplayUnits(appcache_info.size),
157 true));
158 dict->SetString(kKeyCreated, UTF16ToUTF8( 150 dict->SetString(kKeyCreated, UTF16ToUTF8(
159 base::TimeFormatFriendlyDateAndTime(appcache_info.creation_time))); 151 base::TimeFormatFriendlyDateAndTime(appcache_info.creation_time)));
160 dict->SetString(kKeyAccessed, UTF16ToUTF8( 152 dict->SetString(kKeyAccessed, UTF16ToUTF8(
161 base::TimeFormatFriendlyDateAndTime(appcache_info.last_access_time))); 153 base::TimeFormatFriendlyDateAndTime(appcache_info.last_access_time)));
162 154
163 break; 155 break;
164 } 156 }
165 case CookieTreeNode::DetailedInfo::TYPE_INDEXED_DB: { 157 case CookieTreeNode::DetailedInfo::TYPE_INDEXED_DB: {
166 dict->SetString(kKeyType, "indexed_db"); 158 dict->SetString(kKeyType, "indexed_db");
167 dict->SetString(kKeyIcon, "chrome://theme/IDR_COOKIE_STORAGE_ICON"); 159 dict->SetString(kKeyIcon, "chrome://theme/IDR_COOKIE_STORAGE_ICON");
168 160
169 const BrowsingDataIndexedDBHelper::IndexedDBInfo& indexed_db_info = 161 const BrowsingDataIndexedDBHelper::IndexedDBInfo& indexed_db_info =
170 *node.GetDetailedInfo().indexed_db_info; 162 *node.GetDetailedInfo().indexed_db_info;
171 163
172 dict->SetString(kKeyOrigin, indexed_db_info.origin); 164 dict->SetString(kKeyOrigin, indexed_db_info.origin);
173 dict->SetString(kKeySize, 165 dict->SetString(kKeySize, ui::FormatBytes(indexed_db_info.size));
174 FormatBytes(indexed_db_info.size,
175 GetByteDisplayUnits(indexed_db_info.size),
176 true));
177 dict->SetString(kKeyModified, UTF16ToUTF8( 166 dict->SetString(kKeyModified, UTF16ToUTF8(
178 base::TimeFormatFriendlyDateAndTime(indexed_db_info.last_modified))); 167 base::TimeFormatFriendlyDateAndTime(indexed_db_info.last_modified)));
179 168
180 break; 169 break;
181 } 170 }
182 case CookieTreeNode::DetailedInfo::TYPE_FILE_SYSTEM: { 171 case CookieTreeNode::DetailedInfo::TYPE_FILE_SYSTEM: {
183 dict->SetString(kKeyType, "file_system"); 172 dict->SetString(kKeyType, "file_system");
184 dict->SetString(kKeyIcon, "chrome://theme/IDR_COOKIE_STORAGE_ICON"); 173 dict->SetString(kKeyIcon, "chrome://theme/IDR_COOKIE_STORAGE_ICON");
185 174
186 const BrowsingDataFileSystemHelper::FileSystemInfo& file_system_info = 175 const BrowsingDataFileSystemHelper::FileSystemInfo& file_system_info =
187 *node.GetDetailedInfo().file_system_info; 176 *node.GetDetailedInfo().file_system_info;
188 177
189 dict->SetString(kKeyOrigin, file_system_info.origin.spec()); 178 dict->SetString(kKeyOrigin, file_system_info.origin.spec());
190 dict->SetString(kKeyPersistent, 179 dict->SetString(kKeyPersistent,
191 file_system_info.has_persistent ? 180 file_system_info.has_persistent ?
192 UTF16ToUTF8(FormatBytes( 181 UTF16ToUTF8(ui::FormatBytes(
193 file_system_info.usage_persistent, 182 file_system_info.usage_persistent)) :
194 GetByteDisplayUnits(
195 file_system_info.usage_persistent),
196 true)) :
197 l10n_util::GetStringUTF8( 183 l10n_util::GetStringUTF8(
198 IDS_COOKIES_FILE_SYSTEM_USAGE_NONE)); 184 IDS_COOKIES_FILE_SYSTEM_USAGE_NONE));
199 dict->SetString(kKeyTemporary, 185 dict->SetString(kKeyTemporary,
200 file_system_info.has_temporary ? 186 file_system_info.has_temporary ?
201 UTF16ToUTF8(FormatBytes( 187 UTF16ToUTF8(ui::FormatBytes(
202 file_system_info.usage_temporary, 188 file_system_info.usage_temporary)) :
203 GetByteDisplayUnits(
204 file_system_info.usage_temporary),
205 true)) :
206 l10n_util::GetStringUTF8( 189 l10n_util::GetStringUTF8(
207 IDS_COOKIES_FILE_SYSTEM_USAGE_NONE)); 190 IDS_COOKIES_FILE_SYSTEM_USAGE_NONE));
208 break; 191 break;
209 } 192 }
210 default: 193 default:
211 #if defined(OS_MACOSX) 194 #if defined(OS_MACOSX)
212 dict->SetString(kKeyIcon, "chrome://theme/IDR_BOOKMARK_BAR_FOLDER"); 195 dict->SetString(kKeyIcon, "chrome://theme/IDR_BOOKMARK_BAR_FOLDER");
213 #endif 196 #endif
214 break; 197 break;
215 } 198 }
(...skipping 27 matching lines...) Expand all
243 if (child_index == -1) 226 if (child_index == -1)
244 break; 227 break;
245 228
246 parent = child; 229 parent = child;
247 } 230 }
248 231
249 return child_index >= 0 ? child : NULL; 232 return child_index >= 0 ? child : NULL;
250 } 233 }
251 234
252 } // namespace cookies_tree_model_util 235 } // namespace cookies_tree_model_util
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698