Chromium Code Reviews| 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_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 ViewManager; | 19 class ViewManager; |
| 20 class View; | 20 class View; |
| 21 | 21 |
| 22 class SimpleFrameClient : public blink::WebFrameClient { | |
| 23 public: | |
| 24 SimpleFrameClient(ServiceProvider* service_provider, Id root_id); | |
| 25 virtual ~SimpleFrameClient(); | |
| 26 | |
| 27 protected: | |
| 28 // WebFrameClient methods: | |
| 29 virtual blink::WebFrame* createChildFrame(blink::WebLocalFrame* parent, | |
| 30 const blink::WebString& frameName); | |
| 31 virtual void didDisownOpener(blink::WebLocalFrame*); | |
| 32 virtual void frameDetached(blink::WebFrame*); | |
| 33 virtual void frameFocused(); | |
| 34 virtual void willClose(blink::WebFrame*); | |
| 35 virtual blink::WebCookieJar* cookieJar(blink::WebLocalFrame* frame); | |
| 36 virtual blink::WebNavigationPolicy decidePolicyForNavigation( | |
| 37 blink::WebLocalFrame* frame, blink::WebDataSource::ExtraData* data, | |
| 38 const blink::WebURLRequest& request, blink::WebNavigationType nav_type, | |
| 39 blink::WebNavigationPolicy default_policy, bool isRedirect); | |
| 40 virtual void didAddMessageToConsole( | |
| 41 const blink::WebConsoleMessage& message, | |
| 42 const blink::WebString& source_name, | |
| 43 unsigned source_line, | |
| 44 const blink::WebString& stack_trace); | |
| 45 virtual void didNavigateWithinPage( | |
| 46 blink::WebLocalFrame* frame, | |
| 47 const blink::WebHistoryItem& history_item, | |
| 48 blink::WebHistoryCommitType commit_type); | |
| 49 | |
| 50 ServiceProvider* service_provider_; | |
| 51 LazyInterfacePtr<NavigatorHost> navigator_host_; | |
| 52 Id root_id_; | |
| 53 }; | |
| 54 | |
| 22 // A view for a single HTML document. | 55 // A view for a single HTML document. |
| 23 class HTMLDocumentView : public blink::WebViewClient, | 56 class HTMLDocumentView : public blink::WebViewClient, |
| 24 public blink::WebFrameClient, | 57 public SimpleFrameClient, |
|
darin (slow to review)
2014/08/14 23:45:52
perhaps it would be better to use composition here
| |
| 25 public ViewObserver { | 58 public ViewObserver { |
| 26 public: | 59 public: |
| 27 HTMLDocumentView(ServiceProvider* service_provider, | 60 HTMLDocumentView(ServiceProvider* service_provider, |
| 28 ViewManager* view_manager); | 61 ViewManager* view_manager); |
| 29 virtual ~HTMLDocumentView(); | 62 virtual ~HTMLDocumentView(); |
| 30 | 63 |
| 31 void AttachToView(View* view); | 64 void AttachToView(View* view); |
| 32 | 65 |
| 33 void Load(URLResponsePtr response); | 66 void Load(URLResponsePtr response); |
| 34 | 67 |
| 35 private: | 68 private: |
| 36 // WebViewClient methods: | 69 // WebViewClient methods: |
| 37 virtual blink::WebStorageNamespace* createSessionStorageNamespace(); | 70 virtual blink::WebStorageNamespace* createSessionStorageNamespace(); |
| 38 | 71 |
| 39 // WebWidgetClient methods: | 72 // WebWidgetClient methods: |
| 40 virtual void didInvalidateRect(const blink::WebRect& rect); | 73 virtual void didInvalidateRect(const blink::WebRect& rect); |
| 41 virtual bool allowsBrokenNullLayerTreeView() const; | 74 virtual bool allowsBrokenNullLayerTreeView() const; |
| 42 | 75 |
| 43 // WebFrameClient methods: | |
| 44 virtual blink::WebCookieJar* cookieJar(blink::WebLocalFrame* frame); | |
| 45 virtual blink::WebNavigationPolicy decidePolicyForNavigation( | |
| 46 blink::WebLocalFrame* frame, blink::WebDataSource::ExtraData* data, | |
| 47 const blink::WebURLRequest& request, blink::WebNavigationType nav_type, | |
| 48 blink::WebNavigationPolicy default_policy, bool isRedirect); | |
| 49 virtual void didAddMessageToConsole( | |
| 50 const blink::WebConsoleMessage& message, | |
| 51 const blink::WebString& source_name, | |
| 52 unsigned source_line, | |
| 53 const blink::WebString& stack_trace); | |
| 54 virtual void didNavigateWithinPage( | |
| 55 blink::WebLocalFrame* frame, | |
| 56 const blink::WebHistoryItem& history_item, | |
| 57 blink::WebHistoryCommitType commit_type); | |
| 58 | |
| 59 // ViewObserver methods: | 76 // ViewObserver methods: |
| 60 virtual void OnViewBoundsChanged(View* view, | 77 virtual void OnViewBoundsChanged(View* view, |
| 61 const gfx::Rect& old_bounds, | 78 const gfx::Rect& old_bounds, |
| 62 const gfx::Rect& new_bounds) OVERRIDE; | 79 const gfx::Rect& new_bounds) OVERRIDE; |
| 63 virtual void OnViewDestroyed(View* view) OVERRIDE; | 80 virtual void OnViewDestroyed(View* view) OVERRIDE; |
| 64 virtual void OnViewInputEvent(View* view, const EventPtr& event) OVERRIDE; | 81 virtual void OnViewInputEvent(View* view, const EventPtr& event) OVERRIDE; |
| 65 | 82 |
| 66 void Repaint(); | 83 void Repaint(); |
| 67 | 84 |
| 68 ViewManager* view_manager_; | 85 ViewManager* view_manager_; |
| 69 View* view_; | |
| 70 blink::WebView* web_view_; | 86 blink::WebView* web_view_; |
| 71 View* root_; | 87 View* root_; |
| 72 bool repaint_pending_; | 88 bool repaint_pending_; |
| 73 LazyInterfacePtr<NavigatorHost> navigator_host_; | |
| 74 | 89 |
| 75 base::WeakPtrFactory<HTMLDocumentView> weak_factory_; | 90 base::WeakPtrFactory<HTMLDocumentView> weak_factory_; |
| 76 DISALLOW_COPY_AND_ASSIGN(HTMLDocumentView); | 91 DISALLOW_COPY_AND_ASSIGN(HTMLDocumentView); |
| 77 }; | 92 }; |
| 78 | 93 |
| 79 } // namespace mojo | 94 } // namespace mojo |
| 80 | 95 |
| 81 #endif // MOJO_SERVICES_HTML_VIEWER_HTML_DOCUMENT_VIEW_H_ | 96 #endif // MOJO_SERVICES_HTML_VIEWER_HTML_DOCUMENT_VIEW_H_ |
| OLD | NEW |