Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Side by Side Diff: chrome/browser/plugin_installer.h

Issue 10263022: Move version metadata from PluginGroup into PluginInstaller. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #pragma once 7 #pragma once
8 8
9 #include "base/observer_list.h" 9 #include "base/observer_list.h"
10 #include "base/string16.h" 10 #include "base/string16.h"
11 #include "base/version.h"
11 #include "googleurl/src/gurl.h" 12 #include "googleurl/src/gurl.h"
12 #include "content/public/browser/download_id.h" 13 #include "content/public/browser/download_id.h"
13 #include "content/public/browser/download_item.h" 14 #include "content/public/browser/download_item.h"
14 #include "net/base/net_errors.h" 15 #include "net/base/net_errors.h"
15 16
16 class FilePath; 17 class FilePath;
17 class PluginInstallerObserver; 18 class PluginInstallerObserver;
18 class TabContentsWrapper; 19 class TabContentsWrapper;
19 class WeakPluginInstallerObserver; 20 class WeakPluginInstallerObserver;
20 21
21 namespace content { 22 namespace content {
22 class WebContents; 23 class WebContents;
23 } 24 }
24 25
26 namespace webkit {
27 struct WebPluginInfo;
28 }
29
25 class PluginInstaller : public content::DownloadItem::Observer { 30 class PluginInstaller : public content::DownloadItem::Observer {
26 public: 31 public:
27 enum State { 32 enum InstallerState {
28 kStateIdle, 33 INSTALLER_STATE_IDLE,
29 kStateDownloading, 34 INSTALLER_STATE_DOWNLOADING,
35 };
36
37 // Information about a certain version of the plug-in.
38 enum SecurityStatus {
39 SECURITY_STATUS_UP_TO_DATE,
40 SECURITY_STATUS_OUT_OF_DATE,
41 SECURITY_STATUS_REQUIRES_AUTHORIZATION,
30 }; 42 };
31 43
32 PluginInstaller(const std::string& identifier, 44 PluginInstaller(const std::string& identifier,
33 const GURL& plugin_url,
34 const GURL& help_url,
35 const string16& name, 45 const string16& name,
36 bool url_for_display, 46 bool url_for_display,
37 bool requires_authorization); 47 const GURL& plugin_url,
48 const GURL& help_url);
38 virtual ~PluginInstaller(); 49 virtual ~PluginInstaller();
39 50
40 virtual void OnDownloadUpdated(content::DownloadItem* download) OVERRIDE; 51 virtual void OnDownloadUpdated(content::DownloadItem* download) OVERRIDE;
41 52
42 virtual void OnDownloadOpened(content::DownloadItem* download) OVERRIDE; 53 virtual void OnDownloadOpened(content::DownloadItem* download) OVERRIDE;
43 54
44 void AddObserver(PluginInstallerObserver* observer); 55 void AddObserver(PluginInstallerObserver* observer);
45 void RemoveObserver(PluginInstallerObserver* observer); 56 void RemoveObserver(PluginInstallerObserver* observer);
46 57
47 void AddWeakObserver(WeakPluginInstallerObserver* observer); 58 void AddWeakObserver(WeakPluginInstallerObserver* observer);
48 void RemoveWeakObserver(WeakPluginInstallerObserver* observer); 59 void RemoveWeakObserver(WeakPluginInstallerObserver* observer);
49 60
50 State state() const { return state_; } 61 // Unique identifier for the plug-in.
51
52 // Unique identifier for the plug-in. Should be kept in sync with the
53 // identifier in plugin_list.cc.
54 const std::string& identifier() const { return identifier_; } 62 const std::string& identifier() const { return identifier_; }
55 63
56 // Human-readable name of the plug-in. 64 // Human-readable name of the plug-in.
57 const string16& name() const { return name_; } 65 const string16& name() const { return name_; }
58 66
59 // Whether the plug-in requires user authorization to run.
60 bool requires_authorization() const { return requires_authorization_; }
61
62 // If |url_for_display| is false, |plugin_url| is the URL of the download page 67 // If |url_for_display| is false, |plugin_url| is the URL of the download page
63 // for the plug-in, which should be opened in a new tab. If it is true, 68 // for the plug-in, which should be opened in a new tab. If it is true,
64 // |plugin_url| is the URL of the plug-in installer binary, which can be 69 // |plugin_url| is the URL of the plug-in installer binary, which can be
65 // directly downloaded. 70 // directly downloaded.
66 bool url_for_display() const { return url_for_display_; } 71 bool url_for_display() const { return url_for_display_; }
67 const GURL& plugin_url() const { return plugin_url_; } 72 const GURL& plugin_url() const { return plugin_url_; }
68 73
69 // URL to open when the user clicks on the "Problems installing?" link. 74 // URL to open when the user clicks on the "Problems installing?" link.
70 const GURL& help_url() const { return help_url_; } 75 const GURL& help_url() const { return help_url_; }
71 76
77 InstallerState state() const { return state_; }
78
79 // Adds information about a plug-in version.
80 void AddVersion(const Version& version, SecurityStatus status);
81
82 // Returns the security status for the given plug-in (i.e. whether it is
83 // considered out-of-date, etc.)
84 SecurityStatus GetSecurityStatus(const webkit::WebPluginInfo& plugin) const;
85
72 // Opens the download URL in a new tab. This method should only be called if 86 // Opens the download URL in a new tab. This method should only be called if
73 // |url_for_display| returns true. 87 // |url_for_display| returns true.
74 void OpenDownloadURL(content::WebContents* web_contents); 88 void OpenDownloadURL(content::WebContents* web_contents);
75 89
76 // Starts downloading the download URL and opens the downloaded file 90 // Starts downloading the download URL and opens the downloaded file
77 // when finished. This method should only be called if |url_for_display| 91 // when finished. This method should only be called if |url_for_display|
78 // returns false. 92 // returns false.
79 void StartInstalling(TabContentsWrapper* wrapper); 93 void StartInstalling(TabContentsWrapper* wrapper);
80 94
95 // If |status_str| describes a valid security status, writes it to |status|
96 // and returns true, else returns false and leaves |status| unchanged.
97 static bool ParseSecurityStatus(const std::string& status_str,
98 SecurityStatus* status);
99
81 private: 100 private:
101 struct VersionComparator {
102 bool operator() (const Version& lhs, const Version& rhs) const;
103 };
104
82 void DownloadStarted(scoped_refptr<content::DownloadManager> dlm, 105 void DownloadStarted(scoped_refptr<content::DownloadManager> dlm,
83 content::DownloadId download_id, 106 content::DownloadId download_id,
84 net::Error error); 107 net::Error error);
85 void DownloadError(const std::string& msg); 108 void DownloadError(const std::string& msg);
86 void DownloadCancelled(); 109 void DownloadCancelled();
87 110
88 State state_; 111 std::string identifier_;
112 string16 name_;
113 bool url_for_display_;
114 GURL plugin_url_;
115 GURL help_url_;
116 std::map<Version, SecurityStatus, VersionComparator> versions_;
117
118 InstallerState state_;
89 ObserverList<PluginInstallerObserver> observers_; 119 ObserverList<PluginInstallerObserver> observers_;
90 ObserverList<WeakPluginInstallerObserver> weak_observers_; 120 ObserverList<WeakPluginInstallerObserver> weak_observers_;
91 121
92 std::string identifier_;
93 GURL plugin_url_;
94 GURL help_url_;
95 string16 name_;
96 bool url_for_display_;
97 bool requires_authorization_;
98
99 DISALLOW_COPY_AND_ASSIGN(PluginInstaller); 122 DISALLOW_COPY_AND_ASSIGN(PluginInstaller);
100 }; 123 };
101 124
102 #endif // CHROME_BROWSER_PLUGIN_INSTALLER_H_ 125 #endif // CHROME_BROWSER_PLUGIN_INSTALLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698