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 1758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1769 return button; | 1769 return button; |
1770 } | 1770 } |
1771 | 1771 |
1772 void BookmarkBarView::ConfigureButton(const BookmarkNode* node, | 1772 void BookmarkBarView::ConfigureButton(const BookmarkNode* node, |
1773 views::LabelButton* button) { | 1773 views::LabelButton* button) { |
1774 button->SetText(node->GetTitle()); | 1774 button->SetText(node->GetTitle()); |
1775 button->SetAccessibleName(node->GetTitle()); | 1775 button->SetAccessibleName(node->GetTitle()); |
1776 button->set_id(VIEW_ID_BOOKMARK_BAR_ELEMENT); | 1776 button->set_id(VIEW_ID_BOOKMARK_BAR_ELEMENT); |
1777 // We don't always have a theme provider (ui tests, for example). | 1777 // We don't always have a theme provider (ui tests, for example). |
1778 if (GetThemeProvider()) { | 1778 if (GetThemeProvider()) { |
1779 SkColor color = | 1779 SkColor color = GetThemeProvider()->GetColor( |
1780 GetThemeProvider()->GetColor(ThemeProperties::COLOR_BOOKMARK_TEXT); | 1780 IsDetached() ? ThemeProperties::COLOR_NTP_TEXT |
| 1781 : ThemeProperties::COLOR_BOOKMARK_TEXT); |
1781 button->SetEnabledTextColors(color); | 1782 button->SetEnabledTextColors(color); |
1782 if (node->is_folder()) { | 1783 if (node->is_folder()) { |
1783 button->SetImage(views::Button::STATE_NORMAL, | 1784 button->SetImage(views::Button::STATE_NORMAL, |
1784 chrome::GetBookmarkFolderIcon(color)); | 1785 chrome::GetBookmarkFolderIcon(color)); |
1785 } | 1786 } |
1786 } | 1787 } |
1787 | 1788 |
1788 button->SetMinSize(gfx::Size()); | 1789 button->SetMinSize(gfx::Size()); |
1789 button->set_context_menu_controller(this); | 1790 button->set_context_menu_controller(this); |
1790 button->set_drag_controller(this); | 1791 button->set_drag_controller(this); |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2095 return supervised_bookmarks_button_; | 2096 return supervised_bookmarks_button_; |
2096 // Node wasn't on the bookmark bar, use the "Other Bookmarks" button. | 2097 // Node wasn't on the bookmark bar, use the "Other Bookmarks" button. |
2097 return other_bookmarks_button_; | 2098 return other_bookmarks_button_; |
2098 } | 2099 } |
2099 | 2100 |
2100 void BookmarkBarView::UpdateAppearanceForTheme() { | 2101 void BookmarkBarView::UpdateAppearanceForTheme() { |
2101 // We don't always have a theme provider (ui tests, for example). | 2102 // We don't always have a theme provider (ui tests, for example). |
2102 const ui::ThemeProvider* theme_provider = GetThemeProvider(); | 2103 const ui::ThemeProvider* theme_provider = GetThemeProvider(); |
2103 if (!theme_provider) | 2104 if (!theme_provider) |
2104 return; | 2105 return; |
2105 SkColor color = | 2106 SkColor color = theme_provider->GetColor( |
2106 theme_provider->GetColor(ThemeProperties::COLOR_BOOKMARK_TEXT); | 2107 IsDetached() ? ThemeProperties::COLOR_NTP_TEXT |
| 2108 : ThemeProperties::COLOR_BOOKMARK_TEXT); |
2107 for (int i = 0; i < GetBookmarkButtonCount(); ++i) { | 2109 for (int i = 0; i < GetBookmarkButtonCount(); ++i) { |
2108 ConfigureButton(model_->bookmark_bar_node()->GetChild(i), | 2110 ConfigureButton(model_->bookmark_bar_node()->GetChild(i), |
2109 GetBookmarkButton(i)); | 2111 GetBookmarkButton(i)); |
2110 } | 2112 } |
2111 other_bookmarks_button_->SetEnabledTextColors(color); | 2113 other_bookmarks_button_->SetEnabledTextColors(color); |
2112 other_bookmarks_button_->SetImage(views::Button::STATE_NORMAL, | 2114 other_bookmarks_button_->SetImage(views::Button::STATE_NORMAL, |
2113 chrome::GetBookmarkFolderIcon(color)); | 2115 chrome::GetBookmarkFolderIcon(color)); |
2114 managed_bookmarks_button_->SetEnabledTextColors(color); | 2116 managed_bookmarks_button_->SetEnabledTextColors(color); |
2115 managed_bookmarks_button_->SetImage( | 2117 managed_bookmarks_button_->SetImage( |
2116 views::Button::STATE_NORMAL, chrome::GetBookmarkManagedFolderIcon(color)); | 2118 views::Button::STATE_NORMAL, chrome::GetBookmarkManagedFolderIcon(color)); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2174 return; | 2176 return; |
2175 apps_page_shortcut_->SetVisible(visible); | 2177 apps_page_shortcut_->SetVisible(visible); |
2176 UpdateBookmarksSeparatorVisibility(); | 2178 UpdateBookmarksSeparatorVisibility(); |
2177 LayoutAndPaint(); | 2179 LayoutAndPaint(); |
2178 } | 2180 } |
2179 | 2181 |
2180 void BookmarkBarView::OnShowManagedBookmarksPrefChanged() { | 2182 void BookmarkBarView::OnShowManagedBookmarksPrefChanged() { |
2181 if (UpdateOtherAndManagedButtonsVisibility()) | 2183 if (UpdateOtherAndManagedButtonsVisibility()) |
2182 LayoutAndPaint(); | 2184 LayoutAndPaint(); |
2183 } | 2185 } |
OLD | NEW |