| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 COMPONENTS_WEB_VIEW_WEB_VIEW_IMPL_H_ | 5 #ifndef COMPONENTS_WEB_VIEW_WEB_VIEW_IMPL_H_ |
| 6 #define COMPONENTS_WEB_VIEW_WEB_VIEW_IMPL_H_ | 6 #define COMPONENTS_WEB_VIEW_WEB_VIEW_IMPL_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 namespace web_view { | 22 namespace web_view { |
| 23 | 23 |
| 24 class Frame; | 24 class Frame; |
| 25 class FrameDevToolsAgent; | 25 class FrameDevToolsAgent; |
| 26 class FrameTree; | 26 class FrameTree; |
| 27 class HTMLMessageEvent; | 27 class HTMLMessageEvent; |
| 28 class PendingWebViewLoad; | 28 class PendingWebViewLoad; |
| 29 class URLRequestCloneable; | 29 class URLRequestCloneable; |
| 30 | 30 |
| 31 class WebViewImpl : public mojom::WebView, | 31 class WebViewImpl : public mojom::WebView, |
| 32 public mojo::ViewTreeDelegate, | 32 public mus::ViewTreeDelegate, |
| 33 public mojo::ViewObserver, | 33 public mus::ViewObserver, |
| 34 public FrameTreeDelegate, | 34 public FrameTreeDelegate, |
| 35 public FrameDevToolsAgentDelegate { | 35 public FrameDevToolsAgentDelegate { |
| 36 public: | 36 public: |
| 37 WebViewImpl(mojo::ApplicationImpl* app, | 37 WebViewImpl(mojo::ApplicationImpl* app, |
| 38 mojom::WebViewClientPtr client, | 38 mojom::WebViewClientPtr client, |
| 39 mojo::InterfaceRequest<WebView> request); | 39 mojo::InterfaceRequest<WebView> request); |
| 40 ~WebViewImpl() override; | 40 ~WebViewImpl() override; |
| 41 | 41 |
| 42 private: | 42 private: |
| 43 friend class PendingWebViewLoad; | 43 friend class PendingWebViewLoad; |
| 44 | 44 |
| 45 // See description above |pending_load_| for details. | 45 // See description above |pending_load_| for details. |
| 46 void OnLoad(); | 46 void OnLoad(); |
| 47 | 47 |
| 48 // Actually performs the load and tells our delegate the state of the | 48 // Actually performs the load and tells our delegate the state of the |
| 49 // forward/back list is. This is the shared implementation between | 49 // forward/back list is. This is the shared implementation between |
| 50 // LoadRequest() and Go{Back,Forward}(). | 50 // LoadRequest() and Go{Back,Forward}(). |
| 51 void LoadRequestImpl(mojo::URLRequestPtr request); | 51 void LoadRequestImpl(mojo::URLRequestPtr request); |
| 52 | 52 |
| 53 // Overridden from WebView: | 53 // Overridden from WebView: |
| 54 void LoadRequest(mojo::URLRequestPtr request) override; | 54 void LoadRequest(mojo::URLRequestPtr request) override; |
| 55 void GetViewTreeClient( | 55 void GetViewTreeClient( |
| 56 mojo::InterfaceRequest<mojo::ViewTreeClient> view_tree_client) | 56 mojo::InterfaceRequest<mojo::ViewTreeClient> view_tree_client) |
| 57 override; | 57 override; |
| 58 void GoBack() override; | 58 void GoBack() override; |
| 59 void GoForward() override; | 59 void GoForward() override; |
| 60 | 60 |
| 61 // Overridden from mojo::ViewTreeDelegate: | 61 // Overridden from mus::ViewTreeDelegate: |
| 62 void OnEmbed(mojo::View* root) override; | 62 void OnEmbed(mus::View* root) override; |
| 63 void OnConnectionLost(mojo::ViewTreeConnection* connection) override; | 63 void OnConnectionLost(mus::ViewTreeConnection* connection) override; |
| 64 | 64 |
| 65 // Overridden from mojo::ViewObserver: | 65 // Overridden from mus::ViewObserver: |
| 66 void OnViewBoundsChanged(mojo::View* view, | 66 void OnViewBoundsChanged(mus::View* view, |
| 67 const mojo::Rect& old_bounds, | 67 const mojo::Rect& old_bounds, |
| 68 const mojo::Rect& new_bounds) override; | 68 const mojo::Rect& new_bounds) override; |
| 69 void OnViewDestroyed(mojo::View* view) override; | 69 void OnViewDestroyed(mus::View* view) override; |
| 70 | 70 |
| 71 // Overridden from FrameTreeDelegate: | 71 // Overridden from FrameTreeDelegate: |
| 72 bool CanPostMessageEventToFrame(const Frame* source, | 72 bool CanPostMessageEventToFrame(const Frame* source, |
| 73 const Frame* target, | 73 const Frame* target, |
| 74 HTMLMessageEvent* event) override; | 74 HTMLMessageEvent* event) override; |
| 75 void LoadingStateChanged(bool loading, double progress) override; | 75 void LoadingStateChanged(bool loading, double progress) override; |
| 76 void TitleChanged(const mojo::String& title) override; | 76 void TitleChanged(const mojo::String& title) override; |
| 77 void NavigateTopLevel(Frame* source, mojo::URLRequestPtr request) override; | 77 void NavigateTopLevel(Frame* source, mojo::URLRequestPtr request) override; |
| 78 void CanNavigateFrame(Frame* target, | 78 void CanNavigateFrame(Frame* target, |
| 79 mojo::URLRequestPtr request, | 79 mojo::URLRequestPtr request, |
| 80 const CanNavigateFrameCallback& callback) override; | 80 const CanNavigateFrameCallback& callback) override; |
| 81 void DidStartNavigation(Frame* frame) override; | 81 void DidStartNavigation(Frame* frame) override; |
| 82 | 82 |
| 83 // Overridden from FrameDevToolsAgent::Delegate: | 83 // Overridden from FrameDevToolsAgent::Delegate: |
| 84 void HandlePageNavigateRequest(const GURL& url) override; | 84 void HandlePageNavigateRequest(const GURL& url) override; |
| 85 | 85 |
| 86 mojo::ApplicationImpl* app_; | 86 mojo::ApplicationImpl* app_; |
| 87 mojom::WebViewClientPtr client_; | 87 mojom::WebViewClientPtr client_; |
| 88 mojo::StrongBinding<WebView> binding_; | 88 mojo::StrongBinding<WebView> binding_; |
| 89 mojo::View* root_; | 89 mus::View* root_; |
| 90 mojo::View* content_; | 90 mus::View* content_; |
| 91 scoped_ptr<FrameTree> frame_tree_; | 91 scoped_ptr<FrameTree> frame_tree_; |
| 92 | 92 |
| 93 // When LoadRequest() is called a PendingWebViewLoad is created to wait for | 93 // When LoadRequest() is called a PendingWebViewLoad is created to wait for |
| 94 // state needed to process the request. When the state is obtained OnLoad() | 94 // state needed to process the request. When the state is obtained OnLoad() |
| 95 // is invoked. | 95 // is invoked. |
| 96 scoped_ptr<PendingWebViewLoad> pending_load_; | 96 scoped_ptr<PendingWebViewLoad> pending_load_; |
| 97 | 97 |
| 98 scoped_ptr<FrameDevToolsAgent> devtools_agent_; | 98 scoped_ptr<FrameDevToolsAgent> devtools_agent_; |
| 99 | 99 |
| 100 // It would be nice if mojo::URLRequest were cloneable; however, its use of | 100 // It would be nice if mojo::URLRequest were cloneable; however, its use of |
| 101 // ScopedDataPipieConsumerHandle means that it isn't. | 101 // ScopedDataPipieConsumerHandle means that it isn't. |
| 102 ScopedVector<URLRequestCloneable> back_list_; | 102 ScopedVector<URLRequestCloneable> back_list_; |
| 103 ScopedVector<URLRequestCloneable> forward_list_; | 103 ScopedVector<URLRequestCloneable> forward_list_; |
| 104 | 104 |
| 105 // The request which is either currently loading or completed. Added to | 105 // The request which is either currently loading or completed. Added to |
| 106 // |back_list_| or |forward_list_| on further navigation. | 106 // |back_list_| or |forward_list_| on further navigation. |
| 107 scoped_ptr<URLRequestCloneable> current_page_request_; | 107 scoped_ptr<URLRequestCloneable> current_page_request_; |
| 108 | 108 |
| 109 DISALLOW_COPY_AND_ASSIGN(WebViewImpl); | 109 DISALLOW_COPY_AND_ASSIGN(WebViewImpl); |
| 110 }; | 110 }; |
| 111 | 111 |
| 112 } // namespace web_view | 112 } // namespace web_view |
| 113 | 113 |
| 114 #endif // COMPONENTS_WEB_VIEW_WEB_VIEW_IMPL_H_ | 114 #endif // COMPONENTS_WEB_VIEW_WEB_VIEW_IMPL_H_ |
| OLD | NEW |