| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 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 CHROME_DEFAULT_PLUGIN_PLUGIN_IMPL_WIN_H_ | 5 #ifndef CHROME_DEFAULT_PLUGIN_PLUGIN_IMPL_WIN_H_ |
| 6 #define CHROME_DEFAULT_PLUGIN_PLUGIN_IMPL_WIN_H_ | 6 #define CHROME_DEFAULT_PLUGIN_PLUGIN_IMPL_WIN_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/win/process_monitor.h" |
| 11 #include "chrome/default_plugin/install_dialog.h" | 13 #include "chrome/default_plugin/install_dialog.h" |
| 12 #include "chrome/default_plugin/plugin_database_handler.h" | 14 #include "chrome/browser/plugin_database_handler.h" |
| 13 #include "chrome/default_plugin/plugin_installer_base.h" | 15 #include "chrome/default_plugin/plugin_installer_base.h" |
| 14 #include "chrome/default_plugin/plugin_install_job_monitor.h" | |
| 15 #include "chrome/default_plugin/plugin_main.h" | 16 #include "chrome/default_plugin/plugin_main.h" |
| 16 #include "third_party/npapi/bindings/npapi.h" | 17 #include "third_party/npapi/bindings/npapi.h" |
| 17 #include "ui/base/win/window_impl.h" | 18 #include "ui/base/win/window_impl.h" |
| 18 #include "webkit/plugins/npapi/default_plugin_shared.h" | 19 #include "webkit/plugins/npapi/default_plugin_shared.h" |
| 19 | 20 |
| 20 // Possible plugin installer states. | 21 // Possible plugin installer states. |
| 21 enum PluginInstallerState { | 22 enum PluginInstallerState { |
| 22 PluginInstallerStateUndefined, | 23 PluginInstallerStateUndefined, |
| 23 PluginListDownloadInitiated, | 24 PluginListDownloadInitiated, |
| 24 PluginListDownloaded, | 25 PluginListDownloaded, |
| 25 PluginListDownloadedPluginNotFound, | 26 PluginListDownloadedPluginNotFound, |
| 26 PluginListDownloadFailed, | 27 PluginListDownloadFailed, |
| 27 PluginDownloadInitiated, | 28 PluginDownloadInitiated, |
| 28 PluginDownloadCompleted, | 29 PluginDownloadCompleted, |
| 29 PluginDownloadFailed, | 30 PluginDownloadFailed, |
| 30 PluginInstallerLaunchSuccess, | 31 PluginInstallerLaunchSuccess, |
| 31 PluginInstallerLaunchFailure | 32 PluginInstallerLaunchFailure |
| 32 }; | 33 }; |
| 33 | 34 |
| 34 class PluginInstallDialog; | 35 class PluginInstallDialog; |
| 35 class PluginDatabaseHandler; | 36 class PluginDatabaseHandler; |
| 36 | 37 |
| 37 // Provides the plugin installation functionality. This class is | 38 // Provides the plugin installation functionality. This class is |
| 38 // instantiated with the information like the mime type of the | 39 // instantiated with the information like the mime type of the |
| 39 // target plugin, the display mode, etc. | 40 // target plugin, the display mode, etc. |
| 40 class PluginInstallerImpl : public PluginInstallerBase, | 41 class PluginInstallerImpl : public PluginInstallerBase, |
| 42 public PluginDatabaseHandler::Client, |
| 41 public ui::WindowImpl { | 43 public ui::WindowImpl { |
| 42 public: | 44 public: |
| 43 static const int kRefreshPluginsMessage = WM_APP + 1; | |
| 44 | |
| 45 // mode is the plugin instantiation mode, i.e. whether it is a full | 45 // mode is the plugin instantiation mode, i.e. whether it is a full |
| 46 // page plugin (NP_FULL) or an embedded plugin (NP_EMBED) | 46 // page plugin (NP_FULL) or an embedded plugin (NP_EMBED) |
| 47 explicit PluginInstallerImpl(int16 mode); | 47 explicit PluginInstallerImpl(int16 mode); |
| 48 virtual ~PluginInstallerImpl(); | 48 virtual ~PluginInstallerImpl(); |
| 49 | 49 |
| 50 // PluginDatabaseHandler::Client methods: |
| 51 virtual void DownloadPluginList( |
| 52 const std::string& plugin_finder_url) OVERRIDE; |
| 53 virtual void OnPluginListDownloaded() OVERRIDE; |
| 54 |
| 50 BEGIN_MSG_MAP_EX(PluginInstallerImpl) | 55 BEGIN_MSG_MAP_EX(PluginInstallerImpl) |
| 51 MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBackGround) | 56 MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBackGround) |
| 52 MESSAGE_HANDLER(WM_PAINT, OnPaint) | 57 MESSAGE_HANDLER(WM_PAINT, OnPaint) |
| 53 MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown) | 58 MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown) |
| 54 MESSAGE_HANDLER(kRefreshPluginsMessage, OnRefreshPlugins) | |
| 55 MESSAGE_HANDLER(WM_COPYDATA, OnCopyData) | 59 MESSAGE_HANDLER(WM_COPYDATA, OnCopyData) |
| 56 MESSAGE_HANDLER(WM_SETCURSOR, OnSetCursor) | 60 MESSAGE_HANDLER(WM_SETCURSOR, OnSetCursor) |
| 57 MESSAGE_HANDLER( | 61 MESSAGE_HANDLER( |
| 58 webkit::npapi::default_plugin::kInstallMissingPluginMessage, | 62 webkit::npapi::default_plugin::kInstallMissingPluginMessage, |
| 59 OnInstallPluginMessage) | 63 OnInstallPluginMessage) |
| 60 END_MSG_MAP() | 64 END_MSG_MAP() |
| 61 | 65 |
| 62 // Initializes the plugin with the instance information, mime type | 66 // Initializes the plugin with the instance information, mime type |
| 63 // and the list of parameters passed down to the plugin from the webpage. | 67 // and the list of parameters passed down to the plugin from the webpage. |
| 64 // | 68 // |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 BOOL& handled); | 199 BOOL& handled); |
| 196 LRESULT OnLButtonDown(UINT message, WPARAM wparam, LPARAM lparam, | 200 LRESULT OnLButtonDown(UINT message, WPARAM wparam, LPARAM lparam, |
| 197 BOOL& handled); | 201 BOOL& handled); |
| 198 LRESULT OnSetCursor(UINT message, WPARAM wparam, LPARAM lparam, | 202 LRESULT OnSetCursor(UINT message, WPARAM wparam, LPARAM lparam, |
| 199 BOOL& handled); | 203 BOOL& handled); |
| 200 // Handles the install plugin message coming from the plugin infobar. | 204 // Handles the install plugin message coming from the plugin infobar. |
| 201 LRESULT OnInstallPluginMessage(UINT message, WPARAM wparam, LPARAM lparam, | 205 LRESULT OnInstallPluginMessage(UINT message, WPARAM wparam, LPARAM lparam, |
| 202 BOOL& handled); | 206 BOOL& handled); |
| 203 | 207 |
| 204 // Refreshes the loaded plugin list and reloads the current page. | 208 // Refreshes the loaded plugin list and reloads the current page. |
| 205 LRESULT OnRefreshPlugins(UINT message, WPARAM wparam, LPARAM lparam, | 209 void RefreshPlugins(); |
| 206 BOOL& handled); | |
| 207 | 210 |
| 208 // Launches the third party plugin installer. This message is | 211 // Launches the third party plugin installer. This message is |
| 209 // received when the request to download the installer, initiated by | 212 // received when the request to download the installer, initiated by |
| 210 // plugin completes. | 213 // plugin completes. |
| 211 LRESULT OnCopyData(UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled); | 214 LRESULT OnCopyData(UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled); |
| 212 | 215 |
| 213 // Displays the plugin install confirmation dialog. | 216 // Displays the plugin install confirmation dialog. |
| 214 void ShowInstallDialog(); | 217 void ShowInstallDialog(); |
| 215 | 218 |
| 216 // Clears the current display state. | 219 // Clears the current display state. |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 PluginInstallerState plugin_installer_state_; | 304 PluginInstallerState plugin_installer_state_; |
| 302 // Used to display the UI for plugin installation. | 305 // Used to display the UI for plugin installation. |
| 303 PluginInstallDialog* install_dialog_; | 306 PluginInstallDialog* install_dialog_; |
| 304 // To enable auto refresh of the plugin window once the installation | 307 // To enable auto refresh of the plugin window once the installation |
| 305 // is complete, we spawn the installation process in a job, and monitor | 308 // is complete, we spawn the installation process in a job, and monitor |
| 306 // IO completion events on the job. When the active process count of the | 309 // IO completion events on the job. When the active process count of the |
| 307 // job falls to zero, we initiate an auto refresh of the plugin list | 310 // job falls to zero, we initiate an auto refresh of the plugin list |
| 308 // which enables the downloaded plugin to be instantiated. | 311 // which enables the downloaded plugin to be instantiated. |
| 309 // The completion events from the job are monitored in an independent | 312 // The completion events from the job are monitored in an independent |
| 310 // thread. | 313 // thread. |
| 311 scoped_refptr<PluginInstallationJobMonitorThread> | 314 scoped_ptr<base::win::ProcessMonitor> installation_job_monitor_thread_; |
| 312 installation_job_monitor_thread_; | |
| 313 // This object handles download and parsing of the plugins database. | 315 // This object handles download and parsing of the plugins database. |
| 314 PluginDatabaseHandler plugin_database_handler_; | 316 PluginDatabaseHandler plugin_database_handler_; |
| 315 // Indicates if the left click to download/refresh should be enabled or not. | 317 // Indicates if the left click to download/refresh should be enabled or not. |
| 316 bool enable_click_; | 318 bool enable_click_; |
| 317 // Handles to the fonts used to display text in the plugin window. | 319 // Handles to the fonts used to display text in the plugin window. |
| 318 HFONT bold_font_; | 320 HFONT bold_font_; |
| 319 HFONT regular_font_; | 321 HFONT regular_font_; |
| 320 HFONT underline_font_; | 322 HFONT underline_font_; |
| 321 // Tooltip Window. | 323 // Tooltip Window. |
| 322 HWND tooltip_; | 324 HWND tooltip_; |
| 323 | 325 |
| 324 // Count of plugin instances. | 326 // Count of plugin instances. |
| 325 static int instance_count_; | 327 static int instance_count_; |
| 326 | 328 |
| 327 // Set to true if the plugin install infobar is to be shown. | 329 // Set to true if the plugin install infobar is to be shown. |
| 328 static bool show_install_infobar_; | 330 static bool show_install_infobar_; |
| 329 | 331 |
| 330 DISALLOW_COPY_AND_ASSIGN(PluginInstallerImpl); | 332 DISALLOW_COPY_AND_ASSIGN(PluginInstallerImpl); |
| 331 }; | 333 }; |
| 332 | 334 |
| 333 | 335 |
| 334 #endif // CHROME_DEFAULT_PLUGIN_PLUGIN_IMPL_WIN_H_ | 336 #endif // CHROME_DEFAULT_PLUGIN_PLUGIN_IMPL_WIN_H_ |
| OLD | NEW |