| 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/modules/installedapp/WebInstalledAppClient.h" | 12 #include "public/platform/WebVector.h" |
| 13 #include "public/platform/modules/installedapp/WebRelatedApplication.h" |
| 14 #include "public/platform/modules/installedapp/WebRelatedAppsFetcher.h" |
| 15 #include "wtf/Vector.h" |
| 16 |
| 17 #include <memory> |
| 13 | 18 |
| 14 namespace blink { | 19 namespace blink { |
| 15 | 20 |
| 16 class WebSecurityOrigin; | 21 class WebSecurityOrigin; |
| 17 | 22 |
| 18 class MODULES_EXPORT InstalledAppController final | 23 class MODULES_EXPORT InstalledAppController final |
| 19 : public GarbageCollectedFinalized<InstalledAppController>, | 24 : public GarbageCollectedFinalized<InstalledAppController>, |
| 20 public Supplement<LocalFrame>, | 25 public Supplement<LocalFrame>, |
| 21 public ContextLifecycleObserver { | 26 public ContextLifecycleObserver { |
| 22 USING_GARBAGE_COLLECTED_MIXIN(InstalledAppController); | 27 USING_GARBAGE_COLLECTED_MIXIN(InstalledAppController); |
| 23 WTF_MAKE_NONCOPYABLE(InstalledAppController); | 28 WTF_MAKE_NONCOPYABLE(InstalledAppController); |
| 24 | 29 |
| 25 public: | 30 public: |
| 26 virtual ~InstalledAppController(); | 31 virtual ~InstalledAppController(); |
| 27 | 32 |
| 28 void getInstalledApps(const WebSecurityOrigin&, | 33 // Gets a list of related apps from a particular origin's manifest that belong |
| 29 std::unique_ptr<AppInstalledCallbacks>); | 34 // to the current underlying platform, and are installed. |
| 35 void getInstalledRelatedApps(const WebSecurityOrigin&, |
| 36 std::unique_ptr<AppInstalledCallbacks>); |
| 30 | 37 |
| 31 static void provideTo(LocalFrame&, WebInstalledAppClient*); | 38 static void provideTo(LocalFrame&, WebRelatedAppsFetcher*); |
| 32 static InstalledAppController* from(LocalFrame&); | 39 static InstalledAppController* from(LocalFrame&); |
| 33 static const char* supplementName(); | 40 static const char* supplementName(); |
| 34 | 41 |
| 35 DECLARE_VIRTUAL_TRACE(); | 42 DECLARE_VIRTUAL_TRACE(); |
| 36 | 43 |
| 37 private: | 44 private: |
| 38 InstalledAppController(LocalFrame&, WebInstalledAppClient*); | 45 InstalledAppController(LocalFrame&, WebRelatedAppsFetcher*); |
| 39 | 46 |
| 40 // Inherited from ContextLifecycleObserver. | 47 // Inherited from ContextLifecycleObserver. |
| 41 void contextDestroyed(ExecutionContext*) override; | 48 void contextDestroyed(ExecutionContext*) override; |
| 42 | 49 |
| 43 WebInstalledAppClient* m_client; | 50 // For a given security origin, takes a set of related applications and |
| 51 // filters them by those which belong to the current underlying platform, and |
| 52 // are actually installed. Passes the filtered list to the callback. |
| 53 void filterByInstalledApps( |
| 54 const blink::WebSecurityOrigin&, |
| 55 const blink::WebVector<blink::WebRelatedApplication>&, |
| 56 std::unique_ptr<blink::AppInstalledCallbacks>); |
| 57 |
| 58 WebRelatedAppsFetcher* m_relatedAppsFetcher; |
| 44 }; | 59 }; |
| 45 | 60 |
| 46 } // namespace blink | 61 } // namespace blink |
| 47 | 62 |
| 48 #endif // InstalledAppController_h | 63 #endif // InstalledAppController_h |
| OLD | NEW |