OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ui/app_list/views/search_result_tile_item_view.h" | 5 #include "ui/app_list/views/search_result_tile_item_view.h" |
6 | 6 |
7 #include "ui/app_list/app_list_view_delegate.h" | 7 #include "ui/app_list/app_list_view_delegate.h" |
8 #include "ui/app_list/search_result.h" | 8 #include "ui/app_list/search_result.h" |
9 #include "ui/app_list/views/search_result_container_view.h" | 9 #include "ui/app_list/views/search_result_container_view.h" |
10 #include "ui/views/controls/menu/menu_runner.h" | 10 #include "ui/views/controls/menu/menu_runner.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 } | 69 } |
70 | 70 |
71 return false; | 71 return false; |
72 } | 72 } |
73 | 73 |
74 void SearchResultTileItemView::OnIconChanged() { | 74 void SearchResultTileItemView::OnIconChanged() { |
75 SetIcon(item_->icon()); | 75 SetIcon(item_->icon()); |
76 } | 76 } |
77 | 77 |
78 void SearchResultTileItemView::OnResultDestroying() { | 78 void SearchResultTileItemView::OnResultDestroying() { |
| 79 // The menu comes from |item_|. If we're showing a menu we need to cancel it. |
| 80 context_menu_runner_.reset(); |
| 81 |
79 if (item_) | 82 if (item_) |
80 item_->RemoveObserver(this); | 83 item_->RemoveObserver(this); |
81 item_ = NULL; | 84 item_ = NULL; |
82 } | 85 } |
83 | 86 |
84 void SearchResultTileItemView::ShowContextMenuForView( | 87 void SearchResultTileItemView::ShowContextMenuForView( |
85 views::View* source, | 88 views::View* source, |
86 const gfx::Point& point, | 89 const gfx::Point& point, |
87 ui::MenuSourceType source_type) { | 90 ui::MenuSourceType source_type) { |
88 // |item_| could be null when result list is changing. | 91 // |item_| could be null when result list is changing. |
(...skipping 12 matching lines...) Expand all Loading... |
101 // If RunMenuAt() fails, return immediately. This is future-proofing for | 104 // If RunMenuAt() fails, return immediately. This is future-proofing for |
102 // adding code after this call. | 105 // adding code after this call. |
103 if (context_menu_runner_->RunMenuAt( | 106 if (context_menu_runner_->RunMenuAt( |
104 GetWidget(), nullptr, gfx::Rect(point, gfx::Size()), | 107 GetWidget(), nullptr, gfx::Rect(point, gfx::Size()), |
105 views::MENU_ANCHOR_TOPLEFT, | 108 views::MENU_ANCHOR_TOPLEFT, |
106 source_type) == views::MenuRunner::MENU_DELETED) | 109 source_type) == views::MenuRunner::MENU_DELETED) |
107 return; | 110 return; |
108 } | 111 } |
109 | 112 |
110 } // namespace app_list | 113 } // namespace app_list |
OLD | NEW |