OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 MOJO_SERVICES_HTML_VIEWER_HTML_DOCUMENT_VIEW_H_ | 5 #ifndef MOJO_SERVICES_HTML_VIEWER_HTML_DOCUMENT_VIEW_H_ |
6 #define MOJO_SERVICES_HTML_VIEWER_HTML_DOCUMENT_VIEW_H_ | 6 #define MOJO_SERVICES_HTML_VIEWER_HTML_DOCUMENT_VIEW_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "mojo/public/cpp/application/lazy_interface_ptr.h" | 10 #include "mojo/services/public/cpp/view_manager/view_manager_client_factory.h" |
| 11 #include "mojo/services/public/cpp/view_manager/view_manager_delegate.h" |
11 #include "mojo/services/public/cpp/view_manager/view_observer.h" | 12 #include "mojo/services/public/cpp/view_manager/view_observer.h" |
| 13 #include "mojo/services/public/interfaces/content_handler/content_handler.mojom.
h" |
12 #include "mojo/services/public/interfaces/navigation/navigation.mojom.h" | 14 #include "mojo/services/public/interfaces/navigation/navigation.mojom.h" |
13 #include "mojo/services/public/interfaces/network/url_loader.mojom.h" | 15 #include "mojo/services/public/interfaces/network/url_loader.mojom.h" |
14 #include "third_party/WebKit/public/web/WebFrameClient.h" | 16 #include "third_party/WebKit/public/web/WebFrameClient.h" |
15 #include "third_party/WebKit/public/web/WebViewClient.h" | 17 #include "third_party/WebKit/public/web/WebViewClient.h" |
16 | 18 |
17 namespace mojo { | 19 namespace mojo { |
18 | 20 |
19 class ViewManager; | 21 class ViewManager; |
20 class View; | 22 class View; |
21 | 23 |
22 // A view for a single HTML document. | 24 // A view for a single HTML document. |
23 class HTMLDocumentView : public blink::WebViewClient, | 25 class HTMLDocumentView : public blink::WebViewClient, |
24 public blink::WebFrameClient, | 26 public blink::WebFrameClient, |
| 27 public ViewManagerDelegate, |
25 public ViewObserver { | 28 public ViewObserver { |
26 public: | 29 public: |
27 HTMLDocumentView(ServiceProvider* service_provider, | 30 // Load a new HTMLDocument with |response|. |
28 ViewManager* view_manager); | 31 // |
| 32 // |imported_from_connector| is used to request services of the connecting |
| 33 // application (e.g., the application that called |
| 34 // Shell::ConnectToApplication()). |
| 35 // |
| 36 // |exported_to_connector| is used to export services from this |
| 37 // HTMLDocumentView to the connecting application. |
| 38 // |
| 39 // |shell| is the Shell connection for this mojo::Application. |
| 40 HTMLDocumentView(URLResponsePtr response, |
| 41 scoped_ptr<ServiceProvider> imported_from_connector, |
| 42 ServiceProviderImpl* exported_to_connector, |
| 43 Shell* shell); |
29 virtual ~HTMLDocumentView(); | 44 virtual ~HTMLDocumentView(); |
30 | 45 |
31 void AttachToView(View* view); | |
32 | |
33 void Load(URLResponsePtr response); | |
34 | |
35 private: | 46 private: |
36 // WebViewClient methods: | 47 // WebViewClient methods: |
37 virtual blink::WebStorageNamespace* createSessionStorageNamespace(); | 48 virtual blink::WebStorageNamespace* createSessionStorageNamespace(); |
38 | 49 |
39 // WebWidgetClient methods: | 50 // WebWidgetClient methods: |
40 virtual void didInvalidateRect(const blink::WebRect& rect); | 51 virtual void didInvalidateRect(const blink::WebRect& rect); |
41 virtual bool allowsBrokenNullLayerTreeView() const; | 52 virtual bool allowsBrokenNullLayerTreeView() const; |
42 | 53 |
43 // WebFrameClient methods: | 54 // WebFrameClient methods: |
44 virtual blink::WebFrame* createChildFrame(blink::WebLocalFrame* parent, | 55 virtual blink::WebFrame* createChildFrame(blink::WebLocalFrame* parent, |
45 const blink::WebString& frameName); | 56 const blink::WebString& frameName); |
46 virtual void frameDetached(blink::WebFrame*); | 57 virtual void frameDetached(blink::WebFrame*); |
47 virtual blink::WebCookieJar* cookieJar(blink::WebLocalFrame* frame); | 58 virtual blink::WebCookieJar* cookieJar(blink::WebLocalFrame* frame); |
48 virtual blink::WebNavigationPolicy decidePolicyForNavigation( | 59 virtual blink::WebNavigationPolicy decidePolicyForNavigation( |
49 blink::WebLocalFrame* frame, blink::WebDataSource::ExtraData* data, | 60 blink::WebLocalFrame* frame, blink::WebDataSource::ExtraData* data, |
50 const blink::WebURLRequest& request, blink::WebNavigationType nav_type, | 61 const blink::WebURLRequest& request, blink::WebNavigationType nav_type, |
51 blink::WebNavigationPolicy default_policy, bool isRedirect); | 62 blink::WebNavigationPolicy default_policy, bool isRedirect); |
52 virtual void didAddMessageToConsole( | 63 virtual void didAddMessageToConsole( |
53 const blink::WebConsoleMessage& message, | 64 const blink::WebConsoleMessage& message, |
54 const blink::WebString& source_name, | 65 const blink::WebString& source_name, |
55 unsigned source_line, | 66 unsigned source_line, |
56 const blink::WebString& stack_trace); | 67 const blink::WebString& stack_trace); |
57 virtual void didNavigateWithinPage( | 68 virtual void didNavigateWithinPage( |
58 blink::WebLocalFrame* frame, | 69 blink::WebLocalFrame* frame, |
59 const blink::WebHistoryItem& history_item, | 70 const blink::WebHistoryItem& history_item, |
60 blink::WebHistoryCommitType commit_type); | 71 blink::WebHistoryCommitType commit_type); |
61 | 72 |
| 73 // ViewManagerDelegate methods: |
| 74 virtual void OnEmbed( |
| 75 ViewManager* view_manager, |
| 76 View* root, |
| 77 ServiceProviderImpl* exported_to_embedder, |
| 78 scoped_ptr<ServiceProvider> exported_from_embedder) OVERRIDE; |
| 79 virtual void OnViewManagerDisconnected(ViewManager* view_manager) OVERRIDE; |
| 80 |
62 // ViewObserver methods: | 81 // ViewObserver methods: |
63 virtual void OnViewBoundsChanged(View* view, | 82 virtual void OnViewBoundsChanged(View* view, |
64 const gfx::Rect& old_bounds, | 83 const gfx::Rect& old_bounds, |
65 const gfx::Rect& new_bounds) OVERRIDE; | 84 const gfx::Rect& new_bounds) OVERRIDE; |
66 virtual void OnViewDestroyed(View* view) OVERRIDE; | 85 virtual void OnViewDestroyed(View* view) OVERRIDE; |
67 virtual void OnViewInputEvent(View* view, const EventPtr& event) OVERRIDE; | 86 virtual void OnViewInputEvent(View* view, const EventPtr& event) OVERRIDE; |
68 | 87 |
| 88 void Load(URLResponsePtr response); |
69 void Repaint(); | 89 void Repaint(); |
| 90 NavigatorHost* GetNavigatorHost(); |
70 | 91 |
71 ViewManager* view_manager_; | 92 URLResponsePtr response_; |
72 LazyInterfacePtr<NavigatorHost> navigator_host_; | 93 scoped_ptr<ServiceProvider> imported_services_; |
| 94 Shell* shell_; |
| 95 InterfacePtr<NavigatorHost> navigator_host_; |
73 blink::WebView* web_view_; | 96 blink::WebView* web_view_; |
74 View* root_; | 97 View* root_; |
| 98 ViewManagerClientFactory view_manager_client_factory_; |
75 bool repaint_pending_; | 99 bool repaint_pending_; |
76 | 100 |
77 base::WeakPtrFactory<HTMLDocumentView> weak_factory_; | 101 base::WeakPtrFactory<HTMLDocumentView> weak_factory_; |
78 DISALLOW_COPY_AND_ASSIGN(HTMLDocumentView); | 102 DISALLOW_COPY_AND_ASSIGN(HTMLDocumentView); |
79 }; | 103 }; |
80 | 104 |
81 } // namespace mojo | 105 } // namespace mojo |
82 | 106 |
83 #endif // MOJO_SERVICES_HTML_VIEWER_HTML_DOCUMENT_VIEW_H_ | 107 #endif // MOJO_SERVICES_HTML_VIEWER_HTML_DOCUMENT_VIEW_H_ |
OLD | NEW |