| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef WEBKIT_DEFAULT_PLUGIN_PLUGIN_IMPL_WIN_H_ | 5 #ifndef WEBKIT_DEFAULT_PLUGIN_PLUGIN_IMPL_WIN_H_ |
| 6 #define WEBKIT_DEFAULT_PLUGIN_PLUGIN_IMPL_WIN_H_ | 6 #define WEBKIT_DEFAULT_PLUGIN_PLUGIN_IMPL_WIN_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 PluginListDownloaded, | 21 PluginListDownloaded, |
| 22 PluginListDownloadedPluginNotFound, | 22 PluginListDownloadedPluginNotFound, |
| 23 PluginListDownloadFailed, | 23 PluginListDownloadFailed, |
| 24 PluginDownloadInitiated, | 24 PluginDownloadInitiated, |
| 25 PluginDownloadCompleted, | 25 PluginDownloadCompleted, |
| 26 PluginDownloadFailed, | 26 PluginDownloadFailed, |
| 27 PluginInstallerLaunchSuccess, | 27 PluginInstallerLaunchSuccess, |
| 28 PluginInstallerLaunchFailure | 28 PluginInstallerLaunchFailure |
| 29 }; | 29 }; |
| 30 | 30 |
| 31 class ActiveXInstaller; | |
| 32 class PluginInstallDialog; | 31 class PluginInstallDialog; |
| 33 class PluginDatabaseHandler; | 32 class PluginDatabaseHandler; |
| 34 | 33 |
| 35 // Provides the plugin installation functionality. This class is | 34 // Provides the plugin installation functionality. This class is |
| 36 // instantiated with the information like the mime type of the | 35 // instantiated with the information like the mime type of the |
| 37 // target plugin, the display mode, etc. | 36 // target plugin, the display mode, etc. |
| 38 class PluginInstallerImpl : public base::WindowImpl { | 37 class PluginInstallerImpl : public base::WindowImpl { |
| 39 public: | 38 public: |
| 40 static const int kRefreshPluginsMessage = WM_APP + 1; | 39 static const int kRefreshPluginsMessage = WM_APP + 1; |
| 41 static const int kInstallMissingPluginMessage = WM_APP + 2; | 40 static const int kInstallMissingPluginMessage = WM_APP + 2; |
| 42 static const int kActivexInstallResult = WM_USER + 74; | |
| 43 | 41 |
| 44 // mode is the plugin instantiation mode, i.e. whether it is a full | 42 // mode is the plugin instantiation mode, i.e. whether it is a full |
| 45 // page plugin (NP_FULL) or an embedded plugin (NP_EMBED) | 43 // page plugin (NP_FULL) or an embedded plugin (NP_EMBED) |
| 46 explicit PluginInstallerImpl(int16 mode); | 44 explicit PluginInstallerImpl(int16 mode); |
| 47 virtual ~PluginInstallerImpl(); | 45 virtual ~PluginInstallerImpl(); |
| 48 | 46 |
| 49 BEGIN_MSG_MAP_EX(PluginInstallerImpl) | 47 BEGIN_MSG_MAP_EX(PluginInstallerImpl) |
| 50 MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBackGround) | 48 MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBackGround) |
| 51 MESSAGE_HANDLER(WM_PAINT, OnPaint) | 49 MESSAGE_HANDLER(WM_PAINT, OnPaint) |
| 52 MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown) | 50 MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown) |
| 53 MESSAGE_HANDLER(kRefreshPluginsMessage, OnRefreshPlugins) | 51 MESSAGE_HANDLER(kRefreshPluginsMessage, OnRefreshPlugins) |
| 54 MESSAGE_HANDLER(WM_COPYDATA, OnCopyData) | 52 MESSAGE_HANDLER(WM_COPYDATA, OnCopyData) |
| 55 MESSAGE_HANDLER(WM_SETCURSOR, OnSetCursor) | 53 MESSAGE_HANDLER(WM_SETCURSOR, OnSetCursor) |
| 56 MESSAGE_HANDLER(kActivexInstallResult, OnActiveXInstallResult) | |
| 57 END_MSG_MAP() | 54 END_MSG_MAP() |
| 58 | 55 |
| 59 // Initializes the plugin with the instance information, mime type | 56 // Initializes the plugin with the instance information, mime type |
| 60 // and the list of parameters passed down to the plugin from the webpage. | 57 // and the list of parameters passed down to the plugin from the webpage. |
| 61 // | 58 // |
| 62 // Parameters: | 59 // Parameters: |
| 63 // module_handle | 60 // module_handle |
| 64 // The handle to the dll in which this object is instantiated. | 61 // The handle to the dll in which this object is instantiated. |
| 65 // instance | 62 // instance |
| 66 // The plugins opaque instance handle. | 63 // The plugins opaque instance handle. |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 // Handles notifications received in response to GetURLNotify calls issued | 133 // Handles notifications received in response to GetURLNotify calls issued |
| 137 // by the plugin. | 134 // by the plugin. |
| 138 // | 135 // |
| 139 // Parameters: | 136 // Parameters: |
| 140 // url | 137 // url |
| 141 // Pointer to the URL. | 138 // Pointer to the URL. |
| 142 // reason | 139 // reason |
| 143 // Describes why the notification was sent. | 140 // Describes why the notification was sent. |
| 144 void URLNotify(const char* url, NPReason reason); | 141 void URLNotify(const char* url, NPReason reason); |
| 145 | 142 |
| 146 // Initiates activex installs if applicable. | 143 // Used by the renderer to indicate plugin install through the infobar. |
| 147 // Note: The null plugin being a windowed plugin does not have to implement | |
| 148 // NPP_HandleEvent. However to handle activex installations, we have this | |
| 149 // hack to allow the renderer to send out a request for installing the | |
| 150 // activex. | |
| 151 int16 NPP_HandleEvent(void* event); | 144 int16 NPP_HandleEvent(void* event); |
| 152 | 145 |
| 153 const std::string& mime_type() const { return mime_type_; } | 146 const std::string& mime_type() const { return mime_type_; } |
| 154 | 147 |
| 155 // Replaces a resource string with the placeholder passed in as an argument | 148 // Replaces a resource string with the placeholder passed in as an argument |
| 156 // | 149 // |
| 157 // Parameters: | 150 // Parameters: |
| 158 // message_id_with_placeholders | 151 // message_id_with_placeholders |
| 159 // The resource id of the string with placeholders. This is only used if | 152 // The resource id of the string with placeholders. This is only used if |
| 160 // the placeholder string (the replacement_string) parameter is valid. | 153 // the placeholder string (the replacement_string) parameter is valid. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 182 | 175 |
| 183 // Getter for the NPP instance member. | 176 // Getter for the NPP instance member. |
| 184 const NPP instance() const { | 177 const NPP instance() const { |
| 185 return instance_; | 178 return instance_; |
| 186 } | 179 } |
| 187 | 180 |
| 188 // Returns whether or not the UI layout is right-to-left (such as Hebrew or | 181 // Returns whether or not the UI layout is right-to-left (such as Hebrew or |
| 189 // Arabic). | 182 // Arabic). |
| 190 static bool IsRTLLayout(); | 183 static bool IsRTLLayout(); |
| 191 | 184 |
| 192 // Parses the plugin instantiation arguments. This includes checking for | |
| 193 // whether this is an activex install and reading the appropriate | |
| 194 // arguments like codebase, etc. For plugin installs we download the | |
| 195 // plugin finder URL and initalize the mime type and the plugin instance | |
| 196 // info. | |
| 197 // | |
| 198 // Parameters: | |
| 199 // module_handle: The handle to the dll in which this object is instantiated. | |
| 200 // instance: The plugins opaque instance handle. | |
| 201 // mime_type: Identifies the third party plugin | |
| 202 // argc: Indicates the count of arguments passed in from the webpage. | |
| 203 // argv: Pointer to the arguments. | |
| 204 // raw_activex_clsid: Output parameter which contains the CLSID of the | |
| 205 // Activex plugin needed for an Activex install | |
| 206 // is_activex: Output parameter indicating if this is an activex install | |
| 207 // activex_clsid: Output parameter containing the classid of the activex | |
| 208 // for an activex install | |
| 209 // activex_codebase: Output parameter containing the activex codebase if | |
| 210 // this is an activex install | |
| 211 // plugin_download_url: Output parameter containing the plugin download url | |
| 212 // on success. | |
| 213 // plugin_finder_url: Output parameter containing the plugin finder url on | |
| 214 // success. | |
| 215 // Returns true on success. | |
| 216 static bool ParseInstantiationArguments(NPMIMEType mime_type, | |
| 217 NPP instance, | |
| 218 int16 argc, | |
| 219 char* argn[], | |
| 220 char* argv[], | |
| 221 std::string* raw_activex_clsid, | |
| 222 bool* is_activex, | |
| 223 std::string* activex_clsid, | |
| 224 std::string* activex_codebase, | |
| 225 std::string* plugin_download_url, | |
| 226 std::string* plugin_finder_url); | |
| 227 protected: | 185 protected: |
| 228 // Window message handlers. | 186 // Window message handlers. |
| 229 LRESULT OnPaint(UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled); | 187 LRESULT OnPaint(UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled); |
| 230 LRESULT OnEraseBackGround(UINT message, WPARAM wparam, LPARAM lparam, | 188 LRESULT OnEraseBackGround(UINT message, WPARAM wparam, LPARAM lparam, |
| 231 BOOL& handled); | 189 BOOL& handled); |
| 232 LRESULT OnLButtonDown(UINT message, WPARAM wparam, LPARAM lparam, | 190 LRESULT OnLButtonDown(UINT message, WPARAM wparam, LPARAM lparam, |
| 233 BOOL& handled); | 191 BOOL& handled); |
| 234 LRESULT OnSetCursor(UINT message, WPARAM wparam, LPARAM lparam, | 192 LRESULT OnSetCursor(UINT message, WPARAM wparam, LPARAM lparam, |
| 235 BOOL& handled); | 193 BOOL& handled); |
| 236 | 194 |
| 237 // Refreshes the loaded plugin list and reloads the current page. | 195 // Refreshes the loaded plugin list and reloads the current page. |
| 238 LRESULT OnRefreshPlugins(UINT message, WPARAM wparam, LPARAM lparam, | 196 LRESULT OnRefreshPlugins(UINT message, WPARAM wparam, LPARAM lparam, |
| 239 BOOL& handled); | 197 BOOL& handled); |
| 240 | 198 |
| 241 // Launches the third party plugin installer. This message is | 199 // Launches the third party plugin installer. This message is |
| 242 // received when the request to download the installer, initiated by | 200 // received when the request to download the installer, initiated by |
| 243 // plugin completes. | 201 // plugin completes. |
| 244 LRESULT OnCopyData(UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled); | 202 LRESULT OnCopyData(UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled); |
| 245 | 203 |
| 246 // Displays status information for ActiveX installs | |
| 247 LRESULT OnActiveXInstallResult(UINT message, WPARAM wparam, LPARAM lparam, | |
| 248 BOOL& handled); | |
| 249 | |
| 250 // Displays the plugin install confirmation dialog. | 204 // Displays the plugin install confirmation dialog. |
| 251 void ShowInstallDialog(); | 205 void ShowInstallDialog(); |
| 252 | 206 |
| 253 // Clears the current display state. | 207 // Clears the current display state. |
| 254 void ClearDisplay(); | 208 void ClearDisplay(); |
| 255 | 209 |
| 256 // Displays the status message identified by the message resource id | 210 // Displays the status message identified by the message resource id |
| 257 // passed in. | 211 // passed in. |
| 258 // | 212 // |
| 259 // Parameters: | 213 // Parameters: |
| (...skipping 11 matching lines...) Expand all Loading... |
| 271 // Enables the plugin window if required and initiates an update of the | 225 // Enables the plugin window if required and initiates an update of the |
| 272 // the plugin window. | 226 // the plugin window. |
| 273 void RefreshDisplay(); | 227 void RefreshDisplay(); |
| 274 | 228 |
| 275 // Create tooltip window. | 229 // Create tooltip window. |
| 276 bool CreateToolTip(); | 230 bool CreateToolTip(); |
| 277 | 231 |
| 278 // Update ToolTip text with the message shown inside the default plugin. | 232 // Update ToolTip text with the message shown inside the default plugin. |
| 279 void UpdateToolTip(); | 233 void UpdateToolTip(); |
| 280 | 234 |
| 281 // Resolves the relative URL (could be already an absolute URL too) to return | |
| 282 // full URL based on current document's URL and base. | |
| 283 // | |
| 284 // Parameters: | |
| 285 // instance | |
| 286 // The plugins opaque instance handle. | |
| 287 // relative_url | |
| 288 // The URL to be resolved. | |
| 289 // Returns the resolved URL. | |
| 290 static std::string ResolveURL(NPP instance, const std::string& relative_url); | |
| 291 | |
| 292 // Initializes resources like the icon, fonts, etc needed by the plugin | 235 // Initializes resources like the icon, fonts, etc needed by the plugin |
| 293 // installer | 236 // installer |
| 294 // | 237 // |
| 295 // Parameters: | 238 // Parameters: |
| 296 // module_handle | 239 // module_handle |
| 297 // Handle to the dll in which this object is instantiated. | 240 // Handle to the dll in which this object is instantiated. |
| 298 // Returns true on success. | 241 // Returns true on success. |
| 299 bool InitializeResources(HINSTANCE module_handle); | 242 bool InitializeResources(HINSTANCE module_handle); |
| 300 | 243 |
| 301 // Paints user action messages to the plugin window. These include messages | 244 // Paints user action messages to the plugin window. These include messages |
| 302 // like whether the user should click on the plugin window to download the | 245 // like whether the user should click on the plugin window to download the |
| 303 // plugin, etc. | 246 // plugin, etc. |
| 304 // | 247 // |
| 305 // Parameters: | 248 // Parameters: |
| 306 // paint_dc | 249 // paint_dc |
| 307 // The device context returned in BeginPaint. | 250 // The device context returned in BeginPaint. |
| 308 // x_origin | 251 // x_origin |
| 309 // Horizontal reference point indicating where the text is to be displayed. | 252 // Horizontal reference point indicating where the text is to be displayed. |
| 310 // y_origin | 253 // y_origin |
| 311 // Vertical reference point indicating where the text is to be displayed. | 254 // Vertical reference point indicating where the text is to be displayed. |
| 312 // | 255 // |
| 313 void PaintUserActionInformation(HDC paint_dc, int x_origin, int y_origin); | 256 void PaintUserActionInformation(HDC paint_dc, int x_origin, int y_origin); |
| 314 | 257 |
| 315 private: | 258 private: |
| 316 // Notify the renderer that plugin is available to download. | 259 // Notify the renderer that plugin is available to download. |
| 317 void NotifyPluginStatus(int status); | 260 void NotifyPluginStatus(int status); |
| 318 | 261 |
| 319 // The plugins opaque instance handle | 262 // The plugins opaque instance handle |
| 320 NPP instance_; | 263 NPP instance_; |
| 321 // If this is to install activex | |
| 322 bool is_activex_; | |
| 323 // The plugin instantiation mode (NP_FULL or NP_EMBED) | 264 // The plugin instantiation mode (NP_FULL or NP_EMBED) |
| 324 int16 mode_; | 265 int16 mode_; |
| 325 // The handle to the icon displayed in the plugin installation window. | 266 // The handle to the icon displayed in the plugin installation window. |
| 326 HICON icon_; | 267 HICON icon_; |
| 327 // The Get plugin link message string displayed at the top left corner of | 268 // The Get plugin link message string displayed at the top left corner of |
| 328 // the plugin window. | 269 // the plugin window. |
| 329 std::wstring get_plugin_link_message_; | 270 std::wstring get_plugin_link_message_; |
| 330 // The command string displayed in the plugin installation window. | 271 // The command string displayed in the plugin installation window. |
| 331 std::wstring command_; | 272 std::wstring command_; |
| 332 // An additional message displayed at times by the plugin. | 273 // An additional message displayed at times by the plugin. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 361 // This object handles download and parsing of the plugins database. | 302 // This object handles download and parsing of the plugins database. |
| 362 PluginDatabaseHandler plugin_database_handler_; | 303 PluginDatabaseHandler plugin_database_handler_; |
| 363 // Indicates if the left click to download/refresh should be enabled or not. | 304 // Indicates if the left click to download/refresh should be enabled or not. |
| 364 bool enable_click_; | 305 bool enable_click_; |
| 365 // Handles to the fonts used to display text in the plugin window. | 306 // Handles to the fonts used to display text in the plugin window. |
| 366 HFONT bold_font_; | 307 HFONT bold_font_; |
| 367 HFONT regular_font_; | 308 HFONT regular_font_; |
| 368 HFONT underline_font_; | 309 HFONT underline_font_; |
| 369 // Tooltip Window. | 310 // Tooltip Window. |
| 370 HWND tooltip_; | 311 HWND tooltip_; |
| 371 // ActiveX related. | |
| 372 std::string activex_codebase_; | |
| 373 std::string activex_clsid_; | |
| 374 CComObject<ActiveXInstaller>* activex_installer_; | |
| 375 | 312 |
| 376 DISALLOW_COPY_AND_ASSIGN(PluginInstallerImpl); | 313 DISALLOW_COPY_AND_ASSIGN(PluginInstallerImpl); |
| 377 }; | 314 }; |
| 378 | 315 |
| 379 | 316 |
| 380 #endif // WEBKIT_DEFAULT_PLUGIN_PLUGIN_IMPL_WIN_H_ | 317 #endif // WEBKIT_DEFAULT_PLUGIN_PLUGIN_IMPL_WIN_H_ |
| OLD | NEW |