diff options
Diffstat (limited to 'chromium/components/arc/intent_helper/arc_intent_helper_bridge.h')
-rw-r--r-- | chromium/components/arc/intent_helper/arc_intent_helper_bridge.h | 50 |
1 files changed, 36 insertions, 14 deletions
diff --git a/chromium/components/arc/intent_helper/arc_intent_helper_bridge.h b/chromium/components/arc/intent_helper/arc_intent_helper_bridge.h index 06e58aaec0a..ac5dd705426 100644 --- a/chromium/components/arc/intent_helper/arc_intent_helper_bridge.h +++ b/chromium/components/arc/intent_helper/arc_intent_helper_bridge.h @@ -11,42 +11,52 @@ #include "ash/link_handler_model_factory.h" #include "base/macros.h" -#include "base/memory/ref_counted.h" #include "base/observer_list.h" #include "base/threading/thread_checker.h" -#include "components/arc/arc_service.h" #include "components/arc/common/intent_helper.mojom.h" #include "components/arc/instance_holder.h" #include "components/arc/intent_helper/activity_icon_loader.h" #include "components/arc/intent_helper/arc_intent_helper_observer.h" +#include "components/keyed_service/core/keyed_service.h" #include "mojo/public/cpp/bindings/binding.h" -namespace ash { +class KeyedServiceBaseFactory; +namespace ash { class LinkHandlerModel; - } // namespace ash +namespace content { +class BrowserContext; +} // namespace content + namespace arc { class ArcBridgeService; class IntentFilter; -class LocalActivityResolver; // Receives intents from ARC. class ArcIntentHelperBridge - : public ArcService, + : public KeyedService, public InstanceHolder<mojom::IntentHelperInstance>::Observer, public mojom::IntentHelperHost, public ash::LinkHandlerModelFactory { public: - ArcIntentHelperBridge( - ArcBridgeService* bridge_service, - const scoped_refptr<LocalActivityResolver>& activity_resolver); + // Returns singleton instance for the given BrowserContext, + // or nullptr if the browser |context| is not allowed to use ARC. + static ArcIntentHelperBridge* GetForBrowserContext( + content::BrowserContext* context); + + // Returns factory for the ArcIntentHelperBridge. + static KeyedServiceBaseFactory* GetFactory(); + + ArcIntentHelperBridge(content::BrowserContext* context, + ArcBridgeService* bridge_service); ~ArcIntentHelperBridge() override; void AddObserver(ArcIntentHelperObserver* observer); void RemoveObserver(ArcIntentHelperObserver* observer); + bool HasObserver(ArcIntentHelperObserver* observer) const; // InstanceHolder<mojom::IntentHelperInstance>::Observer void OnInstanceReady() override; @@ -60,6 +70,7 @@ class ArcIntentHelperBridge void OnOpenUrl(const std::string& url) override; void OpenWallpaperPicker() override; void SetWallpaperDeprecated(const std::vector<uint8_t>& jpeg_data) override; + void OpenVolumeControl() override; // Retrieves icons for the |activities| and calls |callback|. // See ActivityIconLoader::GetActivityIcons() for more details. @@ -72,6 +83,14 @@ class ArcIntentHelperBridge GetResult GetActivityIcons(const std::vector<ActivityName>& activities, const OnIconsReadyCallback& callback); + // Returns true when |url| can only be handled by Chrome. Otherwise, which is + // when there might be one or more ARC apps that can handle |url|, returns + // false. This function synchronously checks the |url| without making any IPC + // to ARC side. Note that this function only supports http and https. If url's + // scheme is neither http nor https, the function immediately returns true + // without checking the filters. + bool ShouldChromeHandleUrl(const GURL& url); + // ash::LinkHandlerModelFactory std::unique_ptr<ash::LinkHandlerModel> CreateModel(const GURL& url) override; @@ -83,17 +102,20 @@ class ArcIntentHelperBridge static std::vector<mojom::IntentHandlerInfoPtr> FilterOutIntentHelper( std::vector<mojom::IntentHandlerInfoPtr> handlers); - // For supporting ArcServiceManager::GetService<T>(). - static const char kArcServiceName[]; - static const char kArcIntentHelperPackageName[]; private: + THREAD_CHECKER(thread_checker_); + + content::BrowserContext* const context_; + ArcBridgeService* const arc_bridge_service_; // Owned by ArcServiceManager. + mojo::Binding<mojom::IntentHelperHost> binding_; internal::ActivityIconLoader icon_loader_; - scoped_refptr<LocalActivityResolver> activity_resolver_; - base::ThreadChecker thread_checker_; + // List of intent filters from Android. Used to determine if Chrome should + // handle a URL without handing off to Android. + std::vector<IntentFilter> intent_filters_; base::ObserverList<ArcIntentHelperObserver> observer_list_; |