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

Side by Side Diff: ash/shell/content/client/shell_browser_main_parts.cc

Issue 2618143002: cros: Remove some OS platform ifdefs from ash (Closed)
Patch Set: rebase Created 3 years, 11 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
« no previous file with comments | « ash/shell.cc ('k') | ash/shell/content/shell_with_content_main.cc » ('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) 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/common/login_status.h" 7 #include "ash/common/login_status.h"
8 #include "ash/common/material_design/material_design_controller.h" 8 #include "ash/common/material_design/material_design_controller.h"
9 #include "ash/common/wm_shell.h" 9 #include "ash/common/wm_shell.h"
10 #include "ash/content/shell_content_state.h" 10 #include "ash/content/shell_content_state.h"
11 #include "ash/shell.h" 11 #include "ash/shell.h"
12 #include "ash/shell/content/shell_content_state_impl.h" 12 #include "ash/shell/content/shell_content_state_impl.h"
13 #include "ash/shell/example_app_list_presenter.h" 13 #include "ash/shell/example_app_list_presenter.h"
14 #include "ash/shell/shell_delegate_impl.h" 14 #include "ash/shell/shell_delegate_impl.h"
15 #include "ash/shell/window_watcher.h" 15 #include "ash/shell/window_watcher.h"
16 #include "ash/shell_init_params.h" 16 #include "ash/shell_init_params.h"
17 #include "base/bind.h" 17 #include "base/bind.h"
18 #include "base/command_line.h" 18 #include "base/command_line.h"
19 #include "base/i18n/icu_util.h" 19 #include "base/i18n/icu_util.h"
20 #include "base/message_loop/message_loop.h" 20 #include "base/message_loop/message_loop.h"
21 #include "base/run_loop.h" 21 #include "base/run_loop.h"
22 #include "base/strings/string_number_conversions.h" 22 #include "base/strings/string_number_conversions.h"
23 #include "base/threading/thread.h" 23 #include "base/threading/thread.h"
24 #include "base/threading/thread_restrictions.h" 24 #include "base/threading/thread_restrictions.h"
25 #include "chromeos/audio/cras_audio_handler.h"
26 #include "chromeos/dbus/dbus_thread_manager.h"
25 #include "content/public/browser/browser_thread.h" 27 #include "content/public/browser/browser_thread.h"
26 #include "content/public/browser/context_factory.h" 28 #include "content/public/browser/context_factory.h"
27 #include "content/public/common/content_switches.h" 29 #include "content/public/common/content_switches.h"
28 #include "content/shell/browser/shell_browser_context.h" 30 #include "content/shell/browser/shell_browser_context.h"
29 #include "content/shell/browser/shell_net_log.h" 31 #include "content/shell/browser/shell_net_log.h"
32 #include "device/bluetooth/dbus/bluez_dbus_manager.h"
30 #include "net/base/net_module.h" 33 #include "net/base/net_module.h"
31 #include "ui/app_list/presenter/app_list.h" 34 #include "ui/app_list/presenter/app_list.h"
32 #include "ui/aura/env.h" 35 #include "ui/aura/env.h"
33 #include "ui/aura/window.h" 36 #include "ui/aura/window.h"
34 #include "ui/aura/window_tree_host.h" 37 #include "ui/aura/window_tree_host.h"
35 #include "ui/base/material_design/material_design_controller.h" 38 #include "ui/base/material_design/material_design_controller.h"
36 #include "ui/base/ui_base_paths.h" 39 #include "ui/base/ui_base_paths.h"
37 #include "ui/compositor/compositor.h" 40 #include "ui/compositor/compositor.h"
38 #include "ui/display/screen.h" 41 #include "ui/display/screen.h"
39 #include "ui/message_center/message_center.h" 42 #include "ui/message_center/message_center.h"
40 #include "ui/views/test/test_views_delegate.h" 43 #include "ui/views/test/test_views_delegate.h"
41 #include "ui/wm/core/wm_state.h" 44 #include "ui/wm/core/wm_state.h"
42 45
43 #if defined(USE_X11) 46 #if defined(USE_X11)
44 #include "ui/events/devices/x11/touch_factory_x11.h" // nogncheck 47 #include "ui/events/devices/x11/touch_factory_x11.h" // nogncheck
45 #endif 48 #endif
46 49
47 #if defined(OS_CHROMEOS)
48 #include "chromeos/audio/cras_audio_handler.h"
49 #include "chromeos/dbus/dbus_thread_manager.h"
50 #include "device/bluetooth/dbus/bluez_dbus_manager.h"
51 #endif
52
53 namespace ash { 50 namespace ash {
54 namespace shell { 51 namespace shell {
55 void InitWindowTypeLauncher(); 52 void InitWindowTypeLauncher();
56 53
57 namespace { 54 namespace {
58 55
59 class ShellViewsDelegate : public views::TestViewsDelegate { 56 class ShellViewsDelegate : public views::TestViewsDelegate {
60 public: 57 public:
61 ShellViewsDelegate() {} 58 ShellViewsDelegate() {}
62 ~ShellViewsDelegate() override {} 59 ~ShellViewsDelegate() override {}
(...skipping 28 matching lines...) Expand all
91 88
92 ShellBrowserMainParts::~ShellBrowserMainParts() {} 89 ShellBrowserMainParts::~ShellBrowserMainParts() {}
93 90
94 void ShellBrowserMainParts::PreMainMessageLoopStart() { 91 void ShellBrowserMainParts::PreMainMessageLoopStart() {
95 #if defined(USE_X11) 92 #if defined(USE_X11)
96 ui::TouchFactory::SetTouchDeviceListFromCommandLine(); 93 ui::TouchFactory::SetTouchDeviceListFromCommandLine();
97 #endif 94 #endif
98 } 95 }
99 96
100 void ShellBrowserMainParts::PostMainMessageLoopStart() { 97 void ShellBrowserMainParts::PostMainMessageLoopStart() {
101 #if defined(OS_CHROMEOS)
102 chromeos::DBusThreadManager::Initialize( 98 chromeos::DBusThreadManager::Initialize(
103 chromeos::DBusThreadManager::PROCESS_ASH); 99 chromeos::DBusThreadManager::PROCESS_ASH);
104 #endif
105 } 100 }
106 101
107 void ShellBrowserMainParts::ToolkitInitialized() { 102 void ShellBrowserMainParts::ToolkitInitialized() {
108 ash::MaterialDesignController::Initialize(); 103 ash::MaterialDesignController::Initialize();
109 wm_state_.reset(new ::wm::WMState); 104 wm_state_.reset(new ::wm::WMState);
110 } 105 }
111 106
112 void ShellBrowserMainParts::PreMainMessageLoopRun() { 107 void ShellBrowserMainParts::PreMainMessageLoopRun() {
113 net_log_.reset(new content::ShellNetLog("ash_shell")); 108 net_log_.reset(new content::ShellNetLog("ash_shell"));
114 browser_context_.reset( 109 browser_context_.reset(
115 new content::ShellBrowserContext(false, net_log_.get())); 110 new content::ShellBrowserContext(false, net_log_.get()));
116 111
117 // A ViewsDelegate is required. 112 // A ViewsDelegate is required.
118 if (!views::ViewsDelegate::GetInstance()) 113 if (!views::ViewsDelegate::GetInstance())
119 views_delegate_.reset(new ShellViewsDelegate); 114 views_delegate_.reset(new ShellViewsDelegate);
120 115
121 delegate_ = new ash::shell::ShellDelegateImpl; 116 delegate_ = new ash::shell::ShellDelegateImpl;
122 // The global message center state must be initialized absent 117 // The global message center state must be initialized absent
123 // g_browser_process. 118 // g_browser_process.
124 message_center::MessageCenter::Initialize(); 119 message_center::MessageCenter::Initialize();
125 120
126 #if defined(OS_CHROMEOS)
127 // Create CrasAudioHandler for testing since g_browser_process 121 // Create CrasAudioHandler for testing since g_browser_process
128 // is absent. 122 // is absent.
129 chromeos::CrasAudioHandler::InitializeForTesting(); 123 chromeos::CrasAudioHandler::InitializeForTesting();
130 124
131 bluez::BluezDBusManager::Initialize(nullptr, true /* use stub */); 125 bluez::BluezDBusManager::Initialize(nullptr, true /* use stub */);
132 #endif
133 126
134 ShellContentState::SetInstance( 127 ShellContentState::SetInstance(
135 new ShellContentStateImpl(browser_context_.get())); 128 new ShellContentStateImpl(browser_context_.get()));
136 ui::MaterialDesignController::Initialize(); 129 ui::MaterialDesignController::Initialize();
137 ash::ShellInitParams init_params; 130 ash::ShellInitParams init_params;
138 init_params.delegate = delegate_; 131 init_params.delegate = delegate_;
139 init_params.context_factory = content::GetContextFactory(); 132 init_params.context_factory = content::GetContextFactory();
140 init_params.context_factory_private = content::GetContextFactoryPrivate(); 133 init_params.context_factory_private = content::GetContextFactoryPrivate();
141 init_params.blocking_pool = content::BrowserThread::GetBlockingPool(); 134 init_params.blocking_pool = content::BrowserThread::GetBlockingPool();
142 ash::Shell::CreateInstance(init_params); 135 ash::Shell::CreateInstance(init_params);
(...skipping 17 matching lines...) Expand all
160 display::Screen::GetScreen()->RemoveObserver(window_watcher_.get()); 153 display::Screen::GetScreen()->RemoveObserver(window_watcher_.get());
161 154
162 window_watcher_.reset(); 155 window_watcher_.reset();
163 delegate_ = nullptr; 156 delegate_ = nullptr;
164 ash::Shell::DeleteInstance(); 157 ash::Shell::DeleteInstance();
165 ShellContentState::DestroyInstance(); 158 ShellContentState::DestroyInstance();
166 // The global message center state must be shutdown absent 159 // The global message center state must be shutdown absent
167 // g_browser_process. 160 // g_browser_process.
168 message_center::MessageCenter::Shutdown(); 161 message_center::MessageCenter::Shutdown();
169 162
170 #if defined(OS_CHROMEOS)
171 chromeos::CrasAudioHandler::Shutdown(); 163 chromeos::CrasAudioHandler::Shutdown();
172 #endif
173 164
174 views_delegate_.reset(); 165 views_delegate_.reset();
175 166
176 // The keyboard may have created a WebContents. The WebContents is destroyed 167 // The keyboard may have created a WebContents. The WebContents is destroyed
177 // with the UI, and it needs the BrowserContext to be alive during its 168 // with the UI, and it needs the BrowserContext to be alive during its
178 // destruction. So destroy all of the UI elements before destroying the 169 // destruction. So destroy all of the UI elements before destroying the
179 // browser context. 170 // browser context.
180 browser_context_.reset(); 171 browser_context_.reset();
181 } 172 }
182 173
183 bool ShellBrowserMainParts::MainMessageLoopRun(int* result_code) { 174 bool ShellBrowserMainParts::MainMessageLoopRun(int* result_code) {
184 base::RunLoop().Run(); 175 base::RunLoop().Run();
185 return true; 176 return true;
186 } 177 }
187 178
188 } // namespace shell 179 } // namespace shell
189 } // namespace ash 180 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shell.cc ('k') | ash/shell/content/shell_with_content_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698