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

Side by Side Diff: ui/aura_shell/shell.cc

Issue 8561012: Add ShellAcceleratorController that manages global keyboard accelerators (2nd try). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 9 years 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 | « ui/aura_shell/shell.h ('k') | ui/aura_shell/shell_accelerator_controller.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "ui/aura_shell/shell.h" 5 #include "ui/aura_shell/shell.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "ui/aura/aura_switches.h" 9 #include "ui/aura/aura_switches.h"
10 #include "ui/aura/client/aura_constants.h" 10 #include "ui/aura/client/aura_constants.h"
11 #include "ui/aura/client/drag_drop_client.h" 11 #include "ui/aura/client/drag_drop_client.h"
12 #include "ui/aura/desktop.h" 12 #include "ui/aura/desktop.h"
13 #include "ui/aura/window.h" 13 #include "ui/aura/window.h"
14 #include "ui/aura/window_types.h" 14 #include "ui/aura/window_types.h"
15 #include "ui/aura_shell/app_list.h" 15 #include "ui/aura_shell/app_list.h"
16 #include "ui/aura_shell/default_container_event_filter.h" 16 #include "ui/aura_shell/default_container_event_filter.h"
17 #include "ui/aura_shell/default_container_layout_manager.h" 17 #include "ui/aura_shell/default_container_layout_manager.h"
18 #include "ui/aura_shell/desktop_event_filter.h" 18 #include "ui/aura_shell/desktop_event_filter.h"
19 #include "ui/aura_shell/desktop_layout_manager.h" 19 #include "ui/aura_shell/desktop_layout_manager.h"
20 #include "ui/aura_shell/drag_drop_controller.h" 20 #include "ui/aura_shell/drag_drop_controller.h"
21 #include "ui/aura_shell/launcher/launcher.h" 21 #include "ui/aura_shell/launcher/launcher.h"
22 #include "ui/aura_shell/modal_container_layout_manager.h" 22 #include "ui/aura_shell/modal_container_layout_manager.h"
23 #include "ui/aura_shell/shadow_controller.h" 23 #include "ui/aura_shell/shadow_controller.h"
24 #include "ui/aura_shell/shelf_layout_controller.h" 24 #include "ui/aura_shell/shelf_layout_controller.h"
25 #include "ui/aura_shell/shell_accelerator_controller.h"
26 #include "ui/aura_shell/shell_accelerator_filter.h"
25 #include "ui/aura_shell/shell_delegate.h" 27 #include "ui/aura_shell/shell_delegate.h"
26 #include "ui/aura_shell/shell_factory.h" 28 #include "ui/aura_shell/shell_factory.h"
27 #include "ui/aura_shell/shell_window_ids.h" 29 #include "ui/aura_shell/shell_window_ids.h"
28 #include "ui/aura_shell/stacking_controller.h" 30 #include "ui/aura_shell/stacking_controller.h"
29 #include "ui/aura_shell/toplevel_layout_manager.h" 31 #include "ui/aura_shell/toplevel_layout_manager.h"
30 #include "ui/aura_shell/toplevel_window_event_filter.h" 32 #include "ui/aura_shell/toplevel_window_event_filter.h"
31 #include "ui/aura_shell/workspace_controller.h" 33 #include "ui/aura_shell/workspace_controller.h"
32 #include "ui/gfx/compositor/layer.h" 34 #include "ui/gfx/compositor/layer.h"
33 #include "ui/gfx/compositor/layer_animator.h" 35 #include "ui/gfx/compositor/layer_animator.h"
34 #include "views/widget/native_widget_aura.h" 36 #include "views/widget/native_widget_aura.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 } // namespace 95 } // namespace
94 96
95 // static 97 // static
96 Shell* Shell::instance_ = NULL; 98 Shell* Shell::instance_ = NULL;
97 99
98 //////////////////////////////////////////////////////////////////////////////// 100 ////////////////////////////////////////////////////////////////////////////////
99 // Shell, public: 101 // Shell, public:
100 102
101 Shell::Shell(ShellDelegate* delegate) 103 Shell::Shell(ShellDelegate* delegate)
102 : ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)), 104 : ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)),
105 accelerator_controller_(new ShellAcceleratorController),
103 delegate_(delegate) { 106 delegate_(delegate) {
104 aura::Desktop::GetInstance()->SetEventFilter( 107 aura::Desktop::GetInstance()->SetEventFilter(
105 new internal::DesktopEventFilter); 108 new internal::DesktopEventFilter);
106 aura::Desktop::GetInstance()->SetStackingClient( 109 aura::Desktop::GetInstance()->SetStackingClient(
107 new internal::StackingController); 110 new internal::StackingController);
108 } 111 }
109 112
110 Shell::~Shell() { 113 Shell::~Shell() {
114 RemoveDesktopEventFilter(accelerator_filter_.get());
115
111 // Drag drop controller needs a valid shell instance. We destroy it first. 116 // Drag drop controller needs a valid shell instance. We destroy it first.
112 drag_drop_controller_.reset(); 117 drag_drop_controller_.reset();
113 118
114 DCHECK(instance_ == this); 119 DCHECK(instance_ == this);
115 instance_ = NULL; 120 instance_ = NULL;
116 121
117 // Make sure we delete WorkspaceController before launcher is 122 // Make sure we delete WorkspaceController before launcher is
118 // deleted as it has a reference to launcher model. 123 // deleted as it has a reference to launcher model.
119 workspace_controller_.reset(); 124 workspace_controller_.reset();
120 } 125 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 } else { 189 } else {
185 internal::ToplevelLayoutManager* toplevel_layout_manager = 190 internal::ToplevelLayoutManager* toplevel_layout_manager =
186 new internal::ToplevelLayoutManager(); 191 new internal::ToplevelLayoutManager();
187 default_container->SetLayoutManager(toplevel_layout_manager); 192 default_container->SetLayoutManager(toplevel_layout_manager);
188 toplevel_layout_manager->set_shelf(shelf_layout_controller_.get()); 193 toplevel_layout_manager->set_shelf(shelf_layout_controller_.get());
189 } 194 }
190 195
191 // Force a layout. 196 // Force a layout.
192 desktop_layout->OnWindowResized(); 197 desktop_layout->OnWindowResized();
193 198
199 // Initialize ShellAcceleratorFilter
200 accelerator_filter_.reset(new internal::ShellAcceleratorFilter);
201 AddDesktopEventFilter(accelerator_filter_.get());
202
203 // Initialize drag drop controller.
194 drag_drop_controller_.reset(new internal::DragDropController); 204 drag_drop_controller_.reset(new internal::DragDropController);
195 aura::Desktop::GetInstance()->SetProperty(aura::kDesktopDragDropClientKey, 205 aura::Desktop::GetInstance()->SetProperty(aura::kDesktopDragDropClientKey,
196 static_cast<aura::DragDropClient*>(drag_drop_controller_.get())); 206 static_cast<aura::DragDropClient*>(drag_drop_controller_.get()));
197 } 207 }
198 208
199 aura::Window* Shell::GetContainer(int container_id) { 209 aura::Window* Shell::GetContainer(int container_id) {
200 return const_cast<aura::Window*>( 210 return const_cast<aura::Window*>(
201 const_cast<const aura_shell::Shell*>(this)->GetContainer(container_id)); 211 const_cast<const aura_shell::Shell*>(this)->GetContainer(container_id));
202 } 212 }
203 213
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 new internal::WorkspaceController(default_container)); 247 new internal::WorkspaceController(default_container));
238 workspace_controller_->SetLauncherModel(launcher_->model()); 248 workspace_controller_->SetLauncherModel(launcher_->model());
239 default_container->SetEventFilter( 249 default_container->SetEventFilter(
240 new internal::DefaultContainerEventFilter(default_container)); 250 new internal::DefaultContainerEventFilter(default_container));
241 default_container->SetLayoutManager( 251 default_container->SetLayoutManager(
242 new internal::DefaultContainerLayoutManager( 252 new internal::DefaultContainerLayoutManager(
243 workspace_controller_->workspace_manager())); 253 workspace_controller_->workspace_manager()));
244 } 254 }
245 255
246 } // namespace aura_shell 256 } // namespace aura_shell
OLDNEW
« no previous file with comments | « ui/aura_shell/shell.h ('k') | ui/aura_shell/shell_accelerator_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698