~rpadovani/oxide/type-info

« back to all changes in this revision

Viewing changes to shared/browser/oxide_web_frame_tree.h

  • Committer: Riccardo Padovani
  • Date: 2015-10-19 07:56:29 UTC
  • mfrom: (1088.1.131 oxide)
  • Revision ID: riccardo@rpadovani.com-20151019075629-z0mlhwlb9xflkovw
MergeĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// vim:expandtab:shiftwidth=2:tabstop=2:
 
2
// Copyright (C) 2015 Canonical Ltd.
 
3
 
 
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.
 
8
 
 
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.
 
13
 
 
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
 
17
 
 
18
#ifndef _OXIDE_SHARED_BROWSER_WEB_FRAME_TREE_H_
 
19
#define _OXIDE_SHARED_BROWSER_WEB_FRAME_TREE_H_
 
20
 
 
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"
 
27
 
 
28
namespace oxide {
 
29
 
 
30
class WebFrame;
 
31
class WebFrameTreeObserver;
 
32
 
 
33
// This class manages a tree of WebFrames
 
34
class WebFrameTree : public content::WebContentsUserData<WebFrameTree>,
 
35
                     public content::WebContentsObserver {
 
36
 public:
 
37
  ~WebFrameTree() override;
 
38
 
 
39
  WebFrame* root_frame() const { return root_frame_.get(); }
 
40
 
 
41
  typedef base::Callback<bool(WebFrame*)> ForEachFrameCallback;
 
42
  void ForEachFrame(const ForEachFrameCallback& callback);
 
43
 
 
44
 private:
 
45
  friend class content::WebContentsUserData<WebFrameTree>;
 
46
  friend class WebFrame;
 
47
  friend class WebFrameTreeObserver;
 
48
 
 
49
  WebFrameTree(content::WebContents* contents);
 
50
 
 
51
  void WebFrameRemoved(WebFrame* frame);
 
52
 
 
53
  void AddObserver(WebFrameTreeObserver* observer);
 
54
  void RemoveObserver(WebFrameTreeObserver* observer);
 
55
 
 
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,
 
63
      const GURL& url,
 
64
      ui::PageTransition transition_type) override;
 
65
 
 
66
  base::ObserverList<WebFrameTreeObserver> observers_;
 
67
 
 
68
  // This should be torn down before |observers_|
 
69
  scoped_ptr<WebFrame> root_frame_;
 
70
 
 
71
  DISALLOW_COPY_AND_ASSIGN(WebFrameTree);
 
72
};
 
73
 
 
74
} // namespace oxide
 
75
 
 
76
#endif // _OXIDE_SHARED_BROWSER_WEB_FRAME_TREE_H_