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

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

Issue 2146273002: TaskManager: when shown or activated, select the last active tab. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@triple_click_tm
Patch Set: Fix compile. 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
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/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"
11 #include "chrome/browser/profiles/profile_manager.h" 11 #include "chrome/browser/profiles/profile_manager.h"
12 #include "chrome/browser/profiles/profile_window.h" 12 #include "chrome/browser/profiles/profile_window.h"
13 #include "chrome/browser/task_management/task_manager_interface.h" 13 #include "chrome/browser/task_management/task_manager_interface.h"
14 #include "chrome/browser/task_management/task_manager_observer.h" 14 #include "chrome/browser/task_management/task_manager_observer.h"
15 #include "chrome/browser/ui/browser_finder.h"
15 #include "chrome/browser/ui/browser_navigator_params.h" 16 #include "chrome/browser/ui/browser_navigator_params.h"
17 #include "chrome/browser/ui/tabs/tab_strip_model.h"
16 #include "chrome/browser/ui/task_manager/task_manager_columns.h" 18 #include "chrome/browser/ui/task_manager/task_manager_columns.h"
17 #include "chrome/browser/ui/user_manager.h" 19 #include "chrome/browser/ui/user_manager.h"
18 #include "chrome/common/pref_names.h" 20 #include "chrome/common/pref_names.h"
19 #include "chrome/common/url_constants.h" 21 #include "chrome/common/url_constants.h"
20 #include "chrome/grit/chromium_strings.h" 22 #include "chrome/grit/chromium_strings.h"
21 #include "chrome/grit/generated_resources.h" 23 #include "chrome/grit/generated_resources.h"
22 #include "components/prefs/pref_service.h" 24 #include "components/prefs/pref_service.h"
23 #include "ui/base/l10n/l10n_util.h" 25 #include "ui/base/l10n/l10n_util.h"
24 #include "ui/base/models/table_model_observer.h" 26 #include "ui/base/models/table_model_observer.h"
25 #include "ui/views/border.h" 27 #include "ui/views/border.h"
(...skipping 28 matching lines...) Expand all
54 NewTaskManagerView::~NewTaskManagerView() { 56 NewTaskManagerView::~NewTaskManagerView() {
55 // Delete child views now, while our table model still exists. 57 // Delete child views now, while our table model still exists.
56 RemoveAllChildViews(true); 58 RemoveAllChildViews(true);
57 } 59 }
58 60
59 // static 61 // static
60 task_management::TaskManagerTableModel* NewTaskManagerView::Show( 62 task_management::TaskManagerTableModel* NewTaskManagerView::Show(
61 Browser* browser) { 63 Browser* browser) {
62 if (g_task_manager_view) { 64 if (g_task_manager_view) {
63 // If there's a Task manager window open already, just activate it. 65 // If there's a Task manager window open already, just activate it.
66 g_task_manager_view->SelectTaskOfActiveTab(browser);
64 g_task_manager_view->GetWidget()->Activate(); 67 g_task_manager_view->GetWidget()->Activate();
65 return g_task_manager_view->table_model_.get(); 68 return g_task_manager_view->table_model_.get();
66 } 69 }
67 70
68 g_task_manager_view = new NewTaskManagerView(); 71 g_task_manager_view = new NewTaskManagerView();
69 72
70 gfx::NativeWindow window = browser ? browser->window()->GetNativeWindow() 73 gfx::NativeWindow window = browser ? browser->window()->GetNativeWindow()
71 : nullptr; 74 : nullptr;
72 #if defined(USE_ASH) 75 #if defined(USE_ASH)
73 if (!window) 76 if (!window)
(...skipping 10 matching lines...) Expand all
84 // no parent is specified, the app id will default to that of the initial 87 // no parent is specified, the app id will default to that of the initial
85 // process. 88 // process.
86 if (browser) { 89 if (browser) {
87 ui::win::SetAppIdForWindow( 90 ui::win::SetAppIdForWindow(
88 shell_integration::win::GetChromiumModelIdForProfile( 91 shell_integration::win::GetChromiumModelIdForProfile(
89 browser->profile()->GetPath()), 92 browser->profile()->GetPath()),
90 views::HWNDForWidget(g_task_manager_view->GetWidget())); 93 views::HWNDForWidget(g_task_manager_view->GetWidget()));
91 } 94 }
92 #endif 95 #endif
93 96
97 g_task_manager_view->SelectTaskOfActiveTab(browser);
94 g_task_manager_view->GetWidget()->Show(); 98 g_task_manager_view->GetWidget()->Show();
95 99
96 // Set the initial focus to the list of tasks. 100 // Set the initial focus to the list of tasks.
97 views::FocusManager* focus_manager = 101 views::FocusManager* focus_manager =
98 g_task_manager_view->GetFocusManager(); 102 g_task_manager_view->GetFocusManager();
99 if (focus_manager) 103 if (focus_manager)
100 focus_manager->SetFocusedView(g_task_manager_view->tab_table_); 104 focus_manager->SetFocusedView(g_task_manager_view->tab_table_);
101 105
102 #if defined(USE_ASH) 106 #if defined(USE_ASH)
103 gfx::NativeWindow native_window = 107 gfx::NativeWindow native_window =
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 void NewTaskManagerView::GetGroupRange(int model_index, 244 void NewTaskManagerView::GetGroupRange(int model_index,
241 views::GroupRange* range) { 245 views::GroupRange* range) {
242 table_model_->GetRowsGroupRange(model_index, &range->start, &range->length); 246 table_model_->GetRowsGroupRange(model_index, &range->start, &range->length);
243 } 247 }
244 248
245 void NewTaskManagerView::OnSelectionChanged() { 249 void NewTaskManagerView::OnSelectionChanged() {
246 GetDialogClientView()->UpdateDialogButtons(); 250 GetDialogClientView()->UpdateDialogButtons();
247 } 251 }
248 252
249 void NewTaskManagerView::OnDoubleClick() { 253 void NewTaskManagerView::OnDoubleClick() {
250 ActivateFocusedTab(); 254 ActivateSelectedTab();
251 } 255 }
252 256
253 void NewTaskManagerView::OnKeyDown(ui::KeyboardCode keycode) { 257 void NewTaskManagerView::OnKeyDown(ui::KeyboardCode keycode) {
254 if (keycode == ui::VKEY_RETURN) 258 if (keycode == ui::VKEY_RETURN)
255 ActivateFocusedTab(); 259 ActivateSelectedTab();
256 } 260 }
257 261
258 void NewTaskManagerView::ShowContextMenuForView( 262 void NewTaskManagerView::ShowContextMenuForView(
259 views::View* source, 263 views::View* source,
260 const gfx::Point& point, 264 const gfx::Point& point,
261 ui::MenuSourceType source_type) { 265 ui::MenuSourceType source_type) {
262 ui::SimpleMenuModel menu_model(this); 266 ui::SimpleMenuModel menu_model(this);
263 267
264 for (const auto& table_column : columns_) { 268 for (const auto& table_column : columns_) {
265 menu_model.AddCheckItem(table_column.id, 269 menu_model.AddCheckItem(table_column.id,
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 table_model_->RetrieveSavedColumnsSettingsAndUpdateTable(); 341 table_model_->RetrieveSavedColumnsSettingsAndUpdateTable();
338 342
339 AddAccelerator(ui::Accelerator(ui::VKEY_W, ui::EF_CONTROL_DOWN)); 343 AddAccelerator(ui::Accelerator(ui::VKEY_W, ui::EF_CONTROL_DOWN));
340 } 344 }
341 345
342 void NewTaskManagerView::InitAlwaysOnTopState() { 346 void NewTaskManagerView::InitAlwaysOnTopState() {
343 RetrieveSavedAlwaysOnTopState(); 347 RetrieveSavedAlwaysOnTopState();
344 GetWidget()->SetAlwaysOnTop(is_always_on_top_); 348 GetWidget()->SetAlwaysOnTop(is_always_on_top_);
345 } 349 }
346 350
347 void NewTaskManagerView::ActivateFocusedTab() { 351 void NewTaskManagerView::ActivateSelectedTab() {
348 const int active_row = tab_table_->selection_model().active(); 352 const int active_row = tab_table_->selection_model().active();
349 if (active_row != ui::ListSelectionModel::kUnselectedIndex) 353 if (active_row != ui::ListSelectionModel::kUnselectedIndex)
350 table_model_->ActivateTask(active_row); 354 table_model_->ActivateTask(active_row);
351 } 355 }
352 356
357 void NewTaskManagerView::SelectTaskOfActiveTab(Browser* browser) {
358 if (browser) {
359 tab_table_->Select(table_model_->GetRowForWebContents(
360 browser->tab_strip_model()->GetActiveWebContents()));
361 }
362 }
363
353 void NewTaskManagerView::RetrieveSavedAlwaysOnTopState() { 364 void NewTaskManagerView::RetrieveSavedAlwaysOnTopState() {
354 is_always_on_top_ = false; 365 is_always_on_top_ = false;
355 366
356 if (!g_browser_process->local_state()) 367 if (!g_browser_process->local_state())
357 return; 368 return;
358 369
359 const base::DictionaryValue* dictionary = 370 const base::DictionaryValue* dictionary =
360 g_browser_process->local_state()->GetDictionary(GetWindowName()); 371 g_browser_process->local_state()->GetDictionary(GetWindowName());
361 if (dictionary) 372 if (dictionary)
362 dictionary->GetBoolean("always_on_top", &is_always_on_top_); 373 dictionary->GetBoolean("always_on_top", &is_always_on_top_);
363 } 374 }
364 375
365 } // namespace task_management 376 } // namespace task_management
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/new_task_manager_view.h ('k') | chrome/browser/ui/views/new_task_manager_view_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698