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

Side by Side Diff: chrome/browser/browser_process_platform_part_chromeos.cc

Issue 2916823002: Move Mus into chrome's process when running with --mus.
Patch Set: Removing debug include. Created 3 years, 5 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "chrome/browser/browser_process_platform_part_chromeos.h" 5 #include "chrome/browser/browser_process_platform_part_chromeos.h"
6 6
7 #include "ash/public/interfaces/constants.mojom.h"
7 #include "base/logging.h" 8 #include "base/logging.h"
8 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
9 #include "base/time/default_tick_clock.h" 10 #include "base/time/default_tick_clock.h"
10 #include "base/time/tick_clock.h" 11 #include "base/time/tick_clock.h"
11 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
12 #include "chrome/browser/chromeos/ash_config.h" 13 #include "chrome/browser/chromeos/ash_config.h"
13 #include "chrome/browser/chromeos/chrome_service_name.h" 14 #include "chrome/browser/chromeos/chrome_service_name.h"
14 #include "chrome/browser/chromeos/login/session/chrome_session_manager.h" 15 #include "chrome/browser/chromeos/login/session/chrome_session_manager.h"
15 #include "chrome/browser/chromeos/login/users/chrome_user_manager_impl.h" 16 #include "chrome/browser/chromeos/login/users/chrome_user_manager_impl.h"
16 #include "chrome/browser/chromeos/net/delay_network_call.h" 17 #include "chrome/browser/chromeos/net/delay_network_call.h"
17 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" 18 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
18 #include "chrome/browser/chromeos/profiles/profile_helper.h" 19 #include "chrome/browser/chromeos/profiles/profile_helper.h"
19 #include "chrome/browser/chromeos/settings/cros_settings.h" 20 #include "chrome/browser/chromeos/settings/cros_settings.h"
20 #include "chrome/browser/chromeos/system/automatic_reboot_manager.h" 21 #include "chrome/browser/chromeos/system/automatic_reboot_manager.h"
21 #include "chrome/browser/chromeos/system/device_disabling_manager.h" 22 #include "chrome/browser/chromeos/system/device_disabling_manager.h"
22 #include "chrome/browser/chromeos/system/device_disabling_manager_default_delega te.h" 23 #include "chrome/browser/chromeos/system/device_disabling_manager_default_delega te.h"
23 #include "chrome/browser/chromeos/system/system_clock.h" 24 #include "chrome/browser/chromeos/system/system_clock.h"
24 #include "chrome/browser/chromeos/system/timezone_resolver_manager.h" 25 #include "chrome/browser/chromeos/system/timezone_resolver_manager.h"
25 #include "chrome/browser/chromeos/system/timezone_util.h" 26 #include "chrome/browser/chromeos/system/timezone_util.h"
26 #include "chrome/browser/lifetime/keep_alive_types.h" 27 #include "chrome/browser/lifetime/keep_alive_types.h"
27 #include "chrome/browser/lifetime/scoped_keep_alive.h" 28 #include "chrome/browser/lifetime/scoped_keep_alive.h"
29 #include "chrome/browser/prefs/active_profile_pref_service.h"
30 #include "chrome/browser/profiles/profile_manager.h"
31 #include "chrome/browser/ui/ash/ash_util.h"
32 #include "chrome/browser/ui/browser_commands.h"
33 #include "chrome/browser/ui/browser_finder.h"
34 #include "chrome/browser/ui/browser_window.h"
35 #include "chrome/common/chrome_features.h"
28 #include "chrome/common/chrome_switches.h" 36 #include "chrome/common/chrome_switches.h"
29 #include "chromeos/geolocation/simple_geolocation_provider.h" 37 #include "chromeos/geolocation/simple_geolocation_provider.h"
30 #include "chromeos/timezone/timezone_resolver.h" 38 #include "chromeos/timezone/timezone_resolver.h"
31 #include "components/session_manager/core/session_manager.h" 39 #include "components/session_manager/core/session_manager.h"
32 #include "components/user_manager/user_manager.h" 40 #include "components/user_manager/user_manager.h"
41 #include "mash/public/interfaces/launchable.mojom.h"
42 #include "services/preferences/public/interfaces/preferences.mojom.h"
43 #include "services/service_manager/public/cpp/binder_registry.h"
44 #include "services/service_manager/public/cpp/interface_provider.h"
45 #include "services/service_manager/public/cpp/service.h"
46 #include "services/ui/public/interfaces/constants.mojom.h"
47 #include "services/ui/service.h"
33 48
34 #if defined(USE_OZONE) 49 #if defined(USE_OZONE)
35 #include "ash/public/interfaces/constants.mojom.h"
36 #include "content/public/common/service_manager_connection.h" 50 #include "content/public/common/service_manager_connection.h"
37 #include "services/service_manager/runner/common/client_util.h" 51 #include "services/service_manager/runner/common/client_util.h"
52 #include "services/ui/public/cpp/input_devices/input_device_controller.h"
38 #include "services/ui/public/cpp/input_devices/input_device_controller_client.h" 53 #include "services/ui/public/cpp/input_devices/input_device_controller_client.h"
39 #include "services/ui/public/interfaces/constants.mojom.h" 54 #include "services/ui/public/interfaces/constants.mojom.h"
40 #endif 55 #endif
41 56
57 namespace {
58 // Packaged service implementation used to expose miscellaneous application
59 // control features. This is a singleton service which runs on the main thread
60 // and never stops.
61 class ChromeServiceChromeOS : public service_manager::Service,
62 public mash::mojom::Launchable {
63 public:
64 ChromeServiceChromeOS() {
65 #if defined(USE_OZONE)
66 input_device_controller_.AddInterface(&interfaces_);
67 #endif
68 interfaces_.AddInterface<mash::mojom::Launchable>(
69 base::Bind(&ChromeServiceChromeOS::Create, base::Unretained(this)));
70 }
71 ~ChromeServiceChromeOS() override {}
72
73 static std::unique_ptr<service_manager::Service> CreateService() {
74 return base::MakeUnique<ChromeServiceChromeOS>();
75 }
76
77 private:
78 void CreateNewWindowImpl(bool is_incognito) {
79 Profile* profile = ProfileManager::GetActiveUserProfile();
80 chrome::NewEmptyWindow(is_incognito ? profile->GetOffTheRecordProfile()
81 : profile);
82 }
83
84 // service_manager::Service:
85 void OnBindInterface(const service_manager::BindSourceInfo& remote_info,
86 const std::string& name,
87 mojo::ScopedMessagePipeHandle handle) override {
88 interfaces_.BindInterface(remote_info, name, std::move(handle));
89 }
90
91 // mash::mojom::Launchable:
92 void Launch(uint32_t what, mash::mojom::LaunchMode how) override {
93 bool is_incognito;
94 switch (what) {
95 case mash::mojom::kWindow:
96 is_incognito = false;
97 break;
98 case mash::mojom::kIncognitoWindow:
99 is_incognito = true;
100 break;
101 default:
102 NOTREACHED();
103 }
104
105 bool reuse = how != mash::mojom::LaunchMode::MAKE_NEW;
106 if (reuse) {
107 Profile* profile = ProfileManager::GetActiveUserProfile();
108 Browser* browser = chrome::FindTabbedBrowser(
109 is_incognito ? profile->GetOffTheRecordProfile() : profile, false);
110 if (browser) {
111 browser->window()->Show();
112 return;
113 }
114 }
115
116 CreateNewWindowImpl(is_incognito);
117 }
118
119 void Create(const service_manager::BindSourceInfo& source_info,
120 mash::mojom::LaunchableRequest request) {
121 bindings_.AddBinding(this, std::move(request));
122 }
123
124 service_manager::BinderRegistry interfaces_;
125 mojo::BindingSet<mash::mojom::Launchable> bindings_;
126 #if defined(USE_OZONE)
127 ui::InputDeviceController input_device_controller_;
128 #endif
129
130 DISALLOW_COPY_AND_ASSIGN(ChromeServiceChromeOS);
131 };
132
133 std::unique_ptr<service_manager::Service> CreateEmbeddedUIService(
134 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
135 base::WeakPtr<ui::ImageCursorsSet> image_cursors_set_weak_ptr) {
136 ui::Service::InProcessConfig config;
137 config.resource_runner = task_runner;
138 config.image_cursors_set_weak_ptr = image_cursors_set_weak_ptr;
139 return base::MakeUnique<ui::Service>(&config);
140 }
141
142 } // namespace
143
42 BrowserProcessPlatformPart::BrowserProcessPlatformPart() 144 BrowserProcessPlatformPart::BrowserProcessPlatformPart()
43 : created_profile_helper_(false) {} 145 : created_profile_helper_(false) {}
44 146
45 BrowserProcessPlatformPart::~BrowserProcessPlatformPart() { 147 BrowserProcessPlatformPart::~BrowserProcessPlatformPart() {
46 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); 148 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
47 } 149 }
48 150
49 void BrowserProcessPlatformPart::InitializeAutomaticRebootManager() { 151 void BrowserProcessPlatformPart::InitializeAutomaticRebootManager() {
50 DCHECK(!automatic_reboot_manager_); 152 DCHECK(!automatic_reboot_manager_);
51 153
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 timezone_resolver_.reset(); 251 timezone_resolver_.reset();
150 profile_helper_.reset(); 252 profile_helper_.reset();
151 } 253 }
152 254
153 std::unique_ptr<policy::BrowserPolicyConnector> 255 std::unique_ptr<policy::BrowserPolicyConnector>
154 BrowserProcessPlatformPart::CreateBrowserPolicyConnector() { 256 BrowserProcessPlatformPart::CreateBrowserPolicyConnector() {
155 return std::unique_ptr<policy::BrowserPolicyConnector>( 257 return std::unique_ptr<policy::BrowserPolicyConnector>(
156 new policy::BrowserPolicyConnectorChromeOS()); 258 new policy::BrowserPolicyConnectorChromeOS());
157 } 259 }
158 260
261 void BrowserProcessPlatformPart::RegisterInProcessServices(
262 content::ContentBrowserClient::StaticServiceMap* services) {
263 {
264 service_manager::EmbeddedServiceInfo info;
265 info.factory = base::Bind(&ChromeServiceChromeOS::CreateService);
266 info.task_runner = base::ThreadTaskRunnerHandle::Get();
267 services->insert(std::make_pair(chromeos::kChromeServiceName, info));
268 }
269
270 if (features::PrefServiceEnabled()) {
271 service_manager::EmbeddedServiceInfo info;
272 info.factory = base::Bind([] {
273 return std::unique_ptr<service_manager::Service>(
274 base::MakeUnique<ActiveProfilePrefService>());
275 });
276 info.task_runner = base::ThreadTaskRunnerHandle::Get();
277 services->insert(std::make_pair(prefs::mojom::kForwarderServiceName, info));
278 }
279
280 if (!ash_util::IsRunningInMash()) {
281 {
282 service_manager::EmbeddedServiceInfo info;
283 info.factory = base::Bind(&ash_util::CreateEmbeddedAshService,
284 base::ThreadTaskRunnerHandle::Get());
285 info.task_runner = base::ThreadTaskRunnerHandle::Get();
286 services->insert(std::make_pair(ash::mojom::kServiceName, info));
287 }
288 {
289 service_manager::EmbeddedServiceInfo info;
290 info.factory = base::Bind(&CreateEmbeddedUIService,
291 base::ThreadTaskRunnerHandle::Get(),
292 image_cursors_set_.GetWeakPtr());
293 info.use_own_thread = true;
294 info.message_loop_type = base::MessageLoop::TYPE_UI;
295 info.thread_priority = base::ThreadPriority::DISPLAY;
296 services->insert(std::make_pair(ui::mojom::kServiceName, info));
297 }
298 }
299 }
300
159 chromeos::system::SystemClock* BrowserProcessPlatformPart::GetSystemClock() { 301 chromeos::system::SystemClock* BrowserProcessPlatformPart::GetSystemClock() {
160 if (!system_clock_.get()) 302 if (!system_clock_.get())
161 system_clock_.reset(new chromeos::system::SystemClock()); 303 system_clock_.reset(new chromeos::system::SystemClock());
162 return system_clock_.get(); 304 return system_clock_.get();
163 } 305 }
164 306
165 void BrowserProcessPlatformPart::DestroySystemClock() { 307 void BrowserProcessPlatformPart::DestroySystemClock() {
166 system_clock_.reset(); 308 system_clock_.reset();
167 } 309 }
168 310
(...skipping 22 matching lines...) Expand all
191 } 333 }
192 return input_device_controller_client_.get(); 334 return input_device_controller_client_.get();
193 } 335 }
194 #endif 336 #endif
195 337
196 void BrowserProcessPlatformPart::CreateProfileHelper() { 338 void BrowserProcessPlatformPart::CreateProfileHelper() {
197 DCHECK(!created_profile_helper_ && !profile_helper_); 339 DCHECK(!created_profile_helper_ && !profile_helper_);
198 created_profile_helper_ = true; 340 created_profile_helper_ = true;
199 profile_helper_.reset(new chromeos::ProfileHelper()); 341 profile_helper_.reset(new chromeos::ProfileHelper());
200 } 342 }
OLDNEW
« no previous file with comments | « chrome/browser/browser_process_platform_part_chromeos.h ('k') | chrome/browser/chrome_content_browser_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698