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/public/cpp/application/lazy_interface_ptr.h" |
11 #include "mojo/services/public/cpp/view_manager/view_manager_client_factory.h" | |
12 #include "mojo/services/public/cpp/view_manager/view_manager_delegate.h" | |
11 #include "mojo/services/public/cpp/view_manager/view_observer.h" | 13 #include "mojo/services/public/cpp/view_manager/view_observer.h" |
14 #include "mojo/services/public/interfaces/content_handler/content_handler.mojom. h" | |
12 #include "mojo/services/public/interfaces/navigation/navigation.mojom.h" | 15 #include "mojo/services/public/interfaces/navigation/navigation.mojom.h" |
13 #include "mojo/services/public/interfaces/network/url_loader.mojom.h" | 16 #include "mojo/services/public/interfaces/network/url_loader.mojom.h" |
14 #include "third_party/WebKit/public/web/WebFrameClient.h" | 17 #include "third_party/WebKit/public/web/WebFrameClient.h" |
15 #include "third_party/WebKit/public/web/WebViewClient.h" | 18 #include "third_party/WebKit/public/web/WebViewClient.h" |
16 | 19 |
17 namespace mojo { | 20 namespace mojo { |
18 | 21 |
19 class ViewManager; | 22 class ViewManager; |
20 class View; | 23 class View; |
21 | 24 |
22 // A view for a single HTML document. | 25 // A view for a single HTML document. |
23 class HTMLDocumentView : public blink::WebViewClient, | 26 class HTMLDocumentView : public blink::WebViewClient, |
24 public blink::WebFrameClient, | 27 public blink::WebFrameClient, |
28 public ViewManagerDelegate, | |
25 public ViewObserver { | 29 public ViewObserver { |
26 public: | 30 public: |
27 HTMLDocumentView(ServiceProvider* service_provider, | 31 // Load a new HTMLDocument with |response|. |
28 ViewManager* view_manager); | 32 // |
33 // |imported_from_connector| is used to request services of the connecting | |
34 // application (e.g., the application that called | |
darin (slow to review)
2014/08/29 05:59:42
do you mean the application that called ConnectToA
| |
35 // ContentHandler::OnConnect()). | |
36 // | |
37 // |exported_to_connector| is used to export services from this | |
38 // HTMLDocumentView to the connecting application. | |
39 // | |
40 // |shell_connection| is the original ServiceProvider that was passed to | |
darin (slow to review)
2014/08/29 05:59:42
nit: ServiceProvider -> ApplicationConnection
| |
41 // HTMLViewer. | |
42 // | |
43 // TODO(aa): Remove |shell_connection|. It is used to get the NavigatorHost | |
44 // from the window manager. That should be exposed via the | |
45 // |exported_from_embedder| param to OnEmbed() instead. | |
46 HTMLDocumentView(URLResponsePtr response, | |
47 scoped_ptr<ServiceProvider> imported_from_connector, | |
darin (slow to review)
2014/08/29 05:59:42
in the .cc file you use the variable names importe
| |
48 ServiceProviderImpl* exported_to_connector, | |
49 ApplicationConnection* shell_connection); | |
29 virtual ~HTMLDocumentView(); | 50 virtual ~HTMLDocumentView(); |
30 | 51 |
31 void AttachToView(View* view); | |
32 | |
33 void Load(URLResponsePtr response); | |
34 | |
35 private: | 52 private: |
36 // WebViewClient methods: | 53 // WebViewClient methods: |
37 virtual blink::WebStorageNamespace* createSessionStorageNamespace(); | 54 virtual blink::WebStorageNamespace* createSessionStorageNamespace(); |
38 | 55 |
39 // WebWidgetClient methods: | 56 // WebWidgetClient methods: |
40 virtual void didInvalidateRect(const blink::WebRect& rect); | 57 virtual void didInvalidateRect(const blink::WebRect& rect); |
41 virtual bool allowsBrokenNullLayerTreeView() const; | 58 virtual bool allowsBrokenNullLayerTreeView() const; |
42 | 59 |
43 // WebFrameClient methods: | 60 // WebFrameClient methods: |
44 virtual blink::WebFrame* createChildFrame(blink::WebLocalFrame* parent, | 61 virtual blink::WebFrame* createChildFrame(blink::WebLocalFrame* parent, |
45 const blink::WebString& frameName); | 62 const blink::WebString& frameName); |
46 virtual void frameDetached(blink::WebFrame*); | 63 virtual void frameDetached(blink::WebFrame*); |
47 virtual blink::WebCookieJar* cookieJar(blink::WebLocalFrame* frame); | 64 virtual blink::WebCookieJar* cookieJar(blink::WebLocalFrame* frame); |
48 virtual blink::WebNavigationPolicy decidePolicyForNavigation( | 65 virtual blink::WebNavigationPolicy decidePolicyForNavigation( |
49 blink::WebLocalFrame* frame, blink::WebDataSource::ExtraData* data, | 66 blink::WebLocalFrame* frame, blink::WebDataSource::ExtraData* data, |
50 const blink::WebURLRequest& request, blink::WebNavigationType nav_type, | 67 const blink::WebURLRequest& request, blink::WebNavigationType nav_type, |
51 blink::WebNavigationPolicy default_policy, bool isRedirect); | 68 blink::WebNavigationPolicy default_policy, bool isRedirect); |
52 virtual void didAddMessageToConsole( | 69 virtual void didAddMessageToConsole( |
53 const blink::WebConsoleMessage& message, | 70 const blink::WebConsoleMessage& message, |
54 const blink::WebString& source_name, | 71 const blink::WebString& source_name, |
55 unsigned source_line, | 72 unsigned source_line, |
56 const blink::WebString& stack_trace); | 73 const blink::WebString& stack_trace); |
57 virtual void didNavigateWithinPage( | 74 virtual void didNavigateWithinPage( |
58 blink::WebLocalFrame* frame, | 75 blink::WebLocalFrame* frame, |
59 const blink::WebHistoryItem& history_item, | 76 const blink::WebHistoryItem& history_item, |
60 blink::WebHistoryCommitType commit_type); | 77 blink::WebHistoryCommitType commit_type); |
61 | 78 |
79 // ViewManagerDelegate methods: | |
80 virtual void OnEmbed( | |
81 ViewManager* view_manager, | |
82 View* root, | |
83 ServiceProviderImpl* exported_to_embedder, | |
84 scoped_ptr<ServiceProvider> exported_from_embedder) OVERRIDE; | |
85 virtual void OnViewManagerDisconnected(ViewManager* view_manager) OVERRIDE; | |
86 | |
62 // ViewObserver methods: | 87 // ViewObserver methods: |
63 virtual void OnViewBoundsChanged(View* view, | 88 virtual void OnViewBoundsChanged(View* view, |
64 const gfx::Rect& old_bounds, | 89 const gfx::Rect& old_bounds, |
65 const gfx::Rect& new_bounds) OVERRIDE; | 90 const gfx::Rect& new_bounds) OVERRIDE; |
66 virtual void OnViewDestroyed(View* view) OVERRIDE; | 91 virtual void OnViewDestroyed(View* view) OVERRIDE; |
67 virtual void OnViewInputEvent(View* view, const EventPtr& event) OVERRIDE; | 92 virtual void OnViewInputEvent(View* view, const EventPtr& event) OVERRIDE; |
68 | 93 |
94 void Load(URLResponsePtr response); | |
95 | |
69 void Repaint(); | 96 void Repaint(); |
70 | 97 |
71 ViewManager* view_manager_; | 98 URLResponsePtr response_; |
99 scoped_ptr<ServiceProvider> imported_services_; | |
72 LazyInterfacePtr<NavigatorHost> navigator_host_; | 100 LazyInterfacePtr<NavigatorHost> navigator_host_; |
73 blink::WebView* web_view_; | 101 blink::WebView* web_view_; |
74 View* root_; | 102 View* root_; |
103 ViewManagerClientFactory view_manager_client_factory_; | |
75 bool repaint_pending_; | 104 bool repaint_pending_; |
76 | 105 |
77 base::WeakPtrFactory<HTMLDocumentView> weak_factory_; | 106 base::WeakPtrFactory<HTMLDocumentView> weak_factory_; |
78 DISALLOW_COPY_AND_ASSIGN(HTMLDocumentView); | 107 DISALLOW_COPY_AND_ASSIGN(HTMLDocumentView); |
79 }; | 108 }; |
80 | 109 |
81 } // namespace mojo | 110 } // namespace mojo |
82 | 111 |
83 #endif // MOJO_SERVICES_HTML_VIEWER_HTML_DOCUMENT_VIEW_H_ | 112 #endif // MOJO_SERVICES_HTML_VIEWER_HTML_DOCUMENT_VIEW_H_ |
OLD | NEW |