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/views/bookmark_bar_view.h" | 5 #include "chrome/browser/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> |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 | 107 |
108 // Left-padding for the instructional text. | 108 // Left-padding for the instructional text. |
109 static const int kInstructionsPadding = 6; | 109 static const int kInstructionsPadding = 6; |
110 | 110 |
111 // Color of the instructional text. | 111 // Color of the instructional text. |
112 static const SkColor kInstructionsColor = SkColorSetRGB(128, 128, 142); | 112 static const SkColor kInstructionsColor = SkColorSetRGB(128, 128, 142); |
113 | 113 |
114 // Tag for the 'Other bookmarks' button. | 114 // Tag for the 'Other bookmarks' button. |
115 static const int kOtherFolderButtonTag = 1; | 115 static const int kOtherFolderButtonTag = 1; |
116 | 116 |
117 #if defined(BROWSER_SYNC) | |
118 // Tag for the sync error button. | 117 // Tag for the sync error button. |
119 static const int kSyncErrorButtonTag = 2; | 118 static const int kSyncErrorButtonTag = 2; |
120 #endif | |
121 | 119 |
122 namespace { | 120 namespace { |
123 | 121 |
124 // Returns the tooltip text for the specified url and title. The returned | 122 // Returns the tooltip text for the specified url and title. The returned |
125 // text is clipped to fit within the bounds of the monitor. | 123 // text is clipped to fit within the bounds of the monitor. |
126 // | 124 // |
127 // Note that we adjust the direction of both the URL and the title based on the | 125 // Note that we adjust the direction of both the URL and the title based on the |
128 // locale so that pure LTR strings are displayed properly in RTL locales. | 126 // locale so that pure LTR strings are displayed properly in RTL locales. |
129 static std::wstring CreateToolTipForURLAndTitle(const gfx::Point& screen_loc, | 127 static std::wstring CreateToolTipForURLAndTitle(const gfx::Point& screen_loc, |
130 const GURL& url, | 128 const GURL& url, |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 | 361 |
364 BookmarkBarView::BookmarkBarView(Profile* profile, Browser* browser) | 362 BookmarkBarView::BookmarkBarView(Profile* profile, Browser* browser) |
365 : profile_(NULL), | 363 : profile_(NULL), |
366 page_navigator_(NULL), | 364 page_navigator_(NULL), |
367 model_(NULL), | 365 model_(NULL), |
368 bookmark_menu_(NULL), | 366 bookmark_menu_(NULL), |
369 bookmark_drop_menu_(NULL), | 367 bookmark_drop_menu_(NULL), |
370 other_bookmarked_button_(NULL), | 368 other_bookmarked_button_(NULL), |
371 model_changed_listener_(NULL), | 369 model_changed_listener_(NULL), |
372 show_folder_drop_menu_task_(NULL), | 370 show_folder_drop_menu_task_(NULL), |
373 #if defined(BROWSER_SYNC) | |
374 sync_error_button_(NULL), | 371 sync_error_button_(NULL), |
375 sync_service_(NULL), | 372 sync_service_(NULL), |
376 #endif | |
377 overflow_button_(NULL), | 373 overflow_button_(NULL), |
378 instructions_(NULL), | 374 instructions_(NULL), |
379 bookmarks_separator_view_(NULL), | 375 bookmarks_separator_view_(NULL), |
380 browser_(browser), | 376 browser_(browser), |
381 throbbing_view_(NULL) { | 377 throbbing_view_(NULL) { |
382 #if defined(BROWSER_SYNC) | |
383 if (profile->GetProfileSyncService()) { | 378 if (profile->GetProfileSyncService()) { |
384 // Obtain a pointer to the profile sync service and add our instance as an | 379 // Obtain a pointer to the profile sync service and add our instance as an |
385 // observer. | 380 // observer. |
386 sync_service_ = profile->GetProfileSyncService(); | 381 sync_service_ = profile->GetProfileSyncService(); |
387 sync_service_->AddObserver(this); | 382 sync_service_->AddObserver(this); |
388 } | 383 } |
389 #endif | |
390 | 384 |
391 SetID(VIEW_ID_BOOKMARK_BAR); | 385 SetID(VIEW_ID_BOOKMARK_BAR); |
392 Init(); | 386 Init(); |
393 SetProfile(profile); | 387 SetProfile(profile); |
394 | 388 |
395 if (IsAlwaysShown()) | 389 if (IsAlwaysShown()) |
396 size_animation_->Reset(1); | 390 size_animation_->Reset(1); |
397 else | 391 else |
398 size_animation_->Reset(0); | 392 size_animation_->Reset(0); |
399 } | 393 } |
400 | 394 |
401 BookmarkBarView::~BookmarkBarView() { | 395 BookmarkBarView::~BookmarkBarView() { |
402 NotifyModelChanged(); | 396 NotifyModelChanged(); |
403 if (model_) | 397 if (model_) |
404 model_->RemoveObserver(this); | 398 model_->RemoveObserver(this); |
405 StopShowFolderDropMenuTimer(); | 399 StopShowFolderDropMenuTimer(); |
406 | 400 |
407 #if defined(BROWSER_SYNC) | |
408 if (sync_service_) | 401 if (sync_service_) |
409 sync_service_->RemoveObserver(this); | 402 sync_service_->RemoveObserver(this); |
410 #endif | |
411 } | 403 } |
412 | 404 |
413 void BookmarkBarView::SetProfile(Profile* profile) { | 405 void BookmarkBarView::SetProfile(Profile* profile) { |
414 DCHECK(profile); | 406 DCHECK(profile); |
415 if (profile_ == profile) | 407 if (profile_ == profile) |
416 return; | 408 return; |
417 | 409 |
418 StopThrobbing(true); | 410 StopThrobbing(true); |
419 | 411 |
420 // Cancels the current cancelable. | 412 // Cancels the current cancelable. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 // Bookmarks" folder, along with appropriate margins and button padding. | 451 // Bookmarks" folder, along with appropriate margins and button padding. |
460 int width = kLeftMargin; | 452 int width = kLeftMargin; |
461 | 453 |
462 if (OnNewTabPage()) { | 454 if (OnNewTabPage()) { |
463 double current_state = 1 - size_animation_->GetCurrentValue(); | 455 double current_state = 1 - size_animation_->GetCurrentValue(); |
464 width += 2 * static_cast<int>(static_cast<double> | 456 width += 2 * static_cast<int>(static_cast<double> |
465 (kNewtabHorizontalPadding) * current_state); | 457 (kNewtabHorizontalPadding) * current_state); |
466 } | 458 } |
467 | 459 |
468 int sync_error_total_width = 0; | 460 int sync_error_total_width = 0; |
469 #if defined(BROWSER_SYNC) | |
470 gfx::Size sync_error_button_pref = sync_error_button_->GetPreferredSize(); | 461 gfx::Size sync_error_button_pref = sync_error_button_->GetPreferredSize(); |
471 if (ShouldShowSyncErrorButton()) | 462 if (ShouldShowSyncErrorButton()) |
472 sync_error_total_width += kButtonPadding + sync_error_button_pref.width(); | 463 sync_error_total_width += kButtonPadding + sync_error_button_pref.width(); |
473 #endif | |
474 | 464 |
475 gfx::Size other_bookmarked_pref = | 465 gfx::Size other_bookmarked_pref = |
476 other_bookmarked_button_->GetPreferredSize(); | 466 other_bookmarked_button_->GetPreferredSize(); |
477 gfx::Size overflow_pref = overflow_button_->GetPreferredSize(); | 467 gfx::Size overflow_pref = overflow_button_->GetPreferredSize(); |
478 gfx::Size bookmarks_separator_pref = | 468 gfx::Size bookmarks_separator_pref = |
479 bookmarks_separator_view_->GetPreferredSize(); | 469 bookmarks_separator_view_->GetPreferredSize(); |
480 | 470 |
481 width += (other_bookmarked_pref.width() + kButtonPadding + | 471 width += (other_bookmarked_pref.width() + kButtonPadding + |
482 overflow_pref.width() + kButtonPadding + | 472 overflow_pref.width() + kButtonPadding + |
483 bookmarks_separator_pref.width() + sync_error_total_width); | 473 bookmarks_separator_pref.width() + sync_error_total_width); |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
711 DCHECK(role); | 701 DCHECK(role); |
712 | 702 |
713 *role = AccessibilityTypes::ROLE_TOOLBAR; | 703 *role = AccessibilityTypes::ROLE_TOOLBAR; |
714 return true; | 704 return true; |
715 } | 705 } |
716 | 706 |
717 void BookmarkBarView::SetAccessibleName(const std::wstring& name) { | 707 void BookmarkBarView::SetAccessibleName(const std::wstring& name) { |
718 accessible_name_.assign(name); | 708 accessible_name_.assign(name); |
719 } | 709 } |
720 | 710 |
721 #if defined(BROWSER_SYNC) | |
722 void BookmarkBarView::OnStateChanged() { | 711 void BookmarkBarView::OnStateChanged() { |
723 // When the sync state changes, it is sufficient to invoke View::Layout since | 712 // When the sync state changes, it is sufficient to invoke View::Layout since |
724 // during layout we query the profile sync service and determine whether the | 713 // during layout we query the profile sync service and determine whether the |
725 // new state requires showing the sync error button so that the user can | 714 // new state requires showing the sync error button so that the user can |
726 // re-enter her password. If extension shelf appears along with the bookmark | 715 // re-enter her password. If extension shelf appears along with the bookmark |
727 // shelf, it too needs to be layed out. Since both have the same parent, it is | 716 // shelf, it too needs to be layed out. Since both have the same parent, it is |
728 // enough to let the parent layout both of these children. | 717 // enough to let the parent layout both of these children. |
729 // TODO(sky): This should not require Layout() and SchedulePaint(). Needs | 718 // TODO(sky): This should not require Layout() and SchedulePaint(). Needs |
730 // some cleanup. | 719 // some cleanup. |
731 PreferredSizeChanged(); | 720 PreferredSizeChanged(); |
732 Layout(); | 721 Layout(); |
733 SchedulePaint(); | 722 SchedulePaint(); |
734 } | 723 } |
735 #endif // defined(BROWSER_SYNC) | |
736 | 724 |
737 void BookmarkBarView::OnFullscreenToggled(bool fullscreen) { | 725 void BookmarkBarView::OnFullscreenToggled(bool fullscreen) { |
738 if (!fullscreen) | 726 if (!fullscreen) |
739 size_animation_->Reset(IsAlwaysShown() ? 1 : 0); | 727 size_animation_->Reset(IsAlwaysShown() ? 1 : 0); |
740 else if (IsAlwaysShown()) | 728 else if (IsAlwaysShown()) |
741 size_animation_->Reset(0); | 729 size_animation_->Reset(0); |
742 } | 730 } |
743 | 731 |
744 bool BookmarkBarView::IsDetached() const { | 732 bool BookmarkBarView::IsDetached() const { |
745 return OnNewTabPage() && (size_animation_->GetCurrentValue() != 1); | 733 return OnNewTabPage() && (size_animation_->GetCurrentValue() != 1); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
871 // added in this function. | 859 // added in this function. |
872 | 860 |
873 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 861 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
874 | 862 |
875 if (!kDefaultFavIcon) | 863 if (!kDefaultFavIcon) |
876 kDefaultFavIcon = rb.GetBitmapNamed(IDR_DEFAULT_FAVICON); | 864 kDefaultFavIcon = rb.GetBitmapNamed(IDR_DEFAULT_FAVICON); |
877 | 865 |
878 other_bookmarked_button_ = CreateOtherBookmarkedButton(); | 866 other_bookmarked_button_ = CreateOtherBookmarkedButton(); |
879 AddChildView(other_bookmarked_button_); | 867 AddChildView(other_bookmarked_button_); |
880 | 868 |
881 #if defined(BROWSER_SYNC) | |
882 sync_error_button_ = CreateSyncErrorButton(); | 869 sync_error_button_ = CreateSyncErrorButton(); |
883 AddChildView(sync_error_button_); | 870 AddChildView(sync_error_button_); |
884 #endif | |
885 | 871 |
886 overflow_button_ = CreateOverflowButton(); | 872 overflow_button_ = CreateOverflowButton(); |
887 AddChildView(overflow_button_); | 873 AddChildView(overflow_button_); |
888 | 874 |
889 bookmarks_separator_view_ = new ButtonSeparatorView(); | 875 bookmarks_separator_view_ = new ButtonSeparatorView(); |
890 bookmarks_separator_view_->SetAccessibleName( | 876 bookmarks_separator_view_->SetAccessibleName( |
891 l10n_util::GetString(IDS_ACCNAME_SEPARATOR)); | 877 l10n_util::GetString(IDS_ACCNAME_SEPARATOR)); |
892 AddChildView(bookmarks_separator_view_); | 878 AddChildView(bookmarks_separator_view_); |
893 | 879 |
894 instructions_ = new views::Label( | 880 instructions_ = new views::Label( |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
930 | 916 |
931 // Make visible as necessary. | 917 // Make visible as necessary. |
932 button->SetVisible(false); | 918 button->SetVisible(false); |
933 // Set accessibility name. | 919 // Set accessibility name. |
934 button->SetAccessibleName( | 920 button->SetAccessibleName( |
935 l10n_util::GetString(IDS_ACCNAME_BOOKMARKS_CHEVRON)); | 921 l10n_util::GetString(IDS_ACCNAME_BOOKMARKS_CHEVRON)); |
936 return button; | 922 return button; |
937 } | 923 } |
938 | 924 |
939 int BookmarkBarView::GetBookmarkButtonCount() { | 925 int BookmarkBarView::GetBookmarkButtonCount() { |
940 #if defined(BROWSER_SYNC) | |
941 // We contain at least four non-bookmark button views: other bookmarks, | 926 // We contain at least four non-bookmark button views: other bookmarks, |
942 // bookmarks separator, chevrons (for overflow), the instruction label and | 927 // bookmarks separator, chevrons (for overflow), the instruction label and |
943 // the sync error button. | 928 // the sync error button. |
944 return GetChildViewCount() - 5; | 929 return GetChildViewCount() - 5; |
945 #else | |
946 // We contain at least four non-bookmark button views: other bookmarks, | |
947 // bookmarks separator, chevrons (for overflow) and the instruction label. | |
948 return GetChildViewCount() - 4; | |
949 #endif | |
950 } | 930 } |
951 | 931 |
952 void BookmarkBarView::Loaded(BookmarkModel* model) { | 932 void BookmarkBarView::Loaded(BookmarkModel* model) { |
953 const BookmarkNode* node = model_->GetBookmarkBarNode(); | 933 const BookmarkNode* node = model_->GetBookmarkBarNode(); |
954 DCHECK(node && model_->other_node()); | 934 DCHECK(node && model_->other_node()); |
955 // Create a button for each of the children on the bookmark bar. | 935 // Create a button for each of the children on the bookmark bar. |
956 for (int i = 0, child_count = node->GetChildCount(); i < child_count; ++i) | 936 for (int i = 0, child_count = node->GetChildCount(); i < child_count; ++i) |
957 AddChildView(i, CreateBookmarkButton(node->GetChild(i))); | 937 AddChildView(i, CreateBookmarkButton(node->GetChild(i))); |
958 UpdateColors(); | 938 UpdateColors(); |
959 other_bookmarked_button_->SetEnabled(true); | 939 other_bookmarked_button_->SetEnabled(true); |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1154 | 1134 |
1155 bookmark_menu_ = new BookmarkMenuController( | 1135 bookmark_menu_ = new BookmarkMenuController( |
1156 browser_, profile_, page_navigator_, GetWindow()->GetNativeWindow(), | 1136 browser_, profile_, page_navigator_, GetWindow()->GetNativeWindow(), |
1157 node, start_index, false); | 1137 node, start_index, false); |
1158 bookmark_menu_->set_observer(this); | 1138 bookmark_menu_->set_observer(this); |
1159 bookmark_menu_->RunMenuAt(this, false); | 1139 bookmark_menu_->RunMenuAt(this, false); |
1160 } | 1140 } |
1161 | 1141 |
1162 void BookmarkBarView::ButtonPressed(views::Button* sender, | 1142 void BookmarkBarView::ButtonPressed(views::Button* sender, |
1163 const views::Event& event) { | 1143 const views::Event& event) { |
1164 #if defined(BROWSER_SYNC) | |
1165 // Show the login wizard if the user clicked the re-login button. | 1144 // Show the login wizard if the user clicked the re-login button. |
1166 if (sender->tag() == kSyncErrorButtonTag) { | 1145 if (sender->tag() == kSyncErrorButtonTag) { |
1167 DCHECK(sender == sync_error_button_); | 1146 DCHECK(sender == sync_error_button_); |
1168 DCHECK(sync_service_); | 1147 DCHECK(sync_service_); |
1169 sync_service_->ShowLoginDialog(); | 1148 sync_service_->ShowLoginDialog(); |
1170 return; | 1149 return; |
1171 } | 1150 } |
1172 #endif | |
1173 | 1151 |
1174 const BookmarkNode* node; | 1152 const BookmarkNode* node; |
1175 if (sender->tag() == kOtherFolderButtonTag) { | 1153 if (sender->tag() == kOtherFolderButtonTag) { |
1176 node = model_->other_node(); | 1154 node = model_->other_node(); |
1177 } else { | 1155 } else { |
1178 int index = GetChildIndex(sender); | 1156 int index = GetChildIndex(sender); |
1179 DCHECK_NE(-1, index); | 1157 DCHECK_NE(-1, index); |
1180 node = model_->GetBookmarkBarNode()->GetChild(index); | 1158 node = model_->GetBookmarkBarNode()->GetChild(index); |
1181 } | 1159 } |
1182 DCHECK(page_navigator_); | 1160 DCHECK(page_navigator_); |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1585 (kSeparatorMargin) * current_state); | 1563 (kSeparatorMargin) * current_state); |
1586 } | 1564 } |
1587 | 1565 |
1588 gfx::Size other_bookmarked_pref = | 1566 gfx::Size other_bookmarked_pref = |
1589 other_bookmarked_button_->GetPreferredSize(); | 1567 other_bookmarked_button_->GetPreferredSize(); |
1590 gfx::Size overflow_pref = overflow_button_->GetPreferredSize(); | 1568 gfx::Size overflow_pref = overflow_button_->GetPreferredSize(); |
1591 gfx::Size bookmarks_separator_pref = | 1569 gfx::Size bookmarks_separator_pref = |
1592 bookmarks_separator_view_->GetPreferredSize(); | 1570 bookmarks_separator_view_->GetPreferredSize(); |
1593 | 1571 |
1594 int sync_error_total_width = 0; | 1572 int sync_error_total_width = 0; |
1595 #if defined(BROWSER_SYNC) | |
1596 gfx::Size sync_error_button_pref = sync_error_button_->GetPreferredSize(); | 1573 gfx::Size sync_error_button_pref = sync_error_button_->GetPreferredSize(); |
1597 const bool should_show_sync_error_button = ShouldShowSyncErrorButton(); | 1574 const bool should_show_sync_error_button = ShouldShowSyncErrorButton(); |
1598 if (should_show_sync_error_button) { | 1575 if (should_show_sync_error_button) { |
1599 sync_error_total_width += kButtonPadding + sync_error_button_pref.width(); | 1576 sync_error_total_width += kButtonPadding + sync_error_button_pref.width(); |
1600 } | 1577 } |
1601 #endif | |
1602 const int max_x = width - other_bookmarked_pref.width() - kButtonPadding - | 1578 const int max_x = width - other_bookmarked_pref.width() - kButtonPadding - |
1603 overflow_pref.width() - kButtonPadding - | 1579 overflow_pref.width() - kButtonPadding - |
1604 bookmarks_separator_pref.width() - sync_error_total_width; | 1580 bookmarks_separator_pref.width() - sync_error_total_width; |
1605 | 1581 |
1606 // Next, layout out the buttons. Any buttons that are placed beyond the | 1582 // Next, layout out the buttons. Any buttons that are placed beyond the |
1607 // visible region and made invisible. | 1583 // visible region and made invisible. |
1608 if (GetBookmarkButtonCount() == 0 && model_ && model_->IsLoaded()) { | 1584 if (GetBookmarkButtonCount() == 0 && model_ && model_->IsLoaded()) { |
1609 gfx::Size pref = instructions_->GetPreferredSize(); | 1585 gfx::Size pref = instructions_->GetPreferredSize(); |
1610 if (!compute_bounds_only) { | 1586 if (!compute_bounds_only) { |
1611 instructions_->SetBounds( | 1587 instructions_->SetBounds( |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1660 | 1636 |
1661 x += bookmarks_separator_pref.width(); | 1637 x += bookmarks_separator_pref.width(); |
1662 | 1638 |
1663 // The other bookmarks button. | 1639 // The other bookmarks button. |
1664 if (!compute_bounds_only) { | 1640 if (!compute_bounds_only) { |
1665 other_bookmarked_button_->SetBounds(x, y, other_bookmarked_pref.width(), | 1641 other_bookmarked_button_->SetBounds(x, y, other_bookmarked_pref.width(), |
1666 height); | 1642 height); |
1667 } | 1643 } |
1668 x += other_bookmarked_pref.width() + kButtonPadding; | 1644 x += other_bookmarked_pref.width() + kButtonPadding; |
1669 | 1645 |
1670 #if defined(BROWSER_SYNC) | |
1671 // Set the real bounds of the sync error button only if it needs to appear on | 1646 // Set the real bounds of the sync error button only if it needs to appear on |
1672 // the bookmarks bar. | 1647 // the bookmarks bar. |
1673 if (should_show_sync_error_button) { | 1648 if (should_show_sync_error_button) { |
1674 x += kButtonPadding; | 1649 x += kButtonPadding; |
1675 if (!compute_bounds_only) { | 1650 if (!compute_bounds_only) { |
1676 sync_error_button_->SetBounds( | 1651 sync_error_button_->SetBounds( |
1677 x, y, sync_error_button_pref.width(), height); | 1652 x, y, sync_error_button_pref.width(), height); |
1678 sync_error_button_->SetVisible(true); | 1653 sync_error_button_->SetVisible(true); |
1679 } | 1654 } |
1680 x += sync_error_button_pref.width(); | 1655 x += sync_error_button_pref.width(); |
1681 } else if (!compute_bounds_only) { | 1656 } else if (!compute_bounds_only) { |
1682 sync_error_button_->SetBounds(x, y, 0, height); | 1657 sync_error_button_->SetBounds(x, y, 0, height); |
1683 sync_error_button_->SetVisible(false); | 1658 sync_error_button_->SetVisible(false); |
1684 } | 1659 } |
1685 #endif // defined(BROWSER_SYNC) | |
1686 | 1660 |
1687 // Set the preferred size computed so far. | 1661 // Set the preferred size computed so far. |
1688 if (compute_bounds_only) { | 1662 if (compute_bounds_only) { |
1689 x += kRightMargin; | 1663 x += kRightMargin; |
1690 prefsize.set_width(x); | 1664 prefsize.set_width(x); |
1691 if (OnNewTabPage()) { | 1665 if (OnNewTabPage()) { |
1692 x += static_cast<int>(static_cast<double>(kNewtabHorizontalPadding) * | 1666 x += static_cast<int>(static_cast<double>(kNewtabHorizontalPadding) * |
1693 (1 - size_animation_->GetCurrentValue())); | 1667 (1 - size_animation_->GetCurrentValue())); |
1694 prefsize.set_height(kBarHeight + static_cast<int>(static_cast<double> | 1668 prefsize.set_height(kBarHeight + static_cast<int>(static_cast<double> |
1695 (kNewtabBarHeight - kBarHeight) * | 1669 (kNewtabBarHeight - kBarHeight) * |
1696 (1 - size_animation_->GetCurrentValue()))); | 1670 (1 - size_animation_->GetCurrentValue()))); |
1697 } else { | 1671 } else { |
1698 prefsize.set_height(static_cast<int>(static_cast<double>(kBarHeight) * | 1672 prefsize.set_height(static_cast<int>(static_cast<double>(kBarHeight) * |
1699 size_animation_->GetCurrentValue())); | 1673 size_animation_->GetCurrentValue())); |
1700 } | 1674 } |
1701 } | 1675 } |
1702 return prefsize; | 1676 return prefsize; |
1703 } | 1677 } |
1704 | 1678 |
1705 #if defined(BROWSER_SYNC) | |
1706 // The sync state reported by the profile sync service determines whether or | 1679 // The sync state reported by the profile sync service determines whether or |
1707 // not the re-login indicator button should be visible. | 1680 // not the re-login indicator button should be visible. |
1708 bool BookmarkBarView::ShouldShowSyncErrorButton() { | 1681 bool BookmarkBarView::ShouldShowSyncErrorButton() { |
1709 bool show_sync_error_button(false); | 1682 bool show_sync_error_button(false); |
1710 if (sync_service_ && sync_service_->HasSyncSetupCompleted()) { | 1683 if (sync_service_ && sync_service_->HasSyncSetupCompleted()) { |
1711 string16 status_text; | 1684 string16 status_text; |
1712 string16 link_text; | 1685 string16 link_text; |
1713 SyncStatusUIHelper::MessageType sync_status; | 1686 SyncStatusUIHelper::MessageType sync_status; |
1714 sync_status = SyncStatusUIHelper::GetLabels( | 1687 sync_status = SyncStatusUIHelper::GetLabels( |
1715 sync_service_, &status_text, &link_text); | 1688 sync_service_, &status_text, &link_text); |
(...skipping 13 matching lines...) Expand all Loading... |
1729 // The tooltip is the only way we have to display text explaining the error | 1702 // The tooltip is the only way we have to display text explaining the error |
1730 // to the user. | 1703 // to the user. |
1731 sync_error_button->SetTooltipText( | 1704 sync_error_button->SetTooltipText( |
1732 l10n_util::GetString(IDS_SYNC_BOOKMARK_BAR_ERROR_DESC)); | 1705 l10n_util::GetString(IDS_SYNC_BOOKMARK_BAR_ERROR_DESC)); |
1733 sync_error_button->SetAccessibleName( | 1706 sync_error_button->SetAccessibleName( |
1734 l10n_util::GetString(IDS_ACCNAME_SYNC_ERROR_BUTTON)); | 1707 l10n_util::GetString(IDS_ACCNAME_SYNC_ERROR_BUTTON)); |
1735 sync_error_button->SetIcon( | 1708 sync_error_button->SetIcon( |
1736 *ResourceBundle::GetSharedInstance().GetBitmapNamed(IDR_WARNING)); | 1709 *ResourceBundle::GetSharedInstance().GetBitmapNamed(IDR_WARNING)); |
1737 return sync_error_button; | 1710 return sync_error_button; |
1738 } | 1711 } |
1739 #endif // defined(BROWSER_SYNC) | |
OLD | NEW |