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 mus::ViewTreeDelegate, | 32 public mojo::ViewTreeDelegate, |
33 public mus::ViewObserver, | 33 public mojo::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 mus::ViewTreeDelegate: | 61 // Overridden from mojo::ViewTreeDelegate: |
62 void OnEmbed(mus::View* root) override; | 62 void OnEmbed(mojo::View* root) override; |
63 void OnConnectionLost(mus::ViewTreeConnection* connection) override; | 63 void OnConnectionLost(mojo::ViewTreeConnection* connection) override; |
64 | 64 |
65 // Overridden from mus::ViewObserver: | 65 // Overridden from mojo::ViewObserver: |
66 void OnViewBoundsChanged(mus::View* view, | 66 void OnViewBoundsChanged(mojo::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(mus::View* view) override; | 69 void OnViewDestroyed(mojo::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) override; | 75 void LoadingStateChanged(bool loading) override; |
76 void ProgressChanged(double progress) override; | 76 void ProgressChanged(double progress) override; |
77 void TitleChanged(const mojo::String& title) override; | 77 void TitleChanged(const mojo::String& title) override; |
78 void NavigateTopLevel(Frame* source, mojo::URLRequestPtr request) override; | 78 void NavigateTopLevel(Frame* source, mojo::URLRequestPtr request) override; |
79 void CanNavigateFrame(Frame* target, | 79 void CanNavigateFrame(Frame* target, |
80 mojo::URLRequestPtr request, | 80 mojo::URLRequestPtr request, |
81 const CanNavigateFrameCallback& callback) override; | 81 const CanNavigateFrameCallback& callback) override; |
82 void DidStartNavigation(Frame* frame) override; | 82 void DidStartNavigation(Frame* frame) override; |
83 | 83 |
84 // Overridden from FrameDevToolsAgent::Delegate: | 84 // Overridden from FrameDevToolsAgent::Delegate: |
85 void HandlePageNavigateRequest(const GURL& url) override; | 85 void HandlePageNavigateRequest(const GURL& url) override; |
86 | 86 |
87 mojo::ApplicationImpl* app_; | 87 mojo::ApplicationImpl* app_; |
88 mojom::WebViewClientPtr client_; | 88 mojom::WebViewClientPtr client_; |
89 mojo::StrongBinding<WebView> binding_; | 89 mojo::StrongBinding<WebView> binding_; |
90 mus::View* root_; | 90 mojo::View* root_; |
91 mus::View* content_; | 91 mojo::View* content_; |
92 scoped_ptr<FrameTree> frame_tree_; | 92 scoped_ptr<FrameTree> frame_tree_; |
93 | 93 |
94 // When LoadRequest() is called a PendingWebViewLoad is created to wait for | 94 // When LoadRequest() is called a PendingWebViewLoad is created to wait for |
95 // state needed to process the request. When the state is obtained OnLoad() | 95 // state needed to process the request. When the state is obtained OnLoad() |
96 // is invoked. | 96 // is invoked. |
97 scoped_ptr<PendingWebViewLoad> pending_load_; | 97 scoped_ptr<PendingWebViewLoad> pending_load_; |
98 | 98 |
99 scoped_ptr<FrameDevToolsAgent> devtools_agent_; | 99 scoped_ptr<FrameDevToolsAgent> devtools_agent_; |
100 | 100 |
101 // It would be nice if mojo::URLRequest were cloneable; however, its use of | 101 // It would be nice if mojo::URLRequest were cloneable; however, its use of |
102 // ScopedDataPipieConsumerHandle means that it isn't. | 102 // ScopedDataPipieConsumerHandle means that it isn't. |
103 ScopedVector<URLRequestCloneable> back_list_; | 103 ScopedVector<URLRequestCloneable> back_list_; |
104 ScopedVector<URLRequestCloneable> forward_list_; | 104 ScopedVector<URLRequestCloneable> forward_list_; |
105 | 105 |
106 // The request which is either currently loading or completed. Added to | 106 // The request which is either currently loading or completed. Added to |
107 // |back_list_| or |forward_list_| on further navigation. | 107 // |back_list_| or |forward_list_| on further navigation. |
108 scoped_ptr<URLRequestCloneable> current_page_request_; | 108 scoped_ptr<URLRequestCloneable> current_page_request_; |
109 | 109 |
110 DISALLOW_COPY_AND_ASSIGN(WebViewImpl); | 110 DISALLOW_COPY_AND_ASSIGN(WebViewImpl); |
111 }; | 111 }; |
112 | 112 |
113 } // namespace web_view | 113 } // namespace web_view |
114 | 114 |
115 #endif // COMPONENTS_WEB_VIEW_WEB_VIEW_IMPL_H_ | 115 #endif // COMPONENTS_WEB_VIEW_WEB_VIEW_IMPL_H_ |
OLD | NEW |