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_FRAME_TREE_H_
6 #define MANDOLINE_TAB_FRAME_TREE_H_
8 #include "mandoline/tab/frame.h"
12 class FrameTreeClient
;
13 class FrameTreeDelegate
;
16 // FrameTree manages the set of Frames that comprise a single url. FrameTree
17 // owns the root Frame and each Frame owns its children. Frames are
18 // automatically deleted and removed from the tree if the corresponding view is
19 // deleted. This happens if the creator of the view deletes it (say an iframe is
23 // |view| is the view to do the initial embedding in. It is assumed |view|
24 // outlives FrameTree.
25 FrameTree(mojo::View
* view
,
26 FrameTreeDelegate
* delegate
,
27 FrameTreeClient
* root_client
,
28 scoped_ptr
<FrameUserData
> user_data
);
31 Frame
* root() { return &root_
; }
33 Frame
* CreateAndAddFrame(mojo::View
* view
,
35 FrameTreeClient
* client
,
36 scoped_ptr
<FrameUserData
> user_data
);
38 // If frame->view() == |view|, then |frame| is deleted and a new Frame created
39 // to replace it. Otherwise a new Frame is created as a child of |frame|.
40 // It is expected this is called from
41 // ViewManagerDelegate::OnEmbedForDescendant().
42 Frame
* CreateOrReplaceFrame(Frame
* frame
,
44 FrameTreeClient
* frame_tree_client
,
45 scoped_ptr
<FrameUserData
> user_data
);
47 // Creates a new Frame parented to |parent|. The Frame is considered shared in
48 // that it is sharing the FrameTreeClient/FrameTreeServer of |parent|. There
49 // may or may not be a View identified by |frame_id| yet. See Frame for
51 void CreateSharedFrame(Frame
* parent
, uint32_t frame_id
);
56 Frame
* CreateAndAddFrameImpl(mojo::View
* view
,
59 FrameTreeClient
* client
,
60 scoped_ptr
<FrameUserData
> user_data
);
62 void LoadingStateChanged();
63 void ProgressChanged();
64 void FrameNameChanged(Frame
* frame
);
68 FrameTreeDelegate
* delegate_
;
74 DISALLOW_COPY_AND_ASSIGN(FrameTree
);
77 } // namespace mandoline
79 #endif // MANDOLINE_TAB_FRAME_TREE_H_