1 // Copyright 2017 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.
4 
5 #ifndef CHROME_BROWSER_CHROMEOS_ARC_USER_SESSION_ARC_USER_SESSION_SERVICE_H_
6 #define CHROME_BROWSER_CHROMEOS_ARC_USER_SESSION_ARC_USER_SESSION_SERVICE_H_
7 
8 #include "base/macros.h"
9 #include "components/arc/mojom/intent_helper.mojom-forward.h"
10 #include "components/arc/session/connection_observer.h"
11 #include "components/keyed_service/core/keyed_service.h"
12 #include "components/session_manager/core/session_manager_observer.h"
13 
14 namespace content {
15 class BrowserContext;
16 }  // namespace content
17 
18 namespace arc {
19 
20 class ArcBridgeService;
21 
22 class ArcUserSessionService
23     : public KeyedService,
24       public ConnectionObserver<mojom::IntentHelperInstance>,
25       public session_manager::SessionManagerObserver {
26  public:
27   // Returns singleton instance for the given BrowserContext,
28   // or nullptr if the browser |context| is not allowed to use ARC.
29   static ArcUserSessionService* GetForBrowserContext(
30       content::BrowserContext* context);
31 
32   ArcUserSessionService(content::BrowserContext* context,
33                         ArcBridgeService* bridge_service);
34   ~ArcUserSessionService() override;
35 
36   // ConnectionObserver<mojom::IntentHelperInstance> override.
37   void OnConnectionReady() override;
38   void OnConnectionClosed() override;
39 
40   // session_manager::SessionManagerObserver
41   void OnSessionStateChanged() override;
42 
43  private:
44   ArcBridgeService* const arc_bridge_service_;
45 
46   DISALLOW_COPY_AND_ASSIGN(ArcUserSessionService);
47 };
48 
49 }  // namespace arc
50 
51 #endif  // CHROME_BROWSER_CHROMEOS_ARC_USER_SESSION_ARC_USER_SESSION_SERVICE_H_
52