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

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

Issue 1922683003: Make old task manager tests work against new task manager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix OSX function call namespace Created 4 years, 7 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
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 "chrome/browser/task_manager/task_manager.h" 5 #include "chrome/browser/task_manager/task_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 class TaskManagerView : public views::ButtonListener, 146 class TaskManagerView : public views::ButtonListener,
147 public views::DialogDelegateView, 147 public views::DialogDelegateView,
148 public views::TableViewObserver, 148 public views::TableViewObserver,
149 public views::ContextMenuController, 149 public views::ContextMenuController,
150 public ui::SimpleMenuModel::Delegate { 150 public ui::SimpleMenuModel::Delegate {
151 public: 151 public:
152 TaskManagerView(); 152 TaskManagerView();
153 ~TaskManagerView() override; 153 ~TaskManagerView() override;
154 154
155 // Shows the Task Manager window, or re-activates an existing one. 155 // Shows the Task Manager window, or re-activates an existing one.
156 static void Show(Browser* browser); 156 static ui::TableModel* Show(Browser* browser);
157 157
158 // Hides the Task Manager if it is showing. 158 // Hides the Task Manager if it is showing.
159 static void Hide(); 159 static void Hide();
160 160
161 // views::View: 161 // views::View:
162 void Layout() override; 162 void Layout() override;
163 gfx::Size GetPreferredSize() const override; 163 gfx::Size GetPreferredSize() const override;
164 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; 164 bool AcceleratorPressed(const ui::Accelerator& accelerator) override;
165 void ViewHierarchyChanged( 165 void ViewHierarchyChanged(
166 const ViewHierarchyChangedDetails& details) override; 166 const ViewHierarchyChangedDetails& details) override;
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 } 416 }
417 417
418 bool TaskManagerView::AcceleratorPressed(const ui::Accelerator& accelerator) { 418 bool TaskManagerView::AcceleratorPressed(const ui::Accelerator& accelerator) {
419 DCHECK_EQ(ui::VKEY_W, accelerator.key_code()); 419 DCHECK_EQ(ui::VKEY_W, accelerator.key_code());
420 DCHECK_EQ(ui::EF_CONTROL_DOWN, accelerator.modifiers()); 420 DCHECK_EQ(ui::EF_CONTROL_DOWN, accelerator.modifiers());
421 GetWidget()->Close(); 421 GetWidget()->Close();
422 return true; 422 return true;
423 } 423 }
424 424
425 // static 425 // static
426 void TaskManagerView::Show(Browser* browser) { 426 ui::TableModel* TaskManagerView::Show(Browser* browser) {
427 if (instance_) { 427 if (instance_) {
428 // If there's a Task manager window open already, just activate it. 428 // If there's a Task manager window open already, just activate it.
429 instance_->GetWidget()->Activate(); 429 instance_->GetWidget()->Activate();
430 return; 430 return instance_->table_model_.get();
431 } 431 }
432 instance_ = new TaskManagerView(); 432 instance_ = new TaskManagerView();
433 gfx::NativeWindow window = 433 gfx::NativeWindow window =
434 browser ? browser->window()->GetNativeWindow() : NULL; 434 browser ? browser->window()->GetNativeWindow() : NULL;
435 #if defined(USE_ASH) 435 #if defined(USE_ASH)
436 if (!window) 436 if (!window)
437 window = ash::wm::GetActiveWindow(); 437 window = ash::wm::GetActiveWindow();
438 #endif 438 #endif
439 DialogDelegate::CreateDialogWidget(instance_, window, NULL); 439 DialogDelegate::CreateDialogWidget(instance_, window, NULL);
440 instance_->InitAlwaysOnTopState(); 440 instance_->InitAlwaysOnTopState();
(...skipping 14 matching lines...) Expand all
455 // Set the initial focus to the list of tasks. 455 // Set the initial focus to the list of tasks.
456 views::FocusManager* focus_manager = instance_->GetFocusManager(); 456 views::FocusManager* focus_manager = instance_->GetFocusManager();
457 if (focus_manager) 457 if (focus_manager)
458 focus_manager->SetFocusedView(instance_->tab_table_); 458 focus_manager->SetFocusedView(instance_->tab_table_);
459 459
460 #if defined(USE_ASH) 460 #if defined(USE_ASH)
461 gfx::NativeWindow native_window = instance_->GetWidget()->GetNativeWindow(); 461 gfx::NativeWindow native_window = instance_->GetWidget()->GetNativeWindow();
462 ash::SetShelfItemDetailsForDialogWindow( 462 ash::SetShelfItemDetailsForDialogWindow(
463 native_window, IDR_ASH_SHELF_ICON_TASK_MANAGER, native_window->title()); 463 native_window, IDR_ASH_SHELF_ICON_TASK_MANAGER, native_window->title());
464 #endif 464 #endif
465 return instance_->table_model_.get();
465 } 466 }
466 467
467 // static 468 // static
468 void TaskManagerView::Hide() { 469 void TaskManagerView::Hide() {
469 if (instance_) 470 if (instance_)
470 instance_->GetWidget()->Close(); 471 instance_->GetWidget()->Close();
471 } 472 }
472 473
473 // ButtonListener implementation. 474 // ButtonListener implementation.
474 void TaskManagerView::ButtonPressed( 475 void TaskManagerView::ButtonPressed(
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 g_browser_process->local_state()->GetDictionary(GetWindowName()); 607 g_browser_process->local_state()->GetDictionary(GetWindowName());
607 return dictionary && 608 return dictionary &&
608 dictionary->GetBoolean("always_on_top", always_on_top) && always_on_top; 609 dictionary->GetBoolean("always_on_top", always_on_top) && always_on_top;
609 } 610 }
610 611
611 } // namespace 612 } // namespace
612 613
613 namespace chrome { 614 namespace chrome {
614 615
615 // Declared in browser_dialogs.h so others don't need to depend on our header. 616 // Declared in browser_dialogs.h so others don't need to depend on our header.
616 void ShowTaskManager(Browser* browser) { 617 ui::TableModel* ShowTaskManager(Browser* browser) {
617 if (switches::NewTaskManagerEnabled()) { 618 if (switches::NewTaskManagerEnabled()) {
618 task_management::NewTaskManagerView::Show(browser); 619 return task_management::NewTaskManagerView::Show(browser);
619 return;
620 } 620 }
621 621
622 TaskManagerView::Show(browser); 622 return TaskManagerView::Show(browser);
623 } 623 }
624 624
625 void HideTaskManager() { 625 void HideTaskManager() {
626 if (switches::NewTaskManagerEnabled()) { 626 if (switches::NewTaskManagerEnabled()) {
627 task_management::NewTaskManagerView::Hide(); 627 task_management::NewTaskManagerView::Hide();
628 return; 628 return;
629 } 629 }
630 630
631 TaskManagerView::Hide(); 631 TaskManagerView::Hide();
632 } 632 }
633 633
634 } // namespace chrome 634 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698