| OLD | NEW |
| 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/views/bookmark_bar_view.h" | 5 #include "chrome/browser/ui/views/bookmark_bar_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "app/l10n_util.h" | 12 #include "app/l10n_util.h" |
| 13 #include "app/resource_bundle.h" | 13 #include "app/resource_bundle.h" |
| 14 #include "app/text_elider.h" | |
| 15 #include "base/i18n/rtl.h" | 14 #include "base/i18n/rtl.h" |
| 16 #include "base/string_util.h" | 15 #include "base/string_util.h" |
| 17 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
| 18 #include "chrome/browser/bookmarks/bookmark_model.h" | 17 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 19 #include "chrome/browser/bookmarks/bookmark_utils.h" | 18 #include "chrome/browser/bookmarks/bookmark_utils.h" |
| 20 #include "chrome/browser/browser_shutdown.h" | 19 #include "chrome/browser/browser_shutdown.h" |
| 21 #include "chrome/browser/importer/importer_data_types.h" | 20 #include "chrome/browser/importer/importer_data_types.h" |
| 22 #include "chrome/browser/metrics/user_metrics.h" | 21 #include "chrome/browser/metrics/user_metrics.h" |
| 23 #include "chrome/browser/prefs/pref_service.h" | 22 #include "chrome/browser/prefs/pref_service.h" |
| 24 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 36 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 35 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 37 #include "chrome/common/notification_service.h" | 36 #include "chrome/common/notification_service.h" |
| 38 #include "chrome/common/page_transition_types.h" | 37 #include "chrome/common/page_transition_types.h" |
| 39 #include "chrome/common/pref_names.h" | 38 #include "chrome/common/pref_names.h" |
| 40 #include "gfx/canvas_skia.h" | 39 #include "gfx/canvas_skia.h" |
| 41 #include "grit/app_resources.h" | 40 #include "grit/app_resources.h" |
| 42 #include "grit/generated_resources.h" | 41 #include "grit/generated_resources.h" |
| 43 #include "grit/theme_resources.h" | 42 #include "grit/theme_resources.h" |
| 44 #include "ui/base/animation/slide_animation.h" | 43 #include "ui/base/animation/slide_animation.h" |
| 45 #include "ui/base/dragdrop/os_exchange_data.h" | 44 #include "ui/base/dragdrop/os_exchange_data.h" |
| 45 #include "ui/base/text/text_elider.h" |
| 46 #include "views/controls/button/menu_button.h" | 46 #include "views/controls/button/menu_button.h" |
| 47 #include "views/controls/label.h" | 47 #include "views/controls/label.h" |
| 48 #include "views/controls/menu/menu_item_view.h" | 48 #include "views/controls/menu/menu_item_view.h" |
| 49 #include "views/drag_utils.h" | 49 #include "views/drag_utils.h" |
| 50 #include "views/view_constants.h" | 50 #include "views/view_constants.h" |
| 51 #include "views/widget/tooltip_manager.h" | 51 #include "views/widget/tooltip_manager.h" |
| 52 #include "views/widget/widget.h" | 52 #include "views/widget/widget.h" |
| 53 #include "views/window/window.h" | 53 #include "views/window/window.h" |
| 54 | 54 |
| 55 #if defined(OS_WIN) | 55 #if defined(OS_WIN) |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 const std::wstring& languages) { | 137 const std::wstring& languages) { |
| 138 int max_width = views::TooltipManager::GetMaxWidth(screen_loc.x(), | 138 int max_width = views::TooltipManager::GetMaxWidth(screen_loc.x(), |
| 139 screen_loc.y()); | 139 screen_loc.y()); |
| 140 gfx::Font tt_font = views::TooltipManager::GetDefaultFont(); | 140 gfx::Font tt_font = views::TooltipManager::GetDefaultFont(); |
| 141 std::wstring result; | 141 std::wstring result; |
| 142 | 142 |
| 143 // First the title. | 143 // First the title. |
| 144 if (!title.empty()) { | 144 if (!title.empty()) { |
| 145 std::wstring localized_title = title; | 145 std::wstring localized_title = title; |
| 146 base::i18n::AdjustStringForLocaleDirection(&localized_title); | 146 base::i18n::AdjustStringForLocaleDirection(&localized_title); |
| 147 result.append(UTF16ToWideHack(gfx::ElideText(WideToUTF16Hack( | 147 result.append(UTF16ToWideHack(ui::ElideText(WideToUTF16Hack( |
| 148 localized_title), tt_font, max_width, false))); | 148 localized_title), tt_font, max_width, false))); |
| 149 } | 149 } |
| 150 | 150 |
| 151 // Only show the URL if the url and title differ. | 151 // Only show the URL if the url and title differ. |
| 152 if (title != UTF8ToWide(url.spec())) { | 152 if (title != UTF8ToWide(url.spec())) { |
| 153 if (!result.empty()) | 153 if (!result.empty()) |
| 154 result.append(views::TooltipManager::GetLineSeparator()); | 154 result.append(views::TooltipManager::GetLineSeparator()); |
| 155 | 155 |
| 156 // We need to explicitly specify the directionality of the URL's text to | 156 // We need to explicitly specify the directionality of the URL's text to |
| 157 // make sure it is treated as an LTR string when the context is RTL. For | 157 // make sure it is treated as an LTR string when the context is RTL. For |
| 158 // example, the URL "http://www.yahoo.com/" appears as | 158 // example, the URL "http://www.yahoo.com/" appears as |
| 159 // "/http://www.yahoo.com" when rendered, as is, in an RTL context since | 159 // "/http://www.yahoo.com" when rendered, as is, in an RTL context since |
| 160 // the Unicode BiDi algorithm puts certain characters on the left by | 160 // the Unicode BiDi algorithm puts certain characters on the left by |
| 161 // default. | 161 // default. |
| 162 string16 elided_url(gfx::ElideUrl(url, tt_font, max_width, languages)); | 162 string16 elided_url(ui::ElideUrl(url, tt_font, max_width, languages)); |
| 163 elided_url = base::i18n::GetDisplayStringInLTRDirectionality(elided_url); | 163 elided_url = base::i18n::GetDisplayStringInLTRDirectionality(elided_url); |
| 164 result.append(UTF16ToWideHack(elided_url)); | 164 result.append(UTF16ToWideHack(elided_url)); |
| 165 } | 165 } |
| 166 return result; | 166 return result; |
| 167 } | 167 } |
| 168 | 168 |
| 169 // BookmarkButton ------------------------------------------------------------- | 169 // BookmarkButton ------------------------------------------------------------- |
| 170 | 170 |
| 171 // Buttons used for the bookmarks on the bookmark bar. | 171 // Buttons used for the bookmarks on the bookmark bar. |
| 172 | 172 |
| (...skipping 1561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1734 // The tooltip is the only way we have to display text explaining the error | 1734 // The tooltip is the only way we have to display text explaining the error |
| 1735 // to the user. | 1735 // to the user. |
| 1736 sync_error_button->SetTooltipText( | 1736 sync_error_button->SetTooltipText( |
| 1737 UTF16ToWide(l10n_util::GetStringUTF16(IDS_SYNC_BOOKMARK_BAR_ERROR_DESC))); | 1737 UTF16ToWide(l10n_util::GetStringUTF16(IDS_SYNC_BOOKMARK_BAR_ERROR_DESC))); |
| 1738 sync_error_button->SetAccessibleName( | 1738 sync_error_button->SetAccessibleName( |
| 1739 l10n_util::GetStringUTF16(IDS_ACCNAME_SYNC_ERROR_BUTTON)); | 1739 l10n_util::GetStringUTF16(IDS_ACCNAME_SYNC_ERROR_BUTTON)); |
| 1740 sync_error_button->SetIcon( | 1740 sync_error_button->SetIcon( |
| 1741 *ResourceBundle::GetSharedInstance().GetBitmapNamed(IDR_WARNING)); | 1741 *ResourceBundle::GetSharedInstance().GetBitmapNamed(IDR_WARNING)); |
| 1742 return sync_error_button; | 1742 return sync_error_button; |
| 1743 } | 1743 } |
| OLD | NEW |