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

Unified Diff: chrome/browser/plugin_installer.cc

Issue 8851007: WIP / Do not commit (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/plugin_installer.h ('k') | chrome/browser/plugin_installer_infobar_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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());
+}
« no previous file with comments | « chrome/browser/plugin_installer.h ('k') | chrome/browser/plugin_installer_infobar_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698