| 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/launcher/launcher_view.h" | 5 #include "ash/launcher/launcher_view.h" |
| 6 | 6 |
| 7 #include "ash/launcher/launcher_button.h" | 7 #include "ash/launcher/launcher_button.h" |
| 8 #include "ash/launcher/launcher_delegate.h" | 8 #include "ash/launcher/launcher_delegate.h" |
| 9 #include "ash/launcher/launcher_icon_observer.h" | 9 #include "ash/launcher/launcher_icon_observer.h" |
| 10 #include "ash/launcher/launcher_model.h" | 10 #include "ash/launcher/launcher_model.h" |
| (...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 886 } | 886 } |
| 887 } | 887 } |
| 888 | 888 |
| 889 void LauncherView::ShowContextMenuForView(views::View* source, | 889 void LauncherView::ShowContextMenuForView(views::View* source, |
| 890 const gfx::Point& point) { | 890 const gfx::Point& point) { |
| 891 if (!delegate_) | 891 if (!delegate_) |
| 892 return; | 892 return; |
| 893 | 893 |
| 894 int view_index = view_model_->GetIndexOfView(source); | 894 int view_index = view_model_->GetIndexOfView(source); |
| 895 if (view_index != -1 && | 895 if (view_index != -1 && |
| 896 (model_->items()[view_index].type == TYPE_BROWSER_SHORTCUT || | 896 model_->items()[view_index].type == TYPE_APP_LIST) { |
| 897 model_->items()[view_index].type == TYPE_APP_LIST)) { | |
| 898 view_index = -1; | 897 view_index = -1; |
| 899 } | 898 } |
| 900 #if !defined(OS_MACOSX) | 899 #if !defined(OS_MACOSX) |
| 901 scoped_ptr<ui::MenuModel> menu_model( | 900 scoped_ptr<ui::MenuModel> menu_model( |
| 902 view_index == -1 ? | 901 view_index == -1 ? |
| 903 delegate_->CreateContextMenuForLauncher() : | 902 delegate_->CreateContextMenuForLauncher() : |
| 904 delegate_->CreateContextMenu(model_->items()[view_index])); | 903 delegate_->CreateContextMenu(model_->items()[view_index])); |
| 905 if (!menu_model.get()) | 904 if (!menu_model.get()) |
| 906 return; | 905 return; |
| 907 AutoReset<LauncherID> reseter( | 906 AutoReset<LauncherID> reseter( |
| 908 &context_menu_id_, | 907 &context_menu_id_, |
| 909 view_index == -1 ? 0 : model_->items()[view_index].id); | 908 view_index == -1 ? 0 : model_->items()[view_index].id); |
| 910 views::MenuModelAdapter menu_model_adapter(menu_model.get()); | 909 views::MenuModelAdapter menu_model_adapter(menu_model.get()); |
| 911 launcher_menu_runner_.reset( | 910 launcher_menu_runner_.reset( |
| 912 new views::MenuRunner(menu_model_adapter.CreateMenu())); | 911 new views::MenuRunner(menu_model_adapter.CreateMenu())); |
| 913 // NOTE: if you convert to HAS_MNEMONICS be sure and update menu building | 912 // NOTE: if you convert to HAS_MNEMONICS be sure and update menu building |
| 914 // code. | 913 // code. |
| 915 if (launcher_menu_runner_->RunMenuAt( | 914 if (launcher_menu_runner_->RunMenuAt( |
| 916 source->GetWidget(), NULL, gfx::Rect(point, gfx::Size()), | 915 source->GetWidget(), NULL, gfx::Rect(point, gfx::Size()), |
| 917 views::MenuItemView::TOPLEFT, 0) == views::MenuRunner::MENU_DELETED) | 916 views::MenuItemView::TOPLEFT, 0) == views::MenuRunner::MENU_DELETED) |
| 918 return; | 917 return; |
| 919 | 918 |
| 920 Shell::GetInstance()->UpdateShelfVisibility(); | 919 Shell::GetInstance()->UpdateShelfVisibility(); |
| 921 #endif | 920 #endif |
| 922 } | 921 } |
| 923 | 922 |
| 924 } // namespace internal | 923 } // namespace internal |
| 925 } // namespace ash | 924 } // namespace ash |
| OLD | NEW |