[M120 Migration]Fix for crash during chrome exit
[platform/framework/web/chromium-efl.git] / chrome / browser / file_util_service.cc
1 // Copyright 2019 The Chromium Authors
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 "chrome/browser/file_util_service.h"
6
7 #include "build/build_config.h"
8 #include "chrome/grit/generated_resources.h"
9 #include "chrome/services/file_util/public/mojom/file_util_service.mojom.h"
10 #include "components/strings/grit/components_strings.h"
11 #include "content/public/browser/service_process_host.h"
12 #include "content/public/browser/service_process_host_passkeys.h"
13
14 namespace chrome {
15 // Class allows us to friend the passkeys we need to launch the service.
16 class FileUtilServiceLauncher {
17  public:
18   static mojo::PendingRemote<chrome::mojom::FileUtilService>
19   LaunchFileUtilService() {
20     mojo::PendingRemote<chrome::mojom::FileUtilService> remote;
21     content::ServiceProcessHost::Launch<chrome::mojom::FileUtilService>(
22         remote.InitWithNewPipeAndPassReceiver(),
23         content::ServiceProcessHost::Options()
24 #if BUILDFLAG(IS_WIN)
25             // The FileUtilService supports archive inspection, which uses unrar
26             // for inspecting rar archives. Unrar depends on user32.dll for
27             // handling upper/lowercase.
28             .WithPinUser32(content::ServiceProcessHostPinUser32::GetPassKey())
29 #endif  // BUILDFLAG(IS_WIN)
30             .WithDisplayName(IDS_UTILITY_PROCESS_FILE_UTILITY_NAME)
31             .Pass());
32     return remote;
33   }
34 };
35 }  // namespace chrome
36
37 mojo::PendingRemote<chrome::mojom::FileUtilService> LaunchFileUtilService() {
38   return chrome::FileUtilServiceLauncher::LaunchFileUtilService();
39 }