| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef MOJO_SERVICES_HTML_VIEWER_HTML_DOCUMENT_H_ | |
| 6 #define MOJO_SERVICES_HTML_VIEWER_HTML_DOCUMENT_H_ | |
| 7 | |
| 8 #include <set> | |
| 9 | |
| 10 #include "base/callback.h" | |
| 11 #include "base/macros.h" | |
| 12 #include "mojo/services/html_viewer/ax_provider_impl.h" | |
| 13 #include "mojo/services/html_viewer/touch_handler.h" | |
| 14 #include "mojo/services/network/public/interfaces/url_loader.mojom.h" | |
| 15 #include "third_party/WebKit/public/web/WebFrameClient.h" | |
| 16 #include "third_party/WebKit/public/web/WebSandboxFlags.h" | |
| 17 #include "third_party/WebKit/public/web/WebViewClient.h" | |
| 18 #include "third_party/mojo/src/mojo/public/cpp/application/interface_factory.h" | |
| 19 #include "third_party/mojo/src/mojo/public/cpp/application/lazy_interface_ptr.h" | |
| 20 #include "third_party/mojo/src/mojo/public/cpp/application/service_provider_impl
.h" | |
| 21 #include "third_party/mojo/src/mojo/public/cpp/bindings/interface_impl.h" | |
| 22 #include "third_party/mojo/src/mojo/public/interfaces/application/application.mo
jom.h" | |
| 23 #include "third_party/mojo_services/src/content_handler/public/interfaces/conten
t_handler.mojom.h" | |
| 24 #include "third_party/mojo_services/src/navigation/public/interfaces/navigation.
mojom.h" | |
| 25 #include "third_party/mojo_services/src/view_manager/public/cpp/view_manager_cli
ent_factory.h" | |
| 26 #include "third_party/mojo_services/src/view_manager/public/cpp/view_manager_del
egate.h" | |
| 27 #include "third_party/mojo_services/src/view_manager/public/cpp/view_observer.h" | |
| 28 | |
| 29 namespace base { | |
| 30 class MessageLoopProxy; | |
| 31 } | |
| 32 | |
| 33 namespace media { | |
| 34 class CdmFactory; | |
| 35 class MediaPermission; | |
| 36 class WebEncryptedMediaClientImpl; | |
| 37 } | |
| 38 | |
| 39 namespace mojo { | |
| 40 class ViewManager; | |
| 41 class View; | |
| 42 } | |
| 43 | |
| 44 namespace html_viewer { | |
| 45 | |
| 46 class AxProviderImpl; | |
| 47 class WebLayerTreeViewImpl; | |
| 48 class WebMediaPlayerFactory; | |
| 49 | |
| 50 // A view for a single HTML document. | |
| 51 class HTMLDocument : public blink::WebViewClient, | |
| 52 public blink::WebFrameClient, | |
| 53 public mojo::ViewManagerDelegate, | |
| 54 public mojo::ViewObserver, | |
| 55 public mojo::InterfaceFactory<mojo::AxProvider> { | |
| 56 public: | |
| 57 // Load a new HTMLDocument with |response|. | |
| 58 // | |
| 59 // |services| should be used to implement a ServiceProvider which exposes | |
| 60 // services to the connecting application. | |
| 61 // Commonly, the connecting application is the ViewManager and it will | |
| 62 // request ViewManagerClient. | |
| 63 // | |
| 64 // |shell| is the Shell connection for this mojo::Application. | |
| 65 HTMLDocument(mojo::InterfaceRequest<mojo::ServiceProvider> services, | |
| 66 mojo::URLResponsePtr response, | |
| 67 mojo::Shell* shell, | |
| 68 scoped_refptr<base::MessageLoopProxy> compositor_thread, | |
| 69 WebMediaPlayerFactory* web_media_player_factory, | |
| 70 bool is_headless); | |
| 71 ~HTMLDocument() override; | |
| 72 | |
| 73 private: | |
| 74 // Updates the size and scale factor of the webview and related classes from | |
| 75 // |root_|. | |
| 76 void UpdateWebviewSizeFromViewSize(); | |
| 77 | |
| 78 // WebViewClient methods: | |
| 79 virtual blink::WebStorageNamespace* createSessionStorageNamespace(); | |
| 80 | |
| 81 // WebWidgetClient methods: | |
| 82 void initializeLayerTreeView() override; | |
| 83 blink::WebLayerTreeView* layerTreeView() override; | |
| 84 | |
| 85 // WebFrameClient methods: | |
| 86 virtual blink::WebMediaPlayer* createMediaPlayer( | |
| 87 blink::WebLocalFrame* frame, | |
| 88 const blink::WebURL& url, | |
| 89 blink::WebMediaPlayerClient* client); | |
| 90 virtual blink::WebMediaPlayer* createMediaPlayer( | |
| 91 blink::WebLocalFrame* frame, | |
| 92 const blink::WebURL& url, | |
| 93 blink::WebMediaPlayerClient* client, | |
| 94 blink::WebContentDecryptionModule* initial_cdm); | |
| 95 virtual blink::WebFrame* createChildFrame( | |
| 96 blink::WebLocalFrame* parent, | |
| 97 const blink::WebString& frameName, | |
| 98 blink::WebSandboxFlags sandboxFlags); | |
| 99 virtual void frameDetached(blink::WebFrame*); | |
| 100 virtual blink::WebCookieJar* cookieJar(blink::WebLocalFrame* frame); | |
| 101 virtual blink::WebNavigationPolicy decidePolicyForNavigation( | |
| 102 blink::WebLocalFrame* frame, | |
| 103 blink::WebDataSource::ExtraData* data, | |
| 104 const blink::WebURLRequest& request, | |
| 105 blink::WebNavigationType nav_type, | |
| 106 blink::WebNavigationPolicy default_policy, | |
| 107 bool isRedirect); | |
| 108 virtual void didAddMessageToConsole(const blink::WebConsoleMessage& message, | |
| 109 const blink::WebString& source_name, | |
| 110 unsigned source_line, | |
| 111 const blink::WebString& stack_trace); | |
| 112 virtual void didFinishLoad(blink::WebLocalFrame* frame); | |
| 113 virtual void didNavigateWithinPage(blink::WebLocalFrame* frame, | |
| 114 const blink::WebHistoryItem& history_item, | |
| 115 blink::WebHistoryCommitType commit_type); | |
| 116 virtual blink::WebEncryptedMediaClient* encryptedMediaClient(); | |
| 117 | |
| 118 // ViewManagerDelegate methods: | |
| 119 void OnEmbed(mojo::View* root, | |
| 120 mojo::InterfaceRequest<mojo::ServiceProvider> services, | |
| 121 mojo::ServiceProviderPtr exposed_services) override; | |
| 122 void OnViewManagerDisconnected(mojo::ViewManager* view_manager) override; | |
| 123 | |
| 124 // ViewObserver methods: | |
| 125 void OnViewBoundsChanged(mojo::View* view, | |
| 126 const mojo::Rect& old_bounds, | |
| 127 const mojo::Rect& new_bounds) override; | |
| 128 void OnViewDestroyed(mojo::View* view) override; | |
| 129 void OnViewInputEvent(mojo::View* view, const mojo::EventPtr& event) override; | |
| 130 | |
| 131 // mojo::InterfaceFactory<mojo::AxProvider> | |
| 132 void Create(mojo::ApplicationConnection* connection, | |
| 133 mojo::InterfaceRequest<mojo::AxProvider> request) override; | |
| 134 | |
| 135 void Load(mojo::URLResponsePtr response); | |
| 136 | |
| 137 media::MediaPermission* GetMediaPermission(); | |
| 138 media::CdmFactory* GetCdmFactory(); | |
| 139 | |
| 140 mojo::URLResponsePtr response_; | |
| 141 mojo::ServiceProviderImpl exported_services_; | |
| 142 mojo::ServiceProviderPtr embedder_service_provider_; | |
| 143 mojo::Shell* shell_; | |
| 144 mojo::LazyInterfacePtr<mojo::NavigatorHost> navigator_host_; | |
| 145 blink::WebView* web_view_; | |
| 146 mojo::View* root_; | |
| 147 mojo::ViewManagerClientFactory view_manager_client_factory_; | |
| 148 scoped_ptr<WebLayerTreeViewImpl> web_layer_tree_view_impl_; | |
| 149 scoped_refptr<base::MessageLoopProxy> compositor_thread_; | |
| 150 WebMediaPlayerFactory* web_media_player_factory_; | |
| 151 | |
| 152 // EncryptedMediaClient attached to this frame; lazily initialized. | |
| 153 scoped_ptr<media::WebEncryptedMediaClientImpl> web_encrypted_media_client_; | |
| 154 | |
| 155 scoped_ptr<media::MediaPermission> media_permission_; | |
| 156 scoped_ptr<media::CdmFactory> cdm_factory_; | |
| 157 | |
| 158 // HTMLDocument owns these pointers; binding requests after document load. | |
| 159 std::set<mojo::InterfaceRequest<mojo::AxProvider>*> ax_provider_requests_; | |
| 160 std::set<AxProviderImpl*> ax_providers_; | |
| 161 | |
| 162 // A flag set on didFinishLoad. | |
| 163 bool did_finish_load_ = false; | |
| 164 | |
| 165 // Set if the content will never be displayed. | |
| 166 bool is_headless_; | |
| 167 | |
| 168 scoped_ptr<TouchHandler> touch_handler_; | |
| 169 | |
| 170 float device_pixel_ratio_; | |
| 171 | |
| 172 DISALLOW_COPY_AND_ASSIGN(HTMLDocument); | |
| 173 }; | |
| 174 | |
| 175 } // namespace html_viewer | |
| 176 | |
| 177 #endif // MOJO_SERVICES_HTML_VIEWER_HTML_DOCUMENT_H_ | |
| OLD | NEW |