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_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 | 7 |
8 #include "base/observer_list.h" | 8 #include "base/observer_list.h" |
9 #include "base/string16.h" | 9 #include "base/string16.h" |
10 #include "base/version.h" | 10 #include "base/version.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 enum SecurityStatus { | 37 enum SecurityStatus { |
38 SECURITY_STATUS_UP_TO_DATE, | 38 SECURITY_STATUS_UP_TO_DATE, |
39 SECURITY_STATUS_OUT_OF_DATE, | 39 SECURITY_STATUS_OUT_OF_DATE, |
40 SECURITY_STATUS_REQUIRES_AUTHORIZATION, | 40 SECURITY_STATUS_REQUIRES_AUTHORIZATION, |
41 }; | 41 }; |
42 | 42 |
43 PluginInstaller(const std::string& identifier, | 43 PluginInstaller(const std::string& identifier, |
44 const string16& name, | 44 const string16& name, |
45 bool url_for_display, | 45 bool url_for_display, |
46 const GURL& plugin_url, | 46 const GURL& plugin_url, |
47 const GURL& help_url); | 47 const GURL& help_url, |
| 48 const string16& group_name_matcher); |
48 virtual ~PluginInstaller(); | 49 virtual ~PluginInstaller(); |
49 | 50 |
50 virtual void OnDownloadUpdated(content::DownloadItem* download) OVERRIDE; | 51 virtual void OnDownloadUpdated(content::DownloadItem* download) OVERRIDE; |
51 virtual void OnDownloadDestroyed(content::DownloadItem* download) OVERRIDE; | 52 virtual void OnDownloadDestroyed(content::DownloadItem* download) OVERRIDE; |
52 | 53 |
53 void AddObserver(PluginInstallerObserver* observer); | 54 void AddObserver(PluginInstallerObserver* observer); |
54 void RemoveObserver(PluginInstallerObserver* observer); | 55 void RemoveObserver(PluginInstallerObserver* observer); |
55 | 56 |
56 void AddWeakObserver(WeakPluginInstallerObserver* observer); | 57 void AddWeakObserver(WeakPluginInstallerObserver* observer); |
57 void RemoveWeakObserver(WeakPluginInstallerObserver* observer); | 58 void RemoveWeakObserver(WeakPluginInstallerObserver* observer); |
58 | 59 |
59 // Unique identifier for the plug-in. | 60 // Unique identifier for the plug-in. |
60 const std::string& identifier() const { return identifier_; } | 61 const std::string& identifier() const { return identifier_; } |
61 | 62 |
62 // Human-readable name of the plug-in. | 63 // Human-readable name of the plug-in. |
63 const string16& name() const { return name_; } | 64 const string16& name() const { return name_; } |
64 | 65 |
| 66 // A substring used in matching similar plug-ins. |
| 67 const string16& group_name_matcher() const { return group_name_matcher_; } |
| 68 |
65 // If |url_for_display| is false, |plugin_url| is the URL of the download page | 69 // If |url_for_display| is false, |plugin_url| is the URL of the download page |
66 // for the plug-in, which should be opened in a new tab. If it is true, | 70 // for the plug-in, which should be opened in a new tab. If it is true, |
67 // |plugin_url| is the URL of the plug-in installer binary, which can be | 71 // |plugin_url| is the URL of the plug-in installer binary, which can be |
68 // directly downloaded. | 72 // directly downloaded. |
69 bool url_for_display() const { return url_for_display_; } | 73 bool url_for_display() const { return url_for_display_; } |
70 const GURL& plugin_url() const { return plugin_url_; } | 74 const GURL& plugin_url() const { return plugin_url_; } |
71 | 75 |
72 // URL to open when the user clicks on the "Problems installing?" link. | 76 // URL to open when the user clicks on the "Problems installing?" link. |
73 const GURL& help_url() const { return help_url_; } | 77 const GURL& help_url() const { return help_url_; } |
74 | 78 |
(...skipping 13 matching lines...) Expand all Loading... |
88 // Starts downloading the download URL and opens the downloaded file | 92 // Starts downloading the download URL and opens the downloaded file |
89 // when finished. This method should only be called if |url_for_display| | 93 // when finished. This method should only be called if |url_for_display| |
90 // returns false. | 94 // returns false. |
91 void StartInstalling(TabContents* tab_contents); | 95 void StartInstalling(TabContents* tab_contents); |
92 | 96 |
93 // If |status_str| describes a valid security status, writes it to |status| | 97 // If |status_str| describes a valid security status, writes it to |status| |
94 // and returns true, else returns false and leaves |status| unchanged. | 98 // and returns true, else returns false and leaves |status| unchanged. |
95 static bool ParseSecurityStatus(const std::string& status_str, | 99 static bool ParseSecurityStatus(const std::string& status_str, |
96 SecurityStatus* status); | 100 SecurityStatus* status); |
97 | 101 |
| 102 // Returns matcher part of configured plug-in group names, |
| 103 // or the filename without extension if the name is empty. |
| 104 static string16 GetGroupName(const webkit::WebPluginInfo& plugin); |
| 105 |
| 106 // Generates the (short) identifier string for the given plug-in. |
| 107 // It searches in configured plug-in groups first, and returns the identifier |
| 108 // if a match was found, otherwise it uses the base name of the file path. |
| 109 static std::string GetIdentifier(const webkit::WebPluginInfo& plugin); |
| 110 |
| 111 // Gets the plug-in group name using the plug-in identifier. |
| 112 static string16 GetGroupNameByIdentifier( |
| 113 const std::vector<webkit::WebPluginInfo>& plugins, |
| 114 const std::string& identifier); |
| 115 |
98 private: | 116 private: |
99 struct VersionComparator { | 117 struct VersionComparator { |
100 bool operator() (const Version& lhs, const Version& rhs) const; | 118 bool operator() (const Version& lhs, const Version& rhs) const; |
101 }; | 119 }; |
102 | 120 |
103 void DownloadStarted(scoped_refptr<content::DownloadManager> dlm, | 121 void DownloadStarted(scoped_refptr<content::DownloadManager> dlm, |
104 content::DownloadId download_id, | 122 content::DownloadId download_id, |
105 net::Error error); | 123 net::Error error); |
106 void DownloadError(const std::string& msg); | 124 void DownloadError(const std::string& msg); |
107 void DownloadCancelled(); | 125 void DownloadCancelled(); |
| 126 static PluginInstaller* MatchWithConfiguredPlugins( |
| 127 const webkit::WebPluginInfo& plugin); |
108 | 128 |
109 std::string identifier_; | 129 std::string identifier_; |
110 string16 name_; | 130 string16 name_; |
| 131 string16 group_name_matcher_; |
111 bool url_for_display_; | 132 bool url_for_display_; |
112 GURL plugin_url_; | 133 GURL plugin_url_; |
113 GURL help_url_; | 134 GURL help_url_; |
114 std::map<Version, SecurityStatus, VersionComparator> versions_; | 135 std::map<Version, SecurityStatus, VersionComparator> versions_; |
115 | 136 |
116 InstallerState state_; | 137 InstallerState state_; |
117 ObserverList<PluginInstallerObserver> observers_; | 138 ObserverList<PluginInstallerObserver> observers_; |
118 ObserverList<WeakPluginInstallerObserver> weak_observers_; | 139 ObserverList<WeakPluginInstallerObserver> weak_observers_; |
119 | 140 |
120 DISALLOW_COPY_AND_ASSIGN(PluginInstaller); | 141 DISALLOW_COPY_AND_ASSIGN(PluginInstaller); |
121 }; | 142 }; |
122 | 143 |
123 #endif // CHROME_BROWSER_PLUGIN_INSTALLER_H_ | 144 #endif // CHROME_BROWSER_PLUGIN_INSTALLER_H_ |
OLD | NEW |