• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2013 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.
4 
5 #ifndef CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_
6 #define CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_
7 
8 #include <string>
9 
10 #include "base/compiler_specific.h"
11 #include "content/common/content_export.h"
12 #include "content/public/browser/render_frame_host.h"
13 
14 class GURL;
15 
16 namespace base {
17 class FilePath;
18 }
19 
20 namespace content {
21 
22 class FrameTree;
23 class FrameTreeNode;
24 class RenderFrameHostDelegate;
25 class RenderProcessHost;
26 class RenderViewHostImpl;
27 
28 class CONTENT_EXPORT RenderFrameHostImpl : public RenderFrameHost {
29  public:
30   static RenderFrameHostImpl* FromID(int process_id, int routing_id);
31 
32   virtual ~RenderFrameHostImpl();
33 
34   // RenderFrameHost
35   virtual int GetRoutingID() OVERRIDE;
36 
37   // IPC::Sender
38   virtual bool Send(IPC::Message* msg) OVERRIDE;
39 
40   // IPC::Listener
41   virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
42 
43   void Init();
44   RenderProcessHost* GetProcess() const;
routing_id()45   int routing_id() const { return routing_id_; }
46   void OnCreateChildFrame(int new_frame_routing_id,
47                           int64 parent_frame_id,
48                           int64 frame_id,
49                           const std::string& frame_name);
50 
render_view_host()51   RenderViewHostImpl* render_view_host() { return render_view_host_; }
delegate()52   RenderFrameHostDelegate* delegate() { return delegate_; }
53 
54  protected:
55   friend class RenderFrameHostFactory;
56 
57   // TODO(nasko): Remove dependency on RenderViewHost here. RenderProcessHost
58   // should be the abstraction needed here, but we need RenderViewHost to pass
59   // into WebContentsObserver::FrameDetached for now.
60   RenderFrameHostImpl(RenderViewHostImpl* render_view_host,
61                       RenderFrameHostDelegate* delegate,
62                       FrameTree* frame_tree,
63                       FrameTreeNode* frame_tree_node,
64                       int routing_id,
65                       bool is_swapped_out);
66 
67  private:
68   friend class TestRenderViewHost;
69 
70   // IPC Message handlers.
71   void OnDetach(int64 parent_frame_id, int64 frame_id);
72   void OnDidStartProvisionalLoadForFrame(int64 frame_id,
73                                          int64 parent_frame_id,
74                                          bool main_frame,
75                                          const GURL& url);
76 
is_swapped_out()77   bool is_swapped_out() { return is_swapped_out_; }
78 
79   // TODO(nasko): This should be removed and replaced by RenderProcessHost.
80   RenderViewHostImpl* render_view_host_;  // Not owned.
81 
82   RenderFrameHostDelegate* delegate_;
83 
84   // Reference to the whole frame tree that this RenderFrameHost belongs too.
85   // Allows this RenderFrameHost to add and remove nodes in response to
86   // messages from the renderer requesting DOM manipulation.
87   FrameTree* frame_tree_;
88 
89   // The FrameTreeNode which this RenderFrameHostImpl is hosted in.
90   FrameTreeNode* frame_tree_node_;
91 
92   int routing_id_;
93   bool is_swapped_out_;
94 
95   DISALLOW_COPY_AND_ASSIGN(RenderFrameHostImpl);
96 };
97 
98 }  // namespace content
99 
100 #endif  // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_
101