[Metrics] Make MetricsStateManager take a callback param to check if UMA is enabled.
[chromium-blink-merge.git] / chrome / browser / plugins / plugin_installer.h
blob81d3447b7ddfe2e5b2aac51fcdced182ae1ccd96
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/gtest_prod_util.h"
9 #include "base/observer_list.h"
10 #include "base/strings/string16.h"
11 #include "base/version.h"
12 #include "chrome/browser/plugins/plugin_metadata.h"
13 #include "content/public/browser/download_interrupt_reasons.h"
14 #include "content/public/browser/download_item.h"
15 #include "url/gurl.h"
17 class PluginInstallerObserver;
18 class WeakPluginInstallerObserver;
20 namespace content {
21 class DownloadManager;
22 class WebContents;
23 struct WebPluginInfo;
26 class PluginInstaller : public content::DownloadItem::Observer {
27 public:
28 enum InstallerState {
29 INSTALLER_STATE_IDLE,
30 INSTALLER_STATE_DOWNLOADING,
33 PluginInstaller();
34 virtual ~PluginInstaller();
36 virtual void OnDownloadUpdated(content::DownloadItem* download) OVERRIDE;
37 virtual void OnDownloadDestroyed(content::DownloadItem* download) OVERRIDE;
39 void AddObserver(PluginInstallerObserver* observer);
40 void RemoveObserver(PluginInstallerObserver* observer);
42 void AddWeakObserver(WeakPluginInstallerObserver* observer);
43 void RemoveWeakObserver(WeakPluginInstallerObserver* observer);
45 InstallerState state() const { return state_; }
47 // Opens the download URL in a new tab.
48 void OpenDownloadURL(const GURL& plugin_url,
49 content::WebContents* web_contents);
51 // Starts downloading the download URL and opens the downloaded file
52 // when finished.
53 void StartInstalling(const GURL& plugin_url,
54 content::WebContents* web_contents);
56 private:
57 void StartInstallingWithDownloadManager(
58 const GURL& plugin_url,
59 content::WebContents* web_contents,
60 content::DownloadManager* download_manager);
61 void DownloadStarted(content::DownloadItem* item,
62 content::DownloadInterruptReason interrupt_reason);
63 void DownloadError(const std::string& msg);
64 void DownloadCancelled();
66 InstallerState state_;
67 ObserverList<PluginInstallerObserver> observers_;
68 int strong_observer_count_;
69 ObserverList<WeakPluginInstallerObserver> weak_observers_;
71 FRIEND_TEST_ALL_PREFIXES(PluginInstallerTest,
72 StartInstalling_SuccessfulDownload);
73 FRIEND_TEST_ALL_PREFIXES(PluginInstallerTest, StartInstalling_FailedStart);
74 FRIEND_TEST_ALL_PREFIXES(PluginInstallerTest, StartInstalling_Interrupted);
75 DISALLOW_COPY_AND_ASSIGN(PluginInstaller);
78 #endif // CHROME_BROWSER_PLUGINS_PLUGIN_INSTALLER_H_