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 <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
(...skipping 1053 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1064 | 1064 |
1065 void BookmarkBarView::BookmarkNodeChildrenReordered(BookmarkModel* model, | 1065 void BookmarkBarView::BookmarkNodeChildrenReordered(BookmarkModel* model, |
1066 const BookmarkNode* node) { | 1066 const BookmarkNode* node) { |
1067 if (node != model_->bookmark_bar_node()) | 1067 if (node != model_->bookmark_bar_node()) |
1068 return; // We only care about reordering of the bookmark bar node. | 1068 return; // We only care about reordering of the bookmark bar node. |
1069 | 1069 |
1070 // Remove the existing buttons. | 1070 // Remove the existing buttons. |
1071 while (GetBookmarkButtonCount()) { | 1071 while (GetBookmarkButtonCount()) { |
1072 views::View* button = child_at(0); | 1072 views::View* button = child_at(0); |
1073 RemoveChildView(button); | 1073 RemoveChildView(button); |
1074 MessageLoop::current()->DeleteSoon(FROM_HERE, button); | 1074 base::MessageLoop::current()->DeleteSoon(FROM_HERE, button); |
1075 } | 1075 } |
1076 | 1076 |
1077 // Create the new buttons. | 1077 // Create the new buttons. |
1078 for (int i = 0, child_count = node->child_count(); i < child_count; ++i) | 1078 for (int i = 0, child_count = node->child_count(); i < child_count; ++i) |
1079 AddChildViewAt(CreateBookmarkButton(node->GetChild(i)), i); | 1079 AddChildViewAt(CreateBookmarkButton(node->GetChild(i)), i); |
1080 UpdateColors(); | 1080 UpdateColors(); |
1081 | 1081 |
1082 Layout(); | 1082 Layout(); |
1083 SchedulePaint(); | 1083 SchedulePaint(); |
1084 } | 1084 } |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1450 // No need to start throbbing again as the bookmark bubble can't be up at | 1450 // No need to start throbbing again as the bookmark bubble can't be up at |
1451 // the same time as the user reorders. | 1451 // the same time as the user reorders. |
1452 | 1452 |
1453 if (parent != model_->bookmark_bar_node()) { | 1453 if (parent != model_->bookmark_bar_node()) { |
1454 // We only care about nodes on the bookmark bar. | 1454 // We only care about nodes on the bookmark bar. |
1455 return; | 1455 return; |
1456 } | 1456 } |
1457 DCHECK(index >= 0 && index < GetBookmarkButtonCount()); | 1457 DCHECK(index >= 0 && index < GetBookmarkButtonCount()); |
1458 views::View* button = child_at(index); | 1458 views::View* button = child_at(index); |
1459 RemoveChildView(button); | 1459 RemoveChildView(button); |
1460 MessageLoop::current()->DeleteSoon(FROM_HERE, button); | 1460 base::MessageLoop::current()->DeleteSoon(FROM_HERE, button); |
1461 Layout(); | 1461 Layout(); |
1462 SchedulePaint(); | 1462 SchedulePaint(); |
1463 } | 1463 } |
1464 | 1464 |
1465 void BookmarkBarView::BookmarkNodeChangedImpl(BookmarkModel* model, | 1465 void BookmarkBarView::BookmarkNodeChangedImpl(BookmarkModel* model, |
1466 const BookmarkNode* node) { | 1466 const BookmarkNode* node) { |
1467 if (node->parent() != model_->bookmark_bar_node()) { | 1467 if (node->parent() != model_->bookmark_bar_node()) { |
1468 // We only care about nodes on the bookmark bar. | 1468 // We only care about nodes on the bookmark bar. |
1469 return; | 1469 return; |
1470 } | 1470 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1511 } | 1511 } |
1512 | 1512 |
1513 void BookmarkBarView::StartShowFolderDropMenuTimer(const BookmarkNode* node) { | 1513 void BookmarkBarView::StartShowFolderDropMenuTimer(const BookmarkNode* node) { |
1514 if (!animations_enabled) { | 1514 if (!animations_enabled) { |
1515 // So that tests can run as fast as possible disable the delay during | 1515 // So that tests can run as fast as possible disable the delay during |
1516 // testing. | 1516 // testing. |
1517 ShowDropFolderForNode(node); | 1517 ShowDropFolderForNode(node); |
1518 return; | 1518 return; |
1519 } | 1519 } |
1520 show_folder_method_factory_.InvalidateWeakPtrs(); | 1520 show_folder_method_factory_.InvalidateWeakPtrs(); |
1521 MessageLoop::current()->PostDelayedTask( | 1521 base::MessageLoop::current()->PostDelayedTask( |
1522 FROM_HERE, | 1522 FROM_HERE, |
1523 base::Bind(&BookmarkBarView::ShowDropFolderForNode, | 1523 base::Bind(&BookmarkBarView::ShowDropFolderForNode, |
1524 show_folder_method_factory_.GetWeakPtr(), | 1524 show_folder_method_factory_.GetWeakPtr(), |
1525 node), | 1525 node), |
1526 base::TimeDelta::FromMilliseconds(views::GetMenuShowDelay())); | 1526 base::TimeDelta::FromMilliseconds(views::GetMenuShowDelay())); |
1527 } | 1527 } |
1528 | 1528 |
1529 void BookmarkBarView::CalculateDropLocation(const DropTargetEvent& event, | 1529 void BookmarkBarView::CalculateDropLocation(const DropTargetEvent& event, |
1530 const BookmarkNodeData& data, | 1530 const BookmarkNodeData& data, |
1531 DropLocation* location) { | 1531 DropLocation* location) { |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1878 return; | 1878 return; |
1879 apps_page_shortcut_->SetVisible(visible); | 1879 apps_page_shortcut_->SetVisible(visible); |
1880 UpdateBookmarksSeparatorVisibility(); | 1880 UpdateBookmarksSeparatorVisibility(); |
1881 Layout(); | 1881 Layout(); |
1882 } | 1882 } |
1883 | 1883 |
1884 void BookmarkBarView::OnAppLauncherEnabledCompleted(bool app_launcher_enabled) { | 1884 void BookmarkBarView::OnAppLauncherEnabledCompleted(bool app_launcher_enabled) { |
1885 // Disregard |app_launcher_enabled|, use apps::WasAppLauncherEnable instead. | 1885 // Disregard |app_launcher_enabled|, use apps::WasAppLauncherEnable instead. |
1886 OnAppsPageShortcutVisibilityPrefChanged(); | 1886 OnAppsPageShortcutVisibilityPrefChanged(); |
1887 } | 1887 } |
OLD | NEW |