1 /* 2 * Copyright (C) 2013 Google Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are 6 * met: 7 * 8 * * Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * * Redistributions in binary form must reproduce the above 11 * copyright notice, this list of conditions and the following disclaimer 12 * in the documentation and/or other materials provided with the 13 * distribution. 14 * * Neither the name of Google Inc. nor the names of its 15 * contributors may be used to endorse or promote products derived from 16 * this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31 #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_CORE_INITIALIZER_H_ 32 #define THIRD_PARTY_BLINK_RENDERER_CORE_CORE_INITIALIZER_H_ 33 34 #include <memory> 35 36 #include "base/macros.h" 37 #include "third_party/blink/public/common/dom_storage/session_storage_namespace_id.h" 38 #include "third_party/blink/renderer/core/core_export.h" 39 #include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" 40 41 namespace mojo { 42 class BinderMap; 43 } 44 45 namespace blink { 46 47 class DevToolsSession; 48 class Document; 49 class HTMLMediaElement; 50 class InspectedFrames; 51 class InspectorDOMAgent; 52 class LocalFrame; 53 class MediaControls; 54 class Page; 55 class PictureInPictureController; 56 class Settings; 57 class ShadowRoot; 58 class WebLocalFrameClient; 59 class WebMediaPlayer; 60 class WebMediaPlayerClient; 61 class WebMediaPlayerSource; 62 class WebRemotePlaybackClient; 63 class WebViewClient; 64 65 class CORE_EXPORT CoreInitializer { 66 USING_FAST_MALLOC(CoreInitializer); 67 DISALLOW_COPY_AND_ASSIGN(CoreInitializer); 68 69 public: 70 // Initialize must be called before GetInstance. GetInstance()71 static CoreInitializer& GetInstance() { 72 DCHECK(instance_); 73 return *instance_; 74 } 75 76 virtual ~CoreInitializer() = default; 77 78 // Should be called by clients before trying to create Frames. 79 virtual void Initialize(); 80 81 // Called on startup to register Mojo interfaces that for control messages, 82 // e.g. messages that are not routed to a specific frame. 83 virtual void RegisterInterfaces(mojo::BinderMap&) = 0; 84 // Methods defined in CoreInitializer and implemented by ModulesInitializer to 85 // bypass the inverted dependency from core/ to modules/. 86 // Mojo Interfaces registered with LocalFrame 87 virtual void InitLocalFrame(LocalFrame&) const = 0; 88 // Supplements installed on a frame using ChromeClient 89 virtual void InstallSupplements(LocalFrame&) const = 0; 90 virtual MediaControls* CreateMediaControls(HTMLMediaElement&, 91 ShadowRoot&) const = 0; 92 virtual PictureInPictureController* CreatePictureInPictureController( 93 Document&) const = 0; 94 // Session Initializers for Inspector Agents in modules/ 95 // These methods typically create agents and append them to a session. 96 // TODO(nverne): remove this and restore to WebDevToolsAgentImpl once that 97 // class is a controller/ crbug:731490 98 virtual void InitInspectorAgentSession(DevToolsSession*, 99 bool, 100 InspectorDOMAgent*, 101 InspectedFrames*, 102 Page*) const = 0; 103 104 virtual void OnClearWindowObjectInMainWorld(Document&, 105 const Settings&) const = 0; 106 107 virtual std::unique_ptr<WebMediaPlayer> CreateWebMediaPlayer( 108 WebLocalFrameClient*, 109 HTMLMediaElement&, 110 const WebMediaPlayerSource&, 111 WebMediaPlayerClient*) const = 0; 112 113 virtual WebRemotePlaybackClient* CreateWebRemotePlaybackClient( 114 HTMLMediaElement&) const = 0; 115 116 virtual void ProvideModulesToPage(Page&, WebViewClient*) const = 0; 117 virtual void ForceNextWebGLContextCreationToFail() const = 0; 118 119 virtual void CollectAllGarbageForAnimationAndPaintWorkletForTesting() 120 const = 0; 121 122 virtual void CloneSessionStorage( 123 Page* clone_from_page, 124 const SessionStorageNamespaceId& clone_to_namespace) = 0; 125 126 virtual void DidChangeManifest(LocalFrame&) = 0; 127 virtual void NotifyOrientationChanged(LocalFrame&) = 0; 128 129 protected: 130 // CoreInitializer is only instantiated by subclass ModulesInitializer. 131 CoreInitializer() = default; 132 133 private: 134 static CoreInitializer* instance_; 135 void RegisterEventFactory(); 136 }; 137 138 } // namespace blink 139 140 #endif // THIRD_PARTY_BLINK_RENDERER_CORE_CORE_INITIALIZER_H_ 141