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)
5ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch#ifndef CONTENT_CHILD_NPAPI_WEBPLUGIN_DELEGATE_IMPL_H_
6ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch#define CONTENT_CHILD_NPAPI_WEBPLUGIN_DELEGATE_IMPL_H_
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <string>
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <vector>
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/memory/ref_counted.h"
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/memory/scoped_ptr.h"
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/memory/weak_ptr.h"
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/sequenced_task_runner_helpers.h"
15eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "base/timer/timer.h"
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "build/build_config.h"
17ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch#include "content/child/npapi/webplugin_delegate.h"
1823730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)#include "content/common/cursors/webcursor.h"
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "third_party/npapi/bindings/npapi.h"
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/gfx/native_widget_types.h"
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/gfx/rect.h"
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace base {
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class FilePath;
252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_MACOSX)
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifdef __OBJC__
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)@class CALayer;
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)@class CARenderer;
315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#else
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class CALayer;
335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class CARenderer;
345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
37ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdochnamespace content {
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class PluginInstance;
3958537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)class WebPlugin;
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_MACOSX)
425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class WebPluginAcceleratedSurface;
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class ExternalDragTracker;
445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif  // OS_MACOSX
455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_WIN)
475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class WebPluginIMEWin;
485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif  // OS_WIN
495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// An implementation of WebPluginDelegate that runs in the plugin process,
515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// proxied from the renderer by WebPluginDelegateProxy.
52ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdochclass WebPluginDelegateImpl : public WebPluginDelegate {
535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public:
545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  enum PluginQuirks {
555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PLUGIN_QUIRK_SETWINDOW_TWICE = 1,  // Win32
565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PLUGIN_QUIRK_THROTTLE_WM_USER_PLUS_ONE = 2,  // Win32
575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PLUGIN_QUIRK_DONT_CALL_WND_PROC_RECURSIVELY = 4,  // Win32
585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PLUGIN_QUIRK_DONT_SET_NULL_WINDOW_HANDLE_ON_DESTROY = 8,  // Win32
595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PLUGIN_QUIRK_DONT_ALLOW_MULTIPLE_INSTANCES = 16,  // Win32
605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PLUGIN_QUIRK_DIE_AFTER_UNLOAD = 32,  // Win32
615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PLUGIN_QUIRK_PATCH_SETCURSOR = 64,  // Win32
625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PLUGIN_QUIRK_BLOCK_NONSTANDARD_GETURL_REQUESTS = 128,  // Win32
635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PLUGIN_QUIRK_WINDOWLESS_OFFSET_WINDOW_TO_DRAW = 256,  // Linux
645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PLUGIN_QUIRK_WINDOWLESS_INVALIDATE_AFTER_SET_WINDOW = 512,  // Linux
655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PLUGIN_QUIRK_NO_WINDOWLESS = 1024,  // Windows
665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PLUGIN_QUIRK_PATCH_REGENUMKEYEXW = 2048,  // Windows
675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PLUGIN_QUIRK_ALWAYS_NOTIFY_SUCCESS = 4096,  // Windows
685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PLUGIN_QUIRK_HANDLE_MOUSE_CAPTURE = 16384,  // Windows
695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PLUGIN_QUIRK_WINDOWLESS_NO_RIGHT_CLICK = 32768,  // Linux
705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PLUGIN_QUIRK_IGNORE_FIRST_SETWINDOW_CALL = 65536,  // Windows.
715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PLUGIN_QUIRK_EMULATE_IME = 131072,  // Windows.
72f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)    PLUGIN_QUIRK_FAKE_WINDOW_FROM_POINT = 262144,  // Windows.
735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    PLUGIN_QUIRK_COPY_STREAM_DATA = 524288,  // All platforms
745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  };
755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7658537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)  static WebPluginDelegateImpl* Create(WebPlugin* plugin,
7758537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)                                       const base::FilePath& filename,
785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                       const std::string& mime_type);
795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // WebPluginDelegate implementation
815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool Initialize(const GURL& url,
825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                          const std::vector<std::string>& arg_names,
835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                          const std::vector<std::string>& arg_values,
845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                          bool load_manually) OVERRIDE;
855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void PluginDestroyed() OVERRIDE;
865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void UpdateGeometry(const gfx::Rect& window_rect,
875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                              const gfx::Rect& clip_rect) OVERRIDE;
8858537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)  virtual void Paint(SkCanvas* canvas, const gfx::Rect& rect) OVERRIDE;
895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void SetFocus(bool focused) OVERRIDE;
90f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  virtual bool HandleInputEvent(const blink::WebInputEvent& event,
9190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                WebCursor::CursorInfo* cursor_info) OVERRIDE;
925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual NPObject* GetPluginScriptableObject() OVERRIDE;
9390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  virtual NPP GetPluginNPP() OVERRIDE;
94c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  virtual bool GetFormValue(base::string16* value) OVERRIDE;
955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void DidFinishLoadWithReason(const GURL& url,
965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                       NPReason reason,
975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                       int notify_id) OVERRIDE;
985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual int GetProcessId() OVERRIDE;
995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void SendJavaScriptStream(const GURL& url,
1005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                    const std::string& result,
1015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                    bool success,
1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                    int notify_id) OVERRIDE;
1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void DidReceiveManualResponse(const GURL& url,
1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                        const std::string& mime_type,
1055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                        const std::string& headers,
1065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                        uint32 expected_length,
1075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                        uint32 last_modified) OVERRIDE;
1085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void DidReceiveManualData(const char* buffer, int length) OVERRIDE;
1095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void DidFinishManualLoading() OVERRIDE;
1105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void DidManualLoadFail() OVERRIDE;
1115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual WebPluginResourceClient* CreateResourceClient(
1125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      unsigned long resource_id, const GURL& url, int notify_id) OVERRIDE;
1135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual WebPluginResourceClient* CreateSeekableResourceClient(
1145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      unsigned long resource_id, int range_request_id) OVERRIDE;
11558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)  virtual void FetchURL(unsigned long resource_id,
11658537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)                        int notify_id,
11758537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)                        const GURL& url,
11858537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)                        const GURL& first_party_for_cookies,
11958537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)                        const std::string& method,
120d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)                        const char* buf,
121d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)                        unsigned int len,
12258537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)                        const GURL& referrer,
12358537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)                        bool notify_redirects,
12458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)                        bool is_plugin_src_load,
12558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)                        int origin_pid,
1265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                        int render_frame_id,
12758537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)                        int render_view_id) OVERRIDE;
1285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // End of WebPluginDelegate implementation.
1295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  gfx::PluginWindowHandle windowed_handle() const { return windowed_handle_; }
1312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool IsWindowless() const { return windowless_; }
1322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  PluginInstance* instance() { return instance_.get(); }
1335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  gfx::Rect GetRect() const { return window_rect_; }
1345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  gfx::Rect GetClipRect() const { return clip_rect_; }
1355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the path for the library implementing this plugin.
1372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  base::FilePath GetPluginPath();
1385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns a combination of PluginQuirks.
1405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int GetQuirks() const { return quirks_; }
1415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Informs the plugin that the view it is in has gained or lost focus.
1435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void SetContentAreaHasFocus(bool has_focus);
1445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_WIN)
1465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Informs the plug-in that an IME has changed its status.
147c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  void ImeCompositionUpdated(const base::string16& text,
1485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                             const std::vector<int>& clauses,
1495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                             const std::vector<int>& target,
1505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                             int cursor_position);
1515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Informs the plugin that IME composition has completed./ If |text| is empty,
1535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // IME was cancelled.
154c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  void ImeCompositionCompleted(const base::string16& text);
1555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the IME status retrieved from a plug-in.
1575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool GetIMEStatus(int* input_type, gfx::Rect* caret_rect);
1585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
1595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_MACOSX) && !defined(USE_AURA)
1615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Informs the plugin that the geometry has changed, as with UpdateGeometry,
1625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // but also includes the new buffer context for that new geometry.
1635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void UpdateGeometryAndContext(const gfx::Rect& window_rect,
1645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                const gfx::Rect& clip_rect,
1655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                gfx::NativeDrawingContext context);
1665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Informs the delegate that the plugin called NPN_Invalidate*. Used as a
1675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // trigger for Core Animation drawing.
1685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void PluginDidInvalidate();
1695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the delegate currently processing events.
1705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static WebPluginDelegateImpl* GetActiveDelegate();
1715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Informs the plugin that the window it is in has gained or lost focus.
1725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void SetWindowHasFocus(bool has_focus);
1735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Informs the plugin that its tab or window has been hidden or shown.
1745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void SetContainerVisibility(bool is_visible);
1755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Informs the plugin that its containing window's frame has changed.
1765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Frames are in screen coordinates.
1775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void WindowFrameChanged(const gfx::Rect& window_frame,
1785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                          const gfx::Rect& view_frame);
1795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Informs the plugin that IME composition has completed.
1805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // If |text| is empty, IME was cancelled.
181c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  void ImeCompositionCompleted(const base::string16& text);
1825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Informs the delegate that the plugin set a Cocoa NSCursor.
1835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void SetNSCursor(NSCursor* cursor);
1845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Indicates that the windowless plugins will draw directly to the window
1865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // context instead of a buffer context.
1875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void SetNoBufferContext();
1885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // TODO(caryclark): This is a temporary workaround to allow the Darwin / Skia
1905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // port to share code with the Darwin / CG port. Later, this will be removed
1915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // and all callers will use the Paint defined above.
1925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void CGPaint(CGContextRef context, const gfx::Rect& rect);
1935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif  // OS_MACOSX && !USE_AURA
1945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) private:
1965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  friend class base::DeleteHelper<WebPluginDelegateImpl>;
1975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  friend class WebPluginDelegate;
1985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
19958537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)  WebPluginDelegateImpl(WebPlugin* plugin, PluginInstance* instance);
2005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual ~WebPluginDelegateImpl();
2015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Called by Initialize() for platform-specific initialization.
2035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // If this returns false, the plugin shouldn't be started--see Initialize().
2045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool PlatformInitialize();
2055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Called by DestroyInstance(), used for platform-specific destruction.
2075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void PlatformDestroyInstance();
2085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //--------------------------
2105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // used for windowed plugins
2115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void WindowedUpdateGeometry(const gfx::Rect& window_rect,
2125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                              const gfx::Rect& clip_rect);
2135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Create the native window.
2145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns true if the window is created (or already exists).
2155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns false if unable to create the window.
2165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool WindowedCreatePlugin();
2175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Destroy the native window.
2195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void WindowedDestroyWindow();
2205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Reposition the native window to be in sync with the given geometry.
2225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns true if the native window has moved or been clipped differently.
2235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool WindowedReposition(const gfx::Rect& window_rect,
2245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                          const gfx::Rect& clip_rect);
2255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Tells the plugin about the current state of the window.
2275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // See NPAPI NPP_SetWindow for more information.
2285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void WindowedSetWindow();
2295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_WIN)
2315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Registers the window class for our window
2325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  ATOM RegisterNativeWindowClass();
2335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Our WndProc functions.
2355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static LRESULT CALLBACK WrapperWindowProc(
2365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
2375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static LRESULT CALLBACK NativeWndProc(
2385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
2395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static LRESULT CALLBACK FlashWindowlessWndProc(
2405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
2415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static LRESULT CALLBACK DummyWindowProc(
2425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
2435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Used for throttling Flash messages.
2455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static void ClearThrottleQueueForWindow(HWND window);
2465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static void OnThrottleMessage();
2475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static void ThrottleMessage(WNDPROC proc, HWND hwnd, UINT message,
2485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      WPARAM wParam, LPARAM lParam);
2495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
2505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //----------------------------
2525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // used for windowless plugins
2535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void WindowlessUpdateGeometry(const gfx::Rect& window_rect,
2545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                const gfx::Rect& clip_rect);
2555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void WindowlessPaint(gfx::NativeDrawingContext hdc, const gfx::Rect& rect);
2565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Tells the plugin about the current state of the window.
2585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // See NPAPI NPP_SetWindow for more information.
2595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void WindowlessSetWindow();
2605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Informs the plugin that it has gained or lost keyboard focus (on the Mac,
2625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // this just means window first responder status).
2635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void SetPluginHasFocus(bool focused);
2645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Handles the platform specific details of setting plugin focus. Returns
2665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // false if the platform cancelled the focus tranfer.
2675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool PlatformSetPluginHasFocus(bool focused);
2685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //-----------------------------------------
2705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // used for windowed and windowless plugins
2715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Does platform-specific event handling. Arguments and return are identical
2735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // to HandleInputEvent.
274f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  bool PlatformHandleInputEvent(const blink::WebInputEvent& event,
27590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                WebCursor::CursorInfo* cursor_info);
2765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Closes down and destroys our plugin instance.
2785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void DestroyInstance();
2795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // used for windowed plugins
2825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Note: on Mac OS X, the only time the windowed handle is non-zero
2835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // is the case of accelerated rendering, which uses a fake window handle to
2845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // identify itself back to the browser. It still performs all of its
2855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // work offscreen.
2865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  gfx::PluginWindowHandle windowed_handle_;
2875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  gfx::Rect windowed_last_pos_;
2885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool windowed_did_set_window_;
2905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // used by windowed and windowless plugins
2925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool windowless_;
2935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  WebPlugin* plugin_;
2955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  scoped_refptr<PluginInstance> instance_;
2965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_WIN)
2985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Original wndproc before we subclassed.
2995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  WNDPROC plugin_wnd_proc_;
3005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Used to throttle WM_USER+1 messages in Flash.
3025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  uint32 last_message_;
3035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool is_calling_wndproc;
3045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // An IME emulator used by a windowless plug-in to retrieve IME data through
3065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // IMM32 functions.
3075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  scoped_ptr<WebPluginIMEWin> plugin_ime_;
3085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif  // defined(OS_WIN)
3095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  NPWindow window_;
3115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  gfx::Rect window_rect_;
3125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  gfx::Rect clip_rect_;
3135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int quirks_;
3145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_WIN)
3165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Windowless plugins don't have keyboard focus causing issues with the
3175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // plugin not receiving keyboard events if the plugin enters a modal
3185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // loop like TrackPopupMenuEx or MessageBox, etc.
3195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This is a basic issue with windows activation and focus arising due to
3205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the fact that these windows are created by different threads. Activation
3215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // and focus are thread specific states, and if the browser has focus,
3225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the plugin may not have focus.
3235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // To fix a majority of these activation issues we create a dummy visible
3245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // child window to which we set focus whenever the windowless plugin
3255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // receives a WM_LBUTTONDOWN/WM_RBUTTONDOWN message via NPP_HandleEvent.
3265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  HWND dummy_window_for_activation_;
3285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  HWND dummy_window_parent_;
3295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  WNDPROC old_dummy_window_proc_;
3305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool CreateDummyWindowForActivation();
3315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns true if the event passed in needs to be tracked for a potential
3335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // modal loop.
3345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static bool ShouldTrackEventForModalLoops(NPEvent* event);
3355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The message filter hook procedure, which tracks modal loops entered by
3375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // a plugin in the course of a NPP_HandleEvent call.
3385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static LRESULT CALLBACK HandleEventMessageFilterHook(int code, WPARAM wParam,
3395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                                       LPARAM lParam);
3405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // TrackPopupMenu interceptor. Parameters are the same as the Win32 function
3425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // TrackPopupMenu.
3435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static BOOL WINAPI TrackPopupMenuPatch(HMENU menu, unsigned int flags, int x,
3445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                         int y, int reserved, HWND window,
3455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                         const RECT* rect);
3465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // SetCursor interceptor for windowless plugins.
3485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static HCURSOR WINAPI SetCursorPatch(HCURSOR cursor);
3495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // RegEnumKeyExW interceptor.
3515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static LONG WINAPI RegEnumKeyExWPatch(
3525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      HKEY key, DWORD index, LPWSTR name, LPDWORD name_size, LPDWORD reserved,
3535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      LPWSTR class_name, LPDWORD class_size, PFILETIME last_write_time);
3545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // GetProcAddress intercepter for windowless plugins.
3565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static FARPROC WINAPI GetProcAddressPatch(HMODULE module, LPCSTR name);
3575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
358f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  // WindowFromPoint patch for Flash windowless plugins. When flash receives
359f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  // mouse move messages it calls the WindowFromPoint API to eventually convert
360f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  // the mouse coordinates to screen. We need to return the dummy plugin parent
361f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  // window for Aura to ensure that these conversions occur correctly.
362f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  static HWND WINAPI WindowFromPointPatch(POINT point);
363f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
3645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The mouse hook proc which handles mouse capture in windowed plugins.
3655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static LRESULT CALLBACK MouseHookProc(int code, WPARAM wParam,
3665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                        LPARAM lParam);
3675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Calls SetCapture/ReleaseCapture based on the message type.
3695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static void HandleCaptureForMessage(HWND window, UINT message);
3705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#elif defined(OS_MACOSX) && !defined(USE_AURA)
3725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Sets window_rect_ to |rect|
3735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void SetPluginRect(const gfx::Rect& rect);
3745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Sets content_area_origin to |origin|
3755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void SetContentAreaOrigin(const gfx::Point& origin);
3765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Updates everything that depends on the plugin's absolute screen location.
3775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void PluginScreenLocationChanged();
3785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Updates anything that depends on plugin visibility.
3795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void PluginVisibilityChanged();
3805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Starts an IME session.
3825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void StartIme();
3835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Informs the browser about the updated accelerated drawing surface.
3855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void UpdateAcceleratedSurface();
3865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Uses a CARenderer to draw the plug-in's layer in our OpenGL surface.
3885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void DrawLayerInSurface();
3895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool use_buffer_context_;
3915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  CGContextRef buffer_context_;  // Weak ref.
3925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  CALayer* layer_;  // Used for CA drawing mode. Weak, retained by plug-in.
3945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  WebPluginAcceleratedSurface* surface_;  // Weak ref.
3955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  CARenderer* renderer_;  // Renders layer_ to surface_.
3965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  scoped_ptr<base::RepeatingTimer<WebPluginDelegateImpl> > redraw_timer_;
3975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The upper-left corner of the web content area in screen coordinates,
3995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // relative to an upper-left (0,0).
4005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  gfx::Point content_area_origin_;
4015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool containing_window_has_focus_;
4035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool initial_window_focus_;
4045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool container_is_visible_;
4055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool have_called_set_window_;
4065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  gfx::Rect cached_clip_rect_;
4085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool ime_enabled_;
4105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int keyup_ignore_count_;
4115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  scoped_ptr<ExternalDragTracker> external_drag_tracker_;
4135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif  // OS_MACOSX && !USE_AURA
4145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Called by the message filter hook when the plugin enters a modal loop.
4165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void OnModalLoopEntered();
4175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns true if the message passed in corresponds to a user gesture.
419f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  static bool IsUserGesture(const blink::WebInputEvent& event);
4205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The url with which the plugin was instantiated.
4225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  std::string plugin_url_;
4235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_WIN)
4255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Indicates the end of a user gesture period.
4265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void OnUserGestureEnd();
4275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Handle to the message filter hook
4295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  HHOOK handle_event_message_filter_hook_;
4305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Event which is set when the plugin enters a modal loop in the course
4325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // of a NPP_HandleEvent call.
4335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  HANDLE handle_event_pump_messages_event_;
4345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This flag indicates whether we started tracking a user gesture message.
4365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool user_gesture_message_posted_;
4375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Runnable Method Factory used to invoke the OnUserGestureEnd method
4395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // asynchronously.
4405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  base::WeakPtrFactory<WebPluginDelegateImpl> user_gesture_msg_factory_;
4415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Handle to the mouse hook installed for certain windowed plugins like
4435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // flash.
4445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  HHOOK mouse_hook_;
4455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
4465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Holds the depth of the HandleEvent callstack.
4485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int handle_event_depth_;
4495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Holds the current cursor set by the windowless plugin.
4515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  WebCursor current_windowless_cursor_;
4525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Set to true initially and indicates if this is the first npp_setwindow
4545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // call received by the plugin.
4555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool first_set_window_call_;
4565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // True if the plugin thinks it has keyboard focus
4585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool plugin_has_focus_;
4595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // True if the plugin element has focus within the web content, regardless of
4605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // whether its containing view currently has focus.
4615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool has_webkit_focus_;
4625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // True if the containing view currently has focus.
4635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Initially set to true so that plugin focus still works in environments
4645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // where SetContentAreaHasFocus is never called. See
4655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // https://bugs.webkit.org/show_bug.cgi?id=46013 for details.
4665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool containing_view_has_focus_;
4675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // True if NPP_New did not return an error.
4695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool creation_succeeded_;
4705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(WebPluginDelegateImpl);
4725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
4735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
474ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch}  // namespace content
4755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
476ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch#endif  // CONTENT_CHILD_NPAPI_WEBPLUGIN_DELEGATE_IMPL_H_
477