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