15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_IMPL_H_
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define CONTENT_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_IMPL_H_
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
82a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include <map>
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <string>
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <vector>
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "base/callback.h"
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/compiler_specific.h"
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/logging.h"
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/memory/scoped_ptr.h"
16a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch#include "base/process/kill.h"
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/browser/renderer_host/render_widget_host_impl.h"
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/browser/site_instance_impl.h"
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/common/drag_event_source_info.h"
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/notification_observer.h"
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/render_view_host.h"
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/common/window_container_type.h"
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "net/base/load_states.h"
2458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#include "third_party/WebKit/public/web/WebAXEnums.h"
257d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#include "third_party/WebKit/public/web/WebConsoleMessage.h"
267d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#include "third_party/WebKit/public/web/WebPopupType.h"
2758537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#include "third_party/skia/include/core/SkColor.h"
282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ui/base/window_open_disposition.h"
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class SkBitmap;
315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class FrameMsg_Navigate;
321320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccistruct FrameMsg_Navigate_Params;
335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct MediaPlayerAction;
345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct ViewHostMsg_CreateWindow_Params;
355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct ViewMsg_PostMessage_Params;
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace base {
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class ListValue;
395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4158537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)namespace gfx {
425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class Range;
4358537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)}
4458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)
4558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)namespace ui {
465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class AXTree;
475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct SelectedFileInfo;
485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace content {
515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
52cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)class MediaWebContentsObserver;
535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class ChildProcessSecurityPolicyImpl;
5490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)class PageState;
555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class RenderWidgetHostDelegate;
565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class SessionStorageNamespace;
575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class SessionStorageNamespaceImpl;
585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class TestRenderViewHost;
595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class TimeoutMonitor;
605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct FileChooserParams;
615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(COMPILER_MSVC)
635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// RenderViewHostImpl is the bottom of a diamond-shaped hierarchy,
645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// with RenderWidgetHost at the root. VS warns when methods from the
655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// root are overridden in only one of the base classes and not both
665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// (in this case, RenderWidgetHostImpl provides implementations of
675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// many of the methods).  This is a silly warning when dealing with
685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// pure virtual methods that only have a single implementation in the
695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// hierarchy above this class, and is safe to ignore in this case.
705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#pragma warning(push)
715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#pragma warning(disable: 4250)
725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// This implements the RenderViewHost interface that is exposed to
755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// embedders of content, and adds things only visible to content.
765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//
775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// The exact API of this object needs to be more thoroughly designed. Right
785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// now it mimics what WebContentsImpl exposed, which is a fairly large API and
795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// may contain things that are not relevant to a common subset of views. See
805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// also the comment in render_view_host_delegate.h about the size and scope of
815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// the delegate API.
825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//
835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Right now, the concept of page navigation (both top level and frame) exists
845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// in the WebContentsImpl still, so if you instantiate one of these elsewhere,
855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// you will not be able to traverse pages back and forward. We need to determine
865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// if we want to bring that and other functionality down into this object so it
875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// can be shared by others.
885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class CONTENT_EXPORT RenderViewHostImpl
895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    : public RenderViewHost,
905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      public RenderWidgetHostImpl {
915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public:
925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Keeps track of the state of the RenderViewHostImpl, particularly with
935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // respect to swap out.
945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  enum RenderViewHostImplState {
955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    // The standard state for a RVH handling the communication with a
965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    // RenderView.
975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    STATE_DEFAULT = 0,
985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    // The RVH is waiting for the CloseACK from the RenderView.
995d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    STATE_WAITING_FOR_CLOSE,
1005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    // The RVH has not received the SwapOutACK yet, but the new page has
1015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    // committed in a different RVH. The number of active views of the RVH
1025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    // SiteInstanceImpl is not zero. Upon reception of the SwapOutACK, the RVH
1035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    // will be swapped out.
1045d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    STATE_PENDING_SWAP_OUT,
1055d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    // The RVH has not received the SwapOutACK yet, but the new page has
1065d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    // committed in a different RVH. The number of active views of the RVH
1075d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    // SiteInstanceImpl is zero. Upon reception of the SwapOutACK, the RVH will
1085d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    // be shutdown.
1095d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    STATE_PENDING_SHUTDOWN,
1105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    // The RVH is swapped out, and it is being used as a placeholder to allow
1115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    // for cross-process communication.
1125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    STATE_SWAPPED_OUT,
1135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  };
1145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Helper function to determine whether the RVH state should contribute to the
1155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // number of active views of a SiteInstance or not.
1165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  static bool IsRVHStateActive(RenderViewHostImplState rvh_state);
1175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
1185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Convenience function, just like RenderViewHost::FromID.
1195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static RenderViewHostImpl* FromID(int render_process_id, int render_view_id);
1205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |routing_id| could be a valid route id, or it could be MSG_ROUTING_NONE, in
1225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // which case RenderWidgetHost will create a new one.  |swapped_out| indicates
1235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // whether the view should initially be swapped out (e.g., for an opener
1243551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  // frame being rendered by another process). |hidden| indicates whether the
1253551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  // view is initially hidden or visible.
1265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
1275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The |session_storage_namespace| parameter allows multiple render views and
1285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // WebContentses to share the same session storage (part of the WebStorage
1295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // spec) space. This is useful when restoring contentses, but most callers
1305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // should pass in NULL which will cause a new SessionStorageNamespace to be
1315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // created.
1325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  RenderViewHostImpl(
1335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      SiteInstance* instance,
1345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      RenderViewHostDelegate* delegate,
1355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      RenderWidgetHostDelegate* widget_delegate,
1365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      int routing_id,
137868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)      int main_frame_routing_id,
1383551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)      bool swapped_out,
1393551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)      bool hidden);
1405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual ~RenderViewHostImpl();
1415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // RenderViewHost implementation.
1435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  virtual RenderFrameHost* GetMainFrame() OVERRIDE;
1445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void AllowBindings(int binding_flags) OVERRIDE;
145a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  virtual void ClearFocusedElement() OVERRIDE;
146010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)  virtual bool IsFocusedElementEditable() OVERRIDE;
1475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void ClosePage() OVERRIDE;
1485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void CopyImageAt(int x, int y) OVERRIDE;
149010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)  virtual void SaveImageAt(int x, int y) OVERRIDE;
1505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void DirectoryEnumerationFinished(
1515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      int request_id,
1522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      const std::vector<base::FilePath>& files) OVERRIDE;
1535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void DisableScrollbarsForThreshold(const gfx::Size& size) OVERRIDE;
1545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void DragSourceEndedAt(
1555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      int client_x, int client_y, int screen_x, int screen_y,
156f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)      blink::WebDragOperation operation) OVERRIDE;
1575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void DragSourceSystemDragEnded() OVERRIDE;
1585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void DragTargetDragEnter(
159eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch      const DropData& drop_data,
1605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      const gfx::Point& client_pt,
1615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      const gfx::Point& screen_pt,
162f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)      blink::WebDragOperationsMask operations_allowed,
1635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      int key_modifiers) OVERRIDE;
1645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void DragTargetDragOver(
1655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      const gfx::Point& client_pt,
1665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      const gfx::Point& screen_pt,
167f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)      blink::WebDragOperationsMask operations_allowed,
1685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      int key_modifiers) OVERRIDE;
1695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void DragTargetDragLeave() OVERRIDE;
1705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void DragTargetDrop(const gfx::Point& client_pt,
1715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                              const gfx::Point& screen_pt,
1725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                              int key_modifiers) OVERRIDE;
1735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void EnableAutoResize(const gfx::Size& min_size,
1745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                const gfx::Size& max_size) OVERRIDE;
1755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void DisableAutoResize(const gfx::Size& new_size) OVERRIDE;
1765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void EnablePreferredSizeMode() OVERRIDE;
1775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void ExecuteMediaPlayerActionAtLocation(
1785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      const gfx::Point& location,
179f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)      const blink::WebMediaPlayerAction& action) OVERRIDE;
1805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void ExecutePluginActionAtLocation(
1815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      const gfx::Point& location,
182f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)      const blink::WebPluginAction& action) OVERRIDE;
1835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void ExitFullscreen() OVERRIDE;
1845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void FilesSelectedInChooser(
1855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      const std::vector<ui::SelectedFileInfo>& files,
1867dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch      FileChooserParams::Mode permissions) OVERRIDE;
1875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual RenderViewHostDelegate* GetDelegate() const OVERRIDE;
1885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual int GetEnabledBindings() const OVERRIDE;
1895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual SiteInstance* GetSiteInstance() const OVERRIDE;
1905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool IsRenderViewLive() const OVERRIDE;
1915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void NotifyMoveOrResizeStarted() OVERRIDE;
1925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void SetWebUIProperty(const std::string& name,
1935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                const std::string& value) OVERRIDE;
1945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void Zoom(PageZoom zoom) OVERRIDE;
1955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void SyncRendererPrefs() OVERRIDE;
196c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  virtual WebPreferences GetWebkitPreferences() OVERRIDE;
1975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void UpdateWebkitPreferences(
198c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)      const WebPreferences& prefs) OVERRIDE;
1996e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  virtual void OnWebkitPreferencesChanged() OVERRIDE;
2001e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  virtual void GetAudioOutputControllers(
2011e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)      const GetAudioOutputControllersCallback& callback) const OVERRIDE;
202cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  virtual void SelectWordAroundCaret() OVERRIDE;
2035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_ANDROID)
2055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void ActivateNearestFindResult(int request_id,
2065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                         float x,
2075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                         float y) OVERRIDE;
2085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void RequestFindMatchRects(int current_version) OVERRIDE;
2095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
2105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void set_delegate(RenderViewHostDelegate* d) {
2125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    CHECK(d);  // http://crbug.com/82827
2135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    delegate_ = d;
2145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
2155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Set up the RenderView child process. Virtual because it is overridden by
2175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // TestRenderViewHost. If the |frame_name| parameter is non-empty, it is used
2185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // as the name of the new top-level frame.
2195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The |opener_route_id| parameter indicates which RenderView created this
2205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // (MSG_ROUTING_NONE if none). If |max_page_id| is larger than -1, the
2215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // RenderView is told to start issuing page IDs at |max_page_id| + 1.
2220529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch  // |window_was_created_with_opener| is true if this top-level frame was
2230529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch  // created with an opener. (The opener may have been closed since.)
224cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  // The |proxy_route_id| is only used when creating a RenderView in swapped out
225cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  // state.
226a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  virtual bool CreateRenderView(const base::string16& frame_name,
2275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                int opener_route_id,
228cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)                                int proxy_route_id,
2290529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch                                int32 max_page_id,
2300529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch                                bool window_was_created_with_opener);
2315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  base::TerminationStatus render_view_termination_status() const {
2335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return render_view_termination_status_;
2345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
2355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2361e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  // Returns the content specific prefs for this RenderViewHost.
2376e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  WebPreferences ComputeWebkitPrefs(const GURL& url);
2381e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
2395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Whether this RenderViewHost has been swapped out to be displayed by a
2405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // different process.
2415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  bool IsSwappedOut() const { return rvh_state_ == STATE_SWAPPED_OUT; }
2425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
2435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // The current state of this RVH.
2445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  RenderViewHostImplState rvh_state() const { return rvh_state_; }
2455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
246f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  // Tells the renderer that this RenderView will soon be swapped out, and thus
247f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  // not to create any new modal dialogs until it happens.  This must be done
248f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  // separately so that the PageGroupLoadDeferrers of any current dialogs are no
249f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  // longer on the stack when we attempt to swap it out.
250f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  void SuppressDialogsUntilSwapOut();
251f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
2527d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  // Called when either the SwapOut request has been acknowledged or has timed
2537d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  // out.
2547d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  void OnSwappedOut(bool timed_out);
2555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Set |this| as pending shutdown. |on_swap_out| will be called
2575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // when the SwapOutACK is received, or when the unload timer times out.
2585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  void SetPendingShutdown(const base::Closure& on_swap_out);
2595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Close the page ignoring whether it has unload events registers.
2615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This is called after the beforeunload and unload events have fired
2625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // and the user has agreed to continue with closing the page.
2635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void ClosePageIgnoringUnloadEvents();
2645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Tells the renderer view to focus the first (last if reverse is true) node.
2665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void SetInitialFocus(bool reverse);
2675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Get html data by serializing all frames of current page with lists
2695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // which contain all resource links that have local copy.
2705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The parameter links contain original URLs of all saved links.
2715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The parameter local_paths contain corresponding local file paths of
2725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // all saved links, which matched with vector:links one by one.
2735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The parameter local_directory_name is relative path of directory which
2745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // contain all saved auxiliary files included all sub frames and resouces.
2755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void GetSerializedHtmlDataForCurrentPageWithLocalLinks(
2765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      const std::vector<GURL>& links,
2772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      const std::vector<base::FilePath>& local_paths,
2782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      const base::FilePath& local_directory_name);
2795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Notifies the RenderViewHost that its load state changed.
2815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void LoadStateChanged(const GURL& url,
2825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                        const net::LoadStateWithParam& load_state,
2835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                        uint64 upload_position,
2845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                        uint64 upload_size);
2855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool SuddenTerminationAllowed() const;
2875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void set_sudden_termination_allowed(bool enabled) {
2885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    sudden_termination_allowed_ = enabled;
2895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
2905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // RenderWidgetHost public overrides.
292424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  virtual void Init() OVERRIDE;
2935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void Shutdown() OVERRIDE;
2941320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  virtual void WasHidden() OVERRIDE;
2951320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  virtual void WasShown(const ui::LatencyInfo& latency_info) OVERRIDE;
2965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool IsRenderView() const OVERRIDE;
2975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
2985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void GotFocus() OVERRIDE;
2995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void LostCapture() OVERRIDE;
3005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void LostMouseLock() OVERRIDE;
3011320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  virtual void SetIsLoading(bool is_loading) OVERRIDE;
3025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void ForwardMouseEvent(
303f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)      const blink::WebMouseEvent& mouse_event) OVERRIDE;
3045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void OnPointerEventActivate() OVERRIDE;
3055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void ForwardKeyboardEvent(
3065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      const NativeWebKeyboardEvent& key_event) OVERRIDE;
3075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual gfx::Rect GetRootWindowResizerRect() const OVERRIDE;
3085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Creates a new RenderView with the given route id.
3105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void CreateNewWindow(
3115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      int route_id,
312868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)      int main_frame_route_id,
3135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      const ViewHostMsg_CreateWindow_Params& params,
3145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      SessionStorageNamespace* session_storage_namespace);
3155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Creates a new RenderWidget with the given route id.  |popup_type| indicates
3175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // if this widget is a popup and what kind of popup it is (select, autofill).
318f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  void CreateNewWidget(int route_id, blink::WebPopupType popup_type);
3195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Creates a full screen RenderWidget.
3215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void CreateNewFullscreenWidget(int route_id);
3225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
323f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)#if defined(ENABLE_BROWSER_CDMS)
324cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  MediaWebContentsObserver* media_web_contents_observer() {
325cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)    return media_web_contents_observer_.get();
3265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
327f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)#endif
3285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  int main_frame_routing_id() const {
3305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    return main_frame_routing_id_;
3315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  }
332b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)
3337d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  bool is_waiting_for_beforeunload_ack() {
3347d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)    return is_waiting_for_beforeunload_ack_;
3357d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  }
3367d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)
3375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Whether the RVH is waiting for the unload ack from the renderer.
3385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  bool IsWaitingForUnloadACK() const;
3395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
340f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)  void OnTextSurroundingSelectionResponse(const base::string16& content,
341f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)                                          size_t start_offset,
342f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)                                          size_t end_offset);
343f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)
3444e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  // Update the FrameTree to use this RenderViewHost's main frame
3454e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  // RenderFrameHost. Called when the RenderViewHost is committed.
3464e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  //
3474e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  // TODO(ajwong): Remove once RenderViewHost no longer owns the main frame
3484e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  // RenderFrameHost.
3494e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  void AttachToFrameTree();
3504e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)
3515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Increases the refcounting on this RVH. This is done by the FrameTree on
3525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // creation of a RenderFrameHost.
3535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  void increment_ref_count() { ++frames_ref_count_; }
3545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
3555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Decreases the refcounting on this RVH. This is done by the FrameTree on
3565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // destruction of a RenderFrameHost.
3575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  void decrement_ref_count() { --frames_ref_count_; }
3585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
3595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Returns the refcount on this RVH, that is the number of RenderFrameHosts
3605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // currently using it.
3615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  int ref_count() { return frames_ref_count_; }
3625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
3635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // NOTE: Do not add functions that just send an IPC message that are called in
3645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // one or two places. Have the caller send the IPC message directly (unless
3655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the caller places are in different platforms, in which case it's better
3665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // to keep them consistent).
3675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) protected:
3695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // RenderWidgetHost protected overrides.
3705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void OnUserGesture() OVERRIDE;
3715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void NotifyRendererUnresponsive() OVERRIDE;
3725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void NotifyRendererResponsive() OVERRIDE;
3735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void OnRenderAutoResized(const gfx::Size& size) OVERRIDE;
3745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void RequestToLockMouse(bool user_gesture,
3755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                  bool last_unlocked_by_target) OVERRIDE;
3765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool IsFullscreen() const OVERRIDE;
3772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual void OnFocus() OVERRIDE;
3782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual void OnBlur() OVERRIDE;
3795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // IPC message handlers.
3812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void OnShowView(int route_id,
3822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                  WindowOpenDisposition disposition,
3832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                  const gfx::Rect& initial_pos,
3842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                  bool user_gesture);
3852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void OnShowWidget(int route_id, const gfx::Rect& initial_pos);
3862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void OnShowFullscreenWidget(int route_id);
3872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void OnRunModal(int opener_id, IPC::Message* reply_msg);
3882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void OnRenderViewReady();
3897dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  void OnRenderProcessGone(int status, int error_code);
39090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  void OnUpdateState(int32 page_id, const PageState& state);
3911320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  void OnUpdateTargetURL(const GURL& url);
3922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void OnClose();
3932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void OnRequestMove(const gfx::Rect& pos);
394cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  void OnDocumentAvailableInMainFrame(bool uses_temporary_zoom_level);
3952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void OnToggleFullscreen(bool enter_fullscreen);
3962a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void OnDidContentsPreferredSizeChange(const gfx::Size& new_size);
3972a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void OnPasteFromSelectionClipboard();
3982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void OnRouteCloseEvent();
3992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void OnRouteMessageEvent(const ViewMsg_PostMessage_Params& params);
400eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  void OnStartDragging(const DropData& drop_data,
401f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)                       blink::WebDragOperationsMask operations_allowed,
4022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                       const SkBitmap& bitmap,
4032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                       const gfx::Vector2d& bitmap_offset_in_dip,
4042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                       const DragEventSourceInfo& event_info);
405f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  void OnUpdateDragCursor(blink::WebDragOperation drag_operation);
4065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void OnTargetDropACK();
4075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void OnTakeFocus(bool reverse);
4085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void OnFocusedNodeChanged(bool is_editable_node);
4092a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void OnClosePageACK();
410cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  void OnDidZoomURL(double zoom_level, const GURL& url);
4115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void OnRunFileChooser(const FileChooserParams& params);
412f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  void OnFocusedNodeTouched(bool editable);
4135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) private:
4155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // TODO(nasko): Temporarily friend RenderFrameHostImpl, so we don't duplicate
4165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // utility functions and state needed in both classes, while we move frame
4175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // specific code away from this class.
4185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  friend class RenderFrameHostImpl;
4195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  friend class TestRenderViewHost;
420868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(RenderViewHostTest, BasicRenderFrameHost);
421424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(RenderViewHostTest, RoutingIdSane);
422424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
423a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // TODO(creis): Move to a private namespace on RenderFrameHostImpl.
424a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // Delay to wait on closing the WebContents for a beforeunload/unload handler
425a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // to fire.
426a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  static const int kUnloadTimeoutMS;
427a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
4285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Updates the state of this RenderViewHost and clears any waiting state
4295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // that is no longer relevant.
4305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  void SetState(RenderViewHostImplState rvh_state);
4315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
43290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  bool CanAccessFilesOfPageState(const PageState& state) const;
433b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)
4345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // The number of RenderFrameHosts which have a reference to this RVH.
4355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  int frames_ref_count_;
436868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
4375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Our delegate, which wants to know about changes in the RenderView.
4385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  RenderViewHostDelegate* delegate_;
4395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The SiteInstance associated with this RenderViewHost.  All pages drawn
4415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // in this RenderViewHost are part of this SiteInstance.  Should not change
4425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // over time.
4435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  scoped_refptr<SiteInstanceImpl> instance_;
4445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // true if we are currently waiting for a response for drag context
4465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // information.
4475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool waiting_for_drag_context_response_;
4485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // A bitwise OR of bindings types that have been enabled for this RenderView.
4505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // See BindingsPolicy for details.
4515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int enabled_bindings_;
4525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4531320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  // The most recent page ID we've heard from the renderer process.  This is
4541320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  // used as context when other session history related IPCs arrive.
4551320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  // TODO(creis): Allocate this in WebContents/NavigationController instead.
4561320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  int32 page_id_;
4575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // The current state of this RVH.
4595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // TODO(nasko): Move to RenderFrameHost, as this is per-frame state.
4605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  RenderViewHostImplState rvh_state_;
4612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Routing ID for the main frame's RenderFrameHost.
4635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  int main_frame_routing_id_;
4645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
4655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // If we were asked to RunModal, then this will hold the reply_msg that we
4665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // must return to the renderer to unblock it.
4675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  IPC::Message* run_modal_reply_msg_;
4685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This will hold the routing id of the RenderView that opened us.
4695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int run_modal_opener_id_;
4705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Set to true when there is a pending ViewMsg_ShouldClose message.  This
4725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // ensures we don't spam the renderer with multiple beforeunload requests.
4735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // When either this value or IsWaitingForUnloadACK is true, the value of
4745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // unload_ack_is_for_cross_site_transition_ indicates whether this is for a
4755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // cross-site transition or a tab close attempt.
4765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // TODO(clamy): Remove this boolean and add one more state to the state
4775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // machine.
4785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // TODO(nasko): Move to RenderFrameHost, as this is per-frame state.
4795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool is_waiting_for_beforeunload_ack_;
4805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Valid only when is_waiting_for_beforeunload_ack_ or
4825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // IsWaitingForUnloadACK is true.  This tells us if the unload request
4835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // is for closing the entire tab ( = false), or only this RenderViewHost in
4845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the case of a cross-site transition ( = true).
4855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // TODO(nasko): Move to RenderFrameHost, as this is per-frame state.
4865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool unload_ack_is_for_cross_site_transition_;
4875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // True if the render view can be shut down suddenly.
4895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool sudden_termination_allowed_;
4905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The termination status of the last render view that terminated.
4925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  base::TerminationStatus render_view_termination_status_;
4935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Set to true if we requested the on screen keyboard to be displayed.
4955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  bool virtual_keyboard_requested_;
4965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
497f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)#if defined(ENABLE_BROWSER_CDMS)
498f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)  // Manages all the media player and CDM managers and forwards IPCs to them.
499cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  scoped_ptr<MediaWebContentsObserver> media_web_contents_observer_;
5005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
5015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Used to swap out or shutdown this RVH when the unload event is taking too
5035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // long to execute, depending on the number of active views in the
5045d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // SiteInstance.
5055d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // TODO(nasko): Move to RenderFrameHost, as this is per-frame state.
5065d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  scoped_ptr<TimeoutMonitor> unload_event_monitor_timeout_;
5075d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
5085d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Called after receiving the SwapOutACK when the RVH is in state pending
5095d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // shutdown. Also called if the unload timer times out.
5105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // TODO(nasko): Move to RenderFrameHost, as this is per-frame state.
5115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  base::Closure pending_shutdown_on_swap_out_;
5125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
513010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)  // True if the current focused element is editable.
514010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)  bool is_focused_element_editable_;
515010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)
5166e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  // This is updated every time UpdateWebkitPreferences is called. That method
5176e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  // is in turn called when any of the settings change that the WebPreferences
5186e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  // values depend on.
5196e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  scoped_ptr<WebPreferences> web_preferences_;
5206e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)
5216e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  bool updating_web_preferences_;
5226e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)
5231320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  base::WeakPtrFactory<RenderViewHostImpl> weak_factory_;
5241320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
5255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(RenderViewHostImpl);
5265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
5275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(COMPILER_MSVC)
5295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#pragma warning(pop)
5305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
5315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}  // namespace content
5335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif  // CONTENT_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_IMPL_H_
535