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/view_manager/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 // Returns whether a request to post a message from |source| to |target|
33 // is allowed. |source| and |target| are never null.
34 virtual bool CanPostMessageEventToFrame(const Frame
* source
,
36 HTMLMessageEvent
* event
) = 0;
38 virtual void LoadingStateChanged(bool loading
) = 0;
39 virtual void ProgressChanged(double progress
) = 0;
41 virtual void TitleChanged(const mojo::String
& title
) = 0;
43 // |source| is requesting a navigation. If |target_type| is
44 // |EXISTING_FRAME| then |target_frame| identifies the frame to perform the
45 // navigation in, otherwise |target_frame| is not used. |target_frame| may
46 // be null, even for |EXISTING_FRAME|.
47 // TODO(sky): this needs to distinguish between navigate in source, vs new
48 // background tab, vs new foreground tab.
49 virtual void NavigateTopLevel(Frame
* source
, mojo::URLRequestPtr request
) = 0;
51 // Asks the client if navigation is allowed. If the navigation is allowed
52 // |callback| should be called to continue the navigation. |callback|
53 // may be called synchronously or asynchronously. In the callback
54 // ViewTreeClientPtr should only be set if an app other than
55 // frame->app_id() is used to render |request|.
56 virtual void CanNavigateFrame(Frame
* target
,
57 mojo::URLRequestPtr request
,
58 const CanNavigateFrameCallback
& callback
) = 0;
60 // Invoked when a navigation in |frame| has been initiated.
61 virtual void DidStartNavigation(Frame
* frame
) = 0;
64 virtual ~FrameTreeDelegate() {}
67 } // namespace web_view
69 #endif // COMPONENTS_WEB_VIEW_FRAME_TREE_DELEGATE_H_