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

Side by Side Diff: ash/shell.cc

Issue 10960015: aura: Start converting event-filters into event-handlers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: leak Created 8 years, 3 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 | « ash/shell.h ('k') | ui/aura/env.h » ('j') | ui/aura/env.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/shell.h" 5 #include "ash/shell.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "ash/accelerators/focus_manager_factory.h" 10 #include "ash/accelerators/focus_manager_factory.h"
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 Shell::TestApi::screen_position_controller() { 176 Shell::TestApi::screen_position_controller() {
177 return shell_->screen_position_controller_.get(); 177 return shell_->screen_position_controller_.get();
178 } 178 }
179 179
180 //////////////////////////////////////////////////////////////////////////////// 180 ////////////////////////////////////////////////////////////////////////////////
181 // Shell, public: 181 // Shell, public:
182 182
183 Shell::Shell(ShellDelegate* delegate) 183 Shell::Shell(ShellDelegate* delegate)
184 : screen_(new ScreenAsh), 184 : screen_(new ScreenAsh),
185 active_root_window_(NULL), 185 active_root_window_(NULL),
186 env_filter_(NULL),
187 delegate_(delegate), 186 delegate_(delegate),
188 #if defined(OS_CHROMEOS) 187 #if defined(OS_CHROMEOS)
189 output_configurator_(new chromeos::OutputConfigurator()), 188 output_configurator_(new chromeos::OutputConfigurator()),
190 output_configurator_animation_( 189 output_configurator_animation_(
191 new internal::OutputConfiguratorAnimation()), 190 new internal::OutputConfiguratorAnimation()),
192 #endif // defined(OS_CHROMEOS) 191 #endif // defined(OS_CHROMEOS)
193 shelf_(NULL), 192 shelf_(NULL),
194 panel_layout_manager_(NULL), 193 panel_layout_manager_(NULL),
195 status_area_widget_(NULL), 194 status_area_widget_(NULL),
196 browser_context_(NULL) { 195 browser_context_(NULL) {
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 if (container) 353 if (container)
355 containers.push_back(container); 354 containers.push_back(container);
356 return containers; 355 return containers;
357 } 356 }
358 357
359 void Shell::Init() { 358 void Shell::Init() {
360 // Install the custom factory first so that views::FocusManagers for Tray, 359 // Install the custom factory first so that views::FocusManagers for Tray,
361 // Launcher, and WallPaper could be created by the factory. 360 // Launcher, and WallPaper could be created by the factory.
362 views::FocusManagerFactory::Install(new AshFocusManagerFactory); 361 views::FocusManagerFactory::Install(new AshFocusManagerFactory);
363 362
364 env_filter_ = new aura::shared::CompoundEventFilter; 363 env_filter_.reset(new aura::shared::CompoundEventFilter);
365 // Pass ownership of the filter to the Env. 364 AddEnvEventFilter(env_filter_.get());
366 aura::Env::GetInstance()->SetEventFilter(env_filter_);
367 365
368 cursor_manager_.set_delegate(this); 366 cursor_manager_.set_delegate(this);
369 367
370 focus_manager_.reset(new aura::FocusManager); 368 focus_manager_.reset(new aura::FocusManager);
371 activation_controller_.reset( 369 activation_controller_.reset(
372 new internal::ActivationController(focus_manager_.get())); 370 new internal::ActivationController(focus_manager_.get()));
373 371
374 screen_position_controller_.reset(new internal::ScreenPositionController); 372 screen_position_controller_.reset(new internal::ScreenPositionController);
375 display_controller_.reset(new DisplayController); 373 display_controller_.reset(new DisplayController);
376 display_controller_->InitPrimaryDisplay(); 374 display_controller_->InitPrimaryDisplay();
377 aura::RootWindow* root_window = display_controller_->GetPrimaryRootWindow(); 375 aura::RootWindow* root_window = display_controller_->GetPrimaryRootWindow();
378 active_root_window_ = root_window; 376 active_root_window_ = root_window;
379 377
380 cursor_manager_.SetDeviceScaleFactor( 378 cursor_manager_.SetDeviceScaleFactor(
381 root_window->AsRootWindowHostDelegate()->GetDeviceScaleFactor()); 379 root_window->AsRootWindowHostDelegate()->GetDeviceScaleFactor());
382 380
383 #if !defined(OS_MACOSX) 381 #if !defined(OS_MACOSX)
384 nested_dispatcher_controller_.reset(new NestedDispatcherController); 382 nested_dispatcher_controller_.reset(new NestedDispatcherController);
385 accelerator_controller_.reset(new AcceleratorController); 383 accelerator_controller_.reset(new AcceleratorController);
386 #endif 384 #endif
387 shell_context_menu_.reset(new internal::ShellContextMenu); 385 shell_context_menu_.reset(new internal::ShellContextMenu);
388 386
389 // The order in which event filters are added is significant. 387 // The order in which event filters are added is significant.
390 DCHECK(!GetEnvEventFilterCount());
391 user_activity_detector_.reset(new UserActivityDetector); 388 user_activity_detector_.reset(new UserActivityDetector);
392 AddEnvEventFilter(user_activity_detector_.get()); 389 AddEnvEventFilter(user_activity_detector_.get());
393 390
394 DCHECK_EQ(1U, GetEnvEventFilterCount());
395 event_rewriter_filter_.reset(new internal::EventRewriterEventFilter); 391 event_rewriter_filter_.reset(new internal::EventRewriterEventFilter);
396 AddEnvEventFilter(event_rewriter_filter_.get()); 392 AddEnvEventFilter(event_rewriter_filter_.get());
397 393
398 DCHECK_EQ(2U, GetEnvEventFilterCount());
399 overlay_filter_.reset(new internal::OverlayEventFilter); 394 overlay_filter_.reset(new internal::OverlayEventFilter);
400 AddEnvEventFilter(overlay_filter_.get()); 395 AddEnvEventFilter(overlay_filter_.get());
401 AddShellObserver(overlay_filter_.get()); 396 AddShellObserver(overlay_filter_.get());
402 397
403 DCHECK_EQ(3U, GetEnvEventFilterCount());
404 input_method_filter_.reset(new aura::shared::InputMethodEventFilter()); 398 input_method_filter_.reset(new aura::shared::InputMethodEventFilter());
405 AddEnvEventFilter(input_method_filter_.get()); 399 AddEnvEventFilter(input_method_filter_.get());
406 400
407 #if !defined(OS_MACOSX) 401 #if !defined(OS_MACOSX)
408 accelerator_filter_.reset(new internal::AcceleratorFilter); 402 accelerator_filter_.reset(new internal::AcceleratorFilter);
409 AddEnvEventFilter(accelerator_filter_.get()); 403 AddEnvEventFilter(accelerator_filter_.get());
410 #endif 404 #endif
411 405
412 system_gesture_filter_.reset(new internal::SystemGestureEventFilter); 406 system_gesture_filter_.reset(new internal::SystemGestureEventFilter);
413 AddEnvEventFilter(system_gesture_filter_.get()); 407 AddEnvEventFilter(system_gesture_filter_.get());
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 user_wallpaper_delegate_->InitializeWallpaper(); 493 user_wallpaper_delegate_->InitializeWallpaper();
500 494
501 power_button_controller_.reset(new PowerButtonController); 495 power_button_controller_.reset(new PowerButtonController);
502 AddShellObserver(power_button_controller_.get()); 496 AddShellObserver(power_button_controller_.get());
503 497
504 if (initially_hide_cursor_) 498 if (initially_hide_cursor_)
505 cursor_manager_.ShowCursor(false); 499 cursor_manager_.ShowCursor(false);
506 } 500 }
507 501
508 void Shell::AddEnvEventFilter(aura::EventFilter* filter) { 502 void Shell::AddEnvEventFilter(aura::EventFilter* filter) {
509 env_filter_->AddFilter(filter); 503 aura::Env::GetInstance()->AddPreTargetEventHandler(filter);
510 } 504 }
511 505
512 void Shell::RemoveEnvEventFilter(aura::EventFilter* filter) { 506 void Shell::RemoveEnvEventFilter(aura::EventFilter* filter) {
513 env_filter_->RemoveFilter(filter); 507 aura::Env::GetInstance()->RemovePreTargetEventHandler(filter);
514 }
515
516 size_t Shell::GetEnvEventFilterCount() const {
517 return env_filter_->GetFilterCount();
518 } 508 }
519 509
520 void Shell::ShowBackgroundMenu(views::Widget* widget, 510 void Shell::ShowBackgroundMenu(views::Widget* widget,
521 const gfx::Point& location) { 511 const gfx::Point& location) {
522 // No context menus if user have not logged in. 512 // No context menus if user have not logged in.
523 if (!delegate_.get() || !delegate_->IsUserLoggedIn()) 513 if (!delegate_.get() || !delegate_->IsUserLoggedIn())
524 return; 514 return;
525 // No context menus when screen is locked. 515 // No context menus when screen is locked.
526 if (IsScreenLocked()) 516 if (IsScreenLocked())
527 return; 517 return;
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 } 763 }
774 764
775 void Shell::ShowCursor(bool visible) { 765 void Shell::ShowCursor(bool visible) {
776 RootWindowList root_windows = GetAllRootWindows(); 766 RootWindowList root_windows = GetAllRootWindows();
777 for (RootWindowList::iterator iter = root_windows.begin(); 767 for (RootWindowList::iterator iter = root_windows.begin();
778 iter != root_windows.end(); ++iter) 768 iter != root_windows.end(); ++iter)
779 (*iter)->ShowCursor(visible); 769 (*iter)->ShowCursor(visible);
780 } 770 }
781 771
782 } // namespace ash 772 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shell.h ('k') | ui/aura/env.h » ('j') | ui/aura/env.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698