OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/bookmarks/bookmark_table_model.h" | 5 #include "chrome/browser/bookmarks/bookmark_table_model.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
11 #include "app/table_model_observer.h" | 11 #include "app/table_model_observer.h" |
| 12 #include "base/i18n/rtl.h" |
12 #include "base/i18n/time_formatting.h" | 13 #include "base/i18n/time_formatting.h" |
13 #include "base/string_util.h" | 14 #include "base/string_util.h" |
14 #include "chrome/browser/bookmarks/bookmark_model.h" | 15 #include "chrome/browser/bookmarks/bookmark_model.h" |
15 #include "chrome/browser/bookmarks/bookmark_utils.h" | 16 #include "chrome/browser/bookmarks/bookmark_utils.h" |
16 #include "chrome/browser/pref_service.h" | 17 #include "chrome/browser/pref_service.h" |
17 #include "chrome/browser/profile.h" | 18 #include "chrome/browser/profile.h" |
18 #include "chrome/common/pref_names.h" | 19 #include "chrome/common/pref_names.h" |
19 #include "googleurl/src/gurl.h" | 20 #include "googleurl/src/gurl.h" |
20 #include "grit/app_resources.h" | 21 #include "grit/app_resources.h" |
21 #include "grit/generated_resources.h" | 22 #include "grit/generated_resources.h" |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 case IDS_BOOKMARK_TABLE_TITLE: { | 308 case IDS_BOOKMARK_TABLE_TITLE: { |
308 std::wstring title = node->GetTitle(); | 309 std::wstring title = node->GetTitle(); |
309 // Adjust the text as well, for example, put LRE-PDF pair around LTR text | 310 // Adjust the text as well, for example, put LRE-PDF pair around LTR text |
310 // in RTL enviroment, so that the ending punctuation in the text will not | 311 // in RTL enviroment, so that the ending punctuation in the text will not |
311 // be rendered incorrectly (such as rendered as the leftmost character, | 312 // be rendered incorrectly (such as rendered as the leftmost character, |
312 // and/or rendered as a mirrored punctuation character). | 313 // and/or rendered as a mirrored punctuation character). |
313 // | 314 // |
314 // TODO(xji): Consider adding a special case if the title text is a URL, | 315 // TODO(xji): Consider adding a special case if the title text is a URL, |
315 // since those should always be displayed LTR. Please refer to | 316 // since those should always be displayed LTR. Please refer to |
316 // http://crbug.com/6726 for more information. | 317 // http://crbug.com/6726 for more information. |
317 l10n_util::AdjustStringForLocaleDirection(title, &title); | 318 base::i18n::AdjustStringForLocaleDirection(title, &title); |
318 return title; | 319 return title; |
319 } | 320 } |
320 | 321 |
321 case IDS_BOOKMARK_TABLE_URL: { | 322 case IDS_BOOKMARK_TABLE_URL: { |
322 if (!node->is_url()) | 323 if (!node->is_url()) |
323 return std::wstring(); | 324 return std::wstring(); |
324 std::wstring languages = model_ && model_->profile() | 325 std::wstring languages = model_ && model_->profile() |
325 ? model_->profile()->GetPrefs()->GetString(prefs::kAcceptLanguages) | 326 ? model_->profile()->GetPrefs()->GetString(prefs::kAcceptLanguages) |
326 : std::wstring(); | 327 : std::wstring(); |
327 std::wstring url_text = net::FormatUrl(node->GetURL(), languages, false, | 328 std::wstring url_text = net::FormatUrl(node->GetURL(), languages, false, |
328 UnescapeRule::SPACES, NULL, NULL, NULL); | 329 UnescapeRule::SPACES, NULL, NULL, NULL); |
329 if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) | 330 if (base::i18n::IsRTL()) |
330 l10n_util::WrapStringWithLTRFormatting(&url_text); | 331 base::i18n::WrapStringWithLTRFormatting(&url_text); |
331 return url_text; | 332 return url_text; |
332 } | 333 } |
333 | 334 |
334 case IDS_BOOKMARK_TABLE_PATH: { | 335 case IDS_BOOKMARK_TABLE_PATH: { |
335 std::wstring path; | 336 std::wstring path; |
336 BuildPath(node->GetParent(), &path); | 337 BuildPath(node->GetParent(), &path); |
337 // Force path to have LTR directionality. The whole path (but not every | 338 // Force path to have LTR directionality. The whole path (but not every |
338 // single path component) is marked with LRE-PDF. For example, | 339 // single path component) is marked with LRE-PDF. For example, |
339 // ALEPH/BET/GIMEL (using uppercase English for Hebrew) is supposed to | 340 // ALEPH/BET/GIMEL (using uppercase English for Hebrew) is supposed to |
340 // appear (visually) as LEMIG/TEB/HPELA; foo/C/B/A.doc refers to file | 341 // appear (visually) as LEMIG/TEB/HPELA; foo/C/B/A.doc refers to file |
341 // C.doc in directory B in directory A in directory foo, not to file | 342 // C.doc in directory B in directory A in directory foo, not to file |
342 // A.doc in directory B in directory C in directory foo. The reason to | 343 // A.doc in directory B in directory C in directory foo. The reason to |
343 // mark the whole path, but not every single path component, as LTR is | 344 // mark the whole path, but not every single path component, as LTR is |
344 // because paths need to get written in text documents, and that is how | 345 // because paths need to get written in text documents, and that is how |
345 // they will appear there. Being a saint and doing the tedious formatting | 346 // they will appear there. Being a saint and doing the tedious formatting |
346 // to every single path component to get it to come out in the logical | 347 // to every single path component to get it to come out in the logical |
347 // order will accomplish nothing but confuse people, since they will now | 348 // order will accomplish nothing but confuse people, since they will now |
348 // see both formats being used, and will never know what anything means. | 349 // see both formats being used, and will never know what anything means. |
349 // Furthermore, doing the "logical" formatting with characters like LRM, | 350 // Furthermore, doing the "logical" formatting with characters like LRM, |
350 // LRE, and PDF to every single path component means that when someone | 351 // LRE, and PDF to every single path component means that when someone |
351 // copy/pastes your path, it will still contain those characters, and | 352 // copy/pastes your path, it will still contain those characters, and |
352 // trying to access the file will fail because of them. Windows Explorer, | 353 // trying to access the file will fail because of them. Windows Explorer, |
353 // Firefox, IE, Nautilus, gedit choose to format only the whole path as | 354 // Firefox, IE, Nautilus, gedit choose to format only the whole path as |
354 // LTR too. The point here is to display the path the same way as it's | 355 // LTR too. The point here is to display the path the same way as it's |
355 // displayed by other software. | 356 // displayed by other software. |
356 if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) | 357 if (base::i18n::IsRTL()) |
357 l10n_util::WrapStringWithLTRFormatting(&path); | 358 base::i18n::WrapStringWithLTRFormatting(&path); |
358 return path; | 359 return path; |
359 } | 360 } |
360 } | 361 } |
361 NOTREACHED(); | 362 NOTREACHED(); |
362 return std::wstring(); | 363 return std::wstring(); |
363 } | 364 } |
364 | 365 |
365 SkBitmap BookmarkTableModel::GetIcon(int row) { | 366 SkBitmap BookmarkTableModel::GetIcon(int row) { |
366 static SkBitmap* folder_icon = ResourceBundle::GetSharedInstance(). | 367 static SkBitmap* folder_icon = ResourceBundle::GetSharedInstance(). |
367 GetBitmapNamed(IDR_BOOKMARK_BAR_FOLDER); | 368 GetBitmapNamed(IDR_BOOKMARK_BAR_FOLDER); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 return; | 403 return; |
403 } | 404 } |
404 if (node == model()->other_node()) { | 405 if (node == model()->other_node()) { |
405 *path = l10n_util::GetString(IDS_BOOKMARK_TABLE_OTHER_BOOKMARKS_PATH); | 406 *path = l10n_util::GetString(IDS_BOOKMARK_TABLE_OTHER_BOOKMARKS_PATH); |
406 return; | 407 return; |
407 } | 408 } |
408 BuildPath(node->GetParent(), path); | 409 BuildPath(node->GetParent(), path); |
409 path->append(l10n_util::GetString(IDS_BOOKMARK_TABLE_PATH_SEPARATOR)); | 410 path->append(l10n_util::GetString(IDS_BOOKMARK_TABLE_PATH_SEPARATOR)); |
410 path->append(node->GetTitle()); | 411 path->append(node->GetTitle()); |
411 } | 412 } |
OLD | NEW |