#ifndef CONTENT_RENDERER_RENDER_FRAME_IMPL_H_
#define CONTENT_RENDERER_RENDER_FRAME_IMPL_H_
#include <vector>
#include "base/basictypes.h"
#include "base/files/file_path.h"
#include "base/gtest_prod_util.h"
#include "base/id_map.h"
#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
#include "base/process/process_handle.h"
#include "content/public/common/referrer.h"
#include "content/public/renderer/render_frame.h"
#include "content/renderer/renderer_webcookiejar_impl.h"
#include "ipc/ipc_message.h"
#include "third_party/WebKit/public/web/WebDataSource.h"
#include "third_party/WebKit/public/web/WebFrameClient.h"
#include "third_party/WebKit/public/web/WebHistoryCommitType.h"
#include "ui/gfx/range/range.h"
class TransportDIB;
struct FrameMsg_BuffersSwapped_Params;
struct FrameMsg_CompositorFrameSwapped_Params;
struct FrameMsg_Navigate_Params;
namespace blink {
class WebInputEvent;
class WebMouseEvent;
class WebContentDecryptionModule;
class WebSecurityOrigin;
struct WebCompositionUnderline;
struct WebContextMenuData;
struct WebCursorInfo;
}
namespace gfx {
class Point;
class Range;
class Rect;
}
namespace content {
class ChildFrameCompositingHelper;
class PepperPluginInstanceImpl;
class RendererPpapiHost;
class RenderFrameObserver;
class RenderViewImpl;
class RenderWidget;
class RenderWidgetFullscreenPepper;
struct CustomContextMenuContext;
class CONTENT_EXPORT RenderFrameImpl
: public RenderFrame,
NON_EXPORTED_BASE(public blink::WebFrameClient) {
public:
static RenderFrameImpl* Create(RenderViewImpl* render_view, int32 routing_id);
static RenderFrameImpl* FromWebFrame(blink::WebFrame* web_frame);
static void InstallCreateHook(
RenderFrameImpl* (*create_render_frame_impl)(RenderViewImpl*, int32));
virtual ~RenderFrameImpl();
bool is_swapped_out() const {
return is_swapped_out_;
}
void DidCommitCompositorFrame();
RenderViewImpl* render_view() { return render_view_.get(); }
RendererWebCookieJarImpl* cookie_jar() { return &cookie_jar_; }
RenderWidget* GetRenderWidget();
void SetWebFrame(blink::WebLocalFrame* web_frame);
virtual void OnStop();
virtual void didStartLoading(bool to_different_document);
virtual void didStopLoading();
virtual void didChangeLoadProgress(double load_progress);
#if defined(ENABLE_PLUGINS)
void PepperPluginCreated(RendererPpapiHost* host);
void PepperDidChangeCursor(PepperPluginInstanceImpl* instance,
const blink::WebCursorInfo& cursor);
void PepperDidReceiveMouseEvent(PepperPluginInstanceImpl* instance);
void PepperTextInputTypeChanged(PepperPluginInstanceImpl* instance);
void PepperCaretPositionChanged(PepperPluginInstanceImpl* instance);
void PepperCancelComposition(PepperPluginInstanceImpl* instance);
void PepperSelectionChanged(PepperPluginInstanceImpl* instance);
RenderWidgetFullscreenPepper* CreatePepperFullscreenContainer(
PepperPluginInstanceImpl* plugin);
bool IsPepperAcceptingCompositionEvents() const;
void PluginCrashed(const base::FilePath& plugin_path,
base::ProcessId plugin_pid);
void SimulateImeSetComposition(
const base::string16& text,
const std::vector<blink::WebCompositionUnderline>& underlines,
int selection_start,
int selection_end);
void SimulateImeConfirmComposition(const base::string16& text,
const gfx::Range& replacement_range);
void OnImeSetComposition(
const base::string16& text,
const std::vector<blink::WebCompositionUnderline>& underlines,
int selection_start,
int selection_end);
void OnImeConfirmComposition(
const base::string16& text,
const gfx::Range& replacement_range,
bool keep_selection);
#endif
virtual bool Send(IPC::Message* msg) OVERRIDE;
virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
virtual RenderView* GetRenderView() OVERRIDE;
virtual int GetRoutingID() OVERRIDE;
virtual blink::WebFrame* GetWebFrame() OVERRIDE;
virtual WebPreferences& GetWebkitPreferences() OVERRIDE;
virtual int ShowContextMenu(ContextMenuClient* client,
const ContextMenuParams& params) OVERRIDE;
virtual void CancelContextMenu(int request_id) OVERRIDE;
virtual blink::WebNode GetContextMenuNode() const OVERRIDE;
virtual blink::WebPlugin* CreatePlugin(
blink::WebFrame* frame,
const WebPluginInfo& info,
const blink::WebPluginParams& params) OVERRIDE;
virtual void LoadURLExternally(blink::WebLocalFrame* frame,
const blink::WebURLRequest& request,
blink::WebNavigationPolicy policy) OVERRIDE;
virtual void ExecuteJavaScript(const base::string16& javascript) OVERRIDE;
virtual blink::WebPlugin* createPlugin(blink::WebLocalFrame* frame,
const blink::WebPluginParams& params);
virtual blink::WebMediaPlayer* createMediaPlayer(
blink::WebLocalFrame* frame,
const blink::WebURL& url,
blink::WebMediaPlayerClient* client);
virtual blink::WebContentDecryptionModule* createContentDecryptionModule(
blink::WebLocalFrame* frame,
const blink::WebSecurityOrigin& security_origin,
const blink::WebString& key_system);
virtual blink::WebApplicationCacheHost* createApplicationCacheHost(
blink::WebLocalFrame* frame,
blink::WebApplicationCacheHostClient* client);
virtual blink::WebWorkerPermissionClientProxy*
createWorkerPermissionClientProxy(blink::WebLocalFrame* frame);
virtual blink::WebCookieJar* cookieJar(blink::WebLocalFrame* frame);
virtual blink::WebServiceWorkerProvider* createServiceWorkerProvider(
blink::WebLocalFrame* frame);
virtual void didAccessInitialDocument(blink::WebLocalFrame* frame);
virtual blink::WebFrame* createChildFrame(blink::WebLocalFrame* parent,
const blink::WebString& name);
virtual void didDisownOpener(blink::WebLocalFrame* frame);
virtual void frameDetached(blink::WebFrame* frame);
virtual void frameFocused();
virtual void willClose(blink::WebFrame* frame);
virtual void didChangeName(blink::WebLocalFrame* frame,
const blink::WebString& name);
virtual void didMatchCSS(
blink::WebLocalFrame* frame,
const blink::WebVector<blink::WebString>& newly_matching_selectors,
const blink::WebVector<blink::WebString>& stopped_matching_selectors);
virtual bool shouldReportDetailedMessageForSource(
const blink::WebString& source);
virtual void didAddMessageToConsole(const blink::WebConsoleMessage& message,
const blink::WebString& source_name,
unsigned source_line,
const blink::WebString& stack_trace);
virtual void loadURLExternally(blink::WebLocalFrame* frame,
const blink::WebURLRequest& request,
blink::WebNavigationPolicy policy);
virtual void loadURLExternally(blink::WebLocalFrame* frame,
const blink::WebURLRequest& request,
blink::WebNavigationPolicy policy,
const blink::WebString& suggested_name);
virtual blink::WebNavigationPolicy decidePolicyForNavigation(
blink::WebLocalFrame* frame,
blink::WebDataSource::ExtraData* extra_data,
const blink::WebURLRequest& request,
blink::WebNavigationType type,
blink::WebNavigationPolicy default_policy,
bool is_redirect);
virtual blink::WebHistoryItem historyItemForNewChildFrame(
blink::WebFrame* frame);
virtual void willSendSubmitEvent(blink::WebLocalFrame* frame,
const blink::WebFormElement& form);
virtual void willSubmitForm(blink::WebLocalFrame* frame,
const blink::WebFormElement& form);
virtual void didCreateDataSource(blink::WebLocalFrame* frame,
blink::WebDataSource* datasource);
virtual void didStartProvisionalLoad(blink::WebLocalFrame* frame);
virtual void didReceiveServerRedirectForProvisionalLoad(
blink::WebLocalFrame* frame);
virtual void didFailProvisionalLoad(
blink::WebLocalFrame* frame,
const blink::WebURLError& error);
virtual void didCommitProvisionalLoad(
blink::WebLocalFrame* frame,
const blink::WebHistoryItem& item,
blink::WebHistoryCommitType commit_type);
virtual void didCommitProvisionalLoad(blink::WebLocalFrame* frame,
bool is_new_navigation);
virtual void didClearWindowObject(blink::WebLocalFrame* frame, int world_id);
virtual void didCreateDocumentElement(blink::WebLocalFrame* frame);
virtual void didReceiveTitle(blink::WebLocalFrame* frame,
const blink::WebString& title,
blink::WebTextDirection direction);
virtual void didChangeIcon(blink::WebLocalFrame* frame,
blink::WebIconURL::Type icon_type);
virtual void didFinishDocumentLoad(blink::WebLocalFrame* frame);
virtual void didHandleOnloadEvents(blink::WebLocalFrame* frame);
virtual void didFailLoad(blink::WebLocalFrame* frame,
const blink::WebURLError& error);
virtual void didFinishLoad(blink::WebLocalFrame* frame);
virtual void didNavigateWithinPage(blink::WebLocalFrame* frame,
const blink::WebHistoryItem& item,
blink::WebHistoryCommitType commit_type);
virtual void didNavigateWithinPage(blink::WebLocalFrame* frame,
bool is_new_navigation);
virtual void didUpdateCurrentHistoryItem(blink::WebLocalFrame* frame);
virtual void didChangeSelection(bool is_empty_selection);
virtual void showContextMenu(const blink::WebContextMenuData& data);
virtual void clearContextMenu();
virtual void willRequestAfterPreconnect(blink::WebLocalFrame* frame,
blink::WebURLRequest& request);
virtual void willSendRequest(blink::WebLocalFrame* frame,
unsigned identifier,
blink::WebURLRequest& request,
const blink::WebURLResponse& redirect_response);
virtual void didReceiveResponse(blink::WebLocalFrame* frame,
unsigned identifier,
const blink::WebURLResponse& response);
virtual void didFinishResourceLoad(blink::WebLocalFrame* frame,
unsigned identifier);
virtual void didLoadResourceFromMemoryCache(
blink::WebLocalFrame* frame,
const blink::WebURLRequest& request,
const blink::WebURLResponse& response);
virtual void didDisplayInsecureContent(blink::WebLocalFrame* frame);
virtual void didRunInsecureContent(blink::WebLocalFrame* frame,
const blink::WebSecurityOrigin& origin,
const blink::WebURL& target);
virtual void didAbortLoading(blink::WebLocalFrame* frame);
virtual void didCreateScriptContext(blink::WebLocalFrame* frame,
v8::Handle<v8::Context> context,
int extension_group,
int world_id);
virtual void willReleaseScriptContext(blink::WebLocalFrame* frame,
v8::Handle<v8::Context> context,
int world_id);
virtual void didFirstVisuallyNonEmptyLayout(blink::WebLocalFrame* frame);
virtual void didChangeContentsSize(blink::WebLocalFrame* frame,
const blink::WebSize& size);
virtual void didChangeScrollOffset(blink::WebLocalFrame* frame);
virtual void willInsertBody(blink::WebLocalFrame* frame);
virtual void reportFindInPageMatchCount(int request_id,
int count,
bool final_update);
virtual void reportFindInPageSelection(int request_id,
int active_match_ordinal,
const blink::WebRect& sel);
virtual void requestStorageQuota(blink::WebLocalFrame* frame,
blink::WebStorageQuotaType type,
unsigned long long requested_size,
blink::WebStorageQuotaCallbacks callbacks);
virtual void willOpenSocketStream(
blink::WebSocketStreamHandle* handle);
virtual void willStartUsingPeerConnectionHandler(
blink::WebLocalFrame* frame,
blink::WebRTCPeerConnectionHandler* handler);
virtual bool willCheckAndDispatchMessageEvent(
blink::WebLocalFrame* sourceFrame,
blink::WebFrame* targetFrame,
blink::WebSecurityOrigin targetOrigin,
blink::WebDOMMessageEvent event);
virtual blink::WebString userAgentOverride(blink::WebLocalFrame* frame,
const blink::WebURL& url);
virtual blink::WebString doNotTrackValue(blink::WebLocalFrame* frame);
virtual bool allowWebGL(blink::WebLocalFrame* frame, bool default_value);
virtual void didLoseWebGLContext(blink::WebLocalFrame* frame,
int arb_robustness_status_code);
virtual void forwardInputEvent(const blink::WebInputEvent* event);
virtual void initializeChildFrame(const blink::WebRect& frame_rect,
float scale_factor);
void OnNavigate(const FrameMsg_Navigate_Params& params);
protected:
RenderFrameImpl(RenderViewImpl* render_view, int32 routing_id);
private:
friend class RenderFrameObserver;
FRIEND_TEST_ALL_PREFIXES(RendererAccessibilityTest,
AccessibilityMessagesQueueWhileSwappedOut);
FRIEND_TEST_ALL_PREFIXES(RenderFrameImplTest,
ShouldUpdateSelectionTextFromContextMenuParams);
FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest,
OnExtendSelectionAndDelete);
FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, ReloadWhileSwappedOut);
FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, SendSwapOutACK);
FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest,
SetEditableSelectionAndComposition);
typedef std::map<GURL, double> HostZoomLevels;
void AddObserver(RenderFrameObserver* observer);
void RemoveObserver(RenderFrameObserver* observer);
void UpdateURL(blink::WebFrame* frame);
blink::WebElement GetFocusedElement();
void OnBeforeUnload();
void OnSwapOut();
void OnChildFrameProcessGone();
void OnBuffersSwapped(const FrameMsg_BuffersSwapped_Params& params);
void OnCompositorFrameSwapped(const IPC::Message& message);
void OnShowContextMenu(const gfx::Point& location);
void OnContextMenuClosed(const CustomContextMenuContext& custom_context);
void OnCustomContextMenuAction(const CustomContextMenuContext& custom_context,
unsigned action);
void OnUndo();
void OnRedo();
void OnCut();
void OnCopy();
void OnPaste();
void OnPasteAndMatchStyle();
void OnDelete();
void OnSelectAll();
void OnSelectRange(const gfx::Point& start, const gfx::Point& end);
void OnUnselect();
void OnReplace(const base::string16& text);
void OnReplaceMisspelling(const base::string16& text);
void OnCSSInsertRequest(const std::string& css);
void OnJavaScriptExecuteRequest(const base::string16& javascript,
int id,
bool notify_result);
void OnSetEditableSelectionOffsets(int start, int end);
void OnSetCompositionFromExistingText(
int start, int end,
const std::vector<blink::WebCompositionUnderline>& underlines);
void OnExtendSelectionAndDelete(int before, int after);
void OnReload(bool ignore_cache);
#if defined(OS_MACOSX)
void OnCopyToFindPboard();
#endif
virtual blink::WebNavigationPolicy DecidePolicyForNavigation(
RenderFrame* render_frame,
blink::WebFrame* frame,
blink::WebDataSource::ExtraData* extraData,
const blink::WebURLRequest& request,
blink::WebNavigationType type,
blink::WebNavigationPolicy default_policy,
bool is_redirect);
void OpenURL(blink::WebFrame* frame,
const GURL& url,
const Referrer& referrer,
blink::WebNavigationPolicy policy);
void SyncSelectionIfRequired();
static bool ShouldUpdateSelectionTextFromContextMenuParams(
const base::string16& selection_text,
size_t selection_text_offset,
const gfx::Range& selection_range,
const ContextMenuParams& params);
blink::WebLocalFrame* frame_;
base::WeakPtr<RenderViewImpl> render_view_;
int routing_id_;
bool is_loading_;
bool is_swapped_out_;
bool is_detaching_;
#if defined(ENABLE_PLUGINS)
base::string16 pepper_composition_text_;
#endif
RendererWebCookieJarImpl cookie_jar_;
ObserverList<RenderFrameObserver> observers_;
scoped_refptr<ChildFrameCompositingHelper> compositing_helper_;
blink::WebNode context_menu_node_;
IDMap<ContextMenuClient, IDMapExternalPointer> pending_context_menus_;
base::string16 selection_text_;
size_t selection_text_offset_;
gfx::Range selection_range_;
bool handling_select_range_;
DISALLOW_COPY_AND_ASSIGN(RenderFrameImpl);
};
}
#endif