Check USB device path access when prompting users to select a device.
[chromium-blink-merge.git] / chrome / browser / apps / app_shim / app_shim_host_manager_mac.h
blob3ac45b182c8f3a460fdcce5608e1610ad5191a51
1 // Copyright 2013 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.
5 #ifndef CHROME_BROWSER_APPS_APP_SHIM_APP_SHIM_HOST_MANAGER_MAC_H_
6 #define CHROME_BROWSER_APPS_APP_SHIM_APP_SHIM_HOST_MANAGER_MAC_H_
8 #include "base/memory/ref_counted.h"
9 #include "chrome/browser/apps/app_shim/extension_app_shim_handler_mac.h"
10 #include "chrome/browser/apps/app_shim/unix_domain_socket_acceptor.h"
11 #include "content/public/browser/browser_thread.h"
13 namespace base {
14 class FilePath;
17 namespace test {
18 class AppShimHostManagerTestApi;
21 // The AppShimHostManager receives connections from app shims on a UNIX
22 // socket (|acceptor_|) and creates a helper object to manage the connection.
23 class AppShimHostManager : public apps::UnixDomainSocketAcceptor::Delegate,
24 public base::RefCountedThreadSafe<
25 AppShimHostManager,
26 content::BrowserThread::DeleteOnUIThread> {
27 public:
28 AppShimHostManager();
30 // Init passes this AppShimHostManager to PostTask which requires it to have
31 // a non-zero refcount. Therefore, Init cannot be called in the constructor
32 // since the refcount is zero at that point.
33 void Init();
35 apps::ExtensionAppShimHandler* extension_app_shim_handler() {
36 return &extension_app_shim_handler_;
39 private:
40 friend class base::RefCountedThreadSafe<AppShimHostManager>;
41 friend struct content::BrowserThread::DeleteOnThread<
42 content::BrowserThread::UI>;
43 friend class base::DeleteHelper<AppShimHostManager>;
44 friend class test::AppShimHostManagerTestApi;
45 virtual ~AppShimHostManager();
47 // UnixDomainSocketAcceptor::Delegate implementation.
48 void OnClientConnected(const IPC::ChannelHandle& handle) override;
49 void OnListenError() override;
51 // The |acceptor_| must be created on a thread which allows blocking I/O, so
52 // part of the initialization of this class must be carried out on the file
53 // thread.
54 void InitOnFileThread();
56 // Called on the IO thread to begin listening for connections from app shims.
57 void ListenOnIOThread();
59 // The AppShimHostManager is only initialized if the Chrome process
60 // successfully took the singleton lock. This prevents subsequent processes
61 // from deleting existing app shim socket files.
62 bool did_init_;
64 base::FilePath directory_in_tmp_;
66 scoped_ptr<apps::UnixDomainSocketAcceptor> acceptor_;
68 apps::ExtensionAppShimHandler extension_app_shim_handler_;
70 DISALLOW_COPY_AND_ASSIGN(AppShimHostManager);
73 #endif // CHROME_BROWSER_APPS_APP_SHIM_APP_SHIM_HOST_MANAGER_MAC_H_