| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2010 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 #ifndef WEBKIT_GLUE_WEBPLUGIN_DELEGATE_H_ | |
| 6 #define WEBKIT_GLUE_WEBPLUGIN_DELEGATE_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "base/string16.h" | |
| 12 #include "build/build_config.h" | |
| 13 #include "gfx/native_widget_types.h" | |
| 14 #include "third_party/npapi/bindings/npapi.h" | |
| 15 #include "third_party/npapi/bindings/npapi_extensions.h" | |
| 16 #include "third_party/WebKit/WebKit/chromium/public/WebCanvas.h" | |
| 17 #include "webkit/glue/plugins/webplugin_2d_device_delegate.h" | |
| 18 #include "webkit/glue/plugins/webplugin_3d_device_delegate.h" | |
| 19 #include "webkit/glue/plugins/webplugin_audio_device_delegate.h" | |
| 20 #include "webkit/glue/plugins/webplugin_file_delegate.h" | |
| 21 #include "webkit/glue/plugins/webplugin_print_delegate.h" | |
| 22 | |
| 23 class FilePath; | |
| 24 class GURL; | |
| 25 struct NPObject; | |
| 26 | |
| 27 namespace WebKit { | |
| 28 class WebInputEvent; | |
| 29 struct WebCursorInfo; | |
| 30 } | |
| 31 | |
| 32 namespace gfx { | |
| 33 class Rect; | |
| 34 } | |
| 35 | |
| 36 namespace webkit_glue { | |
| 37 | |
| 38 class WebPlugin; | |
| 39 class WebPluginResourceClient; | |
| 40 | |
| 41 // This is the interface that a plugin implementation needs to provide. | |
| 42 class WebPluginDelegate : public WebPlugin2DDeviceDelegate, | |
| 43 public WebPlugin3DDeviceDelegate, | |
| 44 public WebPluginAudioDeviceDelegate, | |
| 45 public WebPluginPrintDelegate, | |
| 46 public WebPluginFileDelegate { | |
| 47 public: | |
| 48 virtual ~WebPluginDelegate() {} | |
| 49 | |
| 50 // Initializes the plugin implementation with the given (UTF8) arguments. | |
| 51 // Note that the lifetime of WebPlugin must be longer than this delegate. | |
| 52 // If this function returns false the plugin isn't started and shouldn't be | |
| 53 // called again. If this method succeeds, then the WebPlugin is valid until | |
| 54 // PluginDestroyed is called. | |
| 55 // The load_manually parameter if true indicates that the plugin data would | |
| 56 // be passed from webkit. if false indicates that the plugin should download | |
| 57 // the data. This also controls whether the plugin is instantiated as a full | |
| 58 // page plugin (NP_FULL) or embedded (NP_EMBED). | |
| 59 virtual bool Initialize(const GURL& url, | |
| 60 const std::vector<std::string>& arg_names, | |
| 61 const std::vector<std::string>& arg_values, | |
| 62 WebPlugin* plugin, | |
| 63 bool load_manually) = 0; | |
| 64 | |
| 65 // Called when the WebPlugin is being destroyed. This is a signal to the | |
| 66 // delegate that it should tear-down the plugin implementation and not call | |
| 67 // methods on the WebPlugin again. | |
| 68 virtual void PluginDestroyed() = 0; | |
| 69 | |
| 70 // Update the geometry of the plugin. This is a request to move the | |
| 71 // plugin, relative to its containing window, to the coords given by | |
| 72 // window_rect. Its contents should be clipped to the coords given | |
| 73 // by clip_rect, which are relative to the origin of the plugin | |
| 74 // window. The clip_rect is in plugin-relative coordinates. | |
| 75 virtual void UpdateGeometry(const gfx::Rect& window_rect, | |
| 76 const gfx::Rect& clip_rect) = 0; | |
| 77 | |
| 78 // Tells the plugin to paint the damaged rect. |canvas| is only used for | |
| 79 // windowless plugins. | |
| 80 virtual void Paint(WebKit::WebCanvas* canvas, const gfx::Rect& rect) = 0; | |
| 81 | |
| 82 // Tells the plugin to print itself. | |
| 83 virtual void Print(gfx::NativeDrawingContext hdc) = 0; | |
| 84 | |
| 85 // Informs the plugin that it has gained or lost focus. This is only called in | |
| 86 // windowless mode. | |
| 87 virtual void SetFocus(bool focused) = 0; | |
| 88 | |
| 89 // For windowless plugins, gives them a user event like mouse/keyboard. | |
| 90 // Returns whether the event was handled. This is only called in windowsless | |
| 91 // mode. See NPAPI NPP_HandleEvent for more information. | |
| 92 virtual bool HandleInputEvent(const WebKit::WebInputEvent& event, | |
| 93 WebKit::WebCursorInfo* cursor) = 0; | |
| 94 | |
| 95 // Gets the NPObject associated with the plugin for scripting. | |
| 96 virtual NPObject* GetPluginScriptableObject() = 0; | |
| 97 | |
| 98 // Receives notification about a resource load that the plugin initiated | |
| 99 // for a frame. | |
| 100 virtual void DidFinishLoadWithReason(const GURL& url, NPReason reason, | |
| 101 int notify_id) = 0; | |
| 102 | |
| 103 // Returns the process id of the process that is running the plugin. | |
| 104 virtual int GetProcessId() = 0; | |
| 105 | |
| 106 // The result, UTF-8 encoded, of the script execution is returned via this | |
| 107 // function. | |
| 108 virtual void SendJavaScriptStream(const GURL& url, | |
| 109 const std::string& result, | |
| 110 bool success, | |
| 111 int notify_id) = 0; | |
| 112 | |
| 113 // Receives notification about data being available. | |
| 114 virtual void DidReceiveManualResponse(const GURL& url, | |
| 115 const std::string& mime_type, | |
| 116 const std::string& headers, | |
| 117 uint32 expected_length, | |
| 118 uint32 last_modified) = 0; | |
| 119 | |
| 120 // Receives the data. | |
| 121 virtual void DidReceiveManualData(const char* buffer, int length) = 0; | |
| 122 | |
| 123 // Indicates end of data load. | |
| 124 virtual void DidFinishManualLoading() = 0; | |
| 125 | |
| 126 // Indicates a failure in data receipt. | |
| 127 virtual void DidManualLoadFail() = 0; | |
| 128 | |
| 129 // Only supported when the plugin is the default plugin. | |
| 130 virtual void InstallMissingPlugin() = 0; | |
| 131 | |
| 132 // Creates a WebPluginResourceClient instance and returns the same. | |
| 133 virtual WebPluginResourceClient* CreateResourceClient( | |
| 134 unsigned long resource_id, | |
| 135 const GURL& url, | |
| 136 int notify_id) = 0; | |
| 137 | |
| 138 // Creates a WebPluginResourceClient instance for an existing stream that is | |
| 139 // has become seekable. | |
| 140 virtual WebPluginResourceClient* CreateSeekableResourceClient( | |
| 141 unsigned long resource_id, int range_request_id) = 0; | |
| 142 | |
| 143 // See WebPluginContainerImpl's description of the interface. | |
| 144 virtual bool StartFind(const string16& search_text, | |
| 145 bool case_sensitive, | |
| 146 int identifier); | |
| 147 virtual void SelectFindResult(bool forward) {} | |
| 148 virtual void StopFind() {} | |
| 149 virtual void NumberOfFindResultsChanged(int total, bool final_result) {} | |
| 150 virtual void SelectedFindResultChanged(int index) {} | |
| 151 virtual NPWidgetExtensions* GetWidgetExtensions(); | |
| 152 virtual bool SetCursor(NPCursorType type); | |
| 153 virtual NPFontExtensions* GetFontExtensions(); | |
| 154 | |
| 155 // Used for zooming of full page plugins. 0 means reset, while -1 means zoom | |
| 156 // out and +1 means zoom in. | |
| 157 virtual void SetZoomFactor(float scale, bool text_only) {} | |
| 158 // Gets the selected text, if any. | |
| 159 virtual bool HasSelection() const; | |
| 160 virtual string16 GetSelectionAsText() const; | |
| 161 virtual string16 GetSelectionAsMarkup() const; | |
| 162 }; | |
| 163 | |
| 164 } // namespace webkit_glue | |
| 165 | |
| 166 #endif // WEBKIT_GLUE_WEBPLUGIN_DELEGATE_H_ | |
| OLD | NEW |