1
// vim:expandtab:shiftwidth=2:tabstop=2:
2
// Copyright (C) 2015 Canonical Ltd.
4
// This library is free software; you can redistribute it and/or
5
// modify it under the terms of the GNU Lesser General Public
6
// License as published by the Free Software Foundation; either
7
// version 2.1 of the License, or (at your option) any later version.
9
// This library is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
// Lesser General Public License for more details.
14
// You should have received a copy of the GNU Lesser General Public
15
// License along with this library; if not, write to the Free Software
16
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
#ifndef _OXIDE_SHARED_BROWSER_WEB_FRAME_TREE_H_
19
#define _OXIDE_SHARED_BROWSER_WEB_FRAME_TREE_H_
21
#include "base/callback.h"
22
#include "base/macros.h"
23
#include "base/memory/scoped_ptr.h"
24
#include "base/observer_list.h"
25
#include "content/public/browser/web_contents_observer.h"
26
#include "content/public/browser/web_contents_user_data.h"
31
class WebFrameTreeObserver;
33
// This class manages a tree of WebFrames
34
class WebFrameTree : public content::WebContentsUserData<WebFrameTree>,
35
public content::WebContentsObserver {
37
~WebFrameTree() override;
39
WebFrame* root_frame() const { return root_frame_.get(); }
41
typedef base::Callback<bool(WebFrame*)> ForEachFrameCallback;
42
void ForEachFrame(const ForEachFrameCallback& callback);
45
friend class content::WebContentsUserData<WebFrameTree>;
46
friend class WebFrame;
47
friend class WebFrameTreeObserver;
49
WebFrameTree(content::WebContents* contents);
51
void WebFrameRemoved(WebFrame* frame);
53
void AddObserver(WebFrameTreeObserver* observer);
54
void RemoveObserver(WebFrameTreeObserver* observer);
56
// content::WebContentsObserver implementation
57
void RenderFrameCreated(content::RenderFrameHost* render_frame_host) override;
58
void RenderFrameHostChanged(content::RenderFrameHost* old_host,
59
content::RenderFrameHost* new_host) override;
60
void FrameDeleted(content::RenderFrameHost* render_frame_host) override;
61
void DidCommitProvisionalLoadForFrame(
62
content::RenderFrameHost* render_frame_host,
64
ui::PageTransition transition_type) override;
66
base::ObserverList<WebFrameTreeObserver> observers_;
68
// This should be torn down before |observers_|
69
scoped_ptr<WebFrame> root_frame_;
71
DISALLOW_COPY_AND_ASSIGN(WebFrameTree);
76
#endif // _OXIDE_SHARED_BROWSER_WEB_FRAME_TREE_H_