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