| Index: chrome/browser/plugin_installer.cc
|
| diff --git a/chrome/browser/plugin_installer.cc b/chrome/browser/plugin_installer.cc
|
| index 00d6c493931897a3fa365d02a3cbcacc65692e70..3bdc1b17ed202da190d3ef249865f01bf7c45b01 100644
|
| --- a/chrome/browser/plugin_installer.cc
|
| +++ b/chrome/browser/plugin_installer.cc
|
| @@ -4,6 +4,13 @@
|
|
|
| #include "chrome/browser/plugin_installer.h"
|
|
|
| +#include "base/bind.h"
|
| +#include "base/bind_helpers.h"
|
| +#include "base/process.h"
|
| +#include "chrome/browser/platform_util.h"
|
| +#include "chrome/browser/plugin_download_helper.h"
|
| +#include "chrome/browser/plugin_installer_observer.h"
|
| +
|
| PluginInstaller::~PluginInstaller() {
|
| }
|
|
|
| @@ -12,9 +19,53 @@ PluginInstaller::PluginInstaller(const std::string& identifier,
|
| const GURL& help_url,
|
| const string16& name,
|
| bool url_for_display)
|
| - : identifier_(identifier),
|
| + : state_(kStateIdle),
|
| + identifier_(identifier),
|
| plugin_url_(plugin_url),
|
| help_url_(help_url),
|
| name_(name),
|
| url_for_display_(url_for_display) {
|
| }
|
| +
|
| +void PluginInstaller::AddObserver(PluginInstallerObserver* observer) {
|
| + observers_.AddObserver(observer);
|
| +}
|
| +
|
| +void PluginInstaller::RemoveObserver(PluginInstallerObserver* observer) {
|
| + observers_.RemoveObserver(observer);
|
| +}
|
| +
|
| +void PluginInstaller::StartInstalling(
|
| + net::URLRequestContextGetter* request_context) {
|
| + DCHECK(state_ == kStateIdle);
|
| + DCHECK(!url_for_display_);
|
| + state_ = kStateDownloading;
|
| + FOR_EACH_OBSERVER(PluginInstallerObserver, observers_, DidStartDownload());
|
| + PluginDownloadUrlHelper* downloader = new PluginDownloadUrlHelper();
|
| + downloader->InitiateDownload(
|
| + plugin_url_,
|
| + request_context,
|
| + base::Bind(&PluginInstaller::DidFinishDownload, base::Unretained(this)));
|
| +}
|
| +
|
| +void PluginInstaller::DidFinishDownload(const FilePath& downloaded_file) {
|
| + DCHECK(state_ == kStateDownloading);
|
| + state_ = kStateIdle;
|
| + LOG(ERROR) << "Plug-in installer is at \"" << downloaded_file.value() << "\"";
|
| + FOR_EACH_OBSERVER(PluginInstallerObserver, observers_, DidFinishDownload());
|
| + base::ProcessHandle handle = base::kNullProcessHandle;
|
| + platform_util::OpenItem(downloaded_file, &handle);
|
| +#if defined(OS_WIN)
|
| + if (handle != kNullProcessHandle) {
|
| + installation_process_monitor_.Initialize(
|
| + handle,
|
| + base::Bind(&PluginInstaller::DidFinishInstallation,
|
| + base::Unretained(this)));
|
| + }
|
| +#endif
|
| +}
|
| +
|
| +void PluginInstaller::DidFinishInstallation() {
|
| + FOR_EACH_OBSERVER(PluginInstallerObserver, observers_,
|
| + DidFinishInstallation());
|
| +}
|
|
|