OLD | NEW |
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/new_task_manager_view.h" | 5 #include "chrome/browser/ui/views/new_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 29 matching lines...) Expand all Loading... |
40 #include "ui/views/win/hwnd_util.h" | 40 #include "ui/views/win/hwnd_util.h" |
41 #endif // defined(OS_WIN) | 41 #endif // defined(OS_WIN) |
42 | 42 |
43 namespace task_management { | 43 namespace task_management { |
44 | 44 |
45 namespace { | 45 namespace { |
46 | 46 |
47 NewTaskManagerView* g_task_manager_view = nullptr; | 47 NewTaskManagerView* g_task_manager_view = nullptr; |
48 | 48 |
49 // Opens the "about:memory" for the "stats for nerds" link. | 49 // Opens the "about:memory" for the "stats for nerds" link. |
50 void OpenAboutMemory(chrome::HostDesktopType desktop_type) { | 50 void OpenAboutMemory() { |
51 Profile* profile = ProfileManager::GetLastUsedProfileAllowedByPolicy(); | 51 Profile* profile = ProfileManager::GetLastUsedProfileAllowedByPolicy(); |
52 if (profile->IsGuestSession() && | 52 if (profile->IsGuestSession() && |
53 !g_browser_process->local_state()->GetBoolean( | 53 !g_browser_process->local_state()->GetBoolean( |
54 prefs::kBrowserGuestModeEnabled)) { | 54 prefs::kBrowserGuestModeEnabled)) { |
55 UserManager::Show(base::FilePath(), | 55 UserManager::Show(base::FilePath(), |
56 profiles::USER_MANAGER_NO_TUTORIAL, | 56 profiles::USER_MANAGER_NO_TUTORIAL, |
57 profiles::USER_MANAGER_SELECT_PROFILE_CHROME_MEMORY); | 57 profiles::USER_MANAGER_SELECT_PROFILE_CHROME_MEMORY); |
58 return; | 58 return; |
59 } | 59 } |
60 | 60 |
61 chrome::NavigateParams params(profile, | 61 chrome::NavigateParams params(profile, |
62 GURL(chrome::kChromeUIMemoryURL), | 62 GURL(chrome::kChromeUIMemoryURL), |
63 ui::PAGE_TRANSITION_LINK); | 63 ui::PAGE_TRANSITION_LINK); |
64 params.disposition = NEW_FOREGROUND_TAB; | 64 params.disposition = NEW_FOREGROUND_TAB; |
65 params.host_desktop_type = desktop_type; | |
66 chrome::Navigate(¶ms); | 65 chrome::Navigate(¶ms); |
67 } | 66 } |
68 | 67 |
69 } // namespace | 68 } // namespace |
70 | 69 |
71 NewTaskManagerView::~NewTaskManagerView() { | 70 NewTaskManagerView::~NewTaskManagerView() { |
72 // Delete child views now, while our table model still exists. | 71 // Delete child views now, while our table model still exists. |
73 RemoveAllChildViews(true); | 72 RemoveAllChildViews(true); |
74 } | 73 } |
75 | 74 |
76 // static | 75 // static |
77 void NewTaskManagerView::Show(Browser* browser) { | 76 void NewTaskManagerView::Show(Browser* browser) { |
78 if (g_task_manager_view) { | 77 if (g_task_manager_view) { |
79 // If there's a Task manager window open already, just activate it. | 78 // If there's a Task manager window open already, just activate it. |
80 g_task_manager_view->GetWidget()->Activate(); | 79 g_task_manager_view->GetWidget()->Activate(); |
81 return; | 80 return; |
82 } | 81 } |
83 | 82 |
84 // In ash we can come here through the ChromeShellDelegate. If there is no | 83 g_task_manager_view = new NewTaskManagerView(); |
85 // browser window at that time of the call, browser could be passed as NULL. | |
86 const chrome::HostDesktopType desktop_type = | |
87 browser ? browser->host_desktop_type() : chrome::HOST_DESKTOP_TYPE_ASH; | |
88 | |
89 g_task_manager_view = new NewTaskManagerView(desktop_type); | |
90 | 84 |
91 gfx::NativeWindow window = browser ? browser->window()->GetNativeWindow() | 85 gfx::NativeWindow window = browser ? browser->window()->GetNativeWindow() |
92 : nullptr; | 86 : nullptr; |
93 #if defined(USE_ASH) | 87 #if defined(USE_ASH) |
94 if (!window) | 88 if (!window) |
95 window = ash::wm::GetActiveWindow(); | 89 window = ash::wm::GetActiveWindow(); |
96 #endif | 90 #endif |
97 | 91 |
98 DialogDelegate::CreateDialogWidget(g_task_manager_view, | 92 DialogDelegate::CreateDialogWidget(g_task_manager_view, |
99 window, | 93 window, |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 ActivateFocusedTab(); | 291 ActivateFocusedTab(); |
298 } | 292 } |
299 | 293 |
300 void NewTaskManagerView::OnKeyDown(ui::KeyboardCode keycode) { | 294 void NewTaskManagerView::OnKeyDown(ui::KeyboardCode keycode) { |
301 if (keycode == ui::VKEY_RETURN) | 295 if (keycode == ui::VKEY_RETURN) |
302 ActivateFocusedTab(); | 296 ActivateFocusedTab(); |
303 } | 297 } |
304 | 298 |
305 void NewTaskManagerView::LinkClicked(views::Link* source, int event_flags) { | 299 void NewTaskManagerView::LinkClicked(views::Link* source, int event_flags) { |
306 DCHECK_EQ(about_memory_link_, source); | 300 DCHECK_EQ(about_memory_link_, source); |
307 OpenAboutMemory(desktop_type_); | 301 OpenAboutMemory(); |
308 } | 302 } |
309 | 303 |
310 void NewTaskManagerView::ShowContextMenuForView( | 304 void NewTaskManagerView::ShowContextMenuForView( |
311 views::View* source, | 305 views::View* source, |
312 const gfx::Point& point, | 306 const gfx::Point& point, |
313 ui::MenuSourceType source_type) { | 307 ui::MenuSourceType source_type) { |
314 ui::SimpleMenuModel menu_model(this); | 308 ui::SimpleMenuModel menu_model(this); |
315 | 309 |
316 for (const auto& table_column : columns_) { | 310 for (const auto& table_column : columns_) { |
317 menu_model.AddCheckItem(table_column.id, | 311 menu_model.AddCheckItem(table_column.id, |
(...skipping 23 matching lines...) Expand all Loading... |
341 bool NewTaskManagerView::GetAcceleratorForCommandId( | 335 bool NewTaskManagerView::GetAcceleratorForCommandId( |
342 int command_id, | 336 int command_id, |
343 ui::Accelerator* accelerator) { | 337 ui::Accelerator* accelerator) { |
344 return false; | 338 return false; |
345 } | 339 } |
346 | 340 |
347 void NewTaskManagerView::ExecuteCommand(int id, int event_flags) { | 341 void NewTaskManagerView::ExecuteCommand(int id, int event_flags) { |
348 table_model_->ToggleColumnVisibility(id); | 342 table_model_->ToggleColumnVisibility(id); |
349 } | 343 } |
350 | 344 |
351 NewTaskManagerView::NewTaskManagerView(chrome::HostDesktopType desktop_type) | 345 NewTaskManagerView::NewTaskManagerView() |
352 : kill_button_(nullptr), | 346 : kill_button_(nullptr), |
353 about_memory_link_(nullptr), | 347 about_memory_link_(nullptr), |
354 tab_table_(nullptr), | 348 tab_table_(nullptr), |
355 tab_table_parent_(nullptr), | 349 tab_table_parent_(nullptr), |
356 desktop_type_(desktop_type), | |
357 is_always_on_top_(false) { | 350 is_always_on_top_(false) { |
358 Init(); | 351 Init(); |
359 } | 352 } |
360 | 353 |
361 // static | 354 // static |
362 NewTaskManagerView* NewTaskManagerView::GetInstanceForTests() { | 355 NewTaskManagerView* NewTaskManagerView::GetInstanceForTests() { |
363 return g_task_manager_view; | 356 return g_task_manager_view; |
364 } | 357 } |
365 | 358 |
366 void NewTaskManagerView::Init() { | 359 void NewTaskManagerView::Init() { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 if (!g_browser_process->local_state()) | 413 if (!g_browser_process->local_state()) |
421 return; | 414 return; |
422 | 415 |
423 const base::DictionaryValue* dictionary = | 416 const base::DictionaryValue* dictionary = |
424 g_browser_process->local_state()->GetDictionary(GetWindowName()); | 417 g_browser_process->local_state()->GetDictionary(GetWindowName()); |
425 if (dictionary) | 418 if (dictionary) |
426 dictionary->GetBoolean("always_on_top", &is_always_on_top_); | 419 dictionary->GetBoolean("always_on_top", &is_always_on_top_); |
427 } | 420 } |
428 | 421 |
429 } // namespace task_management | 422 } // namespace task_management |
OLD | NEW |