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_FRAME_TREE_DELEGATE_H_
6 #define COMPONENTS_WEB_VIEW_FRAME_TREE_DELEGATE_H_
10 #include "base/callback_forward.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "components/mus/public/interfaces/view_tree.mojom.h"
13 #include "components/web_view/public/interfaces/frame.mojom.h"
14 #include "mojo/services/network/public/interfaces/url_loader.mojom.h"
22 class HTMLMessageEvent
;
25 class FrameTreeDelegate
{
27 // Callback from CanNavigateFrame(). The uint32_t is the id of the app the
28 // FrameClient comes from; typically the content handler id.
29 using CanNavigateFrameCallback
=
30 base::Callback
<void(uint32_t,
32 scoped_ptr
<FrameUserData
>,
33 mojo::ViewTreeClientPtr
)>;
35 // Called when a Frame creates a new child Frame. |frame_tree_client| is the
36 // FrameClient for the new frame.
37 virtual scoped_ptr
<FrameUserData
> CreateUserDataForNewFrame(
38 mojom::FrameClientPtr frame_client
) = 0;
40 // Returns whether a request to post a message from |source| to |target|
41 // is allowed. |source| and |target| are never null.
42 virtual bool CanPostMessageEventToFrame(const Frame
* source
,
44 mojom::HTMLMessageEvent
* event
) = 0;
46 virtual void LoadingStateChanged(bool loading
, double progress
) = 0;
48 virtual void TitleChanged(const mojo::String
& title
) = 0;
50 // |source| is requesting a navigation. If |target_type| is
51 // |EXISTING_FRAME| then |target_frame| identifies the frame to perform the
52 // navigation in, otherwise |target_frame| is not used. |target_frame| may
53 // be null, even for |EXISTING_FRAME|.
54 // TODO(sky): this needs to distinguish between navigate in source, vs new
55 // background tab, vs new foreground tab.
56 virtual void NavigateTopLevel(Frame
* source
, mojo::URLRequestPtr request
) = 0;
58 // Asks the client if navigation is allowed. If the navigation is allowed
59 // |callback| should be called to continue the navigation. |callback|
60 // may be called synchronously or asynchronously. In the callback
61 // mojo::ViewTreeClientPtr should only be set if an app other than
62 // frame->app_id() is used to render |request|.
63 virtual void CanNavigateFrame(Frame
* target
,
64 mojo::URLRequestPtr request
,
65 const CanNavigateFrameCallback
& callback
) = 0;
67 // Invoked when a navigation in |frame| has been initiated.
68 virtual void DidStartNavigation(Frame
* frame
) = 0;
70 // Invoked when blink has started displaying the frame.
71 virtual void DidCommitProvisionalLoad(Frame
* frame
) = 0;
73 // Notification of various frame state changes. Generally only useful for
75 virtual void DidCreateFrame(Frame
* frame
);
76 virtual void DidDestroyFrame(Frame
* frame
);
78 // Invoked when the View embedded in a Frame premuturely stops rendering
79 // to |frame|'s View. This could mean any of the following:
81 // . There is no app that renders the url.
82 // . The app is still alive, but is shutting down.
83 // Frame does nothing in response to this, but the delegate may wish to take
85 virtual void OnViewEmbeddedInFrameDisconnected(Frame
* frame
);
88 virtual ~FrameTreeDelegate() {}
91 } // namespace web_view
93 #endif // COMPONENTS_WEB_VIEW_FRAME_TREE_DELEGATE_H_