| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/time.h" | 10 #include "base/time.h" |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 } | 268 } |
| 269 | 269 |
| 270 BookmarkTableModel::~BookmarkTableModel() { | 270 BookmarkTableModel::~BookmarkTableModel() { |
| 271 if (model_) | 271 if (model_) |
| 272 model_->RemoveObserver(this); | 272 model_->RemoveObserver(this); |
| 273 } | 273 } |
| 274 | 274 |
| 275 std::wstring BookmarkTableModel::GetText(int row, int column_id) { | 275 std::wstring BookmarkTableModel::GetText(int row, int column_id) { |
| 276 BookmarkNode* node = GetNodeForRow(row); | 276 BookmarkNode* node = GetNodeForRow(row); |
| 277 switch (column_id) { | 277 switch (column_id) { |
| 278 case IDS_BOOKMARK_TABLE_TITLE: | 278 case IDS_BOOKMARK_TABLE_TITLE: { |
| 279 return node->GetTitle(); | 279 std::wstring title = node->GetTitle(); |
| 280 // Adjust the text as well, for example, put LRE-PDF pair around LTR text |
| 281 // in RTL enviroment, so that the ending punctuation in the text will not |
| 282 // be rendered incorrectly (such as rendered as the leftmost character, |
| 283 // and/or rendered as a mirrored punctuation character). |
| 284 // |
| 285 // TODO(xji): Consider adding a special case if the title text is a URL, |
| 286 // since those should always be displayed LTR. Please refer to |
| 287 // http://crbug.com/6726 for more information. |
| 288 l10n_util::AdjustStringForLocaleDirection(title, &title); |
| 289 return title; |
| 290 } |
| 280 | 291 |
| 281 case IDS_BOOKMARK_TABLE_URL: | 292 case IDS_BOOKMARK_TABLE_URL: { |
| 282 return node->is_url() ? UTF8ToWide(node->GetURL().spec()) : | 293 if (!node->is_url()) |
| 283 std::wstring(); | 294 return std::wstring(); |
| 295 std::wstring url_text = UTF8ToWide(node->GetURL().spec()); |
| 296 if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) |
| 297 l10n_util::WrapStringWithLTRFormatting(&url_text); |
| 298 return url_text; |
| 299 } |
| 284 | 300 |
| 285 case IDS_BOOKMARK_TABLE_PATH: { | 301 case IDS_BOOKMARK_TABLE_PATH: { |
| 286 std::wstring path; | 302 std::wstring path; |
| 287 BuildPath(node->GetParent(), &path); | 303 BuildPath(node->GetParent(), &path); |
| 304 // Force path to have LTR directionality. The whole path needs to be |
| 305 // marked with LRE-PDF, so that the path containing both LTR and RTL |
| 306 // subfolder names (such as "CBA/FED/(xji)/.x.j.", in which, "CBA" and |
| 307 // "FED" are subfolder names in Hebrew) can be displayed as LTR. |
| 308 if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) |
| 309 l10n_util::WrapStringWithLTRFormatting(&path); |
| 288 return path; | 310 return path; |
| 289 } | 311 } |
| 290 } | 312 } |
| 291 NOTREACHED(); | 313 NOTREACHED(); |
| 292 return std::wstring(); | 314 return std::wstring(); |
| 293 } | 315 } |
| 294 | 316 |
| 295 SkBitmap BookmarkTableModel::GetIcon(int row) { | 317 SkBitmap BookmarkTableModel::GetIcon(int row) { |
| 296 static SkBitmap* folder_icon = ResourceBundle::GetSharedInstance(). | 318 static SkBitmap* folder_icon = ResourceBundle::GetSharedInstance(). |
| 297 GetBitmapNamed(IDR_BOOKMARK_BAR_FOLDER); | 319 GetBitmapNamed(IDR_BOOKMARK_BAR_FOLDER); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 if (node == model()->GetBookmarkBarNode()) { | 351 if (node == model()->GetBookmarkBarNode()) { |
| 330 *path = l10n_util::GetString(IDS_BOOKMARK_TABLE_BOOKMARK_BAR_PATH); | 352 *path = l10n_util::GetString(IDS_BOOKMARK_TABLE_BOOKMARK_BAR_PATH); |
| 331 return; | 353 return; |
| 332 } | 354 } |
| 333 if (node == model()->other_node()) { | 355 if (node == model()->other_node()) { |
| 334 *path = l10n_util::GetString(IDS_BOOKMARK_TABLE_OTHER_BOOKMARKS_PATH); | 356 *path = l10n_util::GetString(IDS_BOOKMARK_TABLE_OTHER_BOOKMARKS_PATH); |
| 335 return; | 357 return; |
| 336 } | 358 } |
| 337 BuildPath(node->GetParent(), path); | 359 BuildPath(node->GetParent(), path); |
| 338 path->append(l10n_util::GetString(IDS_BOOKMARK_TABLE_PATH_SEPARATOR)); | 360 path->append(l10n_util::GetString(IDS_BOOKMARK_TABLE_PATH_SEPARATOR)); |
| 361 // Force path to have LTR directionality. Otherwise, folder path "CBA/FED" |
| 362 // (in which, "CBA" and "FED" stand for folder names in Hebrew, and "FED" is |
| 363 // a subfolder of "CBA") will be displayed as "FED/CBA". |
| 364 if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) { |
| 365 path->append(l10n_util::kLeftToRightMark); |
| 366 } |
| 339 path->append(node->GetTitle()); | 367 path->append(node->GetTitle()); |
| 340 } | 368 } |
| OLD | NEW |