| OLD | NEW |
| 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/content_client/shell_browser_main_parts.h" | 5 #include "ash/shell/content_client/shell_browser_main_parts.h" |
| 6 | 6 |
| 7 #include "ash/desktop_background/desktop_background_controller.h" | 7 #include "ash/desktop_background/desktop_background_controller.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/shell/shell_delegate_impl.h" | 9 #include "ash/shell/shell_delegate_impl.h" |
| 10 #include "ash/shell/window_watcher.h" | 10 #include "ash/shell/window_watcher.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "net/base/net_module.h" | 21 #include "net/base/net_module.h" |
| 22 #include "ui/aura/client/stacking_client.h" | 22 #include "ui/aura/client/stacking_client.h" |
| 23 #include "ui/aura/env.h" | 23 #include "ui/aura/env.h" |
| 24 #include "ui/aura/root_window.h" | 24 #include "ui/aura/root_window.h" |
| 25 #include "ui/aura/window.h" | 25 #include "ui/aura/window.h" |
| 26 #include "ui/base/resource/resource_bundle.h" | 26 #include "ui/base/resource/resource_bundle.h" |
| 27 #include "ui/base/ui_base_paths.h" | 27 #include "ui/base/ui_base_paths.h" |
| 28 #include "ui/compositor/compositor.h" | 28 #include "ui/compositor/compositor.h" |
| 29 #include "ui/compositor/test/compositor_test_support.h" | 29 #include "ui/compositor/test/compositor_test_support.h" |
| 30 #include "ui/gfx/screen.h" | 30 #include "ui/gfx/screen.h" |
| 31 #include "ui/message_center/message_center.h" |
| 31 #include "ui/views/focus/accelerator_handler.h" | 32 #include "ui/views/focus/accelerator_handler.h" |
| 32 #include "ui/views/test/test_views_delegate.h" | 33 #include "ui/views/test/test_views_delegate.h" |
| 33 | 34 |
| 34 #if defined(ENABLE_MESSAGE_CENTER) | |
| 35 #include "ui/message_center/message_center.h" | |
| 36 #endif | |
| 37 | |
| 38 #if defined(USE_X11) | 35 #if defined(USE_X11) |
| 39 #include "ui/base/touch/touch_factory_x11.h" | 36 #include "ui/base/touch/touch_factory_x11.h" |
| 40 #endif | 37 #endif |
| 41 | 38 |
| 42 #if defined(OS_CHROMEOS) | 39 #if defined(OS_CHROMEOS) |
| 43 #include "chromeos/dbus/dbus_thread_manager.h" | 40 #include "chromeos/dbus/dbus_thread_manager.h" |
| 44 #endif | 41 #endif |
| 45 | 42 |
| 46 namespace ash { | 43 namespace ash { |
| 47 namespace shell { | 44 namespace shell { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 } | 99 } |
| 103 | 100 |
| 104 void ShellBrowserMainParts::PreMainMessageLoopRun() { | 101 void ShellBrowserMainParts::PreMainMessageLoopRun() { |
| 105 browser_context_.reset(new content::ShellBrowserContext(false)); | 102 browser_context_.reset(new content::ShellBrowserContext(false)); |
| 106 | 103 |
| 107 // A ViewsDelegate is required. | 104 // A ViewsDelegate is required. |
| 108 if (!views::ViewsDelegate::views_delegate) | 105 if (!views::ViewsDelegate::views_delegate) |
| 109 views::ViewsDelegate::views_delegate = new ShellViewsDelegate; | 106 views::ViewsDelegate::views_delegate = new ShellViewsDelegate; |
| 110 | 107 |
| 111 delegate_ = new ash::shell::ShellDelegateImpl; | 108 delegate_ = new ash::shell::ShellDelegateImpl; |
| 112 #if defined(ENABLE_MESSAGE_CENTER) | |
| 113 // The global message center state must be initialized absent | 109 // The global message center state must be initialized absent |
| 114 // g_browser_process. | 110 // g_browser_process. |
| 115 message_center::MessageCenter::Initialize(); | 111 message_center::MessageCenter::Initialize(); |
| 116 #endif | |
| 117 ash::Shell::CreateInstance(delegate_); | 112 ash::Shell::CreateInstance(delegate_); |
| 118 ash::Shell::GetInstance()->set_browser_context(browser_context_.get()); | 113 ash::Shell::GetInstance()->set_browser_context(browser_context_.get()); |
| 119 | 114 |
| 120 window_watcher_.reset(new ash::shell::WindowWatcher); | 115 window_watcher_.reset(new ash::shell::WindowWatcher); |
| 121 gfx::Screen* screen = Shell::GetInstance()->GetScreen(); | 116 gfx::Screen* screen = Shell::GetInstance()->GetScreen(); |
| 122 screen->AddObserver(window_watcher_.get()); | 117 screen->AddObserver(window_watcher_.get()); |
| 123 delegate_->SetWatcher(window_watcher_.get()); | 118 delegate_->SetWatcher(window_watcher_.get()); |
| 124 | 119 |
| 125 ash::shell::InitWindowTypeLauncher(); | 120 ash::shell::InitWindowTypeLauncher(); |
| 126 | 121 |
| 127 DesktopBackgroundController* controller = | 122 DesktopBackgroundController* controller = |
| 128 Shell::GetInstance()->desktop_background_controller(); | 123 Shell::GetInstance()->desktop_background_controller(); |
| 129 if (controller->GetAppropriateResolution() == WALLPAPER_RESOLUTION_LARGE) | 124 if (controller->GetAppropriateResolution() == WALLPAPER_RESOLUTION_LARGE) |
| 130 controller->SetDefaultWallpaper(kDefaultLargeWallpaper); | 125 controller->SetDefaultWallpaper(kDefaultLargeWallpaper); |
| 131 else | 126 else |
| 132 controller->SetDefaultWallpaper(kDefaultSmallWallpaper); | 127 controller->SetDefaultWallpaper(kDefaultSmallWallpaper); |
| 133 | 128 |
| 134 ash::Shell::GetPrimaryRootWindow()->ShowRootWindow(); | 129 ash::Shell::GetPrimaryRootWindow()->ShowRootWindow(); |
| 135 } | 130 } |
| 136 | 131 |
| 137 void ShellBrowserMainParts::PostMainMessageLoopRun() { | 132 void ShellBrowserMainParts::PostMainMessageLoopRun() { |
| 138 gfx::Screen* screen = Shell::GetInstance()->GetScreen(); | 133 gfx::Screen* screen = Shell::GetInstance()->GetScreen(); |
| 139 screen->RemoveObserver(window_watcher_.get()); | 134 screen->RemoveObserver(window_watcher_.get()); |
| 140 | 135 |
| 141 window_watcher_.reset(); | 136 window_watcher_.reset(); |
| 142 delegate_->SetWatcher(NULL); | 137 delegate_->SetWatcher(NULL); |
| 143 delegate_ = NULL; | 138 delegate_ = NULL; |
| 144 ash::Shell::DeleteInstance(); | 139 ash::Shell::DeleteInstance(); |
| 145 #if defined(ENABLE_MESSAGE_CENTER) | |
| 146 // The global message center state must be shutdown absent | 140 // The global message center state must be shutdown absent |
| 147 // g_browser_process. | 141 // g_browser_process. |
| 148 message_center::MessageCenter::Shutdown(); | 142 message_center::MessageCenter::Shutdown(); |
| 149 #endif | |
| 150 aura::Env::DeleteInstance(); | 143 aura::Env::DeleteInstance(); |
| 151 | 144 |
| 152 // The keyboard may have created a WebContents. The WebContents is destroyed | 145 // The keyboard may have created a WebContents. The WebContents is destroyed |
| 153 // with the UI, and it needs the BrowserContext to be alive during its | 146 // with the UI, and it needs the BrowserContext to be alive during its |
| 154 // destruction. So destroy all of the UI elements before destroying the | 147 // destruction. So destroy all of the UI elements before destroying the |
| 155 // browser context. | 148 // browser context. |
| 156 browser_context_.reset(); | 149 browser_context_.reset(); |
| 157 } | 150 } |
| 158 | 151 |
| 159 bool ShellBrowserMainParts::MainMessageLoopRun(int* result_code) { | 152 bool ShellBrowserMainParts::MainMessageLoopRun(int* result_code) { |
| 160 base::MessageLoopForUI::current()->Run(); | 153 base::MessageLoopForUI::current()->Run(); |
| 161 return true; | 154 return true; |
| 162 } | 155 } |
| 163 | 156 |
| 164 } // namespace shell | 157 } // namespace shell |
| 165 } // namespace ash | 158 } // namespace ash |
| OLD | NEW |