OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef COMPONENTS_ARC_INTENT_HELPER_ARC_INTENT_HELPER_BRIDGE_H_ | 5 #ifndef COMPONENTS_ARC_INTENT_HELPER_ARC_INTENT_HELPER_BRIDGE_H_ |
6 #define COMPONENTS_ARC_INTENT_HELPER_ARC_INTENT_HELPER_BRIDGE_H_ | 6 #define COMPONENTS_ARC_INTENT_HELPER_ARC_INTENT_HELPER_BRIDGE_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 19 matching lines...) Expand all Loading... | |
30 class LocalActivityResolver; | 30 class LocalActivityResolver; |
31 class SetWallpaperDelegate; | 31 class SetWallpaperDelegate; |
32 | 32 |
33 // Receives intents from ARC. | 33 // Receives intents from ARC. |
34 class ArcIntentHelperBridge | 34 class ArcIntentHelperBridge |
35 : public ArcService, | 35 : public ArcService, |
36 public InstanceHolder<mojom::IntentHelperInstance>::Observer, | 36 public InstanceHolder<mojom::IntentHelperInstance>::Observer, |
37 public mojom::IntentHelperHost, | 37 public mojom::IntentHelperHost, |
38 public ash::LinkHandlerModelFactory { | 38 public ash::LinkHandlerModelFactory { |
39 public: | 39 public: |
40 enum class GetResult { | |
41 // Failed. The intent_helper instance is not yet ready. This is a temporary | |
42 // error. | |
43 FAILED_ARC_NOT_READY, | |
44 // Failed. Either ARC is not supported at all or intent_helper instance | |
45 // version is too old. | |
46 FAILED_ARC_NOT_SUPPORTED, | |
47 }; | |
48 | |
40 ArcIntentHelperBridge( | 49 ArcIntentHelperBridge( |
41 ArcBridgeService* bridge_service, | 50 ArcBridgeService* bridge_service, |
42 const scoped_refptr<ActivityIconLoader>& icon_loader, | 51 const scoped_refptr<ActivityIconLoader>& icon_loader, |
43 const scoped_refptr<LocalActivityResolver>& activity_resolver); | 52 const scoped_refptr<LocalActivityResolver>& activity_resolver); |
44 ~ArcIntentHelperBridge() override; | 53 ~ArcIntentHelperBridge() override; |
45 | 54 |
46 // InstanceHolder<mojom::IntentHelperInstance>::Observer | 55 // InstanceHolder<mojom::IntentHelperInstance>::Observer |
47 void OnInstanceReady() override; | 56 void OnInstanceReady() override; |
48 void OnInstanceClosed() override; | 57 void OnInstanceClosed() override; |
49 | 58 |
(...skipping 10 matching lines...) Expand all Loading... | |
60 std::unique_ptr<ash::LinkHandlerModel> CreateModel(const GURL& url) override; | 69 std::unique_ptr<ash::LinkHandlerModel> CreateModel(const GURL& url) override; |
61 | 70 |
62 // Returns false if |package_name| is for the intent_helper apk. | 71 // Returns false if |package_name| is for the intent_helper apk. |
63 static bool IsIntentHelperPackage(const std::string& package_name); | 72 static bool IsIntentHelperPackage(const std::string& package_name); |
64 | 73 |
65 // Filters out handlers that belong to the intent_helper apk and returns | 74 // Filters out handlers that belong to the intent_helper apk and returns |
66 // a new array. | 75 // a new array. |
67 static mojo::Array<mojom::UrlHandlerInfoPtr> FilterOutIntentHelper( | 76 static mojo::Array<mojom::UrlHandlerInfoPtr> FilterOutIntentHelper( |
68 mojo::Array<mojom::UrlHandlerInfoPtr> handlers); | 77 mojo::Array<mojom::UrlHandlerInfoPtr> handlers); |
69 | 78 |
79 // Gets the mojo instance if it's available. On failure, returns nullptr and | |
80 // updates |out_error_code| if it's not nullptr. | |
81 static mojom::IntentHelperInstance* GetIntentHelperInstance( | |
Luis Héctor Chávez
2016/09/14 20:28:49
I wonder if it's better to provide two versions of
Yusuke Sato
2016/09/14 21:02:25
I didn't do this as function overloading is discou
Luis Héctor Chávez
2016/09/14 21:09:12
You can add a "WithErrorCode" suffix if you want t
Yusuke Sato
2016/09/14 21:21:49
Done.
| |
82 int min_instance_version, | |
83 GetResult* out_error_code); | |
84 | |
70 private: | 85 private: |
71 mojo::Binding<mojom::IntentHelperHost> binding_; | 86 mojo::Binding<mojom::IntentHelperHost> binding_; |
72 scoped_refptr<ActivityIconLoader> icon_loader_; | 87 scoped_refptr<ActivityIconLoader> icon_loader_; |
73 scoped_refptr<LocalActivityResolver> activity_resolver_; | 88 scoped_refptr<LocalActivityResolver> activity_resolver_; |
74 | 89 |
75 base::ThreadChecker thread_checker_; | 90 base::ThreadChecker thread_checker_; |
76 | 91 |
77 DISALLOW_COPY_AND_ASSIGN(ArcIntentHelperBridge); | 92 DISALLOW_COPY_AND_ASSIGN(ArcIntentHelperBridge); |
78 }; | 93 }; |
79 | 94 |
80 } // namespace arc | 95 } // namespace arc |
81 | 96 |
82 #endif // COMPONENTS_ARC_INTENT_HELPER_ARC_INTENT_HELPER_BRIDGE_H_ | 97 #endif // COMPONENTS_ARC_INTENT_HELPER_ARC_INTENT_HELPER_BRIDGE_H_ |
OLD | NEW |