| 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 "ash/shelf/shelf_view.h" | 5 #include "ash/shelf/shelf_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "ash/ash_constants.h" | 9 #include "ash/ash_constants.h" |
| 10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
| (...skipping 1697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1708 if (!item_delegate->ItemSelected(event)) | 1708 if (!item_delegate->ItemSelected(event)) |
| 1709 ShowListMenuForView(model_->items()[view_index], sender, event); | 1709 ShowListMenuForView(model_->items()[view_index], sender, event); |
| 1710 } | 1710 } |
| 1711 } | 1711 } |
| 1712 | 1712 |
| 1713 bool ShelfView::ShowListMenuForView(const ShelfItem& item, | 1713 bool ShelfView::ShowListMenuForView(const ShelfItem& item, |
| 1714 views::View* source, | 1714 views::View* source, |
| 1715 const ui::Event& event) { | 1715 const ui::Event& event) { |
| 1716 ShelfItemDelegate* item_delegate = | 1716 ShelfItemDelegate* item_delegate = |
| 1717 item_manager_->GetShelfItemDelegate(item.id); | 1717 item_manager_->GetShelfItemDelegate(item.id); |
| 1718 list_menu_model_.reset(item_delegate->CreateApplicationMenu(event.flags())); | 1718 scoped_ptr<ui::MenuModel> list_menu_model( |
| 1719 item_delegate->CreateApplicationMenu(event.flags())); |
| 1719 | 1720 |
| 1720 // Make sure we have a menu and it has at least two items in addition to the | 1721 // Make sure we have a menu and it has at least two items in addition to the |
| 1721 // application title and the 3 spacing separators. | 1722 // application title and the 3 spacing separators. |
| 1722 if (!list_menu_model_.get() || list_menu_model_->GetItemCount() <= 5) | 1723 if (!list_menu_model.get() || list_menu_model->GetItemCount() <= 5) |
| 1723 return false; | 1724 return false; |
| 1724 | 1725 |
| 1725 ShowMenu(list_menu_model_.get(), | 1726 ShowMenu(list_menu_model.get(), |
| 1726 source, | 1727 source, |
| 1727 gfx::Point(), | 1728 gfx::Point(), |
| 1728 false, | 1729 false, |
| 1729 ui::GetMenuSourceTypeForEvent(event)); | 1730 ui::GetMenuSourceTypeForEvent(event)); |
| 1730 return true; | 1731 return true; |
| 1731 } | 1732 } |
| 1732 | 1733 |
| 1733 void ShelfView::ShowContextMenuForView(views::View* source, | 1734 void ShelfView::ShowContextMenuForView(views::View* source, |
| 1734 const gfx::Point& point, | 1735 const gfx::Point& point, |
| 1735 ui::MenuSourceType source_type) { | 1736 ui::MenuSourceType source_type) { |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1917 distance = bounds.x() - coordinate.x(); | 1918 distance = bounds.x() - coordinate.x(); |
| 1918 break; | 1919 break; |
| 1919 case SHELF_ALIGNMENT_TOP: | 1920 case SHELF_ALIGNMENT_TOP: |
| 1920 distance = coordinate.y() - bounds.bottom(); | 1921 distance = coordinate.y() - bounds.bottom(); |
| 1921 break; | 1922 break; |
| 1922 } | 1923 } |
| 1923 return distance > 0 ? distance : 0; | 1924 return distance > 0 ? distance : 0; |
| 1924 } | 1925 } |
| 1925 | 1926 |
| 1926 } // namespace ash | 1927 } // namespace ash |
| OLD | NEW |