| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bookmarks/bookmark_bar_view.h" | 5 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <limits> | 10 #include <limits> |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 const GURL& url, | 268 const GURL& url, |
| 269 const base::string16& title, | 269 const base::string16& title, |
| 270 Profile* profile) | 270 Profile* profile) |
| 271 : BookmarkButtonBase(listener, title), url_(url), profile_(profile) {} | 271 : BookmarkButtonBase(listener, title), url_(url), profile_(profile) {} |
| 272 | 272 |
| 273 bool GetTooltipText(const gfx::Point& p, | 273 bool GetTooltipText(const gfx::Point& p, |
| 274 base::string16* tooltip) const override { | 274 base::string16* tooltip) const override { |
| 275 gfx::Point location(p); | 275 gfx::Point location(p); |
| 276 ConvertPointToScreen(this, &location); | 276 ConvertPointToScreen(this, &location); |
| 277 *tooltip = BookmarkBarView::CreateToolTipForURLAndTitle( | 277 *tooltip = BookmarkBarView::CreateToolTipForURLAndTitle( |
| 278 GetWidget(), location, url_, GetText(), profile_); | 278 GetWidget(), location, url_, GetText()); |
| 279 return !tooltip->empty(); | 279 return !tooltip->empty(); |
| 280 } | 280 } |
| 281 | 281 |
| 282 const char* GetClassName() const override { return kViewClassName; } | 282 const char* GetClassName() const override { return kViewClassName; } |
| 283 | 283 |
| 284 private: | 284 private: |
| 285 const GURL& url_; | 285 const GURL& url_; |
| 286 Profile* profile_; | 286 Profile* profile_; |
| 287 | 287 |
| 288 DISALLOW_COPY_AND_ASSIGN(BookmarkButton); | 288 DISALLOW_COPY_AND_ASSIGN(BookmarkButton); |
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 // If not immediate, cycle through 2 more complete cycles. | 762 // If not immediate, cycle through 2 more complete cycles. |
| 763 throbbing_view_->StartThrobbing(immediate ? 0 : 4); | 763 throbbing_view_->StartThrobbing(immediate ? 0 : 4); |
| 764 throbbing_view_ = NULL; | 764 throbbing_view_ = NULL; |
| 765 } | 765 } |
| 766 | 766 |
| 767 // static | 767 // static |
| 768 base::string16 BookmarkBarView::CreateToolTipForURLAndTitle( | 768 base::string16 BookmarkBarView::CreateToolTipForURLAndTitle( |
| 769 const views::Widget* widget, | 769 const views::Widget* widget, |
| 770 const gfx::Point& screen_loc, | 770 const gfx::Point& screen_loc, |
| 771 const GURL& url, | 771 const GURL& url, |
| 772 const base::string16& title, | 772 const base::string16& title) { |
| 773 Profile* profile) { | |
| 774 const views::TooltipManager* tooltip_manager = widget->GetTooltipManager(); | 773 const views::TooltipManager* tooltip_manager = widget->GetTooltipManager(); |
| 775 int max_width = tooltip_manager->GetMaxWidth(screen_loc); | 774 int max_width = tooltip_manager->GetMaxWidth(screen_loc); |
| 776 const gfx::FontList tt_fonts = tooltip_manager->GetFontList(); | 775 const gfx::FontList tt_fonts = tooltip_manager->GetFontList(); |
| 777 base::string16 result; | 776 base::string16 result; |
| 778 | 777 |
| 779 // First the title. | 778 // First the title. |
| 780 if (!title.empty()) { | 779 if (!title.empty()) { |
| 781 base::string16 localized_title = title; | 780 base::string16 localized_title = title; |
| 782 base::i18n::AdjustStringForLocaleDirection(&localized_title); | 781 base::i18n::AdjustStringForLocaleDirection(&localized_title); |
| 783 result.append(gfx::ElideText(localized_title, tt_fonts, max_width, | 782 result.append(gfx::ElideText(localized_title, tt_fonts, max_width, |
| 784 gfx::ELIDE_TAIL)); | 783 gfx::ELIDE_TAIL)); |
| 785 } | 784 } |
| 786 | 785 |
| 787 // Only show the URL if the url and title differ. | 786 // Only show the URL if the url and title differ. |
| 788 if (title != base::UTF8ToUTF16(url.spec())) { | 787 if (title != base::UTF8ToUTF16(url.spec())) { |
| 789 if (!result.empty()) | 788 if (!result.empty()) |
| 790 result.push_back('\n'); | 789 result.push_back('\n'); |
| 791 | 790 |
| 792 // We need to explicitly specify the directionality of the URL's text to | 791 // We need to explicitly specify the directionality of the URL's text to |
| 793 // make sure it is treated as an LTR string when the context is RTL. For | 792 // make sure it is treated as an LTR string when the context is RTL. For |
| 794 // example, the URL "http://www.yahoo.com/" appears as | 793 // example, the URL "http://www.yahoo.com/" appears as |
| 795 // "/http://www.yahoo.com" when rendered, as is, in an RTL context since | 794 // "/http://www.yahoo.com" when rendered, as is, in an RTL context since |
| 796 // the Unicode BiDi algorithm puts certain characters on the left by | 795 // the Unicode BiDi algorithm puts certain characters on the left by |
| 797 // default. | 796 // default. |
| 798 std::string languages = profile->GetPrefs()->GetString( | |
| 799 prefs::kAcceptLanguages); | |
| 800 base::string16 elided_url( | 797 base::string16 elided_url( |
| 801 url_formatter::ElideUrl(url, tt_fonts, max_width, languages)); | 798 url_formatter::ElideUrl(url, tt_fonts, max_width)); |
| 802 elided_url = base::i18n::GetDisplayStringInLTRDirectionality(elided_url); | 799 elided_url = base::i18n::GetDisplayStringInLTRDirectionality(elided_url); |
| 803 result.append(elided_url); | 800 result.append(elided_url); |
| 804 } | 801 } |
| 805 return result; | 802 return result; |
| 806 } | 803 } |
| 807 | 804 |
| 808 bool BookmarkBarView::IsDetached() const { | 805 bool BookmarkBarView::IsDetached() const { |
| 809 return (bookmark_bar_state_ == BookmarkBar::DETACHED) || | 806 return (bookmark_bar_state_ == BookmarkBar::DETACHED) || |
| 810 (animating_detached_ && size_animation_.is_animating()); | 807 (animating_detached_ && size_animation_.is_animating()); |
| 811 } | 808 } |
| (...skipping 1338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2150 return; | 2147 return; |
| 2151 apps_page_shortcut_->SetVisible(visible); | 2148 apps_page_shortcut_->SetVisible(visible); |
| 2152 UpdateBookmarksSeparatorVisibility(); | 2149 UpdateBookmarksSeparatorVisibility(); |
| 2153 LayoutAndPaint(); | 2150 LayoutAndPaint(); |
| 2154 } | 2151 } |
| 2155 | 2152 |
| 2156 void BookmarkBarView::OnShowManagedBookmarksPrefChanged() { | 2153 void BookmarkBarView::OnShowManagedBookmarksPrefChanged() { |
| 2157 if (UpdateOtherAndManagedButtonsVisibility()) | 2154 if (UpdateOtherAndManagedButtonsVisibility()) |
| 2158 LayoutAndPaint(); | 2155 LayoutAndPaint(); |
| 2159 } | 2156 } |
| OLD | NEW |