| 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 "components/arc/arc_bridge_service.h" | 14 #include "components/arc/arc_bridge_service.h" |
| 15 #include "components/arc/arc_service.h" | 15 #include "components/arc/arc_service.h" |
| 16 #include "components/arc/common/intent_helper.mojom.h" | 16 #include "components/arc/common/intent_helper.mojom.h" |
| 17 #include "mojo/public/cpp/bindings/binding.h" | 17 #include "mojo/public/cpp/bindings/binding.h" |
| 18 | 18 |
| 19 namespace ash { | 19 namespace ash { |
| 20 | 20 |
| 21 class LinkHandlerModel; | 21 class LinkHandlerModel; |
| 22 | 22 |
| 23 } // namespace ash | 23 } // namespace ash |
| 24 | 24 |
| 25 namespace arc { | 25 namespace arc { |
| 26 | 26 |
| 27 class ActivityIconLoader; | 27 class ActivityIconLoader; |
| 28 class LocalActivityResolver; |
| 28 | 29 |
| 29 // Receives intents from ARC. | 30 // Receives intents from ARC. |
| 30 class ArcIntentHelperBridge : public ArcService, | 31 class ArcIntentHelperBridge : public ArcService, |
| 31 public ArcBridgeService::Observer, | 32 public ArcBridgeService::Observer, |
| 32 public mojom::IntentHelperHost, | 33 public mojom::IntentHelperHost, |
| 33 public ash::LinkHandlerModelFactory { | 34 public ash::LinkHandlerModelFactory { |
| 34 public: | 35 public: |
| 35 ArcIntentHelperBridge(ArcBridgeService* bridge_service, | 36 ArcIntentHelperBridge( |
| 36 const scoped_refptr<ActivityIconLoader>& icon_loader); | 37 ArcBridgeService* bridge_service, |
| 38 const scoped_refptr<ActivityIconLoader>& icon_loader, |
| 39 const scoped_refptr<LocalActivityResolver>& activity_resolver); |
| 37 ~ArcIntentHelperBridge() override; | 40 ~ArcIntentHelperBridge() override; |
| 38 | 41 |
| 39 // ArcBridgeService::Observer | 42 // ArcBridgeService::Observer |
| 40 void OnIntentHelperInstanceReady() override; | 43 void OnIntentHelperInstanceReady() override; |
| 41 void OnIntentHelperInstanceClosed() override; | 44 void OnIntentHelperInstanceClosed() override; |
| 42 | 45 |
| 43 // arc::mojom::IntentHelperHost | 46 // arc::mojom::IntentHelperHost |
| 44 void OnIconInvalidated(const mojo::String& package_name) override; | 47 void OnIconInvalidated(const mojo::String& package_name) override; |
| 48 void OnIntentFiltersUpdated( |
| 49 mojo::Array<mojom::IntentFilterPtr> intent_filters) override; |
| 45 void OnOpenDownloads() override; | 50 void OnOpenDownloads() override; |
| 46 void OnOpenUrl(const mojo::String& url) override; | 51 void OnOpenUrl(const mojo::String& url) override; |
| 47 void OpenWallpaperPicker() override; | 52 void OpenWallpaperPicker() override; |
| 48 | 53 |
| 49 // ash::LinkHandlerModelFactory | 54 // ash::LinkHandlerModelFactory |
| 50 std::unique_ptr<ash::LinkHandlerModel> CreateModel(const GURL& url) override; | 55 std::unique_ptr<ash::LinkHandlerModel> CreateModel(const GURL& url) override; |
| 51 | 56 |
| 52 // Returns false if |package_name| is for the intent_helper apk. | 57 // Returns false if |package_name| is for the intent_helper apk. |
| 53 static bool IsIntentHelperPackage(const std::string& package_name); | 58 static bool IsIntentHelperPackage(const std::string& package_name); |
| 54 | 59 |
| 55 // Filters out handlers that belong to the intent_helper apk and returns | 60 // Filters out handlers that belong to the intent_helper apk and returns |
| 56 // a new array. | 61 // a new array. |
| 57 static mojo::Array<mojom::UrlHandlerInfoPtr> FilterOutIntentHelper( | 62 static mojo::Array<mojom::UrlHandlerInfoPtr> FilterOutIntentHelper( |
| 58 mojo::Array<mojom::UrlHandlerInfoPtr> handlers); | 63 mojo::Array<mojom::UrlHandlerInfoPtr> handlers); |
| 59 | 64 |
| 60 private: | 65 private: |
| 61 mojo::Binding<mojom::IntentHelperHost> binding_; | 66 mojo::Binding<mojom::IntentHelperHost> binding_; |
| 62 scoped_refptr<ActivityIconLoader> icon_loader_; | 67 scoped_refptr<ActivityIconLoader> icon_loader_; |
| 68 scoped_refptr<LocalActivityResolver> activity_resolver_; |
| 63 | 69 |
| 64 DISALLOW_COPY_AND_ASSIGN(ArcIntentHelperBridge); | 70 DISALLOW_COPY_AND_ASSIGN(ArcIntentHelperBridge); |
| 65 }; | 71 }; |
| 66 | 72 |
| 67 } // namespace arc | 73 } // namespace arc |
| 68 | 74 |
| 69 #endif // COMPONENTS_ARC_INTENT_HELPER_ARC_INTENT_HELPER_BRIDGE_H_ | 75 #endif // COMPONENTS_ARC_INTENT_HELPER_ARC_INTENT_HELPER_BRIDGE_H_ |
| OLD | NEW |