| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ash/wm/overview/window_selector.h" | 5 #include "ash/wm/overview/window_selector.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <functional> | 8 #include <functional> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <utility> | 10 #include <utility> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "ash/ash_switches.h" | 13 #include "ash/ash_switches.h" |
| 14 #include "ash/common/accessibility_delegate.h" | 14 #include "ash/common/accessibility_delegate.h" |
| 15 #include "ash/common/metrics/user_metrics_action.h" |
| 15 #include "ash/common/shelf/wm_shelf.h" | 16 #include "ash/common/shelf/wm_shelf.h" |
| 16 #include "ash/common/shell_window_ids.h" | 17 #include "ash/common/shell_window_ids.h" |
| 17 #include "ash/common/wm/mru_window_tracker.h" | 18 #include "ash/common/wm/mru_window_tracker.h" |
| 18 #include "ash/common/wm/panels/panel_layout_manager.h" | 19 #include "ash/common/wm/panels/panel_layout_manager.h" |
| 19 #include "ash/common/wm/switchable_windows.h" | 20 #include "ash/common/wm/switchable_windows.h" |
| 20 #include "ash/common/wm/window_state.h" | 21 #include "ash/common/wm/window_state.h" |
| 21 #include "ash/common/wm/wm_user_metrics_action.h" | |
| 22 #include "ash/common/wm_lookup.h" | 22 #include "ash/common/wm_lookup.h" |
| 23 #include "ash/common/wm_root_window_controller.h" | 23 #include "ash/common/wm_root_window_controller.h" |
| 24 #include "ash/common/wm_shell.h" | 24 #include "ash/common/wm_shell.h" |
| 25 #include "ash/common/wm_window.h" | 25 #include "ash/common/wm_window.h" |
| 26 #include "ash/wm/overview/window_grid.h" | 26 #include "ash/wm/overview/window_grid.h" |
| 27 #include "ash/wm/overview/window_selector_delegate.h" | 27 #include "ash/wm/overview/window_selector_delegate.h" |
| 28 #include "ash/wm/overview/window_selector_item.h" | 28 #include "ash/wm/overview/window_selector_item.h" |
| 29 #include "base/auto_reset.h" | 29 #include "base/auto_reset.h" |
| 30 #include "base/command_line.h" | 30 #include "base/command_line.h" |
| 31 #include "base/metrics/histogram.h" | 31 #include "base/metrics/histogram.h" |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 text_filter_widget_.reset( | 296 text_filter_widget_.reset( |
| 297 CreateTextFilter(this, shell->GetPrimaryRootWindow())); | 297 CreateTextFilter(this, shell->GetPrimaryRootWindow())); |
| 298 } | 298 } |
| 299 | 299 |
| 300 DCHECK(!grid_list_.empty()); | 300 DCHECK(!grid_list_.empty()); |
| 301 UMA_HISTOGRAM_COUNTS_100("Ash.WindowSelector.Items", num_items_); | 301 UMA_HISTOGRAM_COUNTS_100("Ash.WindowSelector.Items", num_items_); |
| 302 | 302 |
| 303 shell->AddActivationObserver(this); | 303 shell->AddActivationObserver(this); |
| 304 | 304 |
| 305 display::Screen::GetScreen()->AddObserver(this); | 305 display::Screen::GetScreen()->AddObserver(this); |
| 306 shell->RecordUserMetricsAction(wm::WmUserMetricsAction::WINDOW_OVERVIEW); | 306 shell->RecordUserMetricsAction(UMA_WINDOW_OVERVIEW); |
| 307 // Send an a11y alert. | 307 // Send an a11y alert. |
| 308 WmShell::Get()->GetAccessibilityDelegate()->TriggerAccessibilityAlert( | 308 WmShell::Get()->GetAccessibilityDelegate()->TriggerAccessibilityAlert( |
| 309 ui::A11Y_ALERT_WINDOW_OVERVIEW_MODE_ENTERED); | 309 ui::A11Y_ALERT_WINDOW_OVERVIEW_MODE_ENTERED); |
| 310 | 310 |
| 311 UpdateShelfVisibility(); | 311 UpdateShelfVisibility(); |
| 312 } | 312 } |
| 313 | 313 |
| 314 // NOTE: The work done in Shutdown() is not done in the destructor because it | 314 // NOTE: The work done in Shutdown() is not done in the destructor because it |
| 315 // may cause other, unrelated classes, (ie PanelLayoutManager) to make indirect | 315 // may cause other, unrelated classes, (ie PanelLayoutManager) to make indirect |
| 316 // calls to restoring_minimized_windows() on a partially destructed object. | 316 // calls to restoring_minimized_windows() on a partially destructed object. |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 } | 392 } |
| 393 | 393 |
| 394 void WindowSelector::SelectWindow(WmWindow* window) { | 394 void WindowSelector::SelectWindow(WmWindow* window) { |
| 395 // Record UMA_WINDOW_OVERVIEW_ACTIVE_WINDOW_CHANGED if the user is selecting | 395 // Record UMA_WINDOW_OVERVIEW_ACTIVE_WINDOW_CHANGED if the user is selecting |
| 396 // a window other than the window that was active prior to entering overview | 396 // a window other than the window that was active prior to entering overview |
| 397 // mode (i.e., the window at the front of the MRU list). | 397 // mode (i.e., the window at the front of the MRU list). |
| 398 std::vector<WmWindow*> window_list = | 398 std::vector<WmWindow*> window_list = |
| 399 WmShell::Get()->GetMruWindowTracker()->BuildMruWindowList(); | 399 WmShell::Get()->GetMruWindowTracker()->BuildMruWindowList(); |
| 400 if (!window_list.empty() && window_list[0] != window) { | 400 if (!window_list.empty() && window_list[0] != window) { |
| 401 WmShell::Get()->RecordUserMetricsAction( | 401 WmShell::Get()->RecordUserMetricsAction( |
| 402 wm::WmUserMetricsAction::WINDOW_OVERVIEW_ACTIVE_WINDOW_CHANGED); | 402 UMA_WINDOW_OVERVIEW_ACTIVE_WINDOW_CHANGED); |
| 403 } | 403 } |
| 404 | 404 |
| 405 window->GetWindowState()->Activate(); | 405 window->GetWindowState()->Activate(); |
| 406 } | 406 } |
| 407 | 407 |
| 408 bool WindowSelector::HandleKeyEvent(views::Textfield* sender, | 408 bool WindowSelector::HandleKeyEvent(views::Textfield* sender, |
| 409 const ui::KeyEvent& key_event) { | 409 const ui::KeyEvent& key_event) { |
| 410 if (key_event.type() != ui::ET_KEY_PRESSED) | 410 if (key_event.type() != ui::ET_KEY_PRESSED) |
| 411 return false; | 411 return false; |
| 412 | 412 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 433 break; | 433 break; |
| 434 case ui::VKEY_RETURN: | 434 case ui::VKEY_RETURN: |
| 435 // Ignore if no item is selected. | 435 // Ignore if no item is selected. |
| 436 if (!grid_list_[selected_grid_index_]->is_selecting()) | 436 if (!grid_list_[selected_grid_index_]->is_selecting()) |
| 437 return false; | 437 return false; |
| 438 UMA_HISTOGRAM_COUNTS_100("Ash.WindowSelector.ArrowKeyPresses", | 438 UMA_HISTOGRAM_COUNTS_100("Ash.WindowSelector.ArrowKeyPresses", |
| 439 num_key_presses_); | 439 num_key_presses_); |
| 440 UMA_HISTOGRAM_CUSTOM_COUNTS( | 440 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 441 "Ash.WindowSelector.KeyPressesOverItemsRatio", | 441 "Ash.WindowSelector.KeyPressesOverItemsRatio", |
| 442 (num_key_presses_ * 100) / num_items_, 1, 300, 30); | 442 (num_key_presses_ * 100) / num_items_, 1, 300, 30); |
| 443 WmShell::Get()->RecordUserMetricsAction( | 443 WmShell::Get()->RecordUserMetricsAction(UMA_WINDOW_OVERVIEW_ENTER_KEY); |
| 444 wm::WmUserMetricsAction::WINDOW_OVERVIEW_ENTER_KEY); | |
| 445 SelectWindow( | 444 SelectWindow( |
| 446 grid_list_[selected_grid_index_]->SelectedWindow()->GetWindow()); | 445 grid_list_[selected_grid_index_]->SelectedWindow()->GetWindow()); |
| 447 break; | 446 break; |
| 448 default: | 447 default: |
| 449 // Not a key we are interested in, allow the textfield to handle it. | 448 // Not a key we are interested in, allow the textfield to handle it. |
| 450 return false; | 449 return false; |
| 451 } | 450 } |
| 452 return true; | 451 return true; |
| 453 } | 452 } |
| 454 | 453 |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 621 for (size_t i = 0; | 620 for (size_t i = 0; |
| 622 i <= grid_list_.size() && | 621 i <= grid_list_.size() && |
| 623 grid_list_[selected_grid_index_]->Move(direction, animate); i++) { | 622 grid_list_[selected_grid_index_]->Move(direction, animate); i++) { |
| 624 selected_grid_index_ = | 623 selected_grid_index_ = |
| 625 (selected_grid_index_ + display_direction + grid_list_.size()) % | 624 (selected_grid_index_ + display_direction + grid_list_.size()) % |
| 626 grid_list_.size(); | 625 grid_list_.size(); |
| 627 } | 626 } |
| 628 } | 627 } |
| 629 | 628 |
| 630 } // namespace ash | 629 } // namespace ash |
| OLD | NEW |