| 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/bookmarks/bookmark_menu_delegate.h" | 5 #include "chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.h" |
| 6 | 6 |
| 7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/bookmarks/bookmark_model.h" | 9 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 10 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 10 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 break; | 266 break; |
| 267 } | 267 } |
| 268 | 268 |
| 269 return chrome::DropBookmarks(profile_, drop_data_, | 269 return chrome::DropBookmarks(profile_, drop_data_, |
| 270 drop_parent, index_to_drop_at); | 270 drop_parent, index_to_drop_at); |
| 271 } | 271 } |
| 272 | 272 |
| 273 bool BookmarkMenuDelegate::ShowContextMenu(MenuItemView* source, | 273 bool BookmarkMenuDelegate::ShowContextMenu(MenuItemView* source, |
| 274 int id, | 274 int id, |
| 275 const gfx::Point& p, | 275 const gfx::Point& p, |
| 276 bool is_mouse_gesture) { | 276 ui::MenuSourceType source_type) { |
| 277 DCHECK(menu_id_to_node_map_.find(id) != menu_id_to_node_map_.end()); | 277 DCHECK(menu_id_to_node_map_.find(id) != menu_id_to_node_map_.end()); |
| 278 std::vector<const BookmarkNode*> nodes; | 278 std::vector<const BookmarkNode*> nodes; |
| 279 nodes.push_back(menu_id_to_node_map_[id]); | 279 nodes.push_back(menu_id_to_node_map_[id]); |
| 280 bool close_on_delete = !parent_menu_item_ && | 280 bool close_on_delete = !parent_menu_item_ && |
| 281 (nodes[0]->parent() == BookmarkModelFactory::GetForProfile( | 281 (nodes[0]->parent() == BookmarkModelFactory::GetForProfile( |
| 282 profile())->other_node() && | 282 profile())->other_node() && |
| 283 nodes[0]->parent()->child_count() == 1); | 283 nodes[0]->parent()->child_count() == 1); |
| 284 context_menu_.reset( | 284 context_menu_.reset( |
| 285 new BookmarkContextMenu( | 285 new BookmarkContextMenu( |
| 286 parent_, | 286 parent_, |
| 287 browser_, | 287 browser_, |
| 288 profile_, | 288 profile_, |
| 289 page_navigator_, | 289 page_navigator_, |
| 290 nodes[0]->parent(), | 290 nodes[0]->parent(), |
| 291 nodes, | 291 nodes, |
| 292 close_on_delete)); | 292 close_on_delete)); |
| 293 context_menu_->set_observer(this); | 293 context_menu_->set_observer(this); |
| 294 context_menu_->RunMenuAt(p); | 294 context_menu_->RunMenuAt(p, source_type); |
| 295 context_menu_.reset(NULL); | 295 context_menu_.reset(NULL); |
| 296 return true; | 296 return true; |
| 297 } | 297 } |
| 298 | 298 |
| 299 bool BookmarkMenuDelegate::CanDrag(MenuItemView* menu) { | 299 bool BookmarkMenuDelegate::CanDrag(MenuItemView* menu) { |
| 300 const BookmarkNode* node = menu_id_to_node_map_[menu->GetCommand()]; | 300 const BookmarkNode* node = menu_id_to_node_map_[menu->GetCommand()]; |
| 301 // Don't let users drag the other folder. | 301 // Don't let users drag the other folder. |
| 302 return node->parent() != BookmarkModelFactory::GetForProfile( | 302 return node->parent() != BookmarkModelFactory::GetForProfile( |
| 303 profile_)->root_node(); | 303 profile_)->root_node(); |
| 304 } | 304 } |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 gfx::ImageSkia* folder_icon = | 470 gfx::ImageSkia* folder_icon = |
| 471 rb.GetImageSkiaNamed(IDR_BOOKMARK_BAR_FOLDER); | 471 rb.GetImageSkiaNamed(IDR_BOOKMARK_BAR_FOLDER); |
| 472 MenuItemView* submenu = menu->AppendSubMenuWithIcon( | 472 MenuItemView* submenu = menu->AppendSubMenuWithIcon( |
| 473 id, node->GetTitle(), *folder_icon); | 473 id, node->GetTitle(), *folder_icon); |
| 474 BuildMenu(node, 0, submenu, next_menu_id); | 474 BuildMenu(node, 0, submenu, next_menu_id); |
| 475 } else { | 475 } else { |
| 476 NOTREACHED(); | 476 NOTREACHED(); |
| 477 } | 477 } |
| 478 } | 478 } |
| 479 } | 479 } |
| OLD | NEW |