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

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

Issue 12712018: Fixing problem with incomplete browser windows showing up after task manager was used (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Refactored the ShowTaskManager function is requested Created 7 years, 9 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 | Annotate | Revision Log
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 "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
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
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 const chrome::HostDesktopType desktop_type =
539 browser ? browser->host_desktop_type() : chrome::HOST_DESKTOP_TYPE_ASH;
sky 2013/03/20 23:52:08 Document why browser == NULL is treated as ASH.
Mr4D (OOO till 08-26) 2013/03/21 00:20:10 Done.
535 540
536 if (instance_) { 541 if (instance_) {
537 if (instance_->highlight_background_resources_ != 542 if (instance_->highlight_background_resources_ !=
538 highlight_background_resources || 543 highlight_background_resources ||
539 instance_->desktop_type_ != desktop_type) { 544 instance_->desktop_type_ != desktop_type) {
540 instance_->GetWidget()->Close(); 545 instance_->GetWidget()->Close();
541 } else { 546 } else {
542 // If there's a Task manager window open already, just activate it. 547 // If there's a Task manager window open already, just activate it.
543 instance_->GetWidget()->Activate(); 548 instance_->GetWidget()->Activate();
544 return; 549 return;
545 } 550 }
546 } 551 }
547 instance_ = new TaskManagerView(highlight_background_resources, desktop_type); 552 instance_ = new TaskManagerView(highlight_background_resources, desktop_type);
548 DialogDelegateView::CreateDialogWidget(instance_, 553 aura::Window* window = browser ? browser->window()->GetNativeWindow() : NULL;
549 browser->window()->GetNativeWindow(), NULL); 554 #if defined(USE_ASH)
555 if (!window)
556 window = ash::wm::GetActiveWindow();
557 #endif
558 DialogDelegateView::CreateDialogWidget(instance_, window, NULL);
sky 2013/03/20 23:52:08 Can you verify this does the right thing if window
Mr4D (OOO till 08-26) 2013/03/21 00:20:10 I did already before checking in and it did not.
sky 2013/03/21 00:25:55 So then don't you need to deal with it being null
Mr4D (OOO till 08-26) 2013/03/21 00:29:30 You misunderstood - It did not cause any problems
550 instance_->InitAlwaysOnTopState(); 559 instance_->InitAlwaysOnTopState();
551 instance_->model_->StartUpdating(); 560 instance_->model_->StartUpdating();
552 instance_->GetWidget()->Show(); 561 instance_->GetWidget()->Show();
553 562
554 // Set the initial focus to the list of tasks. 563 // Set the initial focus to the list of tasks.
555 views::FocusManager* focus_manager = instance_->GetFocusManager(); 564 views::FocusManager* focus_manager = instance_->GetFocusManager();
556 if (focus_manager) 565 if (focus_manager)
557 focus_manager->SetFocusedView(instance_->tab_table_); 566 focus_manager->SetFocusedView(instance_->tab_table_);
558 } 567 }
559 568
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 g_browser_process->local_state()->GetDictionary(GetWindowName().c_str()); 765 g_browser_process->local_state()->GetDictionary(GetWindowName().c_str());
757 return dictionary && 766 return dictionary &&
758 dictionary->GetBoolean("always_on_top", always_on_top) && always_on_top; 767 dictionary->GetBoolean("always_on_top", always_on_top) && always_on_top;
759 } 768 }
760 769
761 } // namespace 770 } // namespace
762 771
763 namespace chrome { 772 namespace chrome {
764 773
765 // Declared in browser_dialogs.h so others don't need to depend on our header. 774 // Declared in browser_dialogs.h so others don't need to depend on our header.
766 void ShowTaskManager(Browser* browser) { 775 void ShowTaskManager(Browser* browser, bool highlight_background_resources) {
767 TaskManagerView::Show(false, browser); 776 TaskManagerView::Show(highlight_background_resources, browser);
768 }
769
770 void ShowBackgroundPages(Browser* browser) {
771 TaskManagerView::Show(true, browser);
772 } 777 }
773 778
774 } // namespace chrome 779 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698