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

Side by Side Diff: ash/launcher/launcher_view.cc

Issue 16979002: Add ContextMenuSourceType to views::ContextMenuController::ShowContextMenuForView. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix win build Created 7 years, 6 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/launcher/launcher_view.h" 5 #include "ash/launcher/launcher_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 1498 matching lines...) Expand 10 before | Expand all | Expand 10 after
1509 1509
1510 // Make sure we have a menu and it has at least two items in addition to the 1510 // Make sure we have a menu and it has at least two items in addition to the
1511 // application title and the 3 spacing separators. 1511 // application title and the 3 spacing separators.
1512 if (!menu_model.get() || menu_model->GetItemCount() <= 5) 1512 if (!menu_model.get() || menu_model->GetItemCount() <= 5)
1513 return false; 1513 return false;
1514 1514
1515 ShowMenu(scoped_ptr<views::MenuModelAdapter>( 1515 ShowMenu(scoped_ptr<views::MenuModelAdapter>(
1516 new LauncherMenuModelAdapter(menu_model.get())), 1516 new LauncherMenuModelAdapter(menu_model.get())),
1517 source, 1517 source,
1518 gfx::Point(), 1518 gfx::Point(),
1519 false); 1519 false,
1520 ui::MENU_SOURCE_NONE);
sky 2013/06/17 16:08:19 This can be invoked from touch or keyboard.
varunjain 2013/06/17 20:13:55 Done.
1520 return true; 1521 return true;
1521 } 1522 }
1522 1523
1523 void LauncherView::ShowContextMenuForView(views::View* source, 1524 void LauncherView::ShowContextMenuForView(views::View* source,
1524 const gfx::Point& point) { 1525 const gfx::Point& point,
1526 ui:: MenuSourceType source_type) {
1525 int view_index = view_model_->GetIndexOfView(source); 1527 int view_index = view_model_->GetIndexOfView(source);
1526 if (view_index != -1 && 1528 if (view_index != -1 &&
1527 model_->items()[view_index].type == TYPE_APP_LIST) { 1529 model_->items()[view_index].type == TYPE_APP_LIST) {
1528 view_index = -1; 1530 view_index = -1;
1529 } 1531 }
1530 1532
1531 tooltip_->Close(); 1533 tooltip_->Close();
1532 1534
1533 if (view_index == -1) { 1535 if (view_index == -1) {
1534 Shell::GetInstance()->ShowContextMenu(point); 1536 Shell::GetInstance()->ShowContextMenu(point, source_type);
1535 return; 1537 return;
1536 } 1538 }
1537 scoped_ptr<ui::MenuModel> menu_model(delegate_->CreateContextMenu( 1539 scoped_ptr<ui::MenuModel> menu_model(delegate_->CreateContextMenu(
1538 model_->items()[view_index], 1540 model_->items()[view_index],
1539 source->GetWidget()->GetNativeView()->GetRootWindow())); 1541 source->GetWidget()->GetNativeView()->GetRootWindow()));
1540 if (!menu_model) 1542 if (!menu_model)
1541 return; 1543 return;
1542 base::AutoReset<LauncherID> reseter( 1544 base::AutoReset<LauncherID> reseter(
1543 &context_menu_id_, 1545 &context_menu_id_,
1544 view_index == -1 ? 0 : model_->items()[view_index].id); 1546 view_index == -1 ? 0 : model_->items()[view_index].id);
1545 1547
1546 ShowMenu(scoped_ptr<views::MenuModelAdapter>( 1548 ShowMenu(scoped_ptr<views::MenuModelAdapter>(
1547 new views::MenuModelAdapter(menu_model.get())), 1549 new views::MenuModelAdapter(menu_model.get())),
1548 source, 1550 source,
1549 point, 1551 point,
1550 true); 1552 true,
1553 source_type);
1551 } 1554 }
1552 1555
1553 void LauncherView::ShowMenu( 1556 void LauncherView::ShowMenu(
1554 scoped_ptr<views::MenuModelAdapter> menu_model_adapter, 1557 scoped_ptr<views::MenuModelAdapter> menu_model_adapter,
1555 views::View* source, 1558 views::View* source,
1556 const gfx::Point& click_point, 1559 const gfx::Point& click_point,
1557 bool context_menu) { 1560 bool context_menu,
1561 ui::MenuSourceType source_type) {
1558 closing_event_time_ = base::TimeDelta(); 1562 closing_event_time_ = base::TimeDelta();
1559 launcher_menu_runner_.reset( 1563 launcher_menu_runner_.reset(
1560 new views::MenuRunner(menu_model_adapter->CreateMenu())); 1564 new views::MenuRunner(menu_model_adapter->CreateMenu()));
1561 1565
1562 // Determine the menu alignment dependent on the shelf. 1566 // Determine the menu alignment dependent on the shelf.
1563 views::MenuItemView::AnchorPosition menu_alignment = 1567 views::MenuItemView::AnchorPosition menu_alignment =
1564 views::MenuItemView::TOPLEFT; 1568 views::MenuItemView::TOPLEFT;
1565 gfx::Rect anchor_point = gfx::Rect(click_point, gfx::Size()); 1569 gfx::Rect anchor_point = gfx::Rect(click_point, gfx::Size());
1566 1570
1567 ShelfWidget* shelf = RootWindowController::ForLauncher( 1571 ShelfWidget* shelf = RootWindowController::ForLauncher(
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1605 got_deleted_ = &got_deleted; 1609 got_deleted_ = &got_deleted;
1606 1610
1607 shelf->ForceUndimming(true); 1611 shelf->ForceUndimming(true);
1608 // NOTE: if you convert to HAS_MNEMONICS be sure and update menu building 1612 // NOTE: if you convert to HAS_MNEMONICS be sure and update menu building
1609 // code. 1613 // code.
1610 if (launcher_menu_runner_->RunMenuAt( 1614 if (launcher_menu_runner_->RunMenuAt(
1611 source->GetWidget(), 1615 source->GetWidget(),
1612 NULL, 1616 NULL,
1613 anchor_point, 1617 anchor_point,
1614 menu_alignment, 1618 menu_alignment,
1615 views::MenuRunner::CONTEXT_MENU) == views::MenuRunner::MENU_DELETED) { 1619 source_type,
1620 context_menu ? views::MenuRunner::CONTEXT_MENU : 0) ==
1621 views::MenuRunner::MENU_DELETED) {
1616 if (!got_deleted) { 1622 if (!got_deleted) {
1617 got_deleted_ = NULL; 1623 got_deleted_ = NULL;
1618 shelf->ForceUndimming(false); 1624 shelf->ForceUndimming(false);
1619 } 1625 }
1620 return; 1626 return;
1621 } 1627 }
1622 got_deleted_ = NULL; 1628 got_deleted_ = NULL;
1623 shelf->ForceUndimming(false); 1629 shelf->ForceUndimming(false);
1624 1630
1625 // Unpinning an item will reset the |launcher_menu_runner_| before coming 1631 // Unpinning an item will reset the |launcher_menu_runner_| before coming
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1661 bool LauncherView::ShouldShowTooltipForView(const views::View* view) const { 1667 bool LauncherView::ShouldShowTooltipForView(const views::View* view) const {
1662 if (view == GetAppListButtonView() && 1668 if (view == GetAppListButtonView() &&
1663 Shell::GetInstance()->GetAppListWindow()) 1669 Shell::GetInstance()->GetAppListWindow())
1664 return false; 1670 return false;
1665 const LauncherItem* item = LauncherItemForView(view); 1671 const LauncherItem* item = LauncherItemForView(view);
1666 return (!item || delegate_->ShouldShowTooltip(*item)); 1672 return (!item || delegate_->ShouldShowTooltip(*item));
1667 } 1673 }
1668 1674
1669 } // namespace internal 1675 } // namespace internal
1670 } // namespace ash 1676 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698