#ifndef CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_
#define CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_
#include <map>
#include <vector>
#include "base/callback.h"
#include "base/compiler_specific.h"
#include "base/strings/string16.h"
#include "base/time/time.h"
#include "content/common/content_export.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/common/page_transition_types.h"
class GURL;
struct FrameHostMsg_DidFailProvisionalLoadWithError_Params;
struct FrameHostMsg_OpenURL_Params;
struct FrameMsg_Navigate_Params;
namespace base {
class FilePath;
class ListValue;
}
namespace gfx {
class Point;
}
namespace content {
class CrossProcessFrameConnector;
class CrossSiteTransferringRequest;
class FrameTree;
class FrameTreeNode;
class RenderFrameHostDelegate;
class RenderProcessHost;
class RenderViewHostImpl;
struct ContextMenuParams;
struct GlobalRequestID;
struct Referrer;
class CONTENT_EXPORT RenderFrameHostImpl : public RenderFrameHost {
public:
static RenderFrameHostImpl* FromID(int process_id, int routing_id);
virtual ~RenderFrameHostImpl();
virtual int GetRoutingID() OVERRIDE;
virtual SiteInstance* GetSiteInstance() OVERRIDE;
virtual RenderProcessHost* GetProcess() OVERRIDE;
virtual RenderFrameHost* GetParent() OVERRIDE;
virtual const std::string& GetFrameName() OVERRIDE;
virtual bool IsCrossProcessSubframe() OVERRIDE;
virtual GURL GetLastCommittedURL() OVERRIDE;
virtual gfx::NativeView GetNativeView() OVERRIDE;
virtual void DispatchBeforeUnload(bool for_cross_site_transition) OVERRIDE;
virtual void NotifyContextMenuClosed(
const CustomContextMenuContext& context) OVERRIDE;
virtual void ExecuteCustomContextMenuCommand(
int action, const CustomContextMenuContext& context) OVERRIDE;
virtual void Undo() OVERRIDE;
virtual void Redo() OVERRIDE;
virtual void Cut() OVERRIDE;
virtual void Copy() OVERRIDE;
virtual void CopyToFindPboard() OVERRIDE;
virtual void Paste() OVERRIDE;
virtual void PasteAndMatchStyle() OVERRIDE;
virtual void Delete() OVERRIDE;
virtual void SelectAll() OVERRIDE;
virtual void Unselect() OVERRIDE;
virtual void InsertCSS(const std::string& css) OVERRIDE;
virtual void ExecuteJavaScript(
const base::string16& javascript) OVERRIDE;
virtual void ExecuteJavaScript(
const base::string16& javascript,
const JavaScriptResultCallback& callback) OVERRIDE;
virtual RenderViewHost* GetRenderViewHost() OVERRIDE;
virtual bool Send(IPC::Message* msg) OVERRIDE;
virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
void Init();
int routing_id() const { return routing_id_; }
void OnCreateChildFrame(int new_routing_id,
const std::string& frame_name);
RenderViewHostImpl* render_view_host() { return render_view_host_; }
RenderFrameHostDelegate* delegate() { return delegate_; }
FrameTreeNode* frame_tree_node() { return frame_tree_node_; }
void set_cross_process_frame_connector(
CrossProcessFrameConnector* cross_process_frame_connector) {
cross_process_frame_connector_ = cross_process_frame_connector;
}
int GetEnabledBindings();
void OnCrossSiteResponse(
const GlobalRequestID& global_request_id,
scoped_ptr<CrossSiteTransferringRequest> cross_site_transferring_request,
const std::vector<GURL>& transfer_url_chain,
const Referrer& referrer,
PageTransition page_transition,
bool should_replace_current_entry);
void SwapOut();
void OnSwappedOut(bool timed_out);
bool is_swapped_out() { return is_swapped_out_; }
void set_swapped_out(bool is_swapped_out) {
is_swapped_out_ = is_swapped_out;
}
void SetPendingShutdown(const base::Closure& on_swap_out);
void OnDidStartLoading(bool to_different_document);
void Navigate(const FrameMsg_Navigate_Params& params);
void NavigateToURL(const GURL& url);
void SelectRange(const gfx::Point& start, const gfx::Point& end);
void ExtendSelectionAndDelete(size_t before, size_t after);
protected:
friend class RenderFrameHostFactory;
RenderFrameHostImpl(RenderViewHostImpl* render_view_host,
RenderFrameHostDelegate* delegate,
FrameTree* frame_tree,
FrameTreeNode* frame_tree_node,
int routing_id,
bool is_swapped_out);
private:
friend class TestRenderFrameHost;
friend class TestRenderViewHost;
void OnAddMessageToConsole(int32 level,
const base::string16& message,
int32 line_no,
const base::string16& source_id);
void OnDetach();
void OnFrameFocused();
void OnOpenURL(const FrameHostMsg_OpenURL_Params& params);
void OnDidStartProvisionalLoadForFrame(int parent_routing_id,
const GURL& url);
void OnDidFailProvisionalLoadWithError(
const FrameHostMsg_DidFailProvisionalLoadWithError_Params& params);
void OnDidFailLoadWithError(
const GURL& url,
int error_code,
const base::string16& error_description);
void OnDidRedirectProvisionalLoad(int32 page_id,
const GURL& source_url,
const GURL& target_url);
void OnNavigate(const IPC::Message& msg);
void OnDidStopLoading();
void OnBeforeUnloadACK(
bool proceed,
const base::TimeTicks& renderer_before_unload_start_time,
const base::TimeTicks& renderer_before_unload_end_time);
void OnSwapOutACK();
void OnContextMenu(const ContextMenuParams& params);
void OnJavaScriptExecuteResponse(int id, const base::ListValue& result);
bool CanCommitURL(const GURL& url);
RenderViewHostImpl* render_view_host_;
RenderFrameHostDelegate* delegate_;
CrossProcessFrameConnector* cross_process_frame_connector_;
FrameTree* frame_tree_;
FrameTreeNode* frame_tree_node_;
std::map<int, JavaScriptResultCallback> javascript_callbacks_;
int routing_id_;
bool is_swapped_out_;
base::TimeTicks send_before_unload_start_time_;
DISALLOW_COPY_AND_ASSIGN(RenderFrameHostImpl);
};
}
#endif