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

Side by Side Diff: chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc

Issue 143463006: Remove net dependency from ui/gfx (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add gurl include to elide_url_unittest.cc Created 6 years, 10 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) 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 <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
(...skipping 15 matching lines...) Expand all
26 #include "chrome/browser/search/search.h" 26 #include "chrome/browser/search/search.h"
27 #include "chrome/browser/sync/profile_sync_service.h" 27 #include "chrome/browser/sync/profile_sync_service.h"
28 #include "chrome/browser/sync/profile_sync_service_factory.h" 28 #include "chrome/browser/sync/profile_sync_service_factory.h"
29 #include "chrome/browser/themes/theme_properties.h" 29 #include "chrome/browser/themes/theme_properties.h"
30 #include "chrome/browser/ui/bookmarks/bookmark_bar_constants.h" 30 #include "chrome/browser/ui/bookmarks/bookmark_bar_constants.h"
31 #include "chrome/browser/ui/bookmarks/bookmark_drag_drop.h" 31 #include "chrome/browser/ui/bookmarks/bookmark_drag_drop.h"
32 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" 32 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h"
33 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" 33 #include "chrome/browser/ui/bookmarks/bookmark_utils.h"
34 #include "chrome/browser/ui/browser.h" 34 #include "chrome/browser/ui/browser.h"
35 #include "chrome/browser/ui/chrome_pages.h" 35 #include "chrome/browser/ui/chrome_pages.h"
36 #include "chrome/browser/ui/elide_url.h"
36 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" 37 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h"
37 #include "chrome/browser/ui/omnibox/omnibox_view.h" 38 #include "chrome/browser/ui/omnibox/omnibox_view.h"
38 #include "chrome/browser/ui/tabs/tab_strip_model.h" 39 #include "chrome/browser/ui/tabs/tab_strip_model.h"
39 #include "chrome/browser/ui/view_ids.h" 40 #include "chrome/browser/ui/view_ids.h"
40 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_instructions_view.h" 41 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_instructions_view.h"
41 #include "chrome/browser/ui/views/bookmarks/bookmark_context_menu.h" 42 #include "chrome/browser/ui/views/bookmarks/bookmark_context_menu.h"
42 #include "chrome/browser/ui/views/bookmarks/bookmark_drag_drop_views.h" 43 #include "chrome/browser/ui/views/bookmarks/bookmark_drag_drop_views.h"
43 #include "chrome/browser/ui/views/bookmarks/bookmark_menu_controller_views.h" 44 #include "chrome/browser/ui/views/bookmarks/bookmark_menu_controller_views.h"
44 #include "chrome/browser/ui/views/event_utils.h" 45 #include "chrome/browser/ui/views/event_utils.h"
45 #include "chrome/browser/ui/views/frame/browser_view.h" 46 #include "chrome/browser/ui/views/frame/browser_view.h"
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 screen_loc.x(), 605 screen_loc.x(),
605 screen_loc.y(), 606 screen_loc.y(),
606 widget->GetNativeView()); 607 widget->GetNativeView());
607 const gfx::FontList tt_fonts = widget->GetTooltipManager()->GetFontList(); 608 const gfx::FontList tt_fonts = widget->GetTooltipManager()->GetFontList();
608 base::string16 result; 609 base::string16 result;
609 610
610 // First the title. 611 // First the title.
611 if (!title.empty()) { 612 if (!title.empty()) {
612 base::string16 localized_title = title; 613 base::string16 localized_title = title;
613 base::i18n::AdjustStringForLocaleDirection(&localized_title); 614 base::i18n::AdjustStringForLocaleDirection(&localized_title);
614 result.append(gfx::ElideText(localized_title, tt_fonts, max_width, 615 result.append(ElideText(localized_title, tt_fonts, max_width,
615 gfx::ELIDE_AT_END)); 616 gfx::ELIDE_AT_END));
616 } 617 }
617 618
618 // Only show the URL if the url and title differ. 619 // Only show the URL if the url and title differ.
619 if (title != base::UTF8ToUTF16(url.spec())) { 620 if (title != base::UTF8ToUTF16(url.spec())) {
620 if (!result.empty()) 621 if (!result.empty())
621 result.push_back('\n'); 622 result.push_back('\n');
622 623
623 // We need to explicitly specify the directionality of the URL's text to 624 // We need to explicitly specify the directionality of the URL's text to
624 // make sure it is treated as an LTR string when the context is RTL. For 625 // make sure it is treated as an LTR string when the context is RTL. For
625 // example, the URL "http://www.yahoo.com/" appears as 626 // example, the URL "http://www.yahoo.com/" appears as
626 // "/http://www.yahoo.com" when rendered, as is, in an RTL context since 627 // "/http://www.yahoo.com" when rendered, as is, in an RTL context since
627 // the Unicode BiDi algorithm puts certain characters on the left by 628 // the Unicode BiDi algorithm puts certain characters on the left by
628 // default. 629 // default.
629 std::string languages = profile->GetPrefs()->GetString( 630 std::string languages = profile->GetPrefs()->GetString(
630 prefs::kAcceptLanguages); 631 prefs::kAcceptLanguages);
631 base::string16 elided_url( 632 base::string16 elided_url(ElideUrl(url, tt_fonts, max_width, languages));
632 gfx::ElideUrl(url, tt_fonts, max_width, languages));
633 elided_url = base::i18n::GetDisplayStringInLTRDirectionality(elided_url); 633 elided_url = base::i18n::GetDisplayStringInLTRDirectionality(elided_url);
634 result.append(elided_url); 634 result.append(elided_url);
635 } 635 }
636 return result; 636 return result;
637 } 637 }
638 638
639 bool BookmarkBarView::IsDetached() const { 639 bool BookmarkBarView::IsDetached() const {
640 return (bookmark_bar_state_ == BookmarkBar::DETACHED) || 640 return (bookmark_bar_state_ == BookmarkBar::DETACHED) ||
641 (animating_detached_ && size_animation_->is_animating()); 641 (animating_detached_ && size_animation_->is_animating());
642 } 642 }
(...skipping 1212 matching lines...) Expand 10 before | Expand all | Expand 10 after
1855 DCHECK(apps_page_shortcut_); 1855 DCHECK(apps_page_shortcut_);
1856 // Only perform layout if required. 1856 // Only perform layout if required.
1857 bool visible = chrome::ShouldShowAppsShortcutInBookmarkBar( 1857 bool visible = chrome::ShouldShowAppsShortcutInBookmarkBar(
1858 browser_->profile(), browser_->host_desktop_type()); 1858 browser_->profile(), browser_->host_desktop_type());
1859 if (apps_page_shortcut_->visible() == visible) 1859 if (apps_page_shortcut_->visible() == visible)
1860 return; 1860 return;
1861 apps_page_shortcut_->SetVisible(visible); 1861 apps_page_shortcut_->SetVisible(visible);
1862 UpdateBookmarksSeparatorVisibility(); 1862 UpdateBookmarksSeparatorVisibility();
1863 Layout(); 1863 Layout();
1864 } 1864 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/tests/elide_url_unittest.cc ('k') | chrome/browser/ui/views/status_bubble_views.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698