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