render_frame_host_impl.h revision f2477e01787aa58f445919b809d89e252beef54f
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
14class GURL;
15
16namespace content {
17
18class FrameTree;
19class RenderProcessHost;
20class RenderViewHostImpl;
21
22class CONTENT_EXPORT RenderFrameHostImpl : public RenderFrameHost {
23 public:
24  static RenderFrameHostImpl* FromID(int process_id, int routing_id);
25
26  virtual ~RenderFrameHostImpl();
27
28  // IPC::Sender
29  virtual bool Send(IPC::Message* msg) OVERRIDE;
30
31  // IPC::Listener
32  virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
33
34  void Init();
35  RenderProcessHost* GetProcess() const;
36  int routing_id() const { return routing_id_; }
37  void OnCreateChildFrame(int new_frame_routing_id,
38                          int64 parent_frame_id,
39                          int64 frame_id,
40                          const std::string& frame_name);
41
42  RenderViewHostImpl* render_view_host() {
43    return render_view_host_;
44  }
45
46 protected:
47  friend class RenderFrameHostFactory;
48
49  // TODO(nasko): Remove dependency on RenderViewHost here. RenderProcessHost
50  // should be the abstraction needed here, but we need RenderViewHost to pass
51  // into WebContentsObserver::FrameDetached for now.
52  RenderFrameHostImpl(RenderViewHostImpl* render_view_host,
53                      FrameTree* frame_tree,
54                      int routing_id,
55                      bool is_swapped_out);
56
57 private:
58  // IPC Message handlers.
59  void OnDetach(int64 parent_frame_id, int64 frame_id);
60  void OnDidStartProvisionalLoadForFrame(int64 frame_id,
61                                         int64 parent_frame_id,
62                                         bool main_frame,
63                                         const GURL& url);
64
65  bool is_swapped_out() { return is_swapped_out_; }
66
67  // TODO(nasko): This should be removed and replaced by RenderProcessHost.
68  RenderViewHostImpl* render_view_host_;  // Not owned.
69
70  // Reference to the whole frame tree that this RenderFrameHost belongs too.
71  // Allows this RenderFrameHost to add and remove nodes in response to
72  // messages from the renderer requesting DOM manipulation.
73  FrameTree* frame_tree_;
74  int routing_id_;
75  bool is_swapped_out_;
76
77  DISALLOW_COPY_AND_ASSIGN(RenderFrameHostImpl);
78};
79
80}  // namespace content
81
82#endif  // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_
83