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 |
11 #include "ash/link_handler_model_factory.h" | 11 #include "ash/link_handler_model_factory.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/observer_list.h" | |
14 #include "base/threading/thread_checker.h" | 15 #include "base/threading/thread_checker.h" |
15 #include "components/arc/arc_service.h" | 16 #include "components/arc/arc_service.h" |
16 #include "components/arc/common/intent_helper.mojom.h" | 17 #include "components/arc/common/intent_helper.mojom.h" |
17 #include "components/arc/instance_holder.h" | 18 #include "components/arc/instance_holder.h" |
18 #include "mojo/public/cpp/bindings/binding.h" | 19 #include "mojo/public/cpp/bindings/binding.h" |
19 | 20 |
20 namespace ash { | 21 namespace ash { |
21 | 22 |
22 class LinkHandlerModel; | 23 class LinkHandlerModel; |
23 | 24 |
(...skipping 15 matching lines...) Expand all Loading... | |
39 public: | 40 public: |
40 enum class GetResult { | 41 enum class GetResult { |
41 // Failed. The intent_helper instance is not yet ready. This is a temporary | 42 // Failed. The intent_helper instance is not yet ready. This is a temporary |
42 // error. | 43 // error. |
43 FAILED_ARC_NOT_READY, | 44 FAILED_ARC_NOT_READY, |
44 // Failed. Either ARC is not supported at all or intent_helper instance | 45 // Failed. Either ARC is not supported at all or intent_helper instance |
45 // version is too old. | 46 // version is too old. |
46 FAILED_ARC_NOT_SUPPORTED, | 47 FAILED_ARC_NOT_SUPPORTED, |
47 }; | 48 }; |
48 | 49 |
50 class Observer { | |
51 public: | |
52 // OnAppsUpdated is called when intent helper is updated. | |
Yusuke Sato
2016/11/21 17:21:05
// Called when app's intent filter is updated.
?
oka
2016/11/24 15:14:17
Done.
| |
53 virtual void OnAppsUpdated() = 0; | |
54 protected: | |
55 virtual ~Observer() {} | |
56 }; | |
57 | |
49 ArcIntentHelperBridge( | 58 ArcIntentHelperBridge( |
50 ArcBridgeService* bridge_service, | 59 ArcBridgeService* bridge_service, |
51 const scoped_refptr<ActivityIconLoader>& icon_loader, | 60 const scoped_refptr<ActivityIconLoader>& icon_loader, |
52 const scoped_refptr<LocalActivityResolver>& activity_resolver); | 61 const scoped_refptr<LocalActivityResolver>& activity_resolver); |
53 ~ArcIntentHelperBridge() override; | 62 ~ArcIntentHelperBridge() override; |
54 | 63 |
64 // Get returns the only instance of ArcIntentHelperBridge, or nullptr if it | |
65 // has not been created. | |
66 // This method is a workaround for adding observer to this class from | |
67 // Files App. Please avoid to use this as much as possible. | |
68 static ArcIntentHelperBridge* Get(); | |
69 | |
70 void AddObserver(Observer* observer); | |
71 void RemoveObserver(Observer* observer); | |
72 | |
55 // InstanceHolder<mojom::IntentHelperInstance>::Observer | 73 // InstanceHolder<mojom::IntentHelperInstance>::Observer |
56 void OnInstanceReady() override; | 74 void OnInstanceReady() override; |
57 void OnInstanceClosed() override; | 75 void OnInstanceClosed() override; |
58 | 76 |
59 // mojom::IntentHelperHost | 77 // mojom::IntentHelperHost |
60 void OnIconInvalidated(const mojo::String& package_name) override; | 78 void OnIconInvalidated(const mojo::String& package_name) override; |
61 void OnIntentFiltersUpdated( | 79 void OnIntentFiltersUpdated( |
62 mojo::Array<mojom::IntentFilterPtr> intent_filters) override; | 80 mojo::Array<mojom::IntentFilterPtr> intent_filters) override; |
63 void OnOpenDownloads() override; | 81 void OnOpenDownloads() override; |
64 void OnOpenUrl(const mojo::String& url) override; | 82 void OnOpenUrl(const mojo::String& url) override; |
(...skipping 25 matching lines...) Expand all Loading... | |
90 | 108 |
91 static const char kArcIntentHelperPackageName[]; | 109 static const char kArcIntentHelperPackageName[]; |
92 | 110 |
93 private: | 111 private: |
94 mojo::Binding<mojom::IntentHelperHost> binding_; | 112 mojo::Binding<mojom::IntentHelperHost> binding_; |
95 scoped_refptr<ActivityIconLoader> icon_loader_; | 113 scoped_refptr<ActivityIconLoader> icon_loader_; |
96 scoped_refptr<LocalActivityResolver> activity_resolver_; | 114 scoped_refptr<LocalActivityResolver> activity_resolver_; |
97 | 115 |
98 base::ThreadChecker thread_checker_; | 116 base::ThreadChecker thread_checker_; |
99 | 117 |
118 base::ObserverList<Observer> observer_list_; | |
119 | |
100 DISALLOW_COPY_AND_ASSIGN(ArcIntentHelperBridge); | 120 DISALLOW_COPY_AND_ASSIGN(ArcIntentHelperBridge); |
101 }; | 121 }; |
102 | 122 |
103 } // namespace arc | 123 } // namespace arc |
104 | 124 |
105 #endif // COMPONENTS_ARC_INTENT_HELPER_ARC_INTENT_HELPER_BRIDGE_H_ | 125 #endif // COMPONENTS_ARC_INTENT_HELPER_ARC_INTENT_HELPER_BRIDGE_H_ |
OLD | NEW |