| 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 InstalledAppController_h | 5 #ifndef InstalledAppController_h |
| 6 #define InstalledAppController_h | 6 #define InstalledAppController_h |
| 7 | 7 |
| 8 #include "core/dom/ContextLifecycleObserver.h" | 8 #include "core/dom/ContextLifecycleObserver.h" |
| 9 #include "core/frame/LocalFrame.h" | 9 #include "core/frame/LocalFrame.h" |
| 10 #include "modules/ModulesExport.h" | 10 #include "modules/ModulesExport.h" |
| 11 #include "platform/Supplementable.h" | 11 #include "platform/Supplementable.h" |
| 12 #include "public/platform/WebVector.h" | 12 #include "public/platform/WebVector.h" |
| 13 #include "public/platform/modules/installedapp/WebRelatedApplication.h" | 13 #include "public/platform/modules/installedapp/WebRelatedApplication.h" |
| 14 #include "public/platform/modules/installedapp/WebRelatedAppsFetcher.h" | 14 #include "public/platform/modules/installedapp/WebRelatedAppsFetcher.h" |
| 15 #include "public/platform/modules/installedapp/installed_app_provider.mojom-blin
k.h" |
| 16 #include "public/platform/modules/installedapp/related_application.mojom-blink.h
" |
| 15 #include "wtf/RefPtr.h" | 17 #include "wtf/RefPtr.h" |
| 16 #include "wtf/Vector.h" | 18 #include "wtf/Vector.h" |
| 17 | 19 |
| 18 #include <memory> | 20 #include <memory> |
| 19 | 21 |
| 20 namespace blink { | 22 namespace blink { |
| 21 | 23 |
| 22 class SecurityOrigin; | |
| 23 | |
| 24 class MODULES_EXPORT InstalledAppController final | 24 class MODULES_EXPORT InstalledAppController final |
| 25 : public GarbageCollectedFinalized<InstalledAppController>, | 25 : public GarbageCollectedFinalized<InstalledAppController>, |
| 26 public Supplement<LocalFrame>, | 26 public Supplement<LocalFrame>, |
| 27 public ContextLifecycleObserver { | 27 public ContextLifecycleObserver { |
| 28 USING_GARBAGE_COLLECTED_MIXIN(InstalledAppController); | 28 USING_GARBAGE_COLLECTED_MIXIN(InstalledAppController); |
| 29 WTF_MAKE_NONCOPYABLE(InstalledAppController); | 29 WTF_MAKE_NONCOPYABLE(InstalledAppController); |
| 30 | 30 |
| 31 public: | 31 public: |
| 32 virtual ~InstalledAppController(); | 32 virtual ~InstalledAppController(); |
| 33 | 33 |
| 34 // Gets a list of related apps from a particular origin's manifest that belong | 34 // Gets a list of related apps from the current page's manifest that belong |
| 35 // to the current underlying platform, and are installed. | 35 // to the current underlying platform, and are installed. |
| 36 void getInstalledRelatedApps(WTF::RefPtr<SecurityOrigin>, | 36 void getInstalledRelatedApps(std::unique_ptr<AppInstalledCallbacks>); |
| 37 std::unique_ptr<AppInstalledCallbacks>); | |
| 38 | 37 |
| 39 static void provideTo(LocalFrame&, WebRelatedAppsFetcher*); | 38 static void provideTo(LocalFrame&, WebRelatedAppsFetcher*); |
| 40 static InstalledAppController* from(LocalFrame&); | 39 static InstalledAppController* from(LocalFrame&); |
| 41 static const char* supplementName(); | 40 static const char* supplementName(); |
| 42 | 41 |
| 43 DECLARE_VIRTUAL_TRACE(); | 42 DECLARE_VIRTUAL_TRACE(); |
| 44 | 43 |
| 45 private: | 44 private: |
| 46 class GetRelatedAppsCallbacks; | 45 class GetRelatedAppsCallbacks; |
| 47 | 46 |
| 48 InstalledAppController(LocalFrame&, WebRelatedAppsFetcher*); | 47 InstalledAppController(LocalFrame&, WebRelatedAppsFetcher*); |
| 49 | 48 |
| 50 // Inherited from ContextLifecycleObserver. | 49 // Inherited from ContextLifecycleObserver. |
| 51 void contextDestroyed(ExecutionContext*) override; | 50 void contextDestroyed(ExecutionContext*) override; |
| 52 | 51 |
| 53 // For a given security origin, takes a set of related applications and | 52 // Takes a set of related applications and filters them by those which belong |
| 54 // filters them by those which belong to the current underlying platform, and | 53 // to the current underlying platform, and are actually installed and related |
| 55 // are actually installed. Passes the filtered list to the callback. | 54 // to the current page's origin. Passes the filtered list to the callback. |
| 56 void filterByInstalledApps(WTF::RefPtr<SecurityOrigin>, | 55 void filterByInstalledApps(const WebVector<WebRelatedApplication>&, |
| 57 const WebVector<WebRelatedApplication>&, | |
| 58 std::unique_ptr<AppInstalledCallbacks>); | 56 std::unique_ptr<AppInstalledCallbacks>); |
| 59 | 57 |
| 58 // Callback from the InstalledAppProvider mojo service. |
| 59 void OnFilterInstalledApps(std::unique_ptr<blink::AppInstalledCallbacks>, |
| 60 WTF::Vector<mojom::blink::RelatedApplicationPtr>); |
| 61 |
| 62 // Handle to the InstalledApp mojo service. |
| 63 mojom::blink::InstalledAppProviderPtr m_provider; |
| 64 |
| 60 WebRelatedAppsFetcher* m_relatedAppsFetcher; | 65 WebRelatedAppsFetcher* m_relatedAppsFetcher; |
| 61 }; | 66 }; |
| 62 | 67 |
| 63 } // namespace blink | 68 } // namespace blink |
| 64 | 69 |
| 65 #endif // InstalledAppController_h | 70 #endif // InstalledAppController_h |
| OLD | NEW |