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