| 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 | 9 |
| 10 #include "ash/link_handler_model_factory.h" | 10 #include "ash/link_handler_model_factory.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/weak_ptr.h" |
| 14 #include "base/task_runner.h" |
| 13 #include "components/arc/arc_bridge_service.h" | 15 #include "components/arc/arc_bridge_service.h" |
| 14 #include "components/arc/arc_service.h" | 16 #include "components/arc/arc_service.h" |
| 15 #include "components/arc/common/intent_helper.mojom.h" | 17 #include "components/arc/common/intent_helper.mojom.h" |
| 16 #include "mojo/public/cpp/bindings/binding.h" | 18 #include "mojo/public/cpp/bindings/binding.h" |
| 17 | 19 |
| 18 namespace ash { | 20 namespace ash { |
| 19 | 21 |
| 20 class LinkHandlerModel; | 22 class LinkHandlerModel; |
| 21 | 23 |
| 22 } // namespace ash | 24 } // namespace ash |
| 23 | 25 |
| 26 namespace gfx { |
| 27 |
| 28 class ImageSkia; |
| 29 |
| 30 } // namespace gfx |
| 31 |
| 24 namespace arc { | 32 namespace arc { |
| 25 | 33 |
| 26 class ActivityIconLoader; | 34 class ActivityIconLoader; |
| 35 class SetWallpaperDelegate; |
| 27 | 36 |
| 28 // Receives intents from ARC. | 37 // Receives intents from ARC. |
| 29 class ArcIntentHelperBridge : public ArcService, | 38 class ArcIntentHelperBridge : public ArcService, |
| 30 public ArcBridgeService::Observer, | 39 public ArcBridgeService::Observer, |
| 31 public mojom::IntentHelperHost, | 40 public mojom::IntentHelperHost, |
| 32 public ash::LinkHandlerModelFactory { | 41 public ash::LinkHandlerModelFactory { |
| 33 public: | 42 public: |
| 34 ArcIntentHelperBridge(ArcBridgeService* bridge_service, | 43 ArcIntentHelperBridge( |
| 35 const scoped_refptr<ActivityIconLoader>& icon_loader); | 44 ArcBridgeService* bridge_service, |
| 45 const scoped_refptr<ActivityIconLoader>& icon_loader, |
| 46 const scoped_refptr<base::TaskRunner>& blocking_task_runner, |
| 47 std::unique_ptr<SetWallpaperDelegate> set_wallpaper_delegate); |
| 36 ~ArcIntentHelperBridge() override; | 48 ~ArcIntentHelperBridge() override; |
| 37 | 49 |
| 38 // ArcBridgeService::Observer | 50 // ArcBridgeService::Observer |
| 39 void OnIntentHelperInstanceReady() override; | 51 void OnIntentHelperInstanceReady() override; |
| 40 void OnIntentHelperInstanceClosed() override; | 52 void OnIntentHelperInstanceClosed() override; |
| 41 | 53 |
| 42 // arc::mojom::IntentHelperHost | 54 // arc::mojom::IntentHelperHost |
| 43 void OnIconInvalidated(const mojo::String& package_name) override; | 55 void OnIconInvalidated(const mojo::String& package_name) override; |
| 44 void OnOpenDownloads() override; | 56 void OnOpenDownloads() override; |
| 45 void OnOpenUrl(const mojo::String& url) override; | 57 void OnOpenUrl(const mojo::String& url) override; |
| 46 void OpenWallpaperPicker() override; | 58 void OpenWallpaperPicker() override; |
| 59 void SetWallpaper(mojo::Array<uint8_t> jpeg_data) override; |
| 47 | 60 |
| 48 // ash::LinkHandlerModelFactory | 61 // ash::LinkHandlerModelFactory |
| 49 std::unique_ptr<ash::LinkHandlerModel> CreateModel(const GURL& url) override; | 62 std::unique_ptr<ash::LinkHandlerModel> CreateModel(const GURL& url) override; |
| 50 | 63 |
| 51 private: | 64 private: |
| 65 void SetImageAsWallpaper(gfx::ImageSkia image); |
| 66 |
| 52 mojo::Binding<mojom::IntentHelperHost> binding_; | 67 mojo::Binding<mojom::IntentHelperHost> binding_; |
| 53 scoped_refptr<ActivityIconLoader> icon_loader_; | 68 scoped_refptr<ActivityIconLoader> icon_loader_; |
| 69 scoped_refptr<base::TaskRunner> blocking_task_runner_; |
| 70 std::unique_ptr<SetWallpaperDelegate> set_wallpaper_delegate_; |
| 71 |
| 72 // Note: This should remain the last member so it'll be destroyed and |
| 73 // invalidate its weak pointers before any other members are destroyed. |
| 74 base::WeakPtrFactory<ArcIntentHelperBridge> weak_factory_; |
| 54 | 75 |
| 55 DISALLOW_COPY_AND_ASSIGN(ArcIntentHelperBridge); | 76 DISALLOW_COPY_AND_ASSIGN(ArcIntentHelperBridge); |
| 56 }; | 77 }; |
| 57 | 78 |
| 58 } // namespace arc | 79 } // namespace arc |
| 59 | 80 |
| 60 #endif // COMPONENTS_ARC_INTENT_HELPER_ARC_INTENT_HELPER_BRIDGE_H_ | 81 #endif // COMPONENTS_ARC_INTENT_HELPER_ARC_INTENT_HELPER_BRIDGE_H_ |
| OLD | NEW |