OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_PLUGINS_PLUGIN_INSTALLER_H_ | 5 #ifndef CHROME_BROWSER_PLUGINS_PLUGIN_INSTALLER_H_ |
6 #define CHROME_BROWSER_PLUGINS_PLUGIN_INSTALLER_H_ | 6 #define CHROME_BROWSER_PLUGINS_PLUGIN_INSTALLER_H_ |
7 | 7 |
| 8 #include "base/gtest_prod_util.h" |
8 #include "base/observer_list.h" | 9 #include "base/observer_list.h" |
9 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
10 #include "base/version.h" | 11 #include "base/version.h" |
11 #include "chrome/browser/plugins/plugin_metadata.h" | 12 #include "chrome/browser/plugins/plugin_metadata.h" |
12 #include "content/public/browser/download_interrupt_reasons.h" | 13 #include "content/public/browser/download_interrupt_reasons.h" |
13 #include "content/public/browser/download_item.h" | 14 #include "content/public/browser/download_item.h" |
14 #include "url/gurl.h" | 15 #include "url/gurl.h" |
15 | 16 |
16 class PluginInstallerObserver; | 17 class PluginInstallerObserver; |
17 class WeakPluginInstallerObserver; | 18 class WeakPluginInstallerObserver; |
18 | 19 |
19 namespace content { | 20 namespace content { |
| 21 class DownloadManager; |
20 class WebContents; | 22 class WebContents; |
21 struct WebPluginInfo; | 23 struct WebPluginInfo; |
22 } | 24 } |
23 | 25 |
24 class PluginInstaller : public content::DownloadItem::Observer { | 26 class PluginInstaller : public content::DownloadItem::Observer { |
25 public: | 27 public: |
26 enum InstallerState { | 28 enum InstallerState { |
27 INSTALLER_STATE_IDLE, | 29 INSTALLER_STATE_IDLE, |
28 INSTALLER_STATE_DOWNLOADING, | 30 INSTALLER_STATE_DOWNLOADING, |
29 }; | 31 }; |
(...skipping 15 matching lines...) Expand all Loading... |
45 // Opens the download URL in a new tab. | 47 // Opens the download URL in a new tab. |
46 void OpenDownloadURL(const GURL& plugin_url, | 48 void OpenDownloadURL(const GURL& plugin_url, |
47 content::WebContents* web_contents); | 49 content::WebContents* web_contents); |
48 | 50 |
49 // Starts downloading the download URL and opens the downloaded file | 51 // Starts downloading the download URL and opens the downloaded file |
50 // when finished. | 52 // when finished. |
51 void StartInstalling(const GURL& plugin_url, | 53 void StartInstalling(const GURL& plugin_url, |
52 content::WebContents* web_contents); | 54 content::WebContents* web_contents); |
53 | 55 |
54 private: | 56 private: |
| 57 void StartInstallingWithDownloadManager( |
| 58 const GURL& plugin_url, |
| 59 content::WebContents* web_contents, |
| 60 content::DownloadManager* download_manager); |
55 void DownloadStarted(content::DownloadItem* item, | 61 void DownloadStarted(content::DownloadItem* item, |
56 content::DownloadInterruptReason interrupt_reason); | 62 content::DownloadInterruptReason interrupt_reason); |
57 void DownloadError(const std::string& msg); | 63 void DownloadError(const std::string& msg); |
58 void DownloadCancelled(); | 64 void DownloadCancelled(); |
59 | 65 |
60 InstallerState state_; | 66 InstallerState state_; |
61 ObserverList<PluginInstallerObserver> observers_; | 67 ObserverList<PluginInstallerObserver> observers_; |
62 int strong_observer_count_; | 68 int strong_observer_count_; |
63 ObserverList<WeakPluginInstallerObserver> weak_observers_; | 69 ObserverList<WeakPluginInstallerObserver> weak_observers_; |
64 | 70 |
| 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); |
65 DISALLOW_COPY_AND_ASSIGN(PluginInstaller); | 75 DISALLOW_COPY_AND_ASSIGN(PluginInstaller); |
66 }; | 76 }; |
67 | 77 |
68 #endif // CHROME_BROWSER_PLUGINS_PLUGIN_INSTALLER_H_ | 78 #endif // CHROME_BROWSER_PLUGINS_PLUGIN_INSTALLER_H_ |
OLD | NEW |