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

Side by Side Diff: chrome/browser/ui/views/task_manager_view.cc

Issue 2253683003: Turn TaskManagerView Context Menu Async (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
« no previous file with comments | « chrome/browser/ui/views/task_manager_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "chrome/browser/ui/views/task_manager_view.h" 5 #include "chrome/browser/ui/views/task_manager_view.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 } 246 }
247 247
248 void TaskManagerView::OnKeyDown(ui::KeyboardCode keycode) { 248 void TaskManagerView::OnKeyDown(ui::KeyboardCode keycode) {
249 if (keycode == ui::VKEY_RETURN) 249 if (keycode == ui::VKEY_RETURN)
250 ActivateSelectedTab(); 250 ActivateSelectedTab();
251 } 251 }
252 252
253 void TaskManagerView::ShowContextMenuForView(views::View* source, 253 void TaskManagerView::ShowContextMenuForView(views::View* source,
254 const gfx::Point& point, 254 const gfx::Point& point,
255 ui::MenuSourceType source_type) { 255 ui::MenuSourceType source_type) {
256 ui::SimpleMenuModel menu_model(this); 256 menu_model_.reset(new ui::SimpleMenuModel(this));
257 257
258 for (const auto& table_column : columns_) { 258 for (const auto& table_column : columns_) {
259 menu_model.AddCheckItem(table_column.id, 259 menu_model_->AddCheckItem(table_column.id,
260 l10n_util::GetStringUTF16(table_column.id)); 260 l10n_util::GetStringUTF16(table_column.id));
261 } 261 }
262 262
263 menu_runner_.reset( 263 menu_runner_.reset(new views::MenuRunner(
264 new views::MenuRunner(&menu_model, views::MenuRunner::CONTEXT_MENU)); 264 menu_model_.get(),
265 views::MenuRunner::CONTEXT_MENU | views::MenuRunner::ASYNC));
265 266
266 if (menu_runner_->RunMenuAt(GetWidget(), nullptr, 267 menu_runner_->RunMenuAt(GetWidget(), nullptr, gfx::Rect(point, gfx::Size()),
267 gfx::Rect(point, gfx::Size()), 268 views::MENU_ANCHOR_TOPLEFT, source_type);
268 views::MENU_ANCHOR_TOPLEFT,
269 source_type) == views::MenuRunner::MENU_DELETED) {
270 return;
271 }
272 } 269 }
273 270
274 bool TaskManagerView::IsCommandIdChecked(int id) const { 271 bool TaskManagerView::IsCommandIdChecked(int id) const {
275 return tab_table_->IsColumnVisible(id); 272 return tab_table_->IsColumnVisible(id);
276 } 273 }
277 274
278 bool TaskManagerView::IsCommandIdEnabled(int id) const { 275 bool TaskManagerView::IsCommandIdEnabled(int id) const {
279 return true; 276 return true;
280 } 277 }
281 278
282 void TaskManagerView::ExecuteCommand(int id, int event_flags) { 279 void TaskManagerView::ExecuteCommand(int id, int event_flags) {
283 table_model_->ToggleColumnVisibility(id); 280 table_model_->ToggleColumnVisibility(id);
284 } 281 }
285 282
283 void TaskManagerView::MenuClosed(ui::SimpleMenuModel* source) {
284 if (source != menu_model_.get())
sky 2016/08/16 22:33:06 Is this check necessary?
jonross 2016/08/16 23:01:49 It does not appear to be actually needed. You can'
285 return;
286 menu_model_.reset();
287 menu_runner_.reset();
288 }
289
286 TaskManagerView::TaskManagerView() 290 TaskManagerView::TaskManagerView()
287 : tab_table_(nullptr), 291 : tab_table_(nullptr),
288 tab_table_parent_(nullptr), 292 tab_table_parent_(nullptr),
289 is_always_on_top_(false) { 293 is_always_on_top_(false) {
290 Init(); 294 Init();
291 } 295 }
292 296
293 // static 297 // static
294 TaskManagerView* TaskManagerView::GetInstanceForTests() { 298 TaskManagerView* TaskManagerView::GetInstanceForTests() {
295 return g_task_manager_view; 299 return g_task_manager_view;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 if (!g_browser_process->local_state()) 359 if (!g_browser_process->local_state())
356 return; 360 return;
357 361
358 const base::DictionaryValue* dictionary = 362 const base::DictionaryValue* dictionary =
359 g_browser_process->local_state()->GetDictionary(GetWindowName()); 363 g_browser_process->local_state()->GetDictionary(GetWindowName());
360 if (dictionary) 364 if (dictionary)
361 dictionary->GetBoolean("always_on_top", &is_always_on_top_); 365 dictionary->GetBoolean("always_on_top", &is_always_on_top_);
362 } 366 }
363 367
364 } // namespace task_manager 368 } // namespace task_manager
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/task_manager_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698