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/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/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/browser/extensions/extension_action.h" | 9 #include "chrome/browser/extensions/extension_action.h" |
10 #include "chrome/browser/extensions/extension_context_menu_model.h" | 10 #include "chrome/browser/extensions/extension_context_menu_model.h" |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 extensions::ExtensionRegistry::Get(browser_->profile())-> | 232 extensions::ExtensionRegistry::Get(browser_->profile())-> |
233 enabled_extensions().GetByID(drop_data.id()); | 233 enabled_extensions().GetByID(drop_data.id()); |
234 extensions::ExtensionToolbarModel* toolbar_model = | 234 extensions::ExtensionToolbarModel* toolbar_model = |
235 extensions::ExtensionToolbarModel::Get(browser_->profile()); | 235 extensions::ExtensionToolbarModel::Get(browser_->profile()); |
236 if (browser_->profile()->IsOffTheRecord()) | 236 if (browser_->profile()->IsOffTheRecord()) |
237 drop_index = toolbar_model->IncognitoIndexToOriginal(drop_index); | 237 drop_index = toolbar_model->IncognitoIndexToOriginal(drop_index); |
238 toolbar_model->MoveExtensionIcon(extension, drop_index); | 238 toolbar_model->MoveExtensionIcon(extension, drop_index); |
239 | 239 |
240 // If the extension was moved to the overflow menu from the main bar, notify | 240 // If the extension was moved to the overflow menu from the main bar, notify |
241 // the owner. | 241 // the owner. |
242 if (drop_index >= owner_->VisibleBrowserActions()) | 242 if (drop_data.index() < owner_->VisibleBrowserActions()) |
243 owner_->NotifyActionMovedToOverflow(); | 243 owner_->NotifyActionMovedToOverflow(); |
244 | 244 |
245 if (for_drop_) | 245 if (for_drop_) |
246 delete this; | 246 delete this; |
247 return ui::DragDropTypes::DRAG_MOVE; | 247 return ui::DragDropTypes::DRAG_MOVE; |
248 } | 248 } |
249 | 249 |
250 bool BrowserActionOverflowMenuController::CanDrag(views::MenuItemView* menu) { | 250 bool BrowserActionOverflowMenuController::CanDrag(views::MenuItemView* menu) { |
251 return true; | 251 return true; |
252 } | 252 } |
(...skipping 10 matching lines...) Expand all Loading... |
263 views::MenuItemView* sender) { | 263 views::MenuItemView* sender) { |
264 return ui::DragDropTypes::DRAG_MOVE; | 264 return ui::DragDropTypes::DRAG_MOVE; |
265 } | 265 } |
266 | 266 |
267 size_t BrowserActionOverflowMenuController::IndexForId(int id) const { | 267 size_t BrowserActionOverflowMenuController::IndexForId(int id) const { |
268 // The index of the view being dragged (GetCommand gives a 1-based index into | 268 // The index of the view being dragged (GetCommand gives a 1-based index into |
269 // the overflow menu). | 269 // the overflow menu). |
270 DCHECK_GT(owner_->VisibleBrowserActions() + id, 0u); | 270 DCHECK_GT(owner_->VisibleBrowserActions() + id, 0u); |
271 return owner_->VisibleBrowserActions() + id - 1; | 271 return owner_->VisibleBrowserActions() + id - 1; |
272 } | 272 } |
OLD | NEW |