| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 1323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1334 } | 1334 } |
| 1335 | 1335 |
| 1336 void BookmarkBarView::WriteDragDataForView(View* sender, | 1336 void BookmarkBarView::WriteDragDataForView(View* sender, |
| 1337 const gfx::Point& press_pt, | 1337 const gfx::Point& press_pt, |
| 1338 ui::OSExchangeData* data) { | 1338 ui::OSExchangeData* data) { |
| 1339 content::RecordAction(UserMetricsAction("BookmarkBar_DragButton")); | 1339 content::RecordAction(UserMetricsAction("BookmarkBar_DragButton")); |
| 1340 | 1340 |
| 1341 for (int i = 0; i < GetBookmarkButtonCount(); ++i) { | 1341 for (int i = 0; i < GetBookmarkButtonCount(); ++i) { |
| 1342 if (sender == GetBookmarkButton(i)) { | 1342 if (sender == GetBookmarkButton(i)) { |
| 1343 const BookmarkNode* node = model_->bookmark_bar_node()->GetChild(i); | 1343 const BookmarkNode* node = model_->bookmark_bar_node()->GetChild(i); |
| 1344 const gfx::ImageSkia* icon = nullptr; | 1344 gfx::ImageSkia icon; |
| 1345 if (node->is_url()) { | 1345 if (node->is_url()) { |
| 1346 const gfx::Image& image = model_->GetFavicon(node); | 1346 const gfx::Image& image = model_->GetFavicon(node); |
| 1347 icon = image.IsEmpty() ? GetImageSkiaNamed(IDR_DEFAULT_FAVICON) | 1347 icon = image.IsEmpty() ? *GetImageSkiaNamed(IDR_DEFAULT_FAVICON) |
| 1348 : image.ToImageSkia(); | 1348 : image.AsImageSkia(); |
| 1349 } else { | 1349 } else { |
| 1350 icon = GetImageSkiaNamed(IDR_BOOKMARK_BAR_FOLDER); | 1350 icon = chrome::GetBookmarkFolderIcon(); |
| 1351 } | 1351 } |
| 1352 | 1352 |
| 1353 button_drag_utils::SetDragImage(node->url(), | 1353 button_drag_utils::SetDragImage(node->url(), node->GetTitle(), icon, |
| 1354 node->GetTitle(), | 1354 &press_pt, data, |
| 1355 *icon, | |
| 1356 &press_pt, | |
| 1357 data, | |
| 1358 GetBookmarkButton(i)->GetWidget()); | 1355 GetBookmarkButton(i)->GetWidget()); |
| 1359 WriteBookmarkDragData(node, data); | 1356 WriteBookmarkDragData(node, data); |
| 1360 return; | 1357 return; |
| 1361 } | 1358 } |
| 1362 } | 1359 } |
| 1363 NOTREACHED(); | 1360 NOTREACHED(); |
| 1364 } | 1361 } |
| 1365 | 1362 |
| 1366 int BookmarkBarView::GetDragOperationsForView(View* sender, | 1363 int BookmarkBarView::GetDragOperationsForView(View* sender, |
| 1367 const gfx::Point& p) { | 1364 const gfx::Point& p) { |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1616 } | 1613 } |
| 1617 return bb_count; | 1614 return bb_count; |
| 1618 } | 1615 } |
| 1619 | 1616 |
| 1620 MenuButton* BookmarkBarView::CreateOtherBookmarksButton() { | 1617 MenuButton* BookmarkBarView::CreateOtherBookmarksButton() { |
| 1621 // Title is set in Loaded. | 1618 // Title is set in Loaded. |
| 1622 MenuButton* button = | 1619 MenuButton* button = |
| 1623 new BookmarkFolderButton(this, base::string16(), this, false); | 1620 new BookmarkFolderButton(this, base::string16(), this, false); |
| 1624 button->set_id(VIEW_ID_OTHER_BOOKMARKS); | 1621 button->set_id(VIEW_ID_OTHER_BOOKMARKS); |
| 1625 button->SetImage(views::Button::STATE_NORMAL, | 1622 button->SetImage(views::Button::STATE_NORMAL, |
| 1626 *GetImageSkiaNamed(IDR_BOOKMARK_BAR_FOLDER)); | 1623 chrome::GetBookmarkFolderIcon()); |
| 1627 button->set_context_menu_controller(this); | 1624 button->set_context_menu_controller(this); |
| 1628 button->set_tag(kOtherFolderButtonTag); | 1625 button->set_tag(kOtherFolderButtonTag); |
| 1629 return button; | 1626 return button; |
| 1630 } | 1627 } |
| 1631 | 1628 |
| 1632 MenuButton* BookmarkBarView::CreateManagedBookmarksButton() { | 1629 MenuButton* BookmarkBarView::CreateManagedBookmarksButton() { |
| 1633 // Title is set in Loaded. | 1630 // Title is set in Loaded. |
| 1634 MenuButton* button = | 1631 MenuButton* button = |
| 1635 new BookmarkFolderButton(this, base::string16(), this, false); | 1632 new BookmarkFolderButton(this, base::string16(), this, false); |
| 1636 button->set_id(VIEW_ID_MANAGED_BOOKMARKS); | 1633 button->set_id(VIEW_ID_MANAGED_BOOKMARKS); |
| 1637 button->SetImage(views::Button::STATE_NORMAL, | 1634 button->SetImage(views::Button::STATE_NORMAL, |
| 1638 *GetImageSkiaNamed(IDR_BOOKMARK_BAR_FOLDER_MANAGED)); | 1635 chrome::GetBookmarkManagedFolderIcon()); |
| 1639 button->set_context_menu_controller(this); | 1636 button->set_context_menu_controller(this); |
| 1640 button->set_tag(kManagedFolderButtonTag); | 1637 button->set_tag(kManagedFolderButtonTag); |
| 1641 return button; | 1638 return button; |
| 1642 } | 1639 } |
| 1643 | 1640 |
| 1644 MenuButton* BookmarkBarView::CreateSupervisedBookmarksButton() { | 1641 MenuButton* BookmarkBarView::CreateSupervisedBookmarksButton() { |
| 1645 // Title is set in Loaded. | 1642 // Title is set in Loaded. |
| 1646 MenuButton* button = | 1643 MenuButton* button = |
| 1647 new BookmarkFolderButton(this, base::string16(), this, false); | 1644 new BookmarkFolderButton(this, base::string16(), this, false); |
| 1648 button->set_id(VIEW_ID_SUPERVISED_BOOKMARKS); | 1645 button->set_id(VIEW_ID_SUPERVISED_BOOKMARKS); |
| 1649 button->SetImage(views::Button::STATE_NORMAL, | 1646 button->SetImage(views::Button::STATE_NORMAL, |
| 1650 *GetImageSkiaNamed(IDR_BOOKMARK_BAR_FOLDER_SUPERVISED)); | 1647 chrome::GetBookmarkSupervisedFolderIcon()); |
| 1651 button->set_context_menu_controller(this); | 1648 button->set_context_menu_controller(this); |
| 1652 button->set_tag(kSupervisedFolderButtonTag); | 1649 button->set_tag(kSupervisedFolderButtonTag); |
| 1653 return button; | 1650 return button; |
| 1654 } | 1651 } |
| 1655 | 1652 |
| 1656 MenuButton* BookmarkBarView::CreateOverflowButton() { | 1653 MenuButton* BookmarkBarView::CreateOverflowButton() { |
| 1657 MenuButton* button = new OverFlowButton(this); | 1654 MenuButton* button = new OverFlowButton(this); |
| 1658 button->SetImage(views::Button::STATE_NORMAL, | 1655 button->SetImage(views::Button::STATE_NORMAL, |
| 1659 *GetImageSkiaNamed(IDR_BOOKMARK_BAR_CHEVRONS)); | 1656 *GetImageSkiaNamed(IDR_BOOKMARK_BAR_CHEVRONS)); |
| 1660 | 1657 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1678 views::View* BookmarkBarView::CreateBookmarkButton(const BookmarkNode* node) { | 1675 views::View* BookmarkBarView::CreateBookmarkButton(const BookmarkNode* node) { |
| 1679 if (node->is_url()) { | 1676 if (node->is_url()) { |
| 1680 BookmarkButton* button = new BookmarkButton( | 1677 BookmarkButton* button = new BookmarkButton( |
| 1681 this, node->url(), node->GetTitle(), browser_->profile()); | 1678 this, node->url(), node->GetTitle(), browser_->profile()); |
| 1682 ConfigureButton(node, button); | 1679 ConfigureButton(node, button); |
| 1683 return button; | 1680 return button; |
| 1684 } | 1681 } |
| 1685 views::MenuButton* button = | 1682 views::MenuButton* button = |
| 1686 new BookmarkFolderButton(this, node->GetTitle(), this, false); | 1683 new BookmarkFolderButton(this, node->GetTitle(), this, false); |
| 1687 button->SetImage(views::Button::STATE_NORMAL, | 1684 button->SetImage(views::Button::STATE_NORMAL, |
| 1688 *GetImageSkiaNamed(IDR_BOOKMARK_BAR_FOLDER)); | 1685 chrome::GetBookmarkFolderIcon()); |
| 1689 ConfigureButton(node, button); | 1686 ConfigureButton(node, button); |
| 1690 return button; | 1687 return button; |
| 1691 } | 1688 } |
| 1692 | 1689 |
| 1693 views::LabelButton* BookmarkBarView::CreateAppsPageShortcutButton() { | 1690 views::LabelButton* BookmarkBarView::CreateAppsPageShortcutButton() { |
| 1694 views::LabelButton* button = new ShortcutButton( | 1691 views::LabelButton* button = new ShortcutButton( |
| 1695 this, l10n_util::GetStringUTF16(IDS_BOOKMARK_BAR_APPS_SHORTCUT_NAME)); | 1692 this, l10n_util::GetStringUTF16(IDS_BOOKMARK_BAR_APPS_SHORTCUT_NAME)); |
| 1696 button->SetTooltipText(l10n_util::GetStringUTF16( | 1693 button->SetTooltipText(l10n_util::GetStringUTF16( |
| 1697 IDS_BOOKMARK_BAR_APPS_SHORTCUT_TOOLTIP)); | 1694 IDS_BOOKMARK_BAR_APPS_SHORTCUT_TOOLTIP)); |
| 1698 button->set_id(VIEW_ID_BOOKMARK_BAR_ELEMENT); | 1695 button->set_id(VIEW_ID_BOOKMARK_BAR_ELEMENT); |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2074 return; | 2071 return; |
| 2075 apps_page_shortcut_->SetVisible(visible); | 2072 apps_page_shortcut_->SetVisible(visible); |
| 2076 UpdateBookmarksSeparatorVisibility(); | 2073 UpdateBookmarksSeparatorVisibility(); |
| 2077 LayoutAndPaint(); | 2074 LayoutAndPaint(); |
| 2078 } | 2075 } |
| 2079 | 2076 |
| 2080 void BookmarkBarView::OnShowManagedBookmarksPrefChanged() { | 2077 void BookmarkBarView::OnShowManagedBookmarksPrefChanged() { |
| 2081 if (UpdateOtherAndManagedButtonsVisibility()) | 2078 if (UpdateOtherAndManagedButtonsVisibility()) |
| 2082 LayoutAndPaint(); | 2079 LayoutAndPaint(); |
| 2083 } | 2080 } |
| OLD | NEW |