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_H_
6 #define COMPONENTS_WEB_VIEW_FRAME_TREE_H_
8 #include "components/web_view/frame.h"
9 #include "third_party/mojo/src/mojo/public/cpp/bindings/array.h"
17 class FrameTreeClient
;
18 class FrameTreeDelegate
;
21 // FrameTree manages the set of Frames that comprise a single url. FrameTree
22 // owns the root Frame and each Frame owns its children. Frames are
23 // automatically deleted and removed from the tree if the corresponding view is
24 // deleted. This happens if the creator of the view deletes it (say an iframe is
28 // |view| is the view to do the initial embedding in. It is assumed |view|
29 // outlives FrameTree.
30 // |client_properties| is the client properties for the root frame.
31 // |root_app_id| is a unique identifier of the app providing |root_client|.
32 // See Frame for details on app id's.
33 FrameTree(uint32_t root_app_id
,
35 FrameTreeDelegate
* delegate
,
36 FrameTreeClient
* root_client
,
37 scoped_ptr
<FrameUserData
> user_data
,
38 const Frame::ClientPropertyMap
& client_properties
);
41 // Returns true if there should be a distinct renderer per frame. This is
42 // useful for testing.
43 static bool AlwaysCreateNewFrameTree();
45 Frame
* root() { return &root_
; }
47 uint32_t change_id() const { return change_id_
; }
49 Frame
* CreateAndAddFrame(mojo::View
* view
,
52 FrameTreeClient
* client
,
53 scoped_ptr
<FrameUserData
> user_data
);
55 // Creates a new Frame parented to |parent|. The Frame is considered shared in
56 // that it is sharing the FrameTreeClient/FrameTreeServer of |parent|. There
57 // may or may not be a View identified by |frame_id| yet. See Frame for
59 void CreateSharedFrame(Frame
* parent
,
62 const Frame::ClientPropertyMap
& client_properties
);
67 // Increments the change id, returning the new value.
68 uint32_t AdvanceChangeID();
70 Frame
* CreateAndAddFrameImpl(
75 FrameTreeClient
* client
,
76 scoped_ptr
<FrameUserData
> user_data
,
77 const Frame::ClientPropertyMap
& client_properties
);
79 void LoadingStateChanged();
80 void ProgressChanged();
81 void TitleChanged(const mojo::String
& title
);
82 void ClientPropertyChanged(const Frame
* source
,
83 const mojo::String
& name
,
84 const mojo::Array
<uint8_t>& value
);
88 FrameTreeDelegate
* delegate_
;
96 DISALLOW_COPY_AND_ASSIGN(FrameTree
);
99 } // namespace web_view
101 #endif // COMPONENTS_WEB_VIEW_FRAME_TREE_H_