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.
5 #ifndef CONTENT_CHILD_NPAPI_WEBPLUGIN_H_
6 #define CONTENT_CHILD_NPAPI_WEBPLUGIN_H_
11 #include "base/basictypes.h"
12 #include "ui/gfx/geometry/rect.h"
13 #include "ui/gfx/native_widget_types.h"
14 #include "ui/gl/gpu_preference.h"
16 // TODO(port): this typedef is obviously incorrect on non-Windows
17 // platforms, but now a lot of code now accidentally depends on them
18 // existing. #ifdef out these declarations and fix all the users.
26 class WebPluginResourceClient
;
27 #if defined(OS_MACOSX)
28 class WebPluginAcceleratedSurface
;
31 // The WebKit side of a plugin implementation. It provides wrappers around
32 // operations that need to interact with the frame and other WebCore objects.
35 virtual ~WebPlugin() {}
37 // Called by the plugin delegate to let the WebPlugin know if the plugin is
38 // windowed (i.e. handle is not NULL) or windowless (handle is NULL). This
39 // tells the WebPlugin to send mouse/keyboard events to the plugin delegate,
40 // as well as the information about the HDC for paint operations.
41 virtual void SetWindow(gfx::PluginWindowHandle window
) = 0;
43 // Whether input events should be sent to the delegate.
44 virtual void SetAcceptsInputEvents(bool accepts
) = 0;
46 // Called by the plugin delegate to let it know that the window is being
48 virtual void WillDestroyWindow(gfx::PluginWindowHandle window
) = 0;
50 // Cancels a pending request.
51 virtual void CancelResource(unsigned long id
) = 0;
52 virtual void Invalidate() = 0;
53 virtual void InvalidateRect(const gfx::Rect
& rect
) = 0;
55 // Returns the NPObject for the browser's window object. Does not
57 virtual NPObject
* GetWindowScriptNPObject() = 0;
59 // Returns the DOM element that loaded the plugin. Does not take a
61 virtual NPObject
* GetPluginElement() = 0;
63 // Resolves the proxies for the url, returns true on success.
64 virtual bool FindProxyForUrl(const GURL
& url
, std::string
* proxy_list
) = 0;
67 virtual void SetCookie(const GURL
& url
,
68 const GURL
& first_party_for_cookies
,
69 const std::string
& cookie
) = 0;
70 virtual std::string
GetCookies(const GURL
& url
,
71 const GURL
& first_party_for_cookies
) = 0;
73 // Handles GetURL/GetURLNotify/PostURL/PostURLNotify requests initiated
74 // by plugins. If the plugin wants notification of the result, notify_id will
76 virtual void HandleURLRequest(const char* url
,
83 bool notify_redirects
) = 0;
85 // Cancels document load.
86 virtual void CancelDocumentLoad() = 0;
88 // Initiates a HTTP range request for an existing stream.
89 virtual void InitiateHTTPRangeRequest(const char* url
,
90 const char* range_info
,
91 int range_request_id
) = 0;
93 virtual void DidStartLoading() = 0;
94 virtual void DidStopLoading() = 0;
96 // Returns true iff in incognito mode.
97 virtual bool IsOffTheRecord() = 0;
99 // Called when the WebPluginResourceClient instance is deleted.
100 virtual void ResourceClientDeleted(
101 WebPluginResourceClient
* resource_client
) {}
103 // Defers the loading of the resource identified by resource_id. This is
104 // controlled by the defer parameter.
105 virtual void SetDeferResourceLoading(unsigned long resource_id
,
108 // Handles NPN_URLRedirectResponse calls issued by plugins in response to
109 // HTTP URL redirect notifications.
110 virtual void URLRedirectResponse(bool allow
, int resource_id
) = 0;
112 // Returns true if the new url is a secure transition. This is to catch a
113 // plugin src url transitioning from https to http.
114 virtual bool CheckIfRunInsecureContent(const GURL
& url
) = 0;
117 // |pump_messages_event| is a event handle which is used in NPP_HandleEvent
118 // calls to pump messages if the plugin enters a modal loop.
119 // |dummy_activation_window} is used to ensure correct keyboard activation.
120 // It needs to be a child of the parent window.
121 virtual void SetWindowlessData(HANDLE pump_messages_event
,
122 gfx::NativeViewId dummy_activation_window
) = 0;
125 #if defined(OS_MACOSX)
126 // Called to inform the WebPlugin that the plugin has gained or lost focus.
127 virtual void FocusChanged(bool focused
) {}
129 // Starts plugin IME.
130 virtual void StartIme() {}
132 // Returns the accelerated surface abstraction for accelerated plugins.
133 virtual WebPluginAcceleratedSurface
* GetAcceleratedSurface(
134 gfx::GpuPreference gpu_preference
) = 0;
136 // Core Animation plugin support. CA plugins always render through
138 virtual void AcceleratedPluginEnabledRendering() = 0;
139 virtual void AcceleratedPluginAllocatedIOSurface(int32 width
,
141 uint32 surface_id
) = 0;
142 virtual void AcceleratedPluginSwappedIOSurface() = 0;
146 } // namespace content
148 #endif // CONTENT_CHILD_NPAPI_WEBPLUGIN_H_