Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(616)

Side by Side Diff: chrome/default_plugin/plugin_impl_gtk.h

Issue 8689001: Reland 111519: Remove default plug-in on Mac, Gtk and Aura. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/default_plugin/plugin_impl_aura.cc ('k') | chrome/default_plugin/plugin_impl_gtk.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 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 CHROME_DEFAULT_PLUGIN_PLUGIN_IMPL_GTK_H_
6 #define CHROME_DEFAULT_PLUGIN_PLUGIN_IMPL_GTK_H_
7 #pragma once
8
9 #include <string>
10
11 #include <gtk/gtk.h>
12
13 #include "chrome/default_plugin/plugin_installer_base.h"
14 #include "third_party/npapi/bindings/npapi.h"
15 #include "ui/gfx/native_widget_types.h"
16
17 // Possible plugin installer states.
18 enum PluginInstallerState {
19 PluginInstallerStateUndefined,
20 PluginListDownloadInitiated,
21 PluginListDownloaded,
22 PluginListDownloadedPluginNotFound,
23 PluginListDownloadFailed,
24 PluginDownloadInitiated,
25 PluginDownloadCompleted,
26 PluginDownloadFailed,
27 PluginInstallerLaunchSuccess,
28 PluginInstallerLaunchFailure
29 };
30
31 // Provides the plugin installation functionality. This class is
32 // instantiated with the information like the mime type of the
33 // target plugin, the display mode, etc.
34 class PluginInstallerImpl : public PluginInstallerBase {
35 public:
36 // mode is the plugin instantiation mode, i.e. whether it is a full
37 // page plugin (NP_FULL) or an embedded plugin (NP_EMBED)
38 explicit PluginInstallerImpl(int16 mode);
39 virtual ~PluginInstallerImpl();
40
41 // Initializes the plugin with the instance information, mime type
42 // and the list of parameters passed down to the plugin from the webpage.
43 //
44 // Parameters:
45 // module_handle
46 // The handle to the dll in which this object is instantiated.
47 // instance
48 // The plugins opaque instance handle.
49 // mime_type
50 // Identifies the third party plugin which would be eventually installed.
51 // argc
52 // Indicates the count of arguments passed in from the webpage.
53 // argv
54 // Pointer to the arguments.
55 // Returns true on success.
56 bool Initialize(void* module_handle, NPP instance, NPMIMEType mime_type,
57 int16 argc, char* argn[], char* argv[]);
58
59 // Informs the plugin of its window information.
60 //
61 // Parameters:
62 // window_info
63 // The window info passed to npapi.
64 bool NPP_SetWindow(NPWindow* window_info);
65
66 // Destroys the install dialog.
67 void Shutdown();
68
69 // Starts plugin download. Spawns the plugin installer after it is
70 // downloaded.
71 void DownloadPlugin();
72
73 // Indicates that the plugin download was cancelled.
74 void DownloadCancelled();
75
76 // Initializes the plugin download stream.
77 //
78 // Parameters:
79 // stream
80 // Pointer to the new stream being created.
81 void NewStream(NPStream* stream);
82
83 // Uninitializes the plugin download stream.
84 //
85 // Parameters:
86 // stream
87 // Pointer to the stream being destroyed.
88 // reason
89 // Indicates why the stream is being destroyed.
90 //
91 void DestroyStream(NPStream* stream, NPError reason);
92
93 // Determines whether the plugin is ready to accept data.
94 // We only accept data when we have initiated a download for the plugin
95 // database.
96 //
97 // Parameters:
98 // stream
99 // Pointer to the stream being destroyed.
100 // Returns true if the plugin is ready to accept data.
101 bool WriteReady(NPStream* stream);
102
103 // Delivers data to the plugin instance.
104 //
105 // Parameters:
106 // stream
107 // Pointer to the stream being destroyed.
108 // offset
109 // Indicates the data offset.
110 // buffer_length
111 // Indicates the length of the data buffer.
112 // buffer
113 // Pointer to the actual buffer.
114 // Returns the number of bytes actually written, 0 on error.
115 int32 Write(NPStream* stream, int32 offset, int32 buffer_length,
116 void* buffer);
117
118 // Handles notifications received in response to GetURLNotify calls issued
119 // by the plugin.
120 //
121 // Parameters:
122 // url
123 // Pointer to the URL.
124 // reason
125 // Describes why the notification was sent.
126 void URLNotify(const char* url, NPReason reason);
127
128 // Used by the renderer to pass events (for e.g. input events) to the plugin.
129 int16 NPP_HandleEvent(void* event);
130
131 const std::string& mime_type() const { return mime_type_; }
132
133 // Replaces a resource string with the placeholder passed in as an argument
134 //
135 // Parameters:
136 // message_id_with_placeholders
137 // The resource id of the string with placeholders. This is only used if
138 // the placeholder string (the replacement_string) parameter is valid.
139 // message_id_without_placeholders
140 // The resource id of the string to be returned if the placeholder is
141 // empty.
142 // replacement_string
143 // The placeholder which replaces tokens in the string identified by
144 // resource id message_id_with_placeholders.
145 // Returns a string which has the placeholders replaced, or the string
146 // without placeholders.
147 static std::wstring ReplaceStringForPossibleEmptyReplacement(
148 int message_id_with_placeholders, int message_id_without_placeholders,
149 const std::wstring& replacement_string);
150
151 // Setter/getter combination to set and retreieve the current
152 // state of the plugin installer.
153 void set_plugin_installer_state(PluginInstallerState new_state) {
154 plugin_installer_state_ = new_state;
155 }
156
157 PluginInstallerState plugin_installer_state() const {
158 return plugin_installer_state_;
159 }
160
161 // Getter for the NPP instance member.
162 NPP instance() const {
163 return instance_;
164 }
165
166 // Returns whether or not the UI layout is right-to-left (such as Hebrew or
167 // Arabic).
168 bool IsRTLLayout() const;
169
170 protected:
171 // Displays the plugin install confirmation dialog.
172 void ShowInstallDialog();
173
174 // Clears the current display state.
175 void ClearDisplay();
176
177 // Displays the status message identified by the message resource id
178 // passed in.
179 //
180 // Parameters:
181 // message_resource_id parameter
182 // The resource id of the message to be displayed.
183 void DisplayStatus(int message_resource_id);
184
185 // Displays status information for the third party plugin which is needed
186 // by the page.
187 void DisplayAvailablePluginStatus();
188
189 // Displays information related to third party plugin download failure.
190 void DisplayPluginDownloadFailedStatus();
191
192 // Enables the plugin window if required and initiates an update of the
193 // the plugin window.
194 void RefreshDisplay();
195
196 // Create tooltip window.
197 bool CreateToolTip();
198
199 // Update ToolTip text with the message shown inside the default plugin.
200 void UpdateToolTip();
201
202 // Resolves the relative URL (could be already an absolute URL too) to return
203 // full URL based on current document's URL and base.
204 //
205 // Parameters:
206 // instance
207 // The plugins opaque instance handle.
208 // relative_url
209 // The URL to be resolved.
210 // Returns the resolved URL.
211 std::string ResolveURL(NPP instance, const std::string& relative_url);
212
213 // Initializes resources like the icon, fonts, etc needed by the plugin
214 // installer
215 //
216 // Parameters:
217 // module_handle
218 // Handle to the dll in which this object is instantiated.
219 // Returns true on success.
220 bool InitializeResources(void *module_handle);
221
222 // Parses the plugin instantiation arguments. This includes checking for
223 // whether this is an activex install and reading the appropriate
224 // arguments like codebase, etc. For plugin installs we download the
225 // plugin finder URL and initalize the mime type and the plugin instance
226 // info.
227 //
228 // Parameters:
229 // module_handle
230 // The handle to the dll in which this object is instantiated.
231 // instance
232 // The plugins opaque instance handle.
233 // mime_type
234 // Identifies the third party plugin which would be eventually installed.
235 // argc
236 // Indicates the count of arguments passed in from the webpage.
237 // argv
238 // Pointer to the arguments.
239 // raw_activex_clsid
240 // Output parameter which contains the CLSID of the Activex plugin needed.
241 // This is only applicable if the webpage specifically requests an ActiveX
242 // control.
243 // Returns true on success.
244 bool ParseInstantiationArguments(NPMIMEType mime_type, NPP instance,
245 int16 argc, char* argn[], char* argv[],
246 std::string* raw_activex_clsid);
247
248 // Paints user action messages to the plugin window. These include messages
249 // like whether the user should click on the plugin window to download the
250 // plugin, etc.
251 //
252 // Parameters:
253 // paint_dc
254 // The device context returned in BeginPaint.
255 // x_origin
256 // Horizontal reference point indicating where the text is to be displayed.
257 // y_origin
258 // Vertical reference point indicating where the text is to be displayed.
259 //
260 void PaintUserActionInformation(gfx::NativeDrawingContext paint_dc,
261 int x_origin, int y_origin);
262
263 private:
264 // Notify the renderer that plugin is available to download.
265 void NotifyPluginStatus(int status);
266
267 // The plugins opaque instance handle
268 NPP instance_;
269 // The current stream.
270 NPStream* plugin_install_stream_;
271 // The desired mime type.
272 std::string mime_type_;
273 // The current state of the plugin installer.
274 PluginInstallerState plugin_installer_state_;
275 // GtkPlug containing everything in the plugin.
276 GtkWidget* container_;
277
278 DISALLOW_COPY_AND_ASSIGN(PluginInstallerImpl);
279 };
280
281 #endif // CHROME_DEFAULT_PLUGIN_PLUGIN_IMPL_GTK_H_
OLDNEW
« no previous file with comments | « chrome/default_plugin/plugin_impl_aura.cc ('k') | chrome/default_plugin/plugin_impl_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698