Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / plugins / plugin_installer.h
blob6cd865927b2b55401280fe1cf796f5eefff5931c
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_interrupt_reasons.h"
13 #include "content/public/browser/download_item.h"
14 #include "url/gurl.h"
16 class PluginInstallerObserver;
17 class WeakPluginInstallerObserver;
19 namespace content {
20 class WebContents;
21 struct WebPluginInfo;
24 class PluginInstaller : public content::DownloadItem::Observer {
25 public:
26 enum InstallerState {
27 INSTALLER_STATE_IDLE,
28 INSTALLER_STATE_DOWNLOADING,
31 PluginInstaller();
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
50 // when finished.
51 void StartInstalling(const GURL& plugin_url,
52 content::WebContents* web_contents);
54 private:
55 void DownloadStarted(content::DownloadItem* item,
56 content::DownloadInterruptReason interrupt_reason);
57 void DownloadError(const std::string& msg);
58 void DownloadCancelled();
60 InstallerState state_;
61 ObserverList<PluginInstallerObserver> observers_;
62 int strong_observer_count_;
63 ObserverList<WeakPluginInstallerObserver> weak_observers_;
65 DISALLOW_COPY_AND_ASSIGN(PluginInstaller);
68 #endif // CHROME_BROWSER_PLUGINS_PLUGIN_INSTALLER_H_