| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_PLUGIN_INSTALLER_H_ | 5 #ifndef CHROME_BROWSER_PLUGIN_INSTALLER_H_ |
| 6 #define CHROME_BROWSER_PLUGIN_INSTALLER_H_ | 6 #define CHROME_BROWSER_PLUGIN_INSTALLER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/observer_list.h" |
| 9 #include "base/string16.h" | 10 #include "base/string16.h" |
| 10 #include "googleurl/src/gurl.h" | 11 #include "googleurl/src/gurl.h" |
| 11 | 12 |
| 13 #if defined(OS_WINDOWS) |
| 14 #include "base/win/process_monitor.h" |
| 15 #endif |
| 16 |
| 17 class FilePath; |
| 18 class PluginInstallerObserver; |
| 19 |
| 20 namespace net { |
| 21 class URLRequestContextGetter; |
| 22 } |
| 23 |
| 12 class PluginInstaller { | 24 class PluginInstaller { |
| 13 public: | 25 public: |
| 26 enum State { |
| 27 kStateIdle, |
| 28 kStateDownloading, |
| 29 kStateInstalling, |
| 30 }; |
| 31 |
| 14 PluginInstaller(const std::string& identifier, | 32 PluginInstaller(const std::string& identifier, |
| 15 const GURL& plugin_url, | 33 const GURL& plugin_url, |
| 16 const GURL& help_url, | 34 const GURL& help_url, |
| 17 const string16& name, | 35 const string16& name, |
| 18 bool url_for_display); | 36 bool url_for_display); |
| 19 ~PluginInstaller(); | 37 ~PluginInstaller(); |
| 20 | 38 |
| 39 State state() { return state_; } |
| 40 |
| 41 void AddObserver(PluginInstallerObserver* observer); |
| 42 void RemoveObserver(PluginInstallerObserver* observer); |
| 43 |
| 21 // Unique identifier for the plug-in. Should be kept in sync with the | 44 // Unique identifier for the plug-in. Should be kept in sync with the |
| 22 // identifier in plugin_list.cc. | 45 // identifier in plugin_list.cc. |
| 23 const std::string& identifier() const { return identifier_; } | 46 const std::string& identifier() const { return identifier_; } |
| 24 | 47 |
| 25 // Human-readable name of the plug-in. | 48 // Human-readable name of the plug-in. |
| 26 const string16& name() const { return name_; } | 49 const string16& name() const { return name_; } |
| 27 | 50 |
| 28 // If |url_for_display| is false, |plugin_url| is the URL of the download page | 51 // If |url_for_display| is false, |plugin_url| is the URL of the download page |
| 29 // for the plug-in, which should be opened in a new tab. If it is true, | 52 // for the plug-in, which should be opened in a new tab. If it is true, |
| 30 // |plugin_url| is the URL of the plug-in installer binary, which can be | 53 // |plugin_url| is the URL of the plug-in installer binary, which can be |
| 31 // directly downloaded. | 54 // directly downloaded. |
| 32 bool url_for_display() const { return url_for_display_; } | 55 bool url_for_display() const { return url_for_display_; } |
| 33 const GURL& plugin_url() const { return plugin_url_; } | 56 const GURL& plugin_url() const { return plugin_url_; } |
| 34 | 57 |
| 35 // URL to open when the user clicks on the "Problems installing?" link. | 58 // URL to open when the user clicks on the "Problems installing?" link. |
| 36 const GURL& help_url() const { return help_url_; } | 59 const GURL& help_url() const { return help_url_; } |
| 37 | 60 |
| 61 void StartInstalling(net::URLRequestContextGetter* request_context); |
| 62 |
| 38 private: | 63 private: |
| 64 void DidFinishDownload(const FilePath& downloaded_file); |
| 65 void DidFinishInstallation(); |
| 66 |
| 67 State state_; |
| 68 ObserverList<PluginInstallerObserver> observers_; |
| 69 |
| 70 #if defined(OS_WINDOWS) |
| 71 base::win::ProcessMonitor installation_process_monitor_; |
| 72 #endif |
| 73 |
| 39 std::string identifier_; | 74 std::string identifier_; |
| 40 GURL plugin_url_; | 75 GURL plugin_url_; |
| 41 GURL help_url_; | 76 GURL help_url_; |
| 42 string16 name_; | 77 string16 name_; |
| 43 bool url_for_display_; | 78 bool url_for_display_; |
| 44 | 79 |
| 45 DISALLOW_COPY_AND_ASSIGN(PluginInstaller); | 80 DISALLOW_COPY_AND_ASSIGN(PluginInstaller); |
| 46 }; | 81 }; |
| 47 | 82 |
| 48 #endif // CHROME_BROWSER_PLUGIN_INSTALLER_H_ | 83 #endif // CHROME_BROWSER_PLUGIN_INSTALLER_H_ |
| OLD | NEW |