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> |
(...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
908 AddChildView(sync_error_button_); | 908 AddChildView(sync_error_button_); |
909 | 909 |
910 overflow_button_ = CreateOverflowButton(); | 910 overflow_button_ = CreateOverflowButton(); |
911 AddChildView(overflow_button_); | 911 AddChildView(overflow_button_); |
912 | 912 |
913 other_bookmarked_button_ = CreateOtherBookmarkedButton(); | 913 other_bookmarked_button_ = CreateOtherBookmarkedButton(); |
914 AddChildView(other_bookmarked_button_); | 914 AddChildView(other_bookmarked_button_); |
915 | 915 |
916 bookmarks_separator_view_ = new ButtonSeparatorView(); | 916 bookmarks_separator_view_ = new ButtonSeparatorView(); |
917 bookmarks_separator_view_->SetAccessibleName( | 917 bookmarks_separator_view_->SetAccessibleName( |
918 UTF16ToWide(l10n_util::GetStringUTF16(IDS_ACCNAME_SEPARATOR))); | 918 l10n_util::GetStringUTF16(IDS_ACCNAME_SEPARATOR)); |
919 AddChildView(bookmarks_separator_view_); | 919 AddChildView(bookmarks_separator_view_); |
920 | 920 |
921 instructions_ = new BookmarkBarInstructionsView(this); | 921 instructions_ = new BookmarkBarInstructionsView(this); |
922 AddChildView(instructions_); | 922 AddChildView(instructions_); |
923 | 923 |
924 SetContextMenuController(this); | 924 SetContextMenuController(this); |
925 | 925 |
926 size_animation_.reset(new ui::SlideAnimation(this)); | 926 size_animation_.reset(new ui::SlideAnimation(this)); |
927 } | 927 } |
928 | 928 |
929 MenuButton* BookmarkBarView::CreateOtherBookmarkedButton() { | 929 MenuButton* BookmarkBarView::CreateOtherBookmarkedButton() { |
930 MenuButton* button = new BookmarkFolderButton( | 930 MenuButton* button = new BookmarkFolderButton( |
931 this, | 931 this, |
932 UTF16ToWide(l10n_util::GetStringUTF16(IDS_BOOMARK_BAR_OTHER_BOOKMARKED)), | 932 UTF16ToWide(l10n_util::GetStringUTF16(IDS_BOOMARK_BAR_OTHER_BOOKMARKED)), |
933 this, | 933 this, |
934 false); | 934 false); |
935 button->SetID(VIEW_ID_OTHER_BOOKMARKS); | 935 button->SetID(VIEW_ID_OTHER_BOOKMARKS); |
936 button->SetIcon(GetGroupIcon()); | 936 button->SetIcon(GetGroupIcon()); |
937 button->SetContextMenuController(this); | 937 button->SetContextMenuController(this); |
938 button->set_tag(kOtherFolderButtonTag); | 938 button->set_tag(kOtherFolderButtonTag); |
939 button->SetAccessibleName( | 939 button->SetAccessibleName( |
940 UTF16ToWide(l10n_util::GetStringUTF16(IDS_BOOMARK_BAR_OTHER_BOOKMARKED))); | 940 l10n_util::GetStringUTF16(IDS_BOOMARK_BAR_OTHER_BOOKMARKED)); |
941 return button; | 941 return button; |
942 } | 942 } |
943 | 943 |
944 MenuButton* BookmarkBarView::CreateOverflowButton() { | 944 MenuButton* BookmarkBarView::CreateOverflowButton() { |
945 MenuButton* button = new OverFlowButton(this); | 945 MenuButton* button = new OverFlowButton(this); |
946 button->SetIcon(*ResourceBundle::GetSharedInstance(). | 946 button->SetIcon(*ResourceBundle::GetSharedInstance(). |
947 GetBitmapNamed(IDR_BOOKMARK_BAR_CHEVRONS)); | 947 GetBitmapNamed(IDR_BOOKMARK_BAR_CHEVRONS)); |
948 | 948 |
949 // The overflow button's image contains an arrow and therefore it is a | 949 // The overflow button's image contains an arrow and therefore it is a |
950 // direction sensitive image and we need to flip it if the UI layout is | 950 // direction sensitive image and we need to flip it if the UI layout is |
951 // right-to-left. | 951 // right-to-left. |
952 // | 952 // |
953 // By default, menu buttons are not flipped because they generally contain | 953 // By default, menu buttons are not flipped because they generally contain |
954 // text and flipping the gfx::Canvas object will break text rendering. Since | 954 // text and flipping the gfx::Canvas object will break text rendering. Since |
955 // the overflow button does not contain text, we can safely flip it. | 955 // the overflow button does not contain text, we can safely flip it. |
956 button->EnableCanvasFlippingForRTLUI(true); | 956 button->EnableCanvasFlippingForRTLUI(true); |
957 | 957 |
958 // Make visible as necessary. | 958 // Make visible as necessary. |
959 button->SetVisible(false); | 959 button->SetVisible(false); |
960 // Set accessibility name. | 960 // Set accessibility name. |
961 button->SetAccessibleName( | 961 button->SetAccessibleName( |
962 UTF16ToWide(l10n_util::GetStringUTF16(IDS_ACCNAME_BOOKMARKS_CHEVRON))); | 962 l10n_util::GetStringUTF16(IDS_ACCNAME_BOOKMARKS_CHEVRON)); |
963 return button; | 963 return button; |
964 } | 964 } |
965 | 965 |
966 void BookmarkBarView::Loaded(BookmarkModel* model) { | 966 void BookmarkBarView::Loaded(BookmarkModel* model) { |
967 volatile int button_count = GetBookmarkButtonCount(); | 967 volatile int button_count = GetBookmarkButtonCount(); |
968 DCHECK(button_count == 0); // If non-zero it means Load was invoked more than | 968 DCHECK(button_count == 0); // If non-zero it means Load was invoked more than |
969 // once, or we didn't properly clear things. | 969 // once, or we didn't properly clear things. |
970 // Either of which shouldn't happen | 970 // Either of which shouldn't happen |
971 const BookmarkNode* node = model_->GetBookmarkBarNode(); | 971 const BookmarkNode* node = model_->GetBookmarkBarNode(); |
972 DCHECK(node && model_->other_node()); | 972 DCHECK(node && model_->other_node()); |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1281 UTF16ToWide(node->GetTitle()), this, false); | 1281 UTF16ToWide(node->GetTitle()), this, false); |
1282 button->SetIcon(GetGroupIcon()); | 1282 button->SetIcon(GetGroupIcon()); |
1283 ConfigureButton(node, button); | 1283 ConfigureButton(node, button); |
1284 return button; | 1284 return button; |
1285 } | 1285 } |
1286 } | 1286 } |
1287 | 1287 |
1288 void BookmarkBarView::ConfigureButton(const BookmarkNode* node, | 1288 void BookmarkBarView::ConfigureButton(const BookmarkNode* node, |
1289 views::TextButton* button) { | 1289 views::TextButton* button) { |
1290 button->SetText(UTF16ToWide(node->GetTitle())); | 1290 button->SetText(UTF16ToWide(node->GetTitle())); |
1291 button->SetAccessibleName(UTF16ToWide(node->GetTitle())); | 1291 button->SetAccessibleName(node->GetTitle()); |
1292 button->SetID(VIEW_ID_BOOKMARK_BAR_ELEMENT); | 1292 button->SetID(VIEW_ID_BOOKMARK_BAR_ELEMENT); |
1293 // We don't always have a theme provider (ui tests, for example). | 1293 // We don't always have a theme provider (ui tests, for example). |
1294 if (GetThemeProvider()) { | 1294 if (GetThemeProvider()) { |
1295 button->SetEnabledColor(GetThemeProvider()->GetColor( | 1295 button->SetEnabledColor(GetThemeProvider()->GetColor( |
1296 BrowserThemeProvider::COLOR_BOOKMARK_TEXT)); | 1296 BrowserThemeProvider::COLOR_BOOKMARK_TEXT)); |
1297 } | 1297 } |
1298 | 1298 |
1299 button->ClearMaxTextSize(); | 1299 button->ClearMaxTextSize(); |
1300 button->SetContextMenuController(this); | 1300 button->SetContextMenuController(this); |
1301 button->SetDragController(this); | 1301 button->SetDragController(this); |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1729 views::TextButton* sync_error_button = | 1729 views::TextButton* sync_error_button = |
1730 new views::TextButton(this, UTF16ToWide( | 1730 new views::TextButton(this, UTF16ToWide( |
1731 l10n_util::GetStringUTF16(IDS_SYNC_BOOKMARK_BAR_ERROR))); | 1731 l10n_util::GetStringUTF16(IDS_SYNC_BOOKMARK_BAR_ERROR))); |
1732 sync_error_button->set_tag(kSyncErrorButtonTag); | 1732 sync_error_button->set_tag(kSyncErrorButtonTag); |
1733 | 1733 |
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 UTF16ToWide(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 |