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 MANDOLINE_TAB_WEB_VIEW_IMPL_H_
6 #define MANDOLINE_TAB_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 "mandoline/tab/frame_devtools_agent_delegate.h"
13 #include "mandoline/tab/frame_tree_delegate.h"
14 #include "mandoline/tab/public/interfaces/web_view.mojom.h"
15 #include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h"
20 class HTMLMessageEvent
;
24 class ApplicationImpl
;
27 // TODO(beng): remove once these classes are in the web_view namespace.
28 using mandoline::Frame
;
29 using mandoline::FrameTree
;
30 using mandoline::HTMLMessageEvent
;
34 class FrameDevToolsAgent
;
36 class WebViewImpl
: public mojom::WebView
,
37 public mojo::ViewTreeDelegate
,
38 public mojo::ViewObserver
,
39 public mandoline::FrameTreeDelegate
,
40 public FrameDevToolsAgentDelegate
{
42 WebViewImpl(mojo::ApplicationImpl
* app
,
43 mojom::WebViewClientPtr client
,
44 mojo::InterfaceRequest
<WebView
> request
);
45 ~WebViewImpl() override
;
48 // Overridden from WebView:
49 void LoadRequest(mojo::URLRequestPtr request
) override
;
50 void GetViewTreeClient(
51 mojo::InterfaceRequest
<mojo::ViewTreeClient
> view_tree_client
)
54 // Overridden from mojo::ViewTreeDelegate:
55 void OnEmbed(mojo::View
* root
) override
;
56 void OnConnectionLost(mojo::ViewTreeConnection
* connection
) override
;
58 // Overridden from mojo::ViewObserver:
59 void OnViewBoundsChanged(mojo::View
* view
,
60 const mojo::Rect
& old_bounds
,
61 const mojo::Rect
& new_bounds
) override
;
62 void OnViewDestroyed(mojo::View
* view
) override
;
64 // Overridden from mandoline::FrameTreeDelegate:
65 bool CanPostMessageEventToFrame(const Frame
* source
,
67 HTMLMessageEvent
* event
) override
;
68 void LoadingStateChanged(bool loading
) override
;
69 void ProgressChanged(double progress
) override
;
70 void NavigateTopLevel(Frame
* source
, mojo::URLRequestPtr request
) override
;
71 bool CanNavigateFrame(
73 mojo::URLRequestPtr request
,
74 mandoline::FrameTreeClient
** frame_tree_client
,
75 scoped_ptr
<mandoline::FrameUserData
>* frame_user_data
,
76 mojo::ViewTreeClientPtr
* view_tree_client
) override
;
77 void DidStartNavigation(Frame
* frame
) override
;
79 // Overridden from FrameDevToolsAgent::Delegate:
80 void HandlePageNavigateRequest(const GURL
& url
) override
;
82 mojo::ApplicationImpl
* app_
;
83 mojom::WebViewClientPtr client_
;
84 mojo::StrongBinding
<WebView
> binding_
;
86 scoped_ptr
<FrameTree
> frame_tree_
;
88 mojo::URLRequestPtr pending_request_
;
90 scoped_ptr
<FrameDevToolsAgent
> devtools_agent_
;
92 DISALLOW_COPY_AND_ASSIGN(WebViewImpl
);
95 } // namespace web_view
97 #endif // MANDOLINE_TAB_WEB_VIEW_IMPL_H_