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" | |
11 #include "components/view_manager/public/cpp/view_observer.h" | 10 #include "components/view_manager/public/cpp/view_observer.h" |
12 #include "components/view_manager/public/cpp/view_tree_delegate.h" | 11 #include "components/view_manager/public/cpp/view_tree_delegate.h" |
13 #include "components/web_view/frame_devtools_agent_delegate.h" | 12 #include "components/web_view/frame_devtools_agent_delegate.h" |
14 #include "components/web_view/frame_tree_delegate.h" | 13 #include "components/web_view/frame_tree_delegate.h" |
15 #include "components/web_view/public/interfaces/web_view.mojom.h" | 14 #include "components/web_view/public/interfaces/web_view.mojom.h" |
16 #include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h" | 15 #include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h" |
17 | 16 |
18 namespace mojo { | 17 namespace mojo { |
19 class ApplicationImpl; | 18 class ApplicationImpl; |
20 } | 19 } |
21 | 20 |
22 namespace web_view { | 21 namespace web_view { |
23 | 22 |
24 class Frame; | 23 class Frame; |
| 24 class FrameTree; |
25 class FrameDevToolsAgent; | 25 class FrameDevToolsAgent; |
26 class FrameTree; | |
27 class HTMLMessageEvent; | 26 class HTMLMessageEvent; |
28 class PendingWebViewLoad; | 27 class PendingWebViewLoad; |
29 class URLRequestCloneable; | |
30 | 28 |
31 class WebViewImpl : public mojom::WebView, | 29 class WebViewImpl : public mojom::WebView, |
32 public mojo::ViewTreeDelegate, | 30 public mojo::ViewTreeDelegate, |
33 public mojo::ViewObserver, | 31 public mojo::ViewObserver, |
34 public FrameTreeDelegate, | 32 public FrameTreeDelegate, |
35 public FrameDevToolsAgentDelegate { | 33 public FrameDevToolsAgentDelegate { |
36 public: | 34 public: |
37 WebViewImpl(mojo::ApplicationImpl* app, | 35 WebViewImpl(mojo::ApplicationImpl* app, |
38 mojom::WebViewClientPtr client, | 36 mojom::WebViewClientPtr client, |
39 mojo::InterfaceRequest<WebView> request); | 37 mojo::InterfaceRequest<WebView> request); |
40 ~WebViewImpl() override; | 38 ~WebViewImpl() override; |
41 | 39 |
42 private: | 40 private: |
43 friend class PendingWebViewLoad; | 41 friend class PendingWebViewLoad; |
44 | 42 |
45 // See description above |pending_load_| for details. | 43 // See description above |pending_load_| for details. |
46 void OnLoad(); | 44 void OnLoad(); |
47 | 45 |
48 // Actually performs the load and tells our delegate the state of the | |
49 // forward/back list is. This is the shared implementation between | |
50 // LoadRequest() and Go{Back,Forward}(). | |
51 void LoadRequestImpl(mojo::URLRequestPtr request); | |
52 | |
53 // Overridden from WebView: | 46 // Overridden from WebView: |
54 void LoadRequest(mojo::URLRequestPtr request) override; | 47 void LoadRequest(mojo::URLRequestPtr request) override; |
55 void GetViewTreeClient( | 48 void GetViewTreeClient( |
56 mojo::InterfaceRequest<mojo::ViewTreeClient> view_tree_client) | 49 mojo::InterfaceRequest<mojo::ViewTreeClient> view_tree_client) |
57 override; | 50 override; |
58 void GoBack() override; | |
59 void GoForward() override; | |
60 | 51 |
61 // Overridden from mojo::ViewTreeDelegate: | 52 // Overridden from mojo::ViewTreeDelegate: |
62 void OnEmbed(mojo::View* root) override; | 53 void OnEmbed(mojo::View* root) override; |
63 void OnConnectionLost(mojo::ViewTreeConnection* connection) override; | 54 void OnConnectionLost(mojo::ViewTreeConnection* connection) override; |
64 | 55 |
65 // Overridden from mojo::ViewObserver: | 56 // Overridden from mojo::ViewObserver: |
66 void OnViewBoundsChanged(mojo::View* view, | 57 void OnViewBoundsChanged(mojo::View* view, |
67 const mojo::Rect& old_bounds, | 58 const mojo::Rect& old_bounds, |
68 const mojo::Rect& new_bounds) override; | 59 const mojo::Rect& new_bounds) override; |
69 void OnViewDestroyed(mojo::View* view) override; | 60 void OnViewDestroyed(mojo::View* view) override; |
(...skipping 21 matching lines...) Expand all Loading... |
91 mojo::View* content_; | 82 mojo::View* content_; |
92 scoped_ptr<FrameTree> frame_tree_; | 83 scoped_ptr<FrameTree> frame_tree_; |
93 | 84 |
94 // When LoadRequest() is called a PendingWebViewLoad is created to wait for | 85 // When LoadRequest() is called a PendingWebViewLoad is created to wait for |
95 // state needed to process the request. When the state is obtained OnLoad() | 86 // state needed to process the request. When the state is obtained OnLoad() |
96 // is invoked. | 87 // is invoked. |
97 scoped_ptr<PendingWebViewLoad> pending_load_; | 88 scoped_ptr<PendingWebViewLoad> pending_load_; |
98 | 89 |
99 scoped_ptr<FrameDevToolsAgent> devtools_agent_; | 90 scoped_ptr<FrameDevToolsAgent> devtools_agent_; |
100 | 91 |
101 // It would be nice if mojo::URLRequest were cloneable; however, its use of | |
102 // ScopedDataPipieConsumerHandle means that it isn't. | |
103 ScopedVector<URLRequestCloneable> back_list_; | |
104 ScopedVector<URLRequestCloneable> forward_list_; | |
105 | |
106 // The request which is either currently loading or completed. Added to | |
107 // |back_list_| or |forward_list_| on further navigation. | |
108 scoped_ptr<URLRequestCloneable> current_page_request_; | |
109 | |
110 DISALLOW_COPY_AND_ASSIGN(WebViewImpl); | 92 DISALLOW_COPY_AND_ASSIGN(WebViewImpl); |
111 }; | 93 }; |
112 | 94 |
113 } // namespace web_view | 95 } // namespace web_view |
114 | 96 |
115 #endif // COMPONENTS_WEB_VIEW_WEB_VIEW_IMPL_H_ | 97 #endif // COMPONENTS_WEB_VIEW_WEB_VIEW_IMPL_H_ |
OLD | NEW |