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/node_observer.h" | 11 #include "mojo/services/public/cpp/view_manager/view_observer.h" |
12 #include "mojo/services/public/interfaces/navigation/navigation.mojom.h" | 12 #include "mojo/services/public/interfaces/navigation/navigation.mojom.h" |
13 #include "mojo/services/public/interfaces/network/url_loader.mojom.h" | 13 #include "mojo/services/public/interfaces/network/url_loader.mojom.h" |
14 #include "third_party/WebKit/public/web/WebFrameClient.h" | 14 #include "third_party/WebKit/public/web/WebFrameClient.h" |
15 #include "third_party/WebKit/public/web/WebViewClient.h" | 15 #include "third_party/WebKit/public/web/WebViewClient.h" |
16 | 16 |
17 namespace mojo { | 17 namespace mojo { |
18 | 18 |
19 class Node; | |
20 class ViewManager; | 19 class ViewManager; |
21 class View; | 20 class View; |
22 | 21 |
23 // A view for a single HTML document. | 22 // A view for a single HTML document. |
24 class HTMLDocumentView : public blink::WebViewClient, | 23 class HTMLDocumentView : public blink::WebViewClient, |
25 public blink::WebFrameClient, | 24 public blink::WebFrameClient, |
26 public NodeObserver { | 25 public ViewObserver { |
27 public: | 26 public: |
28 HTMLDocumentView(ServiceProvider* service_provider, | 27 HTMLDocumentView(ServiceProvider* service_provider, |
29 ViewManager* view_manager); | 28 ViewManager* view_manager); |
30 virtual ~HTMLDocumentView(); | 29 virtual ~HTMLDocumentView(); |
31 | 30 |
32 void AttachToNode(Node* node); | 31 void AttachToView(View* view); |
33 | 32 |
34 void Load(URLResponsePtr response); | 33 void Load(URLResponsePtr response); |
35 | 34 |
36 private: | 35 private: |
37 // WebViewClient methods: | 36 // WebViewClient methods: |
38 virtual blink::WebStorageNamespace* createSessionStorageNamespace(); | 37 virtual blink::WebStorageNamespace* createSessionStorageNamespace(); |
39 | 38 |
40 // WebWidgetClient methods: | 39 // WebWidgetClient methods: |
41 virtual void didInvalidateRect(const blink::WebRect& rect); | 40 virtual void didInvalidateRect(const blink::WebRect& rect); |
42 virtual bool allowsBrokenNullLayerTreeView() const; | 41 virtual bool allowsBrokenNullLayerTreeView() const; |
43 | 42 |
44 // WebFrameClient methods: | 43 // WebFrameClient methods: |
45 virtual blink::WebCookieJar* cookieJar(blink::WebLocalFrame* frame); | 44 virtual blink::WebCookieJar* cookieJar(blink::WebLocalFrame* frame); |
46 virtual blink::WebNavigationPolicy decidePolicyForNavigation( | 45 virtual blink::WebNavigationPolicy decidePolicyForNavigation( |
47 blink::WebLocalFrame* frame, blink::WebDataSource::ExtraData* data, | 46 blink::WebLocalFrame* frame, blink::WebDataSource::ExtraData* data, |
48 const blink::WebURLRequest& request, blink::WebNavigationType nav_type, | 47 const blink::WebURLRequest& request, blink::WebNavigationType nav_type, |
49 blink::WebNavigationPolicy default_policy, bool isRedirect); | 48 blink::WebNavigationPolicy default_policy, bool isRedirect); |
50 virtual void didAddMessageToConsole( | 49 virtual void didAddMessageToConsole( |
51 const blink::WebConsoleMessage& message, | 50 const blink::WebConsoleMessage& message, |
52 const blink::WebString& source_name, | 51 const blink::WebString& source_name, |
53 unsigned source_line, | 52 unsigned source_line, |
54 const blink::WebString& stack_trace); | 53 const blink::WebString& stack_trace); |
55 virtual void didNavigateWithinPage( | 54 virtual void didNavigateWithinPage( |
56 blink::WebLocalFrame* frame, | 55 blink::WebLocalFrame* frame, |
57 const blink::WebHistoryItem& history_item, | 56 const blink::WebHistoryItem& history_item, |
58 blink::WebHistoryCommitType commit_type); | 57 blink::WebHistoryCommitType commit_type); |
59 | 58 |
60 // NodeObserver methods: | 59 // ViewObserver methods: |
61 virtual void OnNodeBoundsChanged(Node* node, | 60 virtual void OnViewBoundsChanged(View* view, |
62 const gfx::Rect& old_bounds, | 61 const gfx::Rect& old_bounds, |
63 const gfx::Rect& new_bounds) OVERRIDE; | 62 const gfx::Rect& new_bounds) OVERRIDE; |
64 virtual void OnNodeDestroyed(Node* node) OVERRIDE; | 63 virtual void OnViewDestroyed(View* view) OVERRIDE; |
65 virtual void OnNodeInputEvent(Node* node, const EventPtr& event) OVERRIDE; | 64 virtual void OnViewInputEvent(View* view, const EventPtr& event) OVERRIDE; |
66 | 65 |
67 void Repaint(); | 66 void Repaint(); |
68 | 67 |
69 ViewManager* view_manager_; | 68 ViewManager* view_manager_; |
70 View* view_; | 69 View* view_; |
71 blink::WebView* web_view_; | 70 blink::WebView* web_view_; |
72 Node* root_; | 71 View* root_; |
73 bool repaint_pending_; | 72 bool repaint_pending_; |
74 LazyInterfacePtr<NavigatorHost> navigator_host_; | 73 LazyInterfacePtr<NavigatorHost> navigator_host_; |
75 | 74 |
76 base::WeakPtrFactory<HTMLDocumentView> weak_factory_; | 75 base::WeakPtrFactory<HTMLDocumentView> weak_factory_; |
77 DISALLOW_COPY_AND_ASSIGN(HTMLDocumentView); | 76 DISALLOW_COPY_AND_ASSIGN(HTMLDocumentView); |
78 }; | 77 }; |
79 | 78 |
80 } // namespace mojo | 79 } // namespace mojo |
81 | 80 |
82 #endif // MOJO_SERVICES_HTML_VIEWER_HTML_DOCUMENT_VIEW_H_ | 81 #endif // MOJO_SERVICES_HTML_VIEWER_HTML_DOCUMENT_VIEW_H_ |
OLD | NEW |