Home | History | Annotate | Download | only in browser_plugin
      1 // Copyright (c) 2012 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 // A BrowserPluginGuest is the browser side of a browser <--> embedder
      6 // renderer channel. A BrowserPlugin (a WebPlugin) is on the embedder
      7 // renderer side of browser <--> embedder renderer communication.
      8 //
      9 // BrowserPluginGuest lives on the UI thread of the browser process. Any
     10 // messages about the guest render process that the embedder might be interested
     11 // in receiving should be listened for here.
     12 //
     13 // BrowserPluginGuest is a WebContentsDelegate and WebContentsObserver for the
     14 // guest WebContents. BrowserPluginGuest operates under the assumption that the
     15 // guest will be accessible through only one RenderViewHost for the lifetime of
     16 // the guest WebContents. Thus, cross-process navigation is not supported.
     17 
     18 #ifndef CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_
     19 #define CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_
     20 
     21 #include <map>
     22 #include <queue>
     23 
     24 #include "base/compiler_specific.h"
     25 #include "base/id_map.h"
     26 #include "base/memory/shared_memory.h"
     27 #include "base/memory/weak_ptr.h"
     28 #include "base/values.h"
     29 #include "content/common/edit_command.h"
     30 #include "content/port/common/input_event_ack_state.h"
     31 #include "content/public/browser/browser_plugin_guest_delegate.h"
     32 #include "content/public/browser/javascript_dialog_manager.h"
     33 #include "content/public/browser/web_contents_delegate.h"
     34 #include "content/public/browser/web_contents_observer.h"
     35 #include "content/public/common/browser_plugin_permission_type.h"
     36 #include "third_party/WebKit/public/web/WebCompositionUnderline.h"
     37 #include "third_party/WebKit/public/web/WebDragOperation.h"
     38 #include "third_party/WebKit/public/web/WebDragStatus.h"
     39 #include "third_party/WebKit/public/web/WebInputEvent.h"
     40 #include "ui/base/ime/text_input_mode.h"
     41 #include "ui/base/ime/text_input_type.h"
     42 #include "ui/gfx/rect.h"
     43 #include "ui/surface/transport_dib.h"
     44 
     45 struct BrowserPluginHostMsg_AutoSize_Params;
     46 struct BrowserPluginHostMsg_Attach_Params;
     47 struct BrowserPluginHostMsg_ResizeGuest_Params;
     48 struct ViewHostMsg_CreateWindow_Params;
     49 #if defined(OS_MACOSX)
     50 struct ViewHostMsg_ShowPopup_Params;
     51 #endif
     52 struct ViewHostMsg_UpdateRect_Params;
     53 class WebCursor;
     54 
     55 namespace cc {
     56 class CompositorFrameAck;
     57 }
     58 
     59 namespace blink {
     60 class WebInputEvent;
     61 }
     62 
     63 namespace gfx {
     64 class Range;
     65 }
     66 
     67 namespace content {
     68 
     69 class BrowserPluginHostFactory;
     70 class BrowserPluginEmbedder;
     71 class BrowserPluginGuestManager;
     72 class RenderProcessHost;
     73 class RenderWidgetHostView;
     74 class SiteInstance;
     75 struct DropData;
     76 struct MediaStreamRequest;
     77 
     78 // A browser plugin guest provides functionality for WebContents to operate in
     79 // the guest role and implements guest-specific overrides for ViewHostMsg_*
     80 // messages.
     81 //
     82 // When a guest is initially created, it is in an unattached state. That is,
     83 // it is not visible anywhere and has no embedder WebContents assigned.
     84 // A BrowserPluginGuest is said to be "attached" if it has an embedder.
     85 // A BrowserPluginGuest can also create a new unattached guest via
     86 // CreateNewWindow. The newly created guest will live in the same partition,
     87 // which means it can share storage and can script this guest.
     88 class CONTENT_EXPORT BrowserPluginGuest
     89     : public JavaScriptDialogManager,
     90       public WebContentsDelegate,
     91       public WebContentsObserver,
     92       public base::SupportsWeakPtr<BrowserPluginGuest> {
     93  public:
     94   typedef base::Callback<void(bool)> GeolocationCallback;
     95   virtual ~BrowserPluginGuest();
     96 
     97   // The WebContents passed into the factory method here has not been
     98   // initialized yet and so it does not yet hold a SiteInstance.
     99   // BrowserPluginGuest must be constructed and installed into a WebContents
    100   // prior to its initialization because WebContents needs to determine what
    101   // type of WebContentsView to construct on initialization. The content
    102   // embedder needs to be aware of |guest_site_instance| on the guest's
    103   // construction and so we pass it in here.
    104   static BrowserPluginGuest* Create(
    105       int instance_id,
    106       SiteInstance* guest_site_instance,
    107       WebContentsImpl* web_contents,
    108       scoped_ptr<base::DictionaryValue> extra_params);
    109 
    110   static BrowserPluginGuest* CreateWithOpener(
    111       int instance_id,
    112       bool has_render_view,
    113       WebContentsImpl* web_contents,
    114       BrowserPluginGuest* opener);
    115 
    116   // Called when the embedder WebContents is destroyed to give the
    117   // BrowserPluginGuest an opportunity to clean up after itself.
    118   void EmbedderDestroyed();
    119 
    120   // Called when the embedder WebContents changes visibility.
    121   void EmbedderVisibilityChanged(bool visible);
    122 
    123   // Destroys the guest WebContents and all its associated state, including
    124   // this BrowserPluginGuest, and its new unattached windows.
    125   void Destroy();
    126 
    127   // Returns the identifier that uniquely identifies a browser plugin guest
    128   // within an embedder.
    129   int instance_id() const { return instance_id_; }
    130 
    131   bool OnMessageReceivedFromEmbedder(const IPC::Message& message);
    132 
    133   void Initialize(const BrowserPluginHostMsg_Attach_Params& params,
    134                   WebContentsImpl* embedder_web_contents);
    135 
    136   WebContentsImpl* embedder_web_contents() const {
    137     return embedder_web_contents_;
    138   }
    139 
    140   RenderWidgetHostView* GetEmbedderRenderWidgetHostView();
    141 
    142   bool focused() const { return focused_; }
    143   bool visible() const { return guest_visible_; }
    144   void clear_damage_buffer() { damage_buffer_.reset(); }
    145   bool is_in_destruction() { return is_in_destruction_; }
    146 
    147   BrowserPluginGuest* opener() const { return opener_.get(); }
    148 
    149   // Returns whether the mouse pointer was unlocked.
    150   bool UnlockMouseIfNecessary(const NativeWebKeyboardEvent& event);
    151 
    152   void UpdateVisibility();
    153 
    154   void CopyFromCompositingSurface(
    155       gfx::Rect src_subrect,
    156       gfx::Size dst_size,
    157       const base::Callback<void(bool, const SkBitmap&)>& callback);
    158 
    159   // WebContentsObserver implementation.
    160   virtual void DidCommitProvisionalLoadForFrame(
    161       int64 frame_id,
    162       const base::string16& frame_unique_name,
    163       bool is_main_frame,
    164       const GURL& url,
    165       PageTransition transition_type,
    166       RenderViewHost* render_view_host) OVERRIDE;
    167   virtual void DidStopLoading(RenderViewHost* render_view_host) OVERRIDE;
    168 
    169   virtual void RenderViewReady() OVERRIDE;
    170   virtual void RenderProcessGone(base::TerminationStatus status) OVERRIDE;
    171   virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
    172 
    173   // WebContentsDelegate implementation.
    174   virtual bool AddMessageToConsole(WebContents* source,
    175                                    int32 level,
    176                                    const base::string16& message,
    177                                    int32 line_no,
    178                                    const base::string16& source_id) OVERRIDE;
    179   // If a new window is created with target="_blank" and rel="noreferrer", then
    180   // this method is called, indicating that the new WebContents is ready to be
    181   // attached.
    182   virtual void AddNewContents(WebContents* source,
    183                               WebContents* new_contents,
    184                               WindowOpenDisposition disposition,
    185                               const gfx::Rect& initial_pos,
    186                               bool user_gesture,
    187                               bool* was_blocked) OVERRIDE;
    188   virtual void CanDownload(RenderViewHost* render_view_host,
    189                            int request_id,
    190                            const std::string& request_method,
    191                            const base::Callback<void(bool)>& callback) OVERRIDE;
    192   virtual void LoadProgressChanged(WebContents* source,
    193                                    double progress) OVERRIDE;
    194   virtual void CloseContents(WebContents* source) OVERRIDE;
    195   virtual JavaScriptDialogManager* GetJavaScriptDialogManager() OVERRIDE;
    196   virtual bool HandleContextMenu(const ContextMenuParams& params) OVERRIDE;
    197   virtual void HandleKeyboardEvent(
    198       WebContents* source,
    199       const NativeWebKeyboardEvent& event) OVERRIDE;
    200   virtual WebContents* OpenURLFromTab(WebContents* source,
    201                                       const OpenURLParams& params) OVERRIDE;
    202   virtual void WebContentsCreated(WebContents* source_contents,
    203                                   int64 source_frame_id,
    204                                   const base::string16& frame_name,
    205                                   const GURL& target_url,
    206                                   WebContents* new_contents) OVERRIDE;
    207   virtual void RendererUnresponsive(WebContents* source) OVERRIDE;
    208   virtual void RendererResponsive(WebContents* source) OVERRIDE;
    209   virtual void RunFileChooser(WebContents* web_contents,
    210                               const FileChooserParams& params) OVERRIDE;
    211   virtual bool ShouldFocusPageAfterCrash() OVERRIDE;
    212   virtual void RequestMediaAccessPermission(
    213       WebContents* web_contents,
    214       const MediaStreamRequest& request,
    215       const MediaResponseCallback& callback) OVERRIDE;
    216 
    217   // JavaScriptDialogManager implementation.
    218   virtual void RunJavaScriptDialog(
    219       WebContents* web_contents,
    220       const GURL& origin_url,
    221       const std::string& accept_lang,
    222       JavaScriptMessageType javascript_message_type,
    223       const base::string16& message_text,
    224       const base::string16& default_prompt_text,
    225       const DialogClosedCallback& callback,
    226       bool* did_suppress_message) OVERRIDE;
    227   virtual void RunBeforeUnloadDialog(
    228       WebContents* web_contents,
    229       const base::string16& message_text,
    230       bool is_reload,
    231       const DialogClosedCallback& callback) OVERRIDE;
    232   virtual bool HandleJavaScriptDialog(
    233       WebContents* web_contents,
    234       bool accept,
    235       const base::string16* prompt_override) OVERRIDE;
    236   virtual void CancelActiveAndPendingDialogs(
    237       WebContents* web_contents) OVERRIDE;
    238   virtual void WebContentsDestroyed(WebContents* web_contents) OVERRIDE;
    239 
    240   // Exposes the protected web_contents() from WebContentsObserver.
    241   WebContentsImpl* GetWebContents();
    242 
    243   // Overridden in tests.
    244   virtual void SetDamageBuffer(
    245       const BrowserPluginHostMsg_ResizeGuest_Params& params);
    246 
    247   gfx::Point GetScreenCoordinates(const gfx::Point& relative_position) const;
    248 
    249   // Helper to send messages to embedder. This methods fills the message with
    250   // the correct routing id.
    251   // Overridden in test implementation since we want to intercept certain
    252   // messages for testing.
    253   virtual void SendMessageToEmbedder(IPC::Message* msg);
    254 
    255   // Returns whether the guest is attached to an embedder.
    256   bool attached() const { return embedder_web_contents_ != NULL; }
    257 
    258   // Attaches this BrowserPluginGuest to the provided |embedder_web_contents|
    259   // and initializes the guest with the provided |params|. Attaching a guest
    260   // to an embedder implies that this guest's lifetime is no longer managed
    261   // by its opener, and it can begin loading resources. |extra_params| are
    262   // parameters passed into BrowserPlugin from JavaScript to be forwarded to
    263   // the content embedder.
    264   void Attach(WebContentsImpl* embedder_web_contents,
    265               BrowserPluginHostMsg_Attach_Params params,
    266               const base::DictionaryValue& extra_params);
    267 
    268   // Requests geolocation permission through Embedder JavaScript API.
    269   void AskEmbedderForGeolocationPermission(int bridge_id,
    270                                            const GURL& requesting_frame,
    271                                            const GeolocationCallback& callback);
    272   // Cancels pending geolocation request.
    273   void CancelGeolocationRequest(int bridge_id);
    274 
    275   // Allow the embedder to call this for unhandled messages when
    276   // BrowserPluginGuest is already destroyed.
    277   static void AcknowledgeBufferPresent(int route_id,
    278                                        int gpu_host_id,
    279                                        const std::string& mailbox_name,
    280                                        uint32 sync_point);
    281 
    282   // Returns whether BrowserPluginGuest is interested in receiving the given
    283   // |message|.
    284   static bool ShouldForwardToBrowserPluginGuest(const IPC::Message& message);
    285   gfx::Rect ToGuestRect(const gfx::Rect& rect);
    286 
    287   void DragSourceEndedAt(int client_x, int client_y, int screen_x,
    288       int screen_y, blink::WebDragOperation operation);
    289 
    290   void DragSourceMovedTo(int client_x, int client_y,
    291                          int screen_x, int screen_y);
    292 
    293   // Called when the drag started by this guest ends at an OS-level.
    294   void EndSystemDrag();
    295 
    296   // |this| takes ownership of |delegate|.
    297   void SetDelegate(BrowserPluginGuestDelegate* delegate);
    298 
    299   void RespondToPermissionRequest(int request_id,
    300                                   bool should_allow,
    301                                   const std::string& user_input);
    302 
    303   // Overrides factory for testing. Default (NULL) value indicates regular
    304   // (non-test) environment.
    305   static void set_factory_for_testing(BrowserPluginHostFactory* factory) {
    306     BrowserPluginGuest::factory_ = factory;
    307   }
    308 
    309  private:
    310   class EmbedderWebContentsObserver;
    311   friend class TestBrowserPluginGuest;
    312 
    313   class DownloadRequest;
    314   class GeolocationRequest;
    315   class JavaScriptDialogRequest;
    316   // MediaRequest because of naming conflicts with MediaStreamRequest.
    317   class MediaRequest;
    318   class NewWindowRequest;
    319   class PermissionRequest;
    320   class PointerLockRequest;
    321 
    322   // Tracks the name, and target URL of the new window and whether or not it has
    323   // changed since the WebContents has been created and before the new window
    324   // has been attached to a BrowserPlugin. Once the first navigation commits, we
    325   // no longer track this information.
    326   struct NewWindowInfo {
    327     bool changed;
    328     GURL url;
    329     std::string name;
    330     NewWindowInfo(const GURL& url, const std::string& name) :
    331         changed(false),
    332         url(url),
    333         name(name) {}
    334   };
    335 
    336   // BrowserPluginGuest is a WebContentsObserver of |web_contents| and
    337   // |web_contents| has to stay valid for the lifetime of BrowserPluginGuest.
    338   BrowserPluginGuest(int instance_id,
    339                      bool has_render_view,
    340                      WebContentsImpl* web_contents,
    341                      BrowserPluginGuest* opener);
    342 
    343   // Destroy unattached new windows that have been opened by this
    344   // BrowserPluginGuest.
    345   void DestroyUnattachedWindows();
    346 
    347   void LoadURLWithParams(const GURL& url,
    348                          const Referrer& referrer,
    349                          PageTransition transition_type,
    350                          WebContents* web_contents);
    351 
    352   // Bridge IDs correspond to a geolocation request. This method will remove
    353   // the bookkeeping for a particular geolocation request associated with the
    354   // provided |bridge_id|. It returns the request ID of the geolocation request.
    355   int RemoveBridgeID(int bridge_id);
    356 
    357   // Returns the |request_id| generated for the |request| provided.
    358   int RequestPermission(
    359       BrowserPluginPermissionType permission_type,
    360       scoped_refptr<BrowserPluginGuest::PermissionRequest> request,
    361       const base::DictionaryValue& request_info);
    362 
    363   // Creates a new guest window, and BrowserPluginGuest that is owned by this
    364   // BrowserPluginGuest.
    365   BrowserPluginGuest* CreateNewGuestWindow(const OpenURLParams& params);
    366 
    367   base::SharedMemory* damage_buffer() const { return damage_buffer_.get(); }
    368   const gfx::Size& damage_view_size() const { return damage_view_size_; }
    369   float damage_buffer_scale_factor() const {
    370     return damage_buffer_scale_factor_;
    371   }
    372   // Returns the damage buffer corresponding to the handle in resize |params|.
    373   base::SharedMemory* GetDamageBufferFromEmbedder(
    374       const BrowserPluginHostMsg_ResizeGuest_Params& params);
    375 
    376   bool InAutoSizeBounds(const gfx::Size& size) const;
    377 
    378   void RequestNewWindowPermission(WindowOpenDisposition disposition,
    379                                   const gfx::Rect& initial_bounds,
    380                                   bool user_gesture,
    381                                   WebContentsImpl* new_contents);
    382 
    383   // Message handlers for messages from embedder.
    384 
    385   void OnCompositorFrameACK(int instance_id,
    386                             int route_id,
    387                             uint32 output_surface_id,
    388                             int renderer_host_id,
    389                             const cc::CompositorFrameAck& ack);
    390   void OnCopyFromCompositingSurfaceAck(int instance_id,
    391                                        int request_id,
    392                                        const SkBitmap& bitmap);
    393   // Handles drag events from the embedder.
    394   // When dragging, the drag events go to the embedder first, and if the drag
    395   // happens on the browser plugin, then the plugin sends a corresponding
    396   // drag-message to the guest. This routes the drag-message to the guest
    397   // renderer.
    398   void OnDragStatusUpdate(int instance_id,
    399                           blink::WebDragStatus drag_status,
    400                           const DropData& drop_data,
    401                           blink::WebDragOperationsMask drag_mask,
    402                           const gfx::Point& location);
    403   // Instructs the guest to execute an edit command decoded in the embedder.
    404   void OnExecuteEditCommand(int instance_id,
    405                             const std::string& command);
    406 
    407   // Returns compositor resources reclaimed in the embedder to the guest.
    408   void OnReclaimCompositorResources(int instance_id,
    409                                     int route_id,
    410                                     uint32 output_surface_id,
    411                                     int renderer_host_id,
    412                                     const cc::CompositorFrameAck& ack);
    413 
    414   // Overriden in tests.
    415   virtual void OnHandleInputEvent(int instance_id,
    416                                   const gfx::Rect& guest_window_rect,
    417                                   const blink::WebInputEvent* event);
    418   void OnLockMouse(bool user_gesture,
    419                    bool last_unlocked_by_target,
    420                    bool privileged);
    421   void OnLockMouseAck(int instance_id, bool succeeded);
    422   void OnNavigateGuest(int instance_id, const std::string& src);
    423   void OnPluginDestroyed(int instance_id);
    424   // Grab the new damage buffer from the embedder, and resize the guest's
    425   // web contents.
    426   void OnResizeGuest(int instance_id,
    427                      const BrowserPluginHostMsg_ResizeGuest_Params& params);
    428   // Overriden in tests.
    429   virtual void OnSetFocus(int instance_id, bool focused);
    430   // Sets the name of the guest so that other guests in the same partition can
    431   // access it.
    432   void OnSetName(int instance_id, const std::string& name);
    433   // Updates the size state of the guest.
    434   void OnSetSize(
    435       int instance_id,
    436       const BrowserPluginHostMsg_AutoSize_Params& auto_size_params,
    437       const BrowserPluginHostMsg_ResizeGuest_Params& resize_guest_params);
    438   void OnSetEditCommandsForNextKeyEvent(
    439       int instance_id,
    440       const std::vector<EditCommand>& edit_commands);
    441   void OnSetContentsOpaque(int instance_id, bool opaque);
    442   // The guest WebContents is visible if both its embedder is visible and
    443   // the browser plugin element is visible. If either one is not then the
    444   // WebContents is marked as hidden. A hidden WebContents will consume
    445   // fewer GPU and CPU resources.
    446   //
    447   // When every WebContents in a RenderProcessHost is hidden, it will lower
    448   // the priority of the process (see RenderProcessHostImpl::WidgetHidden).
    449   //
    450   // It will also send a message to the guest renderer process to cleanup
    451   // resources such as dropping back buffers and adjusting memory limits (if in
    452   // compositing mode, see CCLayerTreeHost::setVisible).
    453   //
    454   // Additionally, it will slow down Javascript execution and garbage
    455   // collection. See RenderThreadImpl::IdleHandler (executed when hidden) and
    456   // RenderThreadImpl::IdleHandlerInForegroundTab (executed when visible).
    457   void OnSetVisibility(int instance_id, bool visible);
    458   // Message from embedder acknowledging last HW buffer.
    459   void OnSwapBuffersACK(int instance_id,
    460                         int route_id,
    461                         int gpu_host_id,
    462                         const std::string& mailbox_name,
    463                         uint32 sync_point);
    464   void OnUnlockMouse();
    465   void OnUnlockMouseAck(int instance_id);
    466   void OnUpdateGeometry(int instance_id, const gfx::Rect& view_rect);
    467   void OnUpdateRectACK(
    468       int instance_id,
    469       bool needs_ack,
    470       const BrowserPluginHostMsg_AutoSize_Params& auto_size_params,
    471       const BrowserPluginHostMsg_ResizeGuest_Params& resize_guest_params);
    472 
    473   void OnTextInputTypeChanged(ui::TextInputType type,
    474                               ui::TextInputMode input_mode,
    475                               bool can_compose_inline);
    476   void OnImeSetComposition(
    477       int instance_id,
    478       const std::string& text,
    479       const std::vector<blink::WebCompositionUnderline>& underlines,
    480       int selection_start,
    481       int selection_end);
    482   void OnImeConfirmComposition(
    483       int instance_id,
    484       const std::string& text,
    485       bool keep_selection);
    486   void OnExtendSelectionAndDelete(int instance_id, int before, int after);
    487   // Overridden in tests.
    488   virtual void OnImeCancelComposition();
    489 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA)
    490   void OnImeCompositionRangeChanged(
    491       const gfx::Range& range,
    492       const std::vector<gfx::Rect>& character_bounds);
    493 #endif
    494 
    495   // Message handlers for messages from guest.
    496 
    497   void OnDragStopped();
    498   void OnHandleInputEventAck(
    499       blink::WebInputEvent::Type event_type,
    500       InputEventAckState ack_result);
    501   void OnHasTouchEventHandlers(bool accept);
    502   void OnSetCursor(const WebCursor& cursor);
    503   // On MacOSX popups are painted by the browser process. We handle them here
    504   // so that they are positioned correctly.
    505 #if defined(OS_MACOSX)
    506   void OnShowPopup(const ViewHostMsg_ShowPopup_Params& params);
    507 #endif
    508   void OnShowWidget(int route_id, const gfx::Rect& initial_pos);
    509   // Overriden in tests.
    510   virtual void OnTakeFocus(bool reverse);
    511   void OnUpdateFrameName(int frame_id,
    512                          bool is_top_level,
    513                          const std::string& name);
    514   void OnUpdateRect(const ViewHostMsg_UpdateRect_Params& params);
    515 
    516   // Requests download permission through embedder JavaScript API after
    517   // retrieving url information from IO thread.
    518   void DidRetrieveDownloadURLFromRequestId(
    519       const std::string& request_method,
    520       const base::Callback<void(bool)>& callback,
    521       const std::string& url);
    522 
    523   // Embedder sets permission to allow or deny geolocation request.
    524   void SetGeolocationPermission(
    525       GeolocationCallback callback, int bridge_id, bool allowed);
    526 
    527   // Forwards all messages from the |pending_messages_| queue to the embedder.
    528   void SendQueuedMessages();
    529 
    530   // Weak pointer used to ask GeolocationPermissionContext about geolocation
    531   // permission.
    532   base::WeakPtrFactory<BrowserPluginGuest> weak_ptr_factory_;
    533 
    534   // Static factory instance (always NULL for non-test).
    535   static BrowserPluginHostFactory* factory_;
    536 
    537   scoped_ptr<EmbedderWebContentsObserver> embedder_web_contents_observer_;
    538   WebContentsImpl* embedder_web_contents_;
    539 
    540   std::map<int, int> bridge_id_to_request_id_map_;
    541 
    542   // An identifier that uniquely identifies a browser plugin guest within an
    543   // embedder.
    544   int instance_id_;
    545   scoped_ptr<base::SharedMemory> damage_buffer_;
    546   // An identifier that uniquely identifies a damage buffer.
    547   uint32 damage_buffer_sequence_id_;
    548   size_t damage_buffer_size_;
    549   gfx::Size damage_view_size_;
    550   float damage_buffer_scale_factor_;
    551   float guest_device_scale_factor_;
    552   gfx::Rect guest_window_rect_;
    553   gfx::Rect guest_screen_rect_;
    554   base::TimeDelta guest_hang_timeout_;
    555   bool focused_;
    556   bool mouse_locked_;
    557   bool pending_lock_request_;
    558   bool guest_visible_;
    559   bool guest_opaque_;
    560   bool embedder_visible_;
    561   std::string name_;
    562   bool auto_size_enabled_;
    563   gfx::Size max_auto_size_;
    564   gfx::Size min_auto_size_;
    565 
    566   // Each copy-request is identified by a unique number. The unique number is
    567   // used to keep track of the right callback.
    568   int copy_request_id_;
    569   typedef base::Callback<void(bool, const SkBitmap&)> CopyRequestCallback;
    570   typedef std::map<int, const CopyRequestCallback> CopyRequestMap;
    571   CopyRequestMap copy_request_callbacks_;
    572 
    573   typedef std::map<BrowserPluginGuest*, NewWindowInfo> PendingWindowMap;
    574   PendingWindowMap pending_new_windows_;
    575   base::WeakPtr<BrowserPluginGuest> opener_;
    576   // A counter to generate a unique request id for a permission request.
    577   // We only need the ids to be unique for a given BrowserPluginGuest.
    578   int next_permission_request_id_;
    579 
    580   // A map to store relevant info for a request keyed by the request's id.
    581   typedef std::map<int, scoped_refptr<PermissionRequest> > RequestMap;
    582   RequestMap permission_request_map_;
    583 
    584   // Indicates that this BrowserPluginGuest has associated renderer-side state.
    585   // This is used to determine whether or not to create a new RenderView when
    586   // this guest is attached.
    587   bool has_render_view_;
    588 
    589   // Last seen size of guest contents (by OnUpdateRect).
    590   gfx::Size last_seen_view_size_;
    591   // Last seen autosize attribute state (by OnUpdateRect).
    592   bool last_seen_auto_size_enabled_;
    593 
    594   bool is_in_destruction_;
    595 
    596   // This is a queue of messages that are destined to be sent to the embedder
    597   // once the guest is attached to a particular embedder.
    598   std::queue<IPC::Message*> pending_messages_;
    599 
    600   scoped_ptr<BrowserPluginGuestDelegate> delegate_;
    601 
    602   // These are parameters passed from JavaScript on attachment to the content
    603   // embedder.
    604   scoped_ptr<base::DictionaryValue> extra_attach_params_;
    605 
    606   DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest);
    607 };
    608 
    609 }  // namespace content
    610 
    611 #endif  // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_
    612