Home | History | Annotate | Download | only in shell
      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
      3 // found in the LICENSE file.
      4 
      5 #include "ash/shell/shell_delegate_impl.h"
      6 
      7 #include "ash/accessibility_delegate.h"
      8 #include "ash/caps_lock_delegate_stub.h"
      9 #include "ash/default_accessibility_delegate.h"
     10 #include "ash/default_user_wallpaper_delegate.h"
     11 #include "ash/host/root_window_host_factory.h"
     12 #include "ash/media_delegate.h"
     13 #include "ash/new_window_delegate.h"
     14 #include "ash/session_state_delegate.h"
     15 #include "ash/session_state_delegate_stub.h"
     16 #include "ash/shell/context_menu.h"
     17 #include "ash/shell/example_factory.h"
     18 #include "ash/shell/keyboard_controller_proxy_stub.h"
     19 #include "ash/shell/shelf_delegate_impl.h"
     20 #include "ash/shell/toplevel_window.h"
     21 #include "ash/shell_window_ids.h"
     22 #include "ash/system/tray/default_system_tray_delegate.h"
     23 #include "ash/wm/window_state.h"
     24 #include "base/message_loop/message_loop.h"
     25 #include "ui/aura/window.h"
     26 #include "ui/views/corewm/input_method_event_filter.h"
     27 
     28 namespace ash {
     29 namespace shell {
     30 namespace {
     31 
     32 class NewWindowDelegateImpl : public NewWindowDelegate {
     33  public:
     34   NewWindowDelegateImpl() {}
     35   virtual ~NewWindowDelegateImpl() {}
     36 
     37   virtual void NewTab() OVERRIDE {}
     38   virtual void NewWindow(bool incognito) OVERRIDE {
     39     ash::shell::ToplevelWindow::CreateParams create_params;
     40     create_params.can_resize = true;
     41     create_params.can_maximize = true;
     42     ash::shell::ToplevelWindow::CreateToplevelWindow(create_params);
     43   }
     44   virtual void OpenFileManager() OVERRIDE {}
     45   virtual void OpenCrosh() OVERRIDE {}
     46   virtual void RestoreTab() OVERRIDE {}
     47   virtual void ShowKeyboardOverlay() OVERRIDE {}
     48   virtual void ShowTaskManager() OVERRIDE {}
     49   virtual void OpenFeedbackPage() OVERRIDE {}
     50 
     51  private:
     52   DISALLOW_COPY_AND_ASSIGN(NewWindowDelegateImpl);
     53 };
     54 
     55 class MediaDelegateImpl : public MediaDelegate {
     56  public:
     57   MediaDelegateImpl() {}
     58   virtual ~MediaDelegateImpl() {}
     59 
     60   virtual void HandleMediaNextTrack() OVERRIDE {}
     61   virtual void HandleMediaPlayPause() OVERRIDE {}
     62   virtual void HandleMediaPrevTrack() OVERRIDE {}
     63 
     64  private:
     65   DISALLOW_COPY_AND_ASSIGN(MediaDelegateImpl);
     66 };
     67 
     68 }  // namespace
     69 
     70 ShellDelegateImpl::ShellDelegateImpl()
     71     : watcher_(NULL),
     72       shelf_delegate_(NULL),
     73       browser_context_(NULL) {
     74 }
     75 
     76 ShellDelegateImpl::~ShellDelegateImpl() {
     77 }
     78 
     79 void ShellDelegateImpl::SetWatcher(WindowWatcher* watcher) {
     80   watcher_ = watcher;
     81   if (shelf_delegate_)
     82     shelf_delegate_->set_watcher(watcher);
     83 }
     84 
     85 bool ShellDelegateImpl::IsFirstRunAfterBoot() const {
     86   return false;
     87 }
     88 
     89 bool ShellDelegateImpl::IsIncognitoAllowed() const {
     90   return true;
     91 }
     92 
     93 bool ShellDelegateImpl::IsMultiProfilesEnabled() const {
     94   return false;
     95 }
     96 
     97 bool ShellDelegateImpl::IsRunningInForcedAppMode() const {
     98   return false;
     99 }
    100 
    101 void ShellDelegateImpl::PreInit() {
    102 }
    103 
    104 void ShellDelegateImpl::Shutdown() {
    105 }
    106 
    107 void ShellDelegateImpl::Exit() {
    108   base::MessageLoopForUI::current()->Quit();
    109 }
    110 
    111 keyboard::KeyboardControllerProxy*
    112     ShellDelegateImpl::CreateKeyboardControllerProxy() {
    113   return new KeyboardControllerProxyStub();
    114 }
    115 
    116 content::BrowserContext* ShellDelegateImpl::GetActiveBrowserContext() {
    117   return browser_context_;
    118 }
    119 
    120 app_list::AppListViewDelegate* ShellDelegateImpl::CreateAppListViewDelegate() {
    121   return ash::shell::CreateAppListViewDelegate();
    122 }
    123 
    124 ShelfDelegate* ShellDelegateImpl::CreateShelfDelegate(ShelfModel* model) {
    125   shelf_delegate_ = new ShelfDelegateImpl(watcher_);
    126   return shelf_delegate_;
    127 }
    128 
    129 ash::SystemTrayDelegate* ShellDelegateImpl::CreateSystemTrayDelegate() {
    130   return new DefaultSystemTrayDelegate;
    131 }
    132 
    133 ash::UserWallpaperDelegate* ShellDelegateImpl::CreateUserWallpaperDelegate() {
    134   return new DefaultUserWallpaperDelegate();
    135 }
    136 
    137 ash::CapsLockDelegate* ShellDelegateImpl::CreateCapsLockDelegate() {
    138   return new CapsLockDelegateStub;
    139 }
    140 
    141 ash::SessionStateDelegate* ShellDelegateImpl::CreateSessionStateDelegate() {
    142   return new SessionStateDelegateStub;
    143 }
    144 
    145 ash::AccessibilityDelegate* ShellDelegateImpl::CreateAccessibilityDelegate() {
    146   return new internal::DefaultAccessibilityDelegate;
    147 }
    148 
    149 ash::NewWindowDelegate* ShellDelegateImpl::CreateNewWindowDelegate() {
    150   return new NewWindowDelegateImpl;
    151 }
    152 
    153 ash::MediaDelegate* ShellDelegateImpl::CreateMediaDelegate() {
    154   return new MediaDelegateImpl;
    155 }
    156 
    157 aura::client::UserActionClient* ShellDelegateImpl::CreateUserActionClient() {
    158   return NULL;
    159 }
    160 
    161 ui::MenuModel* ShellDelegateImpl::CreateContextMenu(aura::Window* root) {
    162   return new ContextMenu(root);
    163 }
    164 
    165 RootWindowHostFactory* ShellDelegateImpl::CreateRootWindowHostFactory() {
    166   return RootWindowHostFactory::Create();
    167 }
    168 
    169 base::string16 ShellDelegateImpl::GetProductName() const {
    170   return base::string16();
    171 }
    172 
    173 }  // namespace shell
    174 }  // namespace ash
    175