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_action_manager.h" | 10 #include "chrome/browser/extensions/extension_action_manager.h" |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 | 174 |
175 void BrowserActionOverflowMenuController::DropMenuClosed( | 175 void BrowserActionOverflowMenuController::DropMenuClosed( |
176 views::MenuItemView* menu) { | 176 views::MenuItemView* menu) { |
177 delete this; | 177 delete this; |
178 } | 178 } |
179 | 179 |
180 bool BrowserActionOverflowMenuController::GetDropFormats( | 180 bool BrowserActionOverflowMenuController::GetDropFormats( |
181 views::MenuItemView* menu, | 181 views::MenuItemView* menu, |
182 int* formats, | 182 int* formats, |
183 std::set<OSExchangeData::CustomFormat>* custom_formats) { | 183 std::set<OSExchangeData::CustomFormat>* custom_formats) { |
184 custom_formats->insert(BrowserActionDragData::GetBrowserActionCustomFormat()); | 184 return BrowserActionDragData::GetDropFormats(custom_formats); |
185 return true; | |
186 } | 185 } |
187 | 186 |
188 bool BrowserActionOverflowMenuController::AreDropTypesRequired( | 187 bool BrowserActionOverflowMenuController::AreDropTypesRequired( |
189 views::MenuItemView* menu) { | 188 views::MenuItemView* menu) { |
190 return true; | 189 return BrowserActionDragData::AreDropTypesRequired(); |
191 } | 190 } |
192 | 191 |
193 bool BrowserActionOverflowMenuController::CanDrop( | 192 bool BrowserActionOverflowMenuController::CanDrop( |
194 views::MenuItemView* menu, const OSExchangeData& data) { | 193 views::MenuItemView* menu, const OSExchangeData& data) { |
195 BrowserActionDragData drop_data; | 194 return BrowserActionDragData::CanDrop(data, owner_->profile()); |
196 if (!drop_data.Read(data)) | |
197 return false; | |
198 return drop_data.IsFromProfile(owner_->profile()); | |
199 } | 195 } |
200 | 196 |
201 int BrowserActionOverflowMenuController::GetDropOperation( | 197 int BrowserActionOverflowMenuController::GetDropOperation( |
202 views::MenuItemView* item, | 198 views::MenuItemView* item, |
203 const ui::DropTargetEvent& event, | 199 const ui::DropTargetEvent& event, |
204 DropPosition* position) { | 200 DropPosition* position) { |
205 // Don't allow dropping from the BrowserActionContainer into slot 0 of the | 201 // Don't allow dropping from the BrowserActionContainer into slot 0 of the |
206 // overflow menu since once the move has taken place the item you are dragging | 202 // overflow menu since once the move has taken place the item you are dragging |
207 // falls right out of the menu again once the user releases the button | 203 // falls right out of the menu again once the user releases the button |
208 // (because we don't shrink the BrowserActionContainer when you do this). | 204 // (because we don't shrink the BrowserActionContainer when you do this). |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 | 259 |
264 BrowserActionView* BrowserActionOverflowMenuController::ViewForId( | 260 BrowserActionView* BrowserActionOverflowMenuController::ViewForId( |
265 int id, size_t* index) { | 261 int id, size_t* index) { |
266 // The index of the view being dragged (GetCommand gives a 1-based index into | 262 // The index of the view being dragged (GetCommand gives a 1-based index into |
267 // the overflow menu). | 263 // the overflow menu). |
268 size_t view_index = owner_->VisibleBrowserActions() + id - 1; | 264 size_t view_index = owner_->VisibleBrowserActions() + id - 1; |
269 if (index) | 265 if (index) |
270 *index = view_index; | 266 *index = view_index; |
271 return owner_->GetBrowserActionViewAt(view_index); | 267 return owner_->GetBrowserActionViewAt(view_index); |
272 } | 268 } |
OLD | NEW |