1 // Copyright (c) 2012 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.
5 #ifndef CHROME_BROWSER_PLUGINS_PLUGIN_INSTALLER_H_
6 #define CHROME_BROWSER_PLUGINS_PLUGIN_INSTALLER_H_
8 #include "base/observer_list.h"
9 #include "base/strings/string16.h"
10 #include "base/version.h"
11 #include "chrome/browser/plugins/plugin_metadata.h"
12 #include "content/public/browser/download_item.h"
13 #include "net/base/net_errors.h"
16 class PluginInstallerObserver
;
17 class WeakPluginInstallerObserver
;
24 class PluginInstaller
: public content::DownloadItem::Observer
{
28 INSTALLER_STATE_DOWNLOADING
,
32 virtual ~PluginInstaller();
34 virtual void OnDownloadUpdated(content::DownloadItem
* download
) OVERRIDE
;
35 virtual void OnDownloadDestroyed(content::DownloadItem
* download
) OVERRIDE
;
37 void AddObserver(PluginInstallerObserver
* observer
);
38 void RemoveObserver(PluginInstallerObserver
* observer
);
40 void AddWeakObserver(WeakPluginInstallerObserver
* observer
);
41 void RemoveWeakObserver(WeakPluginInstallerObserver
* observer
);
43 InstallerState
state() const { return state_
; }
45 // Opens the download URL in a new tab.
46 void OpenDownloadURL(const GURL
& plugin_url
,
47 content::WebContents
* web_contents
);
49 // Starts downloading the download URL and opens the downloaded file
51 void StartInstalling(const GURL
& plugin_url
,
52 content::WebContents
* web_contents
);
55 void DownloadStarted(content::DownloadItem
* item
, net::Error error
);
56 void DownloadError(const std::string
& msg
);
57 void DownloadCancelled();
59 InstallerState state_
;
60 ObserverList
<PluginInstallerObserver
> observers_
;
61 int strong_observer_count_
;
62 ObserverList
<WeakPluginInstallerObserver
> weak_observers_
;
64 DISALLOW_COPY_AND_ASSIGN(PluginInstaller
);
67 #endif // CHROME_BROWSER_PLUGINS_PLUGIN_INSTALLER_H_