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 "chrome/browser/task_manager/task_manager.h" | 5 #include "chrome/browser/task_manager/task_manager.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/metrics/stats_table.h" | 9 #include "base/metrics/stats_table.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 #include "ui/views/controls/menu/menu_model_adapter.h" | 37 #include "ui/views/controls/menu/menu_model_adapter.h" |
38 #include "ui/views/controls/menu/menu_runner.h" | 38 #include "ui/views/controls/menu/menu_runner.h" |
39 #include "ui/views/controls/table/table_grouper.h" | 39 #include "ui/views/controls/table/table_grouper.h" |
40 #include "ui/views/controls/table/table_view.h" | 40 #include "ui/views/controls/table/table_view.h" |
41 #include "ui/views/controls/table/table_view_observer.h" | 41 #include "ui/views/controls/table/table_view_observer.h" |
42 #include "ui/views/controls/table/table_view_row_background_painter.h" | 42 #include "ui/views/controls/table/table_view_row_background_painter.h" |
43 #include "ui/views/layout/layout_constants.h" | 43 #include "ui/views/layout/layout_constants.h" |
44 #include "ui/views/widget/widget.h" | 44 #include "ui/views/widget/widget.h" |
45 #include "ui/views/window/dialog_delegate.h" | 45 #include "ui/views/window/dialog_delegate.h" |
46 | 46 |
| 47 #if defined(USE_ASH) |
| 48 #include "ash/wm/window_util.h" |
| 49 #endif |
| 50 |
47 #if defined(OS_WIN) | 51 #if defined(OS_WIN) |
48 #include "win8/util/win8_util.h" | 52 #include "win8/util/win8_util.h" |
49 #endif | 53 #endif |
50 | 54 |
51 // Yellow highlight used when highlighting background resources. | 55 // Yellow highlight used when highlighting background resources. |
52 static const SkColor kBackgroundResourceHighlight = | 56 static const SkColor kBackgroundResourceHighlight = |
53 SkColorSetRGB(0xff, 0xf1, 0xcd); | 57 SkColorSetRGB(0xff, 0xf1, 0xcd); |
54 | 58 |
55 namespace { | 59 namespace { |
56 | 60 |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 return gfx::Size(460, 270); | 528 return gfx::Size(460, 270); |
525 } | 529 } |
526 | 530 |
527 // static | 531 // static |
528 void TaskManagerView::Show(bool highlight_background_resources, | 532 void TaskManagerView::Show(bool highlight_background_resources, |
529 Browser* browser) { | 533 Browser* browser) { |
530 #if defined(OS_WIN) | 534 #if defined(OS_WIN) |
531 // In Windows Metro it's not good to open this native window. | 535 // In Windows Metro it's not good to open this native window. |
532 DCHECK(!win8::IsSingleWindowMetroMode()); | 536 DCHECK(!win8::IsSingleWindowMetroMode()); |
533 #endif | 537 #endif |
534 const chrome::HostDesktopType desktop_type = browser->host_desktop_type(); | 538 // In ash we can come here through the ChromeShellDelegate. If there is no |
| 539 // browser window at that time of the call, browser could be passed as NULL. |
| 540 const chrome::HostDesktopType desktop_type = |
| 541 browser ? browser->host_desktop_type() : chrome::HOST_DESKTOP_TYPE_ASH; |
535 | 542 |
536 if (instance_) { | 543 if (instance_) { |
537 if (instance_->highlight_background_resources_ != | 544 if (instance_->highlight_background_resources_ != |
538 highlight_background_resources || | 545 highlight_background_resources || |
539 instance_->desktop_type_ != desktop_type) { | 546 instance_->desktop_type_ != desktop_type) { |
540 instance_->GetWidget()->Close(); | 547 instance_->GetWidget()->Close(); |
541 } else { | 548 } else { |
542 // If there's a Task manager window open already, just activate it. | 549 // If there's a Task manager window open already, just activate it. |
543 instance_->GetWidget()->Activate(); | 550 instance_->GetWidget()->Activate(); |
544 return; | 551 return; |
545 } | 552 } |
546 } | 553 } |
547 instance_ = new TaskManagerView(highlight_background_resources, desktop_type); | 554 instance_ = new TaskManagerView(highlight_background_resources, desktop_type); |
548 DialogDelegateView::CreateDialogWidget(instance_, | 555 gfx::NativeWindow window = |
549 browser->window()->GetNativeWindow(), NULL); | 556 browser ? browser->window()->GetNativeWindow() : NULL; |
| 557 #if defined(USE_ASH) |
| 558 if (!window) |
| 559 window = ash::wm::GetActiveWindow(); |
| 560 #endif |
| 561 DialogDelegateView::CreateDialogWidget(instance_, window, NULL); |
550 instance_->InitAlwaysOnTopState(); | 562 instance_->InitAlwaysOnTopState(); |
551 instance_->model_->StartUpdating(); | 563 instance_->model_->StartUpdating(); |
552 instance_->GetWidget()->Show(); | 564 instance_->GetWidget()->Show(); |
553 | 565 |
554 // Set the initial focus to the list of tasks. | 566 // Set the initial focus to the list of tasks. |
555 views::FocusManager* focus_manager = instance_->GetFocusManager(); | 567 views::FocusManager* focus_manager = instance_->GetFocusManager(); |
556 if (focus_manager) | 568 if (focus_manager) |
557 focus_manager->SetFocusedView(instance_->tab_table_); | 569 focus_manager->SetFocusedView(instance_->tab_table_); |
558 } | 570 } |
559 | 571 |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
756 g_browser_process->local_state()->GetDictionary(GetWindowName().c_str()); | 768 g_browser_process->local_state()->GetDictionary(GetWindowName().c_str()); |
757 return dictionary && | 769 return dictionary && |
758 dictionary->GetBoolean("always_on_top", always_on_top) && always_on_top; | 770 dictionary->GetBoolean("always_on_top", always_on_top) && always_on_top; |
759 } | 771 } |
760 | 772 |
761 } // namespace | 773 } // namespace |
762 | 774 |
763 namespace chrome { | 775 namespace chrome { |
764 | 776 |
765 // Declared in browser_dialogs.h so others don't need to depend on our header. | 777 // Declared in browser_dialogs.h so others don't need to depend on our header. |
766 void ShowTaskManager(Browser* browser) { | 778 void ShowTaskManager(Browser* browser, bool highlight_background_resources) { |
767 TaskManagerView::Show(false, browser); | 779 TaskManagerView::Show(highlight_background_resources, browser); |
768 } | |
769 | |
770 void ShowBackgroundPages(Browser* browser) { | |
771 TaskManagerView::Show(true, browser); | |
772 } | 780 } |
773 | 781 |
774 } // namespace chrome | 782 } // namespace chrome |
OLD | NEW |