| 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/extensions/browser_action_overflow_menu_contro
ller.h" | 5 #include "chrome/browser/ui/views/extensions/browser_action_overflow_menu_contro
ller.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/browser_list.h" | 8 #include "chrome/browser/browser_list.h" |
| 9 #include "chrome/browser/extensions/extension_context_menu_model.h" | 9 #include "chrome/browser/extensions/extension_context_menu_model.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 int BrowserActionOverflowMenuController::GetDropOperation( | 141 int BrowserActionOverflowMenuController::GetDropOperation( |
| 142 views::MenuItemView* item, | 142 views::MenuItemView* item, |
| 143 const views::DropTargetEvent& event, | 143 const views::DropTargetEvent& event, |
| 144 DropPosition* position) { | 144 DropPosition* position) { |
| 145 // Don't allow dropping from the BrowserActionContainer into slot 0 of the | 145 // Don't allow dropping from the BrowserActionContainer into slot 0 of the |
| 146 // overflow menu since once the move has taken place the item you are dragging | 146 // overflow menu since once the move has taken place the item you are dragging |
| 147 // falls right out of the menu again once the user releases the button | 147 // falls right out of the menu again once the user releases the button |
| 148 // (because we don't shrink the BrowserActionContainer when you do this). | 148 // (because we don't shrink the BrowserActionContainer when you do this). |
| 149 if ((item->GetCommand() == 0) && (*position == DROP_BEFORE)) { | 149 if ((item->GetCommand() == 0) && (*position == DROP_BEFORE)) { |
| 150 BrowserActionDragData drop_data; | 150 BrowserActionDragData drop_data; |
| 151 if (!drop_data.Read(event.GetData())) | 151 if (!drop_data.Read(event.data())) |
| 152 return ui::DragDropTypes::DRAG_NONE; | 152 return ui::DragDropTypes::DRAG_NONE; |
| 153 | 153 |
| 154 if (drop_data.index() < owner_->VisibleBrowserActions()) | 154 if (drop_data.index() < owner_->VisibleBrowserActions()) |
| 155 return ui::DragDropTypes::DRAG_NONE; | 155 return ui::DragDropTypes::DRAG_NONE; |
| 156 } | 156 } |
| 157 | 157 |
| 158 return ui::DragDropTypes::DRAG_MOVE; | 158 return ui::DragDropTypes::DRAG_MOVE; |
| 159 } | 159 } |
| 160 | 160 |
| 161 int BrowserActionOverflowMenuController::OnPerformDrop( | 161 int BrowserActionOverflowMenuController::OnPerformDrop( |
| 162 views::MenuItemView* menu, | 162 views::MenuItemView* menu, |
| 163 DropPosition position, | 163 DropPosition position, |
| 164 const views::DropTargetEvent& event) { | 164 const views::DropTargetEvent& event) { |
| 165 BrowserActionDragData drop_data; | 165 BrowserActionDragData drop_data; |
| 166 if (!drop_data.Read(event.GetData())) | 166 if (!drop_data.Read(event.data())) |
| 167 return ui::DragDropTypes::DRAG_NONE; | 167 return ui::DragDropTypes::DRAG_NONE; |
| 168 | 168 |
| 169 size_t drop_index; | 169 size_t drop_index; |
| 170 ViewForId(menu->GetCommand(), &drop_index); | 170 ViewForId(menu->GetCommand(), &drop_index); |
| 171 | 171 |
| 172 // When not dragging within the overflow menu (dragging an icon into the menu) | 172 // When not dragging within the overflow menu (dragging an icon into the menu) |
| 173 // subtract one to get the right index. | 173 // subtract one to get the right index. |
| 174 if (position == DROP_BEFORE && | 174 if (position == DROP_BEFORE && |
| 175 drop_data.index() < owner_->VisibleBrowserActions()) | 175 drop_data.index() < owner_->VisibleBrowserActions()) |
| 176 --drop_index; | 176 --drop_index; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 203 | 203 |
| 204 BrowserActionView* BrowserActionOverflowMenuController::ViewForId( | 204 BrowserActionView* BrowserActionOverflowMenuController::ViewForId( |
| 205 int id, size_t* index) { | 205 int id, size_t* index) { |
| 206 // The index of the view being dragged (GetCommand gives a 1-based index into | 206 // The index of the view being dragged (GetCommand gives a 1-based index into |
| 207 // the overflow menu). | 207 // the overflow menu). |
| 208 size_t view_index = owner_->VisibleBrowserActions() + id - 1; | 208 size_t view_index = owner_->VisibleBrowserActions() + id - 1; |
| 209 if (index) | 209 if (index) |
| 210 *index = view_index; | 210 *index = view_index; |
| 211 return owner_->GetBrowserActionViewAt(view_index); | 211 return owner_->GetBrowserActionViewAt(view_index); |
| 212 } | 212 } |
| OLD | NEW |