Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / ash / shell.cc
index 00f6137..8bd4460 100644 (file)
 #include "ash/frame/custom_frame_view_ash.h"
 #include "ash/gpu_support.h"
 #include "ash/high_contrast/high_contrast_controller.h"
-#include "ash/host/window_tree_host_factory.h"
 #include "ash/keyboard_uma_event_filter.h"
 #include "ash/magnifier/magnification_controller.h"
 #include "ash/magnifier/partial_magnification_controller.h"
 #include "ash/media_delegate.h"
 #include "ash/new_window_delegate.h"
 #include "ash/root_window_controller.h"
-#include "ash/session_state_delegate.h"
+#include "ash/session/session_state_delegate.h"
 #include "ash/shelf/app_list_shelf_item_delegate.h"
 #include "ash/shelf/shelf_delegate.h"
 #include "ash/shelf/shelf_item_delegate.h"
@@ -72,7 +71,6 @@
 #include "ash/wm/system_modal_container_event_filter.h"
 #include "ash/wm/system_modal_container_layout_manager.h"
 #include "ash/wm/toplevel_window_event_handler.h"
-#include "ash/wm/user_activity_detector.h"
 #include "ash/wm/video_detector.h"
 #include "ash/wm/window_animations.h"
 #include "ash/wm/window_positioner.h"
 #include "ui/wm/core/focus_controller.h"
 #include "ui/wm/core/input_method_event_filter.h"
 #include "ui/wm/core/shadow_controller.h"
+#include "ui/wm/core/user_activity_detector.h"
 #include "ui/wm/core/visibility_controller.h"
 #include "ui/wm/core/window_modality_controller.h"
 
 #if defined(USE_X11)
 #include "ash/accelerators/magnifier_key_scroller.h"
 #include "ash/accelerators/spoken_feedback_toggler.h"
+#include "ui/gfx/x/x11_types.h"
+#endif  // defined(USE_X11)
 #include "ash/ash_constants.h"
 #include "ash/display/display_change_observer_chromeos.h"
+#include "ash/display/display_configurator_animation.h"
 #include "ash/display/display_error_observer_chromeos.h"
-#include "ash/display/output_configurator_animation.h"
 #include "ash/display/projecting_observer_chromeos.h"
-#include "ash/system/chromeos/session/last_window_closed_logout_reminder.h"
-#include "base/message_loop/message_pump_x11.h"
-#include "base/sys_info.h"
-#include "ui/display/chromeos/output_configurator.h"
-#endif  // defined(USE_X11)
 #include "ash/display/resolution_notification_controller.h"
 #include "ash/sticky_keys/sticky_keys_controller.h"
 #include "ash/system/chromeos/bluetooth/bluetooth_notification_controller.h"
 #include "ash/system/chromeos/brightness/brightness_controller_chromeos.h"
 #include "ash/system/chromeos/power/power_event_observer.h"
 #include "ash/system/chromeos/power/power_status.h"
-#include "ash/system/chromeos/power/user_activity_notifier.h"
 #include "ash/system/chromeos/power/video_activity_notifier.h"
+#include "ash/system/chromeos/session/last_window_closed_logout_reminder.h"
 #include "ash/system/chromeos/session/logout_confirmation_controller.h"
 #include "base/bind_helpers.h"
+#include "base/sys_info.h"
+#include "ui/chromeos/user_activity_power_manager_notifier.h"
+#include "ui/display/chromeos/display_configurator.h"
 #endif  // defined(OS_CHROMEOS)
 
 namespace ash {
@@ -198,8 +197,8 @@ void Shell::DeleteInstance() {
 }
 
 // static
-internal::RootWindowController* Shell::GetPrimaryRootWindowController() {
-  return internal::GetRootWindowController(GetPrimaryRootWindow());
+RootWindowController* Shell::GetPrimaryRootWindowController() {
+  return GetRootWindowController(GetPrimaryRootWindow());
 }
 
 // static
@@ -274,8 +273,8 @@ void Shell::ShowContextMenu(const gfx::Point& location_in_screen,
 
   aura::Window* root =
       wm::GetRootWindowMatching(gfx::Rect(location_in_screen, gfx::Size()));
-  internal::GetRootWindowController(root)->
-      ShowContextMenu(location_in_screen, source_type);
+  GetRootWindowController(root)
+      ->ShowContextMenu(location_in_screen, source_type);
 }
 
 void Shell::ToggleAppList(aura::Window* window) {
@@ -283,7 +282,7 @@ void Shell::ToggleAppList(aura::Window* window) {
   if (!window)
     window = GetTargetRootWindow();
   if (!app_list_controller_)
-    app_list_controller_.reset(new internal::AppListController);
+    app_list_controller_.reset(new AppListController);
   app_list_controller_->SetVisible(!app_list_controller_->IsVisible(), window);
 }
 
@@ -304,7 +303,7 @@ bool Shell::IsSystemModalWindowOpen() const {
   if (simulate_modal_window_open_for_testing_)
     return true;
   const std::vector<aura::Window*> containers = GetContainersFromAllRootWindows(
-      internal::kShellWindowId_SystemModalContainer, NULL);
+      kShellWindowId_SystemModalContainer, NULL);
   for (std::vector<aura::Window*>::const_iterator cit = containers.begin();
        cit != containers.end(); ++cit) {
     for (aura::Window::Windows::const_iterator wit = (*cit)->children().begin();
@@ -325,9 +324,8 @@ views::NonClientFrameView* Shell::CreateDefaultNonClientFrameView(
 }
 
 void Shell::RotateFocus(Direction direction) {
-  focus_cycler_->RotateFocus(
-      direction == FORWARD ? internal::FocusCycler::FORWARD :
-                             internal::FocusCycler::BACKWARD);
+  focus_cycler_->RotateFocus(direction == FORWARD ? FocusCycler::FORWARD
+                                                  : FocusCycler::BACKWARD);
 }
 
 void Shell::SetDisplayWorkAreaInsets(Window* contains,
@@ -366,8 +364,7 @@ void Shell::OnLockStateChanged(bool locked) {
   // Make sure that there is no system modal in Lock layer when unlocked.
   if (!locked) {
     std::vector<aura::Window*> containers = GetContainersFromAllRootWindows(
-        internal::kShellWindowId_LockSystemModalContainer,
-        GetPrimaryRootWindow());
+        kShellWindowId_LockSystemModalContainer, GetPrimaryRootWindow());
     for (std::vector<aura::Window*>::const_iterator iter = containers.begin();
          iter != containers.end(); ++iter) {
       DCHECK_EQ(0u, (*iter)->children().size());
@@ -399,6 +396,10 @@ void Shell::OnMaximizeModeEnded() {
   FOR_EACH_OBSERVER(ShellObserver, observers_, OnMaximizeModeEnded());
 }
 
+void Shell::OnRootWindowAdded(aura::Window* root_window) {
+  FOR_EACH_OBSERVER(ShellObserver, observers_, OnRootWindowAdded(root_window));
+}
+
 void Shell::CreateShelf() {
   RootWindowControllerList controllers = GetAllRootWindowControllers();
   for (RootWindowControllerList::iterator iter = controllers.begin();
@@ -406,28 +407,34 @@ void Shell::CreateShelf() {
     (*iter)->shelf()->CreateShelf();
 }
 
+void Shell::OnShelfCreatedForRootWindow(aura::Window* root_window) {
+  FOR_EACH_OBSERVER(ShellObserver,
+                    observers_,
+                    OnShelfCreatedForRootWindow(root_window));
+}
+
 void Shell::CreateKeyboard() {
   // TODO(bshe): Primary root window controller may not be the controller to
   // attach virtual keyboard. See http://crbug.com/303429
   InitKeyboard();
   if (keyboard::IsKeyboardUsabilityExperimentEnabled()) {
     display_controller()->virtual_keyboard_window_controller()->
-        ActivateKeyboard(keyboard_controller_.get());
+        ActivateKeyboard(keyboard::KeyboardController::GetInstance());
   } else {
     GetPrimaryRootWindowController()->
-        ActivateKeyboard(keyboard_controller_.get());
+        ActivateKeyboard(keyboard::KeyboardController::GetInstance());
   }
 }
 
 void Shell::DeactivateKeyboard() {
-  if (keyboard_controller_.get()) {
+  if (keyboard::KeyboardController::GetInstance()) {
     RootWindowControllerList controllers = GetAllRootWindowControllers();
     for (RootWindowControllerList::iterator iter = controllers.begin();
         iter != controllers.end(); ++iter) {
-      (*iter)->DeactivateKeyboard(keyboard_controller_.get());
+      (*iter)->DeactivateKeyboard(keyboard::KeyboardController::GetInstance());
     }
   }
-  keyboard_controller_.reset();
+  keyboard::KeyboardController::ResetInstance(NULL);
 }
 
 void Shell::ShowShelf() {
@@ -447,8 +454,7 @@ void Shell::RemoveShellObserver(ShellObserver* observer) {
 
 void Shell::EnableMaximizeModeWindowManager(bool enable) {
   if (enable && !maximize_mode_window_manager_.get()) {
-    maximize_mode_window_manager_.reset(
-        new internal::MaximizeModeWindowManager());
+    maximize_mode_window_manager_.reset(new MaximizeModeWindowManager());
   } else if (!enable && maximize_mode_window_manager_.get()) {
     maximize_mode_window_manager_.reset();
   }
@@ -468,28 +474,26 @@ void Shell::UpdateShelfVisibility() {
 
 void Shell::SetShelfAutoHideBehavior(ShelfAutoHideBehavior behavior,
                                      aura::Window* root_window) {
-  ash::internal::ShelfLayoutManager::ForShelf(root_window)->
-      SetAutoHideBehavior(behavior);
+  ash::ShelfLayoutManager::ForShelf(root_window)->SetAutoHideBehavior(behavior);
 }
 
 ShelfAutoHideBehavior Shell::GetShelfAutoHideBehavior(
     aura::Window* root_window) const {
-  return ash::internal::ShelfLayoutManager::ForShelf(root_window)->
-      auto_hide_behavior();
+  return ash::ShelfLayoutManager::ForShelf(root_window)->auto_hide_behavior();
 }
 
 void Shell::SetShelfAlignment(ShelfAlignment alignment,
                               aura::Window* root_window) {
-  if (ash::internal::ShelfLayoutManager::ForShelf(root_window)->
-      SetAlignment(alignment)) {
+  if (ash::ShelfLayoutManager::ForShelf(root_window)->SetAlignment(alignment)) {
     FOR_EACH_OBSERVER(
         ShellObserver, observers_, OnShelfAlignmentChanged(root_window));
   }
 }
 
 ShelfAlignment Shell::GetShelfAlignment(aura::Window* root_window) {
-  return internal::GetRootWindowController(root_window)->
-      GetShelfLayoutManager()->GetAlignment();
+  return GetRootWindowController(root_window)
+      ->GetShelfLayoutManager()
+      ->GetAlignment();
 }
 
 void Shell::SetDimming(bool should_dim) {
@@ -507,7 +511,7 @@ void Shell::NotifyFullscreenStateChange(bool is_fullscreen,
 
 void Shell::CreateModalBackground(aura::Window* window) {
   if (!modality_filter_) {
-    modality_filter_.reset(new internal::SystemModalContainerEventFilter(this));
+    modality_filter_.reset(new SystemModalContainerEventFilter(this));
     AddPreTargetHandler(modality_filter_.get());
   }
   RootWindowControllerList controllers = GetAllRootWindowControllers();
@@ -555,8 +559,7 @@ ShelfDelegate* Shell::GetShelfDelegate() {
         new ShelfItemDelegateManager(shelf_model_.get()));
 
     shelf_delegate_.reset(delegate_->CreateShelfDelegate(shelf_model_.get()));
-    scoped_ptr<ShelfItemDelegate> controller(
-        new internal::AppListShelfItemDelegate);
+    scoped_ptr<ShelfItemDelegate> controller(new AppListShelfItemDelegate);
 
     // Finding the shelf model's location of the app list and setting its
     // ShelfItemDelegate.
@@ -566,9 +569,8 @@ ShelfDelegate* Shell::GetShelfDelegate() {
     DCHECK(app_list_id);
     shelf_item_delegate_manager_->SetShelfItemDelegate(app_list_id,
                                                        controller.Pass());
-    shelf_window_watcher_.reset(new internal::ShelfWindowWatcher(
-                                        shelf_model_.get(),
-                                        shelf_item_delegate_manager_.get()));
+    shelf_window_watcher_.reset(new ShelfWindowWatcher(
+        shelf_model_.get(), shelf_item_delegate_manager_.get()));
   }
   return shelf_delegate_.get();
 }
@@ -609,24 +611,24 @@ Shell::Shell(ShellDelegate* delegate)
       window_positioner_(new WindowPositioner),
       activation_client_(NULL),
       accelerometer_controller_(new AccelerometerController()),
-#if defined(OS_CHROMEOS) && defined(USE_X11)
-      output_configurator_(new ui::OutputConfigurator()),
-#endif  // defined(OS_CHROMEOS) && defined(USE_X11)
+#if defined(OS_CHROMEOS)
+      display_configurator_(new ui::DisplayConfigurator()),
+#endif  // defined(OS_CHROMEOS)
       native_cursor_manager_(new AshNativeCursorManager),
-      cursor_manager_(scoped_ptr< ::wm::NativeCursorManager>(
-          native_cursor_manager_)),
+      cursor_manager_(
+          scoped_ptr< ::wm::NativeCursorManager>(native_cursor_manager_)),
       simulate_modal_window_open_for_testing_(false),
       is_touch_hud_projection_enabled_(false) {
   DCHECK(delegate_.get());
   gpu_support_.reset(delegate_->CreateGPUSupport());
-  display_manager_.reset(new internal::DisplayManager);
+  display_manager_.reset(new DisplayManager);
   display_controller_.reset(new DisplayController);
 #if defined(OS_CHROMEOS) && defined(USE_X11)
   user_metrics_recorder_.reset(new UserMetricsRecorder);
 #endif  // defined(OS_CHROMEOS)
 
 #if defined(OS_CHROMEOS)
-  internal::PowerStatus::Initialize();
+  PowerStatus::Initialize();
 #endif
 }
 
@@ -706,6 +708,7 @@ Shell::~Shell() {
   video_activity_notifier_.reset();
 #endif  // defined(OS_CHROMEOS)
   video_detector_.reset();
+  high_contrast_controller_.reset();
 
   shadow_controller_.reset();
   resize_shadow_controller_.reset();
@@ -760,26 +763,27 @@ Shell::~Shell() {
   display_controller_->Shutdown();
   display_controller_.reset();
   screen_position_controller_.reset();
-
-  keyboard_controller_.reset();
   accessibility_delegate_.reset();
   new_window_delegate_.reset();
   media_delegate_.reset();
 
-#if defined(OS_CHROMEOS) && defined(USE_X11)
+  keyboard::KeyboardController::ResetInstance(NULL);
+
+#if defined(OS_CHROMEOS)
   if (display_change_observer_)
-    output_configurator_->RemoveObserver(display_change_observer_.get());
-  if (output_configurator_animation_)
-    output_configurator_->RemoveObserver(output_configurator_animation_.get());
+    display_configurator_->RemoveObserver(display_change_observer_.get());
+  if (display_configurator_animation_)
+    display_configurator_->RemoveObserver(
+        display_configurator_animation_.get());
   if (display_error_observer_)
-    output_configurator_->RemoveObserver(display_error_observer_.get());
+    display_configurator_->RemoveObserver(display_error_observer_.get());
   if (projecting_observer_)
-    output_configurator_->RemoveObserver(projecting_observer_.get());
+    display_configurator_->RemoveObserver(projecting_observer_.get());
   display_change_observer_.reset();
 #endif  // defined(OS_CHROMEOS)
 
 #if defined(OS_CHROMEOS)
-  internal::PowerStatus::Shutdown();
+  PowerStatus::Shutdown();
 #endif
 
   DCHECK(instance_ == this);
@@ -789,33 +793,31 @@ Shell::~Shell() {
 void Shell::Init() {
   delegate_->PreInit();
   if (keyboard::IsKeyboardUsabilityExperimentEnabled()) {
-    display_manager_->SetSecondDisplayMode(
-        internal::DisplayManager::VIRTUAL_KEYBOARD);
+    display_manager_->SetSecondDisplayMode(DisplayManager::VIRTUAL_KEYBOARD);
   }
   bool display_initialized = display_manager_->InitFromCommandLine();
-#if defined(OS_CHROMEOS) && defined(USE_X11)
-  output_configurator_->Init(!gpu_support_->IsPanelFittingDisabled());
-  output_configurator_animation_.reset(
-      new internal::OutputConfiguratorAnimation());
-  output_configurator_->AddObserver(output_configurator_animation_.get());
+#if defined(OS_CHROMEOS)
+  display_configurator_->Init(!gpu_support_->IsPanelFittingDisabled());
+  display_configurator_animation_.reset(new DisplayConfiguratorAnimation());
+  display_configurator_->AddObserver(display_configurator_animation_.get());
 
-  projecting_observer_.reset(new internal::ProjectingObserver());
-  output_configurator_->AddObserver(projecting_observer_.get());
+  projecting_observer_.reset(new ProjectingObserver());
+  display_configurator_->AddObserver(projecting_observer_.get());
 
   if (!display_initialized && base::SysInfo::IsRunningOnChromeOS()) {
-    display_change_observer_.reset(new internal::DisplayChangeObserver);
+    display_change_observer_.reset(new DisplayChangeObserver);
     // Register |display_change_observer_| first so that the rest of
     // observer gets invoked after the root windows are configured.
-    output_configurator_->AddObserver(display_change_observer_.get());
-    display_error_observer_.reset(new internal::DisplayErrorObserver());
-    output_configurator_->AddObserver(display_error_observer_.get());
-    output_configurator_->set_state_controller(display_change_observer_.get());
-    output_configurator_->set_mirroring_controller(display_manager_.get());
-    output_configurator_->ForceInitialConfigure(
+    display_configurator_->AddObserver(display_change_observer_.get());
+    display_error_observer_.reset(new DisplayErrorObserver());
+    display_configurator_->AddObserver(display_error_observer_.get());
+    display_configurator_->set_state_controller(display_change_observer_.get());
+    display_configurator_->set_mirroring_controller(display_manager_.get());
+    display_configurator_->ForceInitialConfigure(
         delegate_->IsFirstRunAfterBoot() ? kChromeOsBootColor : 0);
     display_initialized = true;
   }
-#endif  // defined(OS_CHROMEOS) && defined(USE_X11)
+#endif  // defined(OS_CHROMEOS)
   if (!display_initialized)
     display_manager_->InitDefaultDisplay();
 
@@ -826,7 +828,7 @@ void Shell::Init() {
   // Env creates the compositor. Historically it seems to have been implicitly
   // initialized first by the ActivationController, but now that FocusController
   // no longer does this we need to do it explicitly.
-  aura::Env::CreateInstance();
+  aura::Env::CreateInstance(true);
 
   // The WindowModalityController needs to be at the front of the input event
   // pretarget handler list to ensure that it processes input events when modal
@@ -844,19 +846,18 @@ void Shell::Init() {
   focus_client_.reset(focus_controller);
   activation_client_ = focus_controller;
   activation_client_->AddObserver(this);
-  focus_cycler_.reset(new internal::FocusCycler());
+  focus_cycler_.reset(new FocusCycler());
 
-  screen_position_controller_.reset(new internal::ScreenPositionController);
-  window_tree_host_factory_.reset(delegate_->CreateWindowTreeHostFactory());
+  screen_position_controller_.reset(new ScreenPositionController);
 
   display_controller_->Start();
-  display_controller_->InitPrimaryDisplay();
+  display_controller_->CreatePrimaryHost();
   aura::Window* root_window = display_controller_->GetPrimaryRootWindow();
   target_root_window_ = root_window;
 
 #if defined(OS_CHROMEOS)
   resolution_notification_controller_.reset(
-      new internal::ResolutionNotificationController);
+      new ResolutionNotificationController);
 #endif
 
   cursor_manager_.SetDisplay(GetScreen()->GetPrimaryDisplay());
@@ -881,12 +882,12 @@ void Shell::Init() {
   AddPreTargetHandler(sticky_keys_controller_.get());
 #endif
 
-  // UserActivityDetector passes events to observers, so let them get
+  // wm::UserActivityDetector passes events to observers, so let them get
   // rewritten first.
-  user_activity_detector_.reset(new UserActivityDetector);
+  user_activity_detector_.reset(new ::wm::UserActivityDetector);
   AddPreTargetHandler(user_activity_detector_.get());
 
-  overlay_filter_.reset(new internal::OverlayEventFilter);
+  overlay_filter_.reset(new OverlayEventFilter);
   AddPreTargetHandler(overlay_filter_.get());
   AddShellObserver(overlay_filter_.get());
 
@@ -894,18 +895,18 @@ void Shell::Init() {
       root_window->GetHost()->GetAcceleratedWidget()));
   AddPreTargetHandler(input_method_filter_.get());
 
-  accelerator_filter_.reset(new internal::AcceleratorFilter);
+  accelerator_filter_.reset(new AcceleratorFilter);
   AddPreTargetHandler(accelerator_filter_.get());
 
-  event_transformation_handler_.reset(new internal::EventTransformationHandler);
+  event_transformation_handler_.reset(new EventTransformationHandler);
   AddPreTargetHandler(event_transformation_handler_.get());
 
   toplevel_window_event_handler_.reset(new ToplevelWindowEventHandler);
 
-  system_gesture_filter_.reset(new internal::SystemGestureEventFilter);
+  system_gesture_filter_.reset(new SystemGestureEventFilter);
   AddPreTargetHandler(system_gesture_filter_.get());
 
-  keyboard_metrics_filter_.reset(new internal::KeyboardUMAEventFilter);
+  keyboard_metrics_filter_.reset(new KeyboardUMAEventFilter);
   AddPreTargetHandler(keyboard_metrics_filter_.get());
 
   // The keyboard system must be initialized before the RootWindowController is
@@ -917,15 +918,15 @@ void Shell::Init() {
   lock_state_controller_.reset(new LockStateController);
   power_button_controller_.reset(new PowerButtonController(
       lock_state_controller_.get()));
-#if defined(OS_CHROMEOS) && defined(USE_X11)
+#if defined(OS_CHROMEOS)
   // Pass the initial display state to PowerButtonController.
   power_button_controller_->OnDisplayModeChanged(
-      output_configurator_->cached_outputs());
+      display_configurator_->cached_displays());
 #endif
   AddShellObserver(lock_state_controller_.get());
 
-  drag_drop_controller_.reset(new internal::DragDropController);
-  mouse_cursor_filter_.reset(new internal::MouseCursorEventFilter());
+  drag_drop_controller_.reset(new DragDropController);
+  mouse_cursor_filter_.reset(new MouseCursorEventFilter());
   PrependPreTargetHandler(mouse_cursor_filter_.get());
 
   // Create Controllers that may need root window.
@@ -952,7 +953,7 @@ void Shell::Init() {
               new views::corewm::TooltipAura(gfx::SCREEN_TYPE_ALTERNATE))));
   AddPreTargetHandler(tooltip_controller_.get());
 
-  event_client_.reset(new internal::EventClientImpl);
+  event_client_.reset(new EventClientImpl);
 
   // This controller needs to be set before SetupManagedWindowMode.
   desktop_background_controller_.reset(new DesktopBackgroundController());
@@ -963,7 +964,7 @@ void Shell::Init() {
   new_window_delegate_.reset(delegate_->CreateNewWindowDelegate());
   media_delegate_.reset(delegate_->CreateMediaDelegate());
 
-  resize_shadow_controller_.reset(new internal::ResizeShadowController());
+  resize_shadow_controller_.reset(new ResizeShadowController());
   shadow_controller_.reset(
       new ::wm::ShadowController(activation_client_));
 
@@ -974,27 +975,19 @@ void Shell::Init() {
   system_tray_delegate_.reset(delegate()->CreateSystemTrayDelegate());
   DCHECK(system_tray_delegate_.get());
 
-  locale_notification_controller_.reset(
-      new internal::LocaleNotificationController);
+  locale_notification_controller_.reset(new LocaleNotificationController);
 
   // Initialize system_tray_delegate_ after StatusAreaWidget is created.
   system_tray_delegate_->Initialize();
 
 #if defined(OS_CHROMEOS)
   // Create the LogoutConfirmationController after the SystemTrayDelegate.
-  logout_confirmation_controller_.reset(
-      new internal::LogoutConfirmationController(
-          base::Bind(&SystemTrayDelegate::SignOut,
-                     base::Unretained(system_tray_delegate_.get()))));
+  logout_confirmation_controller_.reset(new LogoutConfirmationController(
+      base::Bind(&SystemTrayDelegate::SignOut,
+                 base::Unretained(system_tray_delegate_.get()))));
 #endif
 
-  // TODO(oshima): Initialize all RootWindowControllers once, and
-  // initialize controller/delegates above when initializing the
-  // primary root window controller.
-  internal::RootWindowController::CreateForPrimaryDisplay(
-      root_window->GetHost());
-
-  display_controller_->InitSecondaryDisplays();
+  display_controller_->InitDisplays();
 
   // It needs to be created after RootWindowController has been created
   // (which calls OnWindowResized has been called, otherwise the
@@ -1013,41 +1006,39 @@ void Shell::Init() {
       scoped_ptr<ash::BrightnessControlDelegate>(
           new ash::system::BrightnessControllerChromeos).Pass());
 
-  power_event_observer_.reset(new internal::PowerEventObserver());
+  power_event_observer_.reset(new PowerEventObserver());
   user_activity_notifier_.reset(
-      new internal::UserActivityNotifier(user_activity_detector_.get()));
+      new ui::UserActivityPowerManagerNotifier(user_activity_detector_.get()));
   video_activity_notifier_.reset(
-      new internal::VideoActivityNotifier(video_detector_.get()));
-  bluetooth_notification_controller_.reset(
-      new internal::BluetoothNotificationController);
-  last_window_closed_logout_reminder_.reset(
-      new internal::LastWindowClosedLogoutReminder);
+      new VideoActivityNotifier(video_detector_.get()));
+  bluetooth_notification_controller_.reset(new BluetoothNotificationController);
+  last_window_closed_logout_reminder_.reset(new LastWindowClosedLogoutReminder);
 #endif
 
   weak_display_manager_factory_.reset(
-      new base::WeakPtrFactory<internal::DisplayManager>(
-          display_manager_.get()));
+      new base::WeakPtrFactory<DisplayManager>(display_manager_.get()));
   // The compositor thread and main message loop have to be running in
   // order to create mirror window. Run it after the main message loop
   // is started.
   base::MessageLoopForUI::current()->PostTask(
       FROM_HERE,
-      base::Bind(&internal::DisplayManager::CreateMirrorWindowIfAny,
+      base::Bind(&DisplayManager::CreateMirrorWindowIfAny,
                  weak_display_manager_factory_->GetWeakPtr()));
 }
 
 void Shell::InitKeyboard() {
   if (keyboard::IsKeyboardEnabled()) {
-    if (keyboard_controller_.get()) {
+    if (keyboard::KeyboardController::GetInstance()) {
       RootWindowControllerList controllers = GetAllRootWindowControllers();
       for (RootWindowControllerList::iterator iter = controllers.begin();
            iter != controllers.end(); ++iter) {
-        (*iter)->DeactivateKeyboard(keyboard_controller_.get());
+        (*iter)->DeactivateKeyboard(
+            keyboard::KeyboardController::GetInstance());
       }
     }
     keyboard::KeyboardControllerProxy* proxy =
         delegate_->CreateKeyboardControllerProxy();
-    keyboard_controller_.reset(
+    keyboard::KeyboardController::ResetInstance(
         new keyboard::KeyboardController(proxy));
   }
 }
@@ -1086,7 +1077,7 @@ bool Shell::CanWindowReceiveEvents(aura::Window* window) {
   RootWindowControllerList controllers = GetAllRootWindowControllers();
   for (RootWindowControllerList::iterator iter = controllers.begin();
        iter != controllers.end(); ++iter) {
-    internal::SystemModalContainerLayoutManager* layout_manager =
+    SystemModalContainerLayoutManager* layout_manager =
         (*iter)->GetSystemModalLayoutManager(window);
     if (layout_manager && layout_manager->CanWindowReceiveEvents(window))
       return true;