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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_WEB_VIEW_WEB_VIEW_IMPL_H_
6 #define COMPONENTS_WEB_VIEW_WEB_VIEW_IMPL_H_
8 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "components/view_manager/public/cpp/view_observer.h"
11 #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_tree_delegate.h"
14 #include "components/web_view/public/interfaces/web_view.mojom.h"
15 #include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h"
18 class ApplicationImpl
;
25 class FrameDevToolsAgent
;
26 class HTMLMessageEvent
;
27 class PendingWebViewLoad
;
29 class WebViewImpl
: public mojom::WebView
,
30 public mojo::ViewTreeDelegate
,
31 public mojo::ViewObserver
,
32 public FrameTreeDelegate
,
33 public FrameDevToolsAgentDelegate
{
35 WebViewImpl(mojo::ApplicationImpl
* app
,
36 mojom::WebViewClientPtr client
,
37 mojo::InterfaceRequest
<WebView
> request
);
38 ~WebViewImpl() override
;
41 friend class PendingWebViewLoad
;
43 // See description above |pending_load_| for details.
46 // Overridden from WebView:
47 void LoadRequest(mojo::URLRequestPtr request
) override
;
48 void GetViewTreeClient(
49 mojo::InterfaceRequest
<mojo::ViewTreeClient
> view_tree_client
)
52 // Overridden from mojo::ViewTreeDelegate:
53 void OnEmbed(mojo::View
* root
) override
;
54 void OnConnectionLost(mojo::ViewTreeConnection
* connection
) override
;
56 // Overridden from mojo::ViewObserver:
57 void OnViewBoundsChanged(mojo::View
* view
,
58 const mojo::Rect
& old_bounds
,
59 const mojo::Rect
& new_bounds
) override
;
60 void OnViewDestroyed(mojo::View
* view
) override
;
62 // Overridden from FrameTreeDelegate:
63 bool CanPostMessageEventToFrame(const Frame
* source
,
65 HTMLMessageEvent
* event
) override
;
66 void LoadingStateChanged(bool loading
) override
;
67 void ProgressChanged(double progress
) override
;
68 void TitleChanged(const mojo::String
& title
) override
;
69 void NavigateTopLevel(Frame
* source
, mojo::URLRequestPtr request
) override
;
70 void CanNavigateFrame(Frame
* target
,
71 mojo::URLRequestPtr request
,
72 const CanNavigateFrameCallback
& callback
) override
;
73 void DidStartNavigation(Frame
* frame
) override
;
75 // Overridden from FrameDevToolsAgent::Delegate:
76 void HandlePageNavigateRequest(const GURL
& url
) override
;
78 mojo::ApplicationImpl
* app_
;
79 mojom::WebViewClientPtr client_
;
80 mojo::StrongBinding
<WebView
> binding_
;
83 scoped_ptr
<FrameTree
> frame_tree_
;
85 // When LoadRequest() is called a PendingWebViewLoad is created to wait for
86 // state needed to process the request. When the state is obtained OnLoad()
88 scoped_ptr
<PendingWebViewLoad
> pending_load_
;
90 scoped_ptr
<FrameDevToolsAgent
> devtools_agent_
;
92 DISALLOW_COPY_AND_ASSIGN(WebViewImpl
);
95 } // namespace web_view
97 #endif // COMPONENTS_WEB_VIEW_WEB_VIEW_IMPL_H_