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

Side by Side Diff: ash/accelerators/accelerator_controller.cc

Issue 11017079: Remove Shell::shelf()|status_area_widget()|launcher() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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
« no previous file with comments | « no previous file | ash/dip_unittest.cc » ('j') | ash/launcher/launcher.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "ash/accelerators/accelerator_controller.h" 5 #include "ash/accelerators/accelerator_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <string> 9 #include <string>
10 10
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 81
82 bool HandleCycleWindowMRU(WindowCycleController::Direction direction, 82 bool HandleCycleWindowMRU(WindowCycleController::Direction direction,
83 bool is_alt_down) { 83 bool is_alt_down) {
84 Shell::GetInstance()-> 84 Shell::GetInstance()->
85 window_cycle_controller()->HandleCycleWindow(direction, is_alt_down); 85 window_cycle_controller()->HandleCycleWindow(direction, is_alt_down);
86 // Always report we handled the key, even if the window didn't change. 86 // Always report we handled the key, even if the window didn't change.
87 return true; 87 return true;
88 } 88 }
89 89
90 void HandleCycleWindowLinear(CycleDirection direction) { 90 void HandleCycleWindowLinear(CycleDirection direction) {
91 Shell::GetInstance()->launcher()->CycleWindowLinear(direction); 91 Launcher::ForPrimaryDisplay()->CycleWindowLinear(direction);
92 } 92 }
93 93
94 #if defined(OS_CHROMEOS) 94 #if defined(OS_CHROMEOS)
95 bool HandleLock() { 95 bool HandleLock() {
96 Shell::GetInstance()->delegate()->LockScreen(); 96 Shell::GetInstance()->delegate()->LockScreen();
97 return true; 97 return true;
98 } 98 }
99 99
100 bool HandleFileManager(bool as_dialog) { 100 bool HandleFileManager(bool as_dialog) {
101 Shell::GetInstance()->delegate()->OpenFileManager(as_dialog); 101 Shell::GetInstance()->delegate()->OpenFileManager(as_dialog);
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 break; 588 break;
589 case VOLUME_DOWN: 589 case VOLUME_DOWN:
590 return shell->tray_delegate()->GetVolumeControlDelegate()-> 590 return shell->tray_delegate()->GetVolumeControlDelegate()->
591 HandleVolumeDown(accelerator); 591 HandleVolumeDown(accelerator);
592 break; 592 break;
593 case VOLUME_UP: 593 case VOLUME_UP:
594 return shell->tray_delegate()->GetVolumeControlDelegate()-> 594 return shell->tray_delegate()->GetVolumeControlDelegate()->
595 HandleVolumeUp(accelerator); 595 HandleVolumeUp(accelerator);
596 break; 596 break;
597 case FOCUS_LAUNCHER: 597 case FOCUS_LAUNCHER:
598 if (shell->launcher()) 598 return shell->focus_cycler()->FocusWidget(
599 return shell->focus_cycler()->FocusWidget(shell->launcher()->widget()); 599 Launcher::ForPrimaryDisplay()->widget());
600 break; 600 break;
601 case FOCUS_NEXT_PANE: 601 case FOCUS_NEXT_PANE:
602 return HandleRotatePaneFocus(Shell::FORWARD); 602 return HandleRotatePaneFocus(Shell::FORWARD);
603 case FOCUS_PREVIOUS_PANE: 603 case FOCUS_PREVIOUS_PANE:
604 return HandleRotatePaneFocus(Shell::BACKWARD); 604 return HandleRotatePaneFocus(Shell::BACKWARD);
605 case FOCUS_SYSTEM_TRAY: 605 case FOCUS_SYSTEM_TRAY:
606 if (shell->system_tray()) 606 if (shell->system_tray())
607 return shell->focus_cycler()->FocusWidget( 607 return shell->focus_cycler()->FocusWidget(
608 shell->system_tray()->GetWidget()); 608 shell->system_tray()->GetWidget());
609 break; 609 break;
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 837
838 bool AcceleratorController::AcceleratorPressed( 838 bool AcceleratorController::AcceleratorPressed(
839 const ui::Accelerator& accelerator) { 839 const ui::Accelerator& accelerator) {
840 std::map<ui::Accelerator, int>::const_iterator it = 840 std::map<ui::Accelerator, int>::const_iterator it =
841 accelerators_.find(accelerator); 841 accelerators_.find(accelerator);
842 DCHECK(it != accelerators_.end()); 842 DCHECK(it != accelerators_.end());
843 return PerformAction(static_cast<AcceleratorAction>(it->second), accelerator); 843 return PerformAction(static_cast<AcceleratorAction>(it->second), accelerator);
844 } 844 }
845 845
846 void AcceleratorController::SwitchToWindow(int window) { 846 void AcceleratorController::SwitchToWindow(int window) {
847 const LauncherItems& items = 847 Launcher* launcher = Launcher::ForPrimaryDisplay();
848 Shell::GetInstance()->launcher()->model()->items(); 848 const LauncherItems& items = launcher->model()->items();
849 int item_count = 849 int item_count = launcher->model()->item_count();
850 Shell::GetInstance()->launcher()->model()->item_count();
851 int indexes_left = window >= 0 ? window : item_count; 850 int indexes_left = window >= 0 ? window : item_count;
852 int found_index = -1; 851 int found_index = -1;
853 852
854 // Iterating until we have hit the index we are interested in which 853 // Iterating until we have hit the index we are interested in which
855 // is true once indexes_left becomes negative. 854 // is true once indexes_left becomes negative.
856 for (int i = 0; i < item_count && indexes_left >= 0; i++) { 855 for (int i = 0; i < item_count && indexes_left >= 0; i++) {
857 if (items[i].type != TYPE_APP_LIST && 856 if (items[i].type != TYPE_APP_LIST &&
858 items[i].type != TYPE_BROWSER_SHORTCUT) { 857 items[i].type != TYPE_BROWSER_SHORTCUT) {
859 found_index = i; 858 found_index = i;
860 indexes_left--; 859 indexes_left--;
861 } 860 }
862 } 861 }
863 862
864 // There are two ways how found_index can be valid: a.) the nth item was 863 // There are two ways how found_index can be valid: a.) the nth item was
865 // found (which is true when indexes_left is -1) or b.) the last item was 864 // found (which is true when indexes_left is -1) or b.) the last item was
866 // requested (which is true when index was passed in as a negative number). 865 // requested (which is true when index was passed in as a negative number).
867 if (found_index >= 0 && (indexes_left == -1 || window < 0) && 866 if (found_index >= 0 && (indexes_left == -1 || window < 0) &&
868 (items[found_index].status == ash::STATUS_RUNNING || 867 (items[found_index].status == ash::STATUS_RUNNING ||
869 items[found_index].status == ash::STATUS_CLOSED)) { 868 items[found_index].status == ash::STATUS_CLOSED)) {
870 // Then set this one as active. 869 // Then set this one as active.
871 Shell::GetInstance()->launcher()->ActivateLauncherItem(found_index); 870 launcher->ActivateLauncherItem(found_index);
872 } 871 }
873 } 872 }
874 873
875 void AcceleratorController::RegisterAccelerators( 874 void AcceleratorController::RegisterAccelerators(
876 const AcceleratorData accelerators[], 875 const AcceleratorData accelerators[],
877 size_t accelerators_length) { 876 size_t accelerators_length) {
878 for (size_t i = 0; i < accelerators_length; ++i) { 877 for (size_t i = 0; i < accelerators_length; ++i) {
879 ui::Accelerator accelerator(accelerators[i].keycode, 878 ui::Accelerator accelerator(accelerators[i].keycode,
880 accelerators[i].modifiers); 879 accelerators[i].modifiers);
881 accelerator.set_type(accelerators[i].trigger_on_press ? 880 accelerator.set_type(accelerators[i].trigger_on_press ?
882 ui::ET_KEY_PRESSED : ui::ET_KEY_RELEASED); 881 ui::ET_KEY_PRESSED : ui::ET_KEY_RELEASED);
883 Register(accelerator, this); 882 Register(accelerator, this);
884 accelerators_.insert( 883 accelerators_.insert(
885 std::make_pair(accelerator, accelerators[i].action)); 884 std::make_pair(accelerator, accelerators[i].action));
886 } 885 }
887 } 886 }
888 887
889 bool AcceleratorController::CanHandleAccelerators() const { 888 bool AcceleratorController::CanHandleAccelerators() const {
890 return true; 889 return true;
891 } 890 }
892 891
893 } // namespace ash 892 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/dip_unittest.cc » ('j') | ash/launcher/launcher.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698