base: Change DCHECK_IS_ON to a macro DCHECK_IS_ON().
[chromium-blink-merge.git] / mojo / services / html_viewer / html_document.h
blobd53615796315051f70af7dfa446c94d954e3f140
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.
5 #ifndef MOJO_SERVICES_HTML_VIEWER_HTML_DOCUMENT_H_
6 #define MOJO_SERVICES_HTML_VIEWER_HTML_DOCUMENT_H_
8 #include <set>
10 #include "base/callback.h"
11 #include "base/macros.h"
12 #include "mojo/public/cpp/application/interface_factory.h"
13 #include "mojo/public/cpp/application/lazy_interface_ptr.h"
14 #include "mojo/public/cpp/application/service_provider_impl.h"
15 #include "mojo/public/cpp/bindings/interface_impl.h"
16 #include "mojo/public/interfaces/application/application.mojom.h"
17 #include "mojo/services/content_handler/public/interfaces/content_handler.mojom.h"
18 #include "mojo/services/html_viewer/ax_provider_impl.h"
19 #include "mojo/services/navigation/public/interfaces/navigation.mojom.h"
20 #include "mojo/services/network/public/interfaces/url_loader.mojom.h"
21 #include "mojo/services/view_manager/public/cpp/view_manager_client_factory.h"
22 #include "mojo/services/view_manager/public/cpp/view_manager_delegate.h"
23 #include "mojo/services/view_manager/public/cpp/view_observer.h"
24 #include "third_party/WebKit/public/web/WebFrameClient.h"
25 #include "third_party/WebKit/public/web/WebViewClient.h"
27 namespace base {
28 class MessageLoopProxy;
31 namespace media {
32 class WebEncryptedMediaClientImpl;
35 namespace mojo {
36 class ViewManager;
37 class View;
40 namespace html_viewer {
42 class AxProviderImpl;
43 class WebLayerTreeViewImpl;
44 class WebMediaPlayerFactory;
46 // A view for a single HTML document.
47 class HTMLDocument : public blink::WebViewClient,
48 public blink::WebFrameClient,
49 public mojo::ViewManagerDelegate,
50 public mojo::ViewObserver,
51 public mojo::InterfaceFactory<mojo::AxProvider> {
52 public:
53 // Load a new HTMLDocument with |response|.
55 // |service_provider_request| should be used to implement a
56 // ServiceProvider which exposes services to the connecting application.
57 // Commonly, the connecting application is the ViewManager and it will
58 // request ViewManagerClient.
60 // |shell| is the Shell connection for this mojo::Application.
61 HTMLDocument(mojo::ServiceProviderPtr provider,
62 mojo::URLResponsePtr response,
63 mojo::Shell* shell,
64 scoped_refptr<base::MessageLoopProxy> compositor_thread,
65 WebMediaPlayerFactory* web_media_player_factory);
66 virtual ~HTMLDocument();
68 private:
69 // WebViewClient methods:
70 virtual blink::WebStorageNamespace* createSessionStorageNamespace();
72 // WebWidgetClient methods:
73 virtual void initializeLayerTreeView();
74 virtual blink::WebLayerTreeView* layerTreeView();
76 // WebFrameClient methods:
77 virtual blink::WebMediaPlayer* createMediaPlayer(
78 blink::WebLocalFrame* frame,
79 const blink::WebURL& url,
80 blink::WebMediaPlayerClient* client);
81 virtual blink::WebMediaPlayer* createMediaPlayer(
82 blink::WebLocalFrame* frame,
83 const blink::WebURL& url,
84 blink::WebMediaPlayerClient* client,
85 blink::WebContentDecryptionModule* initial_cdm);
86 virtual blink::WebFrame* createChildFrame(blink::WebLocalFrame* parent,
87 const blink::WebString& frameName);
88 virtual void frameDetached(blink::WebFrame*);
89 virtual blink::WebCookieJar* cookieJar(blink::WebLocalFrame* frame);
90 virtual blink::WebNavigationPolicy decidePolicyForNavigation(
91 blink::WebLocalFrame* frame,
92 blink::WebDataSource::ExtraData* data,
93 const blink::WebURLRequest& request,
94 blink::WebNavigationType nav_type,
95 blink::WebNavigationPolicy default_policy,
96 bool isRedirect);
97 virtual void didAddMessageToConsole(const blink::WebConsoleMessage& message,
98 const blink::WebString& source_name,
99 unsigned source_line,
100 const blink::WebString& stack_trace);
101 virtual void didNavigateWithinPage(blink::WebLocalFrame* frame,
102 const blink::WebHistoryItem& history_item,
103 blink::WebHistoryCommitType commit_type);
104 virtual blink::WebEncryptedMediaClient* encryptedMediaClient();
106 // ViewManagerDelegate methods:
107 void OnEmbed(
108 mojo::View* root,
109 mojo::ServiceProviderImpl* embedee_service_provider_impl,
110 scoped_ptr<mojo::ServiceProvider> embedder_service_provider) override;
111 void OnViewManagerDisconnected(mojo::ViewManager* view_manager) override;
113 // ViewObserver methods:
114 void OnViewBoundsChanged(mojo::View* view,
115 const mojo::Rect& old_bounds,
116 const mojo::Rect& new_bounds) override;
117 void OnViewDestroyed(mojo::View* view) override;
118 void OnViewInputEvent(mojo::View* view, const mojo::EventPtr& event) override;
120 // InterfaceFactory<AxProvider>
121 void Create(mojo::ApplicationConnection* connection,
122 mojo::InterfaceRequest<mojo::AxProvider> request) override;
124 void Load(mojo::URLResponsePtr response);
126 mojo::URLResponsePtr response_;
127 mojo::ServiceProviderImpl exported_services_;
128 scoped_ptr<mojo::ServiceProvider> embedder_service_provider_;
129 mojo::Shell* shell_;
130 mojo::LazyInterfacePtr<mojo::NavigatorHost> navigator_host_;
131 blink::WebView* web_view_;
132 mojo::View* root_;
133 mojo::ViewManagerClientFactory view_manager_client_factory_;
134 scoped_ptr<WebLayerTreeViewImpl> web_layer_tree_view_impl_;
135 scoped_refptr<base::MessageLoopProxy> compositor_thread_;
136 WebMediaPlayerFactory* web_media_player_factory_;
138 // EncryptedMediaClient attached to this frame; lazily initialized.
139 media::WebEncryptedMediaClientImpl* web_encrypted_media_client_;
141 // HTMLDocument owns these pointers.
142 std::set<AxProviderImpl*> ax_provider_impls_;
144 DISALLOW_COPY_AND_ASSIGN(HTMLDocument);
147 } // namespace html_viewer
149 #endif // MOJO_SERVICES_HTML_VIEWER_HTML_DOCUMENT_H_