Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(285)

Side by Side Diff: chrome/browser/ui/views/extensions/browser_action_overflow_menu_controller.cc

Issue 6250014: Move more dnd related files to ui/base (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 views::MenuItemView* item, 138 views::MenuItemView* item,
139 const views::DropTargetEvent& event, 139 const views::DropTargetEvent& event,
140 DropPosition* position) { 140 DropPosition* position) {
141 // Don't allow dropping from the BrowserActionContainer into slot 0 of the 141 // Don't allow dropping from the BrowserActionContainer into slot 0 of the
142 // overflow menu since once the move has taken place the item you are dragging 142 // overflow menu since once the move has taken place the item you are dragging
143 // falls right out of the menu again once the user releases the button 143 // falls right out of the menu again once the user releases the button
144 // (because we don't shrink the BrowserActionContainer when you do this). 144 // (because we don't shrink the BrowserActionContainer when you do this).
145 if ((item->GetCommand() == 0) && (*position == DROP_BEFORE)) { 145 if ((item->GetCommand() == 0) && (*position == DROP_BEFORE)) {
146 BrowserActionDragData drop_data; 146 BrowserActionDragData drop_data;
147 if (!drop_data.Read(event.GetData())) 147 if (!drop_data.Read(event.GetData()))
148 return DragDropTypes::DRAG_NONE; 148 return ui::DragDropTypes::DRAG_NONE;
149 149
150 if (drop_data.index() < owner_->VisibleBrowserActions()) 150 if (drop_data.index() < owner_->VisibleBrowserActions())
151 return DragDropTypes::DRAG_NONE; 151 return ui::DragDropTypes::DRAG_NONE;
152 } 152 }
153 153
154 return DragDropTypes::DRAG_MOVE; 154 return ui::DragDropTypes::DRAG_MOVE;
155 } 155 }
156 156
157 int BrowserActionOverflowMenuController::OnPerformDrop( 157 int BrowserActionOverflowMenuController::OnPerformDrop(
158 views::MenuItemView* menu, 158 views::MenuItemView* menu,
159 DropPosition position, 159 DropPosition position,
160 const views::DropTargetEvent& event) { 160 const views::DropTargetEvent& event) {
161 BrowserActionDragData drop_data; 161 BrowserActionDragData drop_data;
162 if (!drop_data.Read(event.GetData())) 162 if (!drop_data.Read(event.GetData()))
163 return DragDropTypes::DRAG_NONE; 163 return ui::DragDropTypes::DRAG_NONE;
164 164
165 size_t drop_index; 165 size_t drop_index;
166 ViewForId(menu->GetCommand(), &drop_index); 166 ViewForId(menu->GetCommand(), &drop_index);
167 167
168 // When not dragging within the overflow menu (dragging an icon into the menu) 168 // When not dragging within the overflow menu (dragging an icon into the menu)
169 // subtract one to get the right index. 169 // subtract one to get the right index.
170 if (position == DROP_BEFORE && 170 if (position == DROP_BEFORE &&
171 drop_data.index() < owner_->VisibleBrowserActions()) 171 drop_data.index() < owner_->VisibleBrowserActions())
172 --drop_index; 172 --drop_index;
173 173
174 owner_->MoveBrowserAction(drop_data.id(), drop_index); 174 owner_->MoveBrowserAction(drop_data.id(), drop_index);
175 175
176 if (for_drop_) 176 if (for_drop_)
177 delete this; 177 delete this;
178 return DragDropTypes::DRAG_MOVE; 178 return ui::DragDropTypes::DRAG_MOVE;
179 } 179 }
180 180
181 bool BrowserActionOverflowMenuController::CanDrag(views::MenuItemView* menu) { 181 bool BrowserActionOverflowMenuController::CanDrag(views::MenuItemView* menu) {
182 return true; 182 return true;
183 } 183 }
184 184
185 void BrowserActionOverflowMenuController::WriteDragData( 185 void BrowserActionOverflowMenuController::WriteDragData(
186 views::MenuItemView* sender, OSExchangeData* data) { 186 views::MenuItemView* sender, OSExchangeData* data) {
187 size_t drag_index; 187 size_t drag_index;
188 BrowserActionView* view = ViewForId(sender->GetCommand(), &drag_index); 188 BrowserActionView* view = ViewForId(sender->GetCommand(), &drag_index);
189 std::string id = view->button()->extension()->id(); 189 std::string id = view->button()->extension()->id();
190 190
191 BrowserActionDragData drag_data(id, drag_index); 191 BrowserActionDragData drag_data(id, drag_index);
192 drag_data.Write(owner_->profile(), data); 192 drag_data.Write(owner_->profile(), data);
193 } 193 }
194 194
195 int BrowserActionOverflowMenuController::GetDragOperations( 195 int BrowserActionOverflowMenuController::GetDragOperations(
196 views::MenuItemView* sender) { 196 views::MenuItemView* sender) {
197 return DragDropTypes::DRAG_MOVE; 197 return ui::DragDropTypes::DRAG_MOVE;
198 } 198 }
199 199
200 BrowserActionView* BrowserActionOverflowMenuController::ViewForId( 200 BrowserActionView* BrowserActionOverflowMenuController::ViewForId(
201 int id, size_t* index) { 201 int id, size_t* index) {
202 // The index of the view being dragged (GetCommand gives a 1-based index into 202 // The index of the view being dragged (GetCommand gives a 1-based index into
203 // the overflow menu). 203 // the overflow menu).
204 size_t view_index = owner_->VisibleBrowserActions() + id - 1; 204 size_t view_index = owner_->VisibleBrowserActions() + id - 1;
205 if (index) 205 if (index)
206 *index = view_index; 206 *index = view_index;
207 return owner_->GetBrowserActionViewAt(view_index); 207 return owner_->GetBrowserActionViewAt(view_index);
208 } 208 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/browser_actions_container.cc ('k') | chrome/browser/ui/views/frame/browser_root_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698