| 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/threading/thread_checker.h" |
| 14 #include "components/arc/arc_bridge_service.h" | 15 #include "components/arc/arc_bridge_service.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 "mojo/public/cpp/bindings/binding.h" | 18 #include "mojo/public/cpp/bindings/binding.h" |
| 18 | 19 |
| 19 namespace ash { | 20 namespace ash { |
| 20 | 21 |
| 21 class LinkHandlerModel; | 22 class LinkHandlerModel; |
| 22 | 23 |
| 23 } // namespace ash | 24 } // namespace ash |
| 24 | 25 |
| 25 namespace arc { | 26 namespace arc { |
| 26 | 27 |
| 27 class ActivityIconLoader; | 28 class ActivityIconLoader; |
| 29 class SetWallpaperDelegate; |
| 28 | 30 |
| 29 // Receives intents from ARC. | 31 // Receives intents from ARC. |
| 30 class ArcIntentHelperBridge : public ArcService, | 32 class ArcIntentHelperBridge : public ArcService, |
| 31 public ArcBridgeService::Observer, | 33 public ArcBridgeService::Observer, |
| 32 public mojom::IntentHelperHost, | 34 public mojom::IntentHelperHost, |
| 33 public ash::LinkHandlerModelFactory { | 35 public ash::LinkHandlerModelFactory { |
| 34 public: | 36 public: |
| 35 ArcIntentHelperBridge(ArcBridgeService* bridge_service, | 37 ArcIntentHelperBridge( |
| 36 const scoped_refptr<ActivityIconLoader>& icon_loader); | 38 ArcBridgeService* bridge_service, |
| 39 const scoped_refptr<ActivityIconLoader>& icon_loader, |
| 40 std::unique_ptr<SetWallpaperDelegate> set_wallpaper_delegate); |
| 37 ~ArcIntentHelperBridge() override; | 41 ~ArcIntentHelperBridge() override; |
| 38 | 42 |
| 39 // ArcBridgeService::Observer | 43 // ArcBridgeService::Observer |
| 40 void OnIntentHelperInstanceReady() override; | 44 void OnIntentHelperInstanceReady() override; |
| 41 void OnIntentHelperInstanceClosed() override; | 45 void OnIntentHelperInstanceClosed() override; |
| 42 | 46 |
| 43 // arc::mojom::IntentHelperHost | 47 // arc::mojom::IntentHelperHost |
| 44 void OnIconInvalidated(const mojo::String& package_name) override; | 48 void OnIconInvalidated(const mojo::String& package_name) override; |
| 45 void OnOpenDownloads() override; | 49 void OnOpenDownloads() override; |
| 46 void OnOpenUrl(const mojo::String& url) override; | 50 void OnOpenUrl(const mojo::String& url) override; |
| 47 void OpenWallpaperPicker() override; | 51 void OpenWallpaperPicker() override; |
| 52 void SetWallpaper(mojo::Array<uint8_t> jpeg_data) 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 std::unique_ptr<SetWallpaperDelegate> set_wallpaper_delegate_; |
| 69 |
| 70 base::ThreadChecker thread_checker_; |
| 63 | 71 |
| 64 DISALLOW_COPY_AND_ASSIGN(ArcIntentHelperBridge); | 72 DISALLOW_COPY_AND_ASSIGN(ArcIntentHelperBridge); |
| 65 }; | 73 }; |
| 66 | 74 |
| 67 } // namespace arc | 75 } // namespace arc |
| 68 | 76 |
| 69 #endif // COMPONENTS_ARC_INTENT_HELPER_ARC_INTENT_HELPER_BRIDGE_H_ | 77 #endif // COMPONENTS_ARC_INTENT_HELPER_ARC_INTENT_HELPER_BRIDGE_H_ |
| OLD | NEW |