| 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 SKY_VIEWER_DOCUMENT_VIEW_H_ | 5 #ifndef SKY_VIEWER_DOCUMENT_VIEW_H_ |
| 6 #define SKY_VIEWER_DOCUMENT_VIEW_H_ | 6 #define SKY_VIEWER_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" | 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" | 12 #include "mojo/services/public/cpp/view_manager/view_manager_delegate.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/content_handler/content_handler.mojom.
h" | 14 #include "mojo/services/public/interfaces/content_handler/content_handler.mojom.
h" |
| 15 #include "mojo/services/public/interfaces/navigation/navigation.mojom.h" | 15 #include "mojo/services/public/interfaces/navigation/navigation.mojom.h" |
| 16 #include "mojo/services/public/interfaces/network/url_loader.mojom.h" | 16 #include "mojo/services/public/interfaces/network/url_loader.mojom.h" |
| 17 #include "sky/engine/public/platform/ServiceProvider.h" |
| 17 #include "sky/engine/public/web/WebFrameClient.h" | 18 #include "sky/engine/public/web/WebFrameClient.h" |
| 18 #include "sky/engine/public/web/WebViewClient.h" | 19 #include "sky/engine/public/web/WebViewClient.h" |
| 19 #include "sky/viewer/services/inspector_impl.h" | 20 #include "sky/viewer/services/inspector_impl.h" |
| 20 | 21 |
| 21 namespace base { | 22 namespace base { |
| 22 class MessageLoopProxy; | 23 class MessageLoopProxy; |
| 23 } | 24 } |
| 24 | 25 |
| 25 namespace mojo { | 26 namespace mojo { |
| 26 class ViewManager; | 27 class ViewManager; |
| 27 class View; | 28 class View; |
| 28 } | 29 } |
| 29 | 30 |
| 30 namespace sky { | 31 namespace sky { |
| 31 class ScriptRunner; | 32 class ScriptRunner; |
| 32 class WebLayerTreeViewImpl; | 33 class WebLayerTreeViewImpl; |
| 33 | 34 |
| 34 class DocumentView : public blink::WebViewClient, | 35 class DocumentView : public blink::ServiceProvider, |
| 36 public blink::WebViewClient, |
| 35 public blink::WebFrameClient, | 37 public blink::WebFrameClient, |
| 36 public mojo::ViewManagerDelegate, | 38 public mojo::ViewManagerDelegate, |
| 37 public mojo::ViewObserver { | 39 public mojo::ViewObserver { |
| 38 public: | 40 public: |
| 39 // Load a new HTMLDocument with |response|. | 41 // Load a new HTMLDocument with |response|. |
| 40 // | 42 // |
| 41 // |sp_request| should be used to implement a | 43 // |sp_request| should be used to implement a |
| 42 // ServiceProvider which exposes services to the connecting application. | 44 // ServiceProvider which exposes services to the connecting application. |
| 43 // Commonly, the connecting application is the ViewManager and it will | 45 // Commonly, the connecting application is the ViewManager and it will |
| 44 // request ViewManagerClient. | 46 // request ViewManagerClient. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 57 return imported_services_.get(); | 59 return imported_services_.get(); |
| 58 } | 60 } |
| 59 | 61 |
| 60 mojo::Shell* shell() const { return shell_; } | 62 mojo::Shell* shell() const { return shell_; } |
| 61 | 63 |
| 62 private: | 64 private: |
| 63 // WebWidgetClient methods: | 65 // WebWidgetClient methods: |
| 64 virtual blink::WebLayerTreeView* initializeLayerTreeView(); | 66 virtual blink::WebLayerTreeView* initializeLayerTreeView(); |
| 65 | 67 |
| 66 // WebFrameClient methods: | 68 // WebFrameClient methods: |
| 67 virtual void frameDetached(blink::WebFrame*); | 69 void frameDetached(blink::WebFrame*) override; |
| 68 virtual blink::WebNavigationPolicy decidePolicyForNavigation( | 70 blink::WebNavigationPolicy decidePolicyForNavigation( |
| 69 const blink::WebFrameClient::NavigationPolicyInfo& info); | 71 const blink::WebFrameClient::NavigationPolicyInfo& info) override; |
| 70 virtual void didAddMessageToConsole( | 72 void didAddMessageToConsole( |
| 71 const blink::WebConsoleMessage& message, | 73 const blink::WebConsoleMessage& message, |
| 72 const blink::WebString& source_name, | 74 const blink::WebString& source_name, |
| 73 unsigned source_line, | 75 unsigned source_line, |
| 74 const blink::WebString& stack_trace); | 76 const blink::WebString& stack_trace) override; |
| 75 virtual void didCreateScriptContext( | 77 void didCreateScriptContext( |
| 76 blink::WebLocalFrame*, v8::Handle<v8::Context>, int extensionGroup, int wo
rldId); | 78 blink::WebLocalFrame*, |
| 79 v8::Handle<v8::Context>, |
| 80 int extensionGroup, |
| 81 int worldId) override; |
| 82 |
| 83 // WebViewClient methods: |
| 84 blink::ServiceProvider* services() override; |
| 85 |
| 86 // Services methods: |
| 87 mojo::NavigatorHost* NavigatorHost() override; |
| 77 | 88 |
| 78 // ViewManagerDelegate methods: | 89 // ViewManagerDelegate methods: |
| 79 virtual void OnEmbed( | 90 void OnEmbed( |
| 80 mojo::ViewManager* view_manager, | 91 mojo::ViewManager* view_manager, |
| 81 mojo::View* root, | 92 mojo::View* root, |
| 82 mojo::ServiceProviderImpl* exported_services, | 93 mojo::ServiceProviderImpl* exported_services, |
| 83 scoped_ptr<mojo::ServiceProvider> imported_services) override; | 94 scoped_ptr<mojo::ServiceProvider> imported_services) override; |
| 84 virtual void OnViewManagerDisconnected(mojo::ViewManager* view_manager) overri
de; | 95 void OnViewManagerDisconnected(mojo::ViewManager* view_manager) override; |
| 85 | 96 |
| 86 // ViewObserver methods: | 97 // ViewObserver methods: |
| 87 virtual void OnViewBoundsChanged(mojo::View* view, | 98 void OnViewBoundsChanged(mojo::View* view, |
| 88 const mojo::Rect& old_bounds, | 99 const mojo::Rect& old_bounds, |
| 89 const mojo::Rect& new_bounds) override; | 100 const mojo::Rect& new_bounds) override; |
| 90 virtual void OnViewDestroyed(mojo::View* view) override; | 101 void OnViewDestroyed(mojo::View* view) override; |
| 91 virtual void OnViewInputEvent(mojo::View* view, const mojo::EventPtr& event) o
verride; | 102 void OnViewInputEvent(mojo::View* view, const mojo::EventPtr& event) override; |
| 92 | 103 |
| 93 void Load(mojo::URLResponsePtr response); | 104 void Load(mojo::URLResponsePtr response); |
| 94 | 105 |
| 95 mojo::URLResponsePtr response_; | 106 mojo::URLResponsePtr response_; |
| 96 scoped_ptr<mojo::ServiceProvider> imported_services_; | 107 scoped_ptr<mojo::ServiceProvider> imported_services_; |
| 97 mojo::Shell* shell_; | 108 mojo::Shell* shell_; |
| 98 mojo::LazyInterfacePtr<mojo::NavigatorHost> navigator_host_; | 109 mojo::LazyInterfacePtr<mojo::NavigatorHost> navigator_host_; |
| 99 blink::WebView* web_view_; | 110 blink::WebView* web_view_; |
| 100 mojo::View* root_; | 111 mojo::View* root_; |
| 101 mojo::ViewManagerClientFactory view_manager_client_factory_; | 112 mojo::ViewManagerClientFactory view_manager_client_factory_; |
| 102 InspectorServiceFactory inspector_service_factory_; | 113 InspectorServiceFactory inspector_service_factory_; |
| 103 scoped_ptr<WebLayerTreeViewImpl> web_layer_tree_view_impl_; | 114 scoped_ptr<WebLayerTreeViewImpl> web_layer_tree_view_impl_; |
| 104 scoped_refptr<base::MessageLoopProxy> compositor_thread_; | 115 scoped_refptr<base::MessageLoopProxy> compositor_thread_; |
| 105 scoped_ptr<ScriptRunner> script_runner_; | 116 scoped_ptr<ScriptRunner> script_runner_; |
| 106 | 117 |
| 107 base::WeakPtrFactory<DocumentView> weak_factory_; | 118 base::WeakPtrFactory<DocumentView> weak_factory_; |
| 108 DISALLOW_COPY_AND_ASSIGN(DocumentView); | 119 DISALLOW_COPY_AND_ASSIGN(DocumentView); |
| 109 }; | 120 }; |
| 110 | 121 |
| 111 } // namespace sky | 122 } // namespace sky |
| 112 | 123 |
| 113 #endif // SKY_VIEWER_DOCUMENT_VIEW_H_ | 124 #endif // SKY_VIEWER_DOCUMENT_VIEW_H_ |
| OLD | NEW |