| 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 | 11 |
| 11 #include "ash/link_handler_model_factory.h" | 12 #include "ash/link_handler_model_factory.h" |
| 12 #include "base/macros.h" | 13 #include "base/macros.h" |
| 13 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.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 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 50 ArcBridgeService* bridge_service, | 51 ArcBridgeService* bridge_service, |
| 51 const scoped_refptr<ActivityIconLoader>& icon_loader, | 52 const scoped_refptr<ActivityIconLoader>& icon_loader, |
| 52 const scoped_refptr<LocalActivityResolver>& activity_resolver); | 53 const scoped_refptr<LocalActivityResolver>& activity_resolver); |
| 53 ~ArcIntentHelperBridge() override; | 54 ~ArcIntentHelperBridge() override; |
| 54 | 55 |
| 55 // InstanceHolder<mojom::IntentHelperInstance>::Observer | 56 // InstanceHolder<mojom::IntentHelperInstance>::Observer |
| 56 void OnInstanceReady() override; | 57 void OnInstanceReady() override; |
| 57 void OnInstanceClosed() override; | 58 void OnInstanceClosed() override; |
| 58 | 59 |
| 59 // mojom::IntentHelperHost | 60 // mojom::IntentHelperHost |
| 60 void OnIconInvalidated(const mojo::String& package_name) override; | 61 void OnIconInvalidated(const std::string& package_name) override; |
| 61 void OnIntentFiltersUpdated( | 62 void OnIntentFiltersUpdated( |
| 62 mojo::Array<mojom::IntentFilterPtr> intent_filters) override; | 63 std::vector<mojom::IntentFilterPtr> intent_filters) override; |
| 63 void OnOpenDownloads() override; | 64 void OnOpenDownloads() override; |
| 64 void OnOpenUrl(const mojo::String& url) override; | 65 void OnOpenUrl(const std::string& url) override; |
| 65 void OpenWallpaperPicker() override; | 66 void OpenWallpaperPicker() override; |
| 66 void SetWallpaperDeprecated(mojo::Array<uint8_t> jpeg_data) override; | 67 void SetWallpaperDeprecated(const std::vector<uint8_t>& jpeg_data) override; |
| 67 | 68 |
| 68 // ash::LinkHandlerModelFactory | 69 // ash::LinkHandlerModelFactory |
| 69 std::unique_ptr<ash::LinkHandlerModel> CreateModel(const GURL& url) override; | 70 std::unique_ptr<ash::LinkHandlerModel> CreateModel(const GURL& url) override; |
| 70 | 71 |
| 71 // Returns false if |package_name| is for the intent_helper apk. | 72 // Returns false if |package_name| is for the intent_helper apk. |
| 72 static bool IsIntentHelperPackage(const std::string& package_name); | 73 static bool IsIntentHelperPackage(const std::string& package_name); |
| 73 | 74 |
| 74 // Filters out handlers that belong to the intent_helper apk and returns | 75 // Filters out handlers that belong to the intent_helper apk and returns |
| 75 // a new array. | 76 // a new array. |
| 76 static mojo::Array<mojom::IntentHandlerInfoPtr> FilterOutIntentHelper( | 77 static std::vector<mojom::IntentHandlerInfoPtr> FilterOutIntentHelper( |
| 77 mojo::Array<mojom::IntentHandlerInfoPtr> handlers); | 78 std::vector<mojom::IntentHandlerInfoPtr> handlers); |
| 78 | 79 |
| 79 // Gets the mojo instance if it's available. On failure, returns nullptr and | 80 // Gets the mojo instance if it's available. On failure, returns nullptr and |
| 80 // updates |out_error_code| if it's not nullptr. | 81 // updates |out_error_code| if it's not nullptr. |
| 81 static mojom::IntentHelperInstance* GetIntentHelperInstanceWithErrorCode( | 82 static mojom::IntentHelperInstance* GetIntentHelperInstanceWithErrorCode( |
| 82 const std::string& method_name_for_logging, | 83 const std::string& method_name_for_logging, |
| 83 uint32_t min_instance_version, | 84 uint32_t min_instance_version, |
| 84 GetResult* out_error_code); | 85 GetResult* out_error_code); |
| 85 | 86 |
| 86 // Does the same as above without asking for the error code. | 87 // Does the same as above without asking for the error code. |
| 87 static mojom::IntentHelperInstance* GetIntentHelperInstance( | 88 static mojom::IntentHelperInstance* GetIntentHelperInstance( |
| 88 const std::string& method_name_for_logging, | 89 const std::string& method_name_for_logging, |
| 89 uint32_t min_instance_version); | 90 uint32_t min_instance_version); |
| 90 | 91 |
| 91 static const char kArcIntentHelperPackageName[]; | 92 static const char kArcIntentHelperPackageName[]; |
| 92 | 93 |
| 93 private: | 94 private: |
| 94 mojo::Binding<mojom::IntentHelperHost> binding_; | 95 mojo::Binding<mojom::IntentHelperHost> binding_; |
| 95 scoped_refptr<ActivityIconLoader> icon_loader_; | 96 scoped_refptr<ActivityIconLoader> icon_loader_; |
| 96 scoped_refptr<LocalActivityResolver> activity_resolver_; | 97 scoped_refptr<LocalActivityResolver> activity_resolver_; |
| 97 | 98 |
| 98 base::ThreadChecker thread_checker_; | 99 base::ThreadChecker thread_checker_; |
| 99 | 100 |
| 100 DISALLOW_COPY_AND_ASSIGN(ArcIntentHelperBridge); | 101 DISALLOW_COPY_AND_ASSIGN(ArcIntentHelperBridge); |
| 101 }; | 102 }; |
| 102 | 103 |
| 103 } // namespace arc | 104 } // namespace arc |
| 104 | 105 |
| 105 #endif // COMPONENTS_ARC_INTENT_HELPER_ARC_INTENT_HELPER_BRIDGE_H_ | 106 #endif // COMPONENTS_ARC_INTENT_HELPER_ARC_INTENT_HELPER_BRIDGE_H_ |
| OLD | NEW |