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

Side by Side Diff: ash/shelf/shelf_view.cc

Issue 486193004: Ash: Fix browser icon menu model lifetime (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: (menu-leak) simplify Created 6 years, 4 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) 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
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
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
OLDNEW
« no previous file with comments | « ash/shelf/shelf_view.h ('k') | chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_browser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698