OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/toolbar/extension_toolbar_menu_view.h" | 5 #include "chrome/browser/ui/views/toolbar/extension_toolbar_menu_view.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 // In the case of a drag-and-drop, the bounds of the container may have | 94 // In the case of a drag-and-drop, the bounds of the container may have |
95 // changed (in the case of removing an icon that was the last in a row). | 95 // changed (in the case of removing an icon that was the last in a row). |
96 Redraw(); | 96 Redraw(); |
97 | 97 |
98 // We need to close the app menu if it was just opened for the drag and drop, | 98 // We need to close the app menu if it was just opened for the drag and drop, |
99 // or if there are no more extensions in the overflow menu after a drag and | 99 // or if there are no more extensions in the overflow menu after a drag and |
100 // drop. | 100 // drop. |
101 if (app_menu_->for_drop() || | 101 if (app_menu_->for_drop() || |
102 container_->toolbar_actions_bar()->GetIconCount() == 0) { | 102 container_->toolbar_actions_bar()->GetIconCount() == 0) { |
103 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 103 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
104 FROM_HERE, base::Bind(&ExtensionToolbarMenuView::CloseAppMenu, | 104 FROM_HERE, |
105 weak_factory_.GetWeakPtr()), | 105 base::BindOnce(&ExtensionToolbarMenuView::CloseAppMenu, |
| 106 weak_factory_.GetWeakPtr()), |
106 base::TimeDelta::FromMilliseconds(g_close_menu_delay)); | 107 base::TimeDelta::FromMilliseconds(g_close_menu_delay)); |
107 } | 108 } |
108 } | 109 } |
109 | 110 |
110 void ExtensionToolbarMenuView::OnToolbarActionsBarDidStartResize() { | 111 void ExtensionToolbarMenuView::OnToolbarActionsBarDidStartResize() { |
111 Redraw(); | 112 Redraw(); |
112 } | 113 } |
113 | 114 |
114 void ExtensionToolbarMenuView::CloseAppMenu() { | 115 void ExtensionToolbarMenuView::CloseAppMenu() { |
115 app_menu_->CloseMenu(); | 116 app_menu_->CloseMenu(); |
(...skipping 11 matching lines...) Expand all Loading... |
127 } | 128 } |
128 | 129 |
129 int ExtensionToolbarMenuView::start_padding() const { | 130 int ExtensionToolbarMenuView::start_padding() const { |
130 // We pad enough on the left so that the first icon starts at the same point | 131 // We pad enough on the left so that the first icon starts at the same point |
131 // as the labels. We subtract kItemSpacing because there needs to be padding | 132 // as the labels. We subtract kItemSpacing because there needs to be padding |
132 // so we can see the drop indicator. | 133 // so we can see the drop indicator. |
133 return views::MenuItemView::label_start() - | 134 return views::MenuItemView::label_start() - |
134 container_->toolbar_actions_bar()->platform_settings().item_spacing; | 135 container_->toolbar_actions_bar()->platform_settings().item_spacing; |
135 } | 136 } |
136 | 137 |
OLD | NEW |