Chromium Code Reviews| 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 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "ash/link_handler_model_factory.h" | 12 #include "ash/link_handler_model_factory.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/observer_list.h" | 15 #include "base/observer_list.h" |
| 16 #include "base/threading/thread_checker.h" | 16 #include "base/threading/thread_checker.h" |
| 17 #include "components/arc/arc_service.h" | 17 #include "components/arc/arc_service.h" |
| 18 #include "components/arc/common/intent_helper.mojom.h" | 18 #include "components/arc/common/intent_helper.mojom.h" |
| 19 #include "components/arc/instance_holder.h" | 19 #include "components/arc/instance_holder.h" |
| 20 #include "components/arc/intent_helper/activity_icon_loader.h" | |
| 20 #include "components/arc/intent_helper/arc_intent_helper_observer.h" | 21 #include "components/arc/intent_helper/arc_intent_helper_observer.h" |
| 21 #include "mojo/public/cpp/bindings/binding.h" | 22 #include "mojo/public/cpp/bindings/binding.h" |
| 22 | 23 |
| 23 namespace ash { | 24 namespace ash { |
| 24 | 25 |
| 25 class LinkHandlerModel; | 26 class LinkHandlerModel; |
| 26 | 27 |
| 27 } // namespace ash | 28 } // namespace ash |
| 28 | 29 |
| 29 namespace arc { | 30 namespace arc { |
| 30 | 31 |
| 31 class ActivityIconLoader; | |
| 32 class ArcBridgeService; | 32 class ArcBridgeService; |
| 33 class IntentFilter; | 33 class IntentFilter; |
| 34 class LocalActivityResolver; | 34 class LocalActivityResolver; |
| 35 | 35 |
| 36 // Receives intents from ARC. | 36 // Receives intents from ARC. |
| 37 class ArcIntentHelperBridge | 37 class ArcIntentHelperBridge |
| 38 : public ArcService, | 38 : public ArcService, |
| 39 public InstanceHolder<mojom::IntentHelperInstance>::Observer, | 39 public InstanceHolder<mojom::IntentHelperInstance>::Observer, |
| 40 public mojom::IntentHelperHost, | 40 public mojom::IntentHelperHost, |
| 41 public ash::LinkHandlerModelFactory { | 41 public ash::LinkHandlerModelFactory { |
| 42 public: | 42 public: |
| 43 enum class GetResult { | 43 enum class GetResult { |
| 44 // Failed. The intent_helper instance is not yet ready. This is a temporary | 44 // Failed. The intent_helper instance is not yet ready. This is a temporary |
| 45 // error. | 45 // error. |
| 46 FAILED_ARC_NOT_READY, | 46 FAILED_ARC_NOT_READY, |
| 47 // Failed. Either ARC is not supported at all or intent_helper instance | 47 // Failed. Either ARC is not supported at all or intent_helper instance |
| 48 // version is too old. | 48 // version is too old. |
| 49 FAILED_ARC_NOT_SUPPORTED, | 49 FAILED_ARC_NOT_SUPPORTED, |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 ArcIntentHelperBridge( | 52 ArcIntentHelperBridge( |
| 53 ArcBridgeService* bridge_service, | 53 ArcBridgeService* bridge_service, |
| 54 const scoped_refptr<ActivityIconLoader>& icon_loader, | |
| 55 const scoped_refptr<LocalActivityResolver>& activity_resolver); | 54 const scoped_refptr<LocalActivityResolver>& activity_resolver); |
| 56 ~ArcIntentHelperBridge() override; | 55 ~ArcIntentHelperBridge() override; |
| 57 | 56 |
| 58 void AddObserver(ArcIntentHelperObserver* observer); | 57 void AddObserver(ArcIntentHelperObserver* observer); |
| 59 void RemoveObserver(ArcIntentHelperObserver* observer); | 58 void RemoveObserver(ArcIntentHelperObserver* observer); |
| 60 | 59 |
| 60 ActivityIconLoader* icon_loader() { return &icon_loader_; } | |
|
hidehiko
2017/01/27 16:04:06
Note: or, alternatively we may want to provide Get
Yusuke Sato
2017/01/27 18:21:17
Just in case, can you mention that the returned po
hidehiko
2017/01/30 17:04:03
Instead, I removed this method, in the new PS.
| |
| 61 | |
| 61 // InstanceHolder<mojom::IntentHelperInstance>::Observer | 62 // InstanceHolder<mojom::IntentHelperInstance>::Observer |
| 62 void OnInstanceReady() override; | 63 void OnInstanceReady() override; |
| 63 void OnInstanceClosed() override; | 64 void OnInstanceClosed() override; |
| 64 | 65 |
| 65 // mojom::IntentHelperHost | 66 // mojom::IntentHelperHost |
| 66 void OnIconInvalidated(const std::string& package_name) override; | 67 void OnIconInvalidated(const std::string& package_name) override; |
| 67 void OnIntentFiltersUpdated( | 68 void OnIntentFiltersUpdated( |
| 68 std::vector<IntentFilter> intent_filters) override; | 69 std::vector<IntentFilter> intent_filters) override; |
| 69 void OnOpenDownloads() override; | 70 void OnOpenDownloads() override; |
| 70 void OnOpenUrl(const std::string& url) override; | 71 void OnOpenUrl(const std::string& url) override; |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 86 // false and updates |out_error_code| if it's not nullptr. | 87 // false and updates |out_error_code| if it's not nullptr. |
| 87 static bool IsIntentHelperAvailable(GetResult* out_error_code); | 88 static bool IsIntentHelperAvailable(GetResult* out_error_code); |
| 88 | 89 |
| 89 // For supporting ArcServiceManager::GetService<T>(). | 90 // For supporting ArcServiceManager::GetService<T>(). |
| 90 static const char kArcServiceName[]; | 91 static const char kArcServiceName[]; |
| 91 | 92 |
| 92 static const char kArcIntentHelperPackageName[]; | 93 static const char kArcIntentHelperPackageName[]; |
| 93 | 94 |
| 94 private: | 95 private: |
| 95 mojo::Binding<mojom::IntentHelperHost> binding_; | 96 mojo::Binding<mojom::IntentHelperHost> binding_; |
| 96 scoped_refptr<ActivityIconLoader> icon_loader_; | 97 ActivityIconLoader icon_loader_; |
| 97 scoped_refptr<LocalActivityResolver> activity_resolver_; | 98 scoped_refptr<LocalActivityResolver> activity_resolver_; |
| 98 | 99 |
| 99 base::ThreadChecker thread_checker_; | 100 base::ThreadChecker thread_checker_; |
| 100 | 101 |
| 101 base::ObserverList<ArcIntentHelperObserver> observer_list_; | 102 base::ObserverList<ArcIntentHelperObserver> observer_list_; |
| 102 | 103 |
| 103 DISALLOW_COPY_AND_ASSIGN(ArcIntentHelperBridge); | 104 DISALLOW_COPY_AND_ASSIGN(ArcIntentHelperBridge); |
| 104 }; | 105 }; |
| 105 | 106 |
| 106 } // namespace arc | 107 } // namespace arc |
| 107 | 108 |
| 108 #endif // COMPONENTS_ARC_INTENT_HELPER_ARC_INTENT_HELPER_BRIDGE_H_ | 109 #endif // COMPONENTS_ARC_INTENT_HELPER_ARC_INTENT_HELPER_BRIDGE_H_ |
| OLD | NEW |