Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / mandoline / tab / frame_tree.h
blob4600fc8947b0d833a6027181c675a55fc74d5fe6
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"
10 namespace mandoline {
12 class FrameTreeClient;
13 class FrameTreeDelegate;
14 class FrameUserData;
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
20 // destroyed).
21 class FrameTree {
22 public:
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);
29 ~FrameTree();
31 Frame* root() { return &root_; }
33 Frame* CreateAndAddFrame(mojo::View* view,
34 Frame* parent,
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,
43 mojo::View* view,
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
50 // details.
51 void CreateSharedFrame(Frame* parent, uint32_t frame_id);
53 private:
54 friend class Frame;
56 Frame* CreateAndAddFrameImpl(mojo::View* view,
57 uint32_t frame_id,
58 Frame* parent,
59 FrameTreeClient* client,
60 scoped_ptr<FrameUserData> user_data);
62 void LoadingStateChanged();
63 void ProgressChanged();
64 void FrameNameChanged(Frame* frame);
66 mojo::View* view_;
68 FrameTreeDelegate* delegate_;
70 Frame root_;
72 double progress_;
74 DISALLOW_COPY_AND_ASSIGN(FrameTree);
77 } // namespace mandoline
79 #endif // MANDOLINE_TAB_FRAME_TREE_H_