Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / plugins / plugin_metadata.h
blob99ed7d3202150e26a1c167c6b4f23467760180eb
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_METADATA_H_
6 #define CHROME_BROWSER_PLUGINS_PLUGIN_METADATA_H_
8 #include <map>
10 #include "base/memory/scoped_ptr.h"
11 #include "base/strings/string16.h"
12 #include "base/version.h"
13 #include "url/gurl.h"
15 namespace content {
16 struct WebPluginInfo;
19 class PluginMetadata {
20 public:
21 // Information about a certain version of the plugin.
22 enum SecurityStatus {
23 SECURITY_STATUS_UP_TO_DATE,
24 SECURITY_STATUS_OUT_OF_DATE,
25 SECURITY_STATUS_REQUIRES_AUTHORIZATION,
28 // Used by about:plugins to disable Reader plugin when internal PDF viewer is
29 // enabled.
30 static const char kAdobeReaderGroupName[];
31 static const char kJavaGroupName[];
32 static const char kQuickTimeGroupName[];
33 static const char kShockwaveGroupName[];
34 static const char kRealPlayerGroupName[];
35 static const char kSilverlightGroupName[];
36 static const char kWindowsMediaPlayerGroupName[];
37 static const char kGoogleTalkGroupName[];
38 static const char kGoogleEarthGroupName[];
40 PluginMetadata(const std::string& identifier,
41 const base::string16& name,
42 bool url_for_display,
43 const GURL& plugin_url,
44 const GURL& help_url,
45 const base::string16& group_name_matcher,
46 const std::string& language);
47 ~PluginMetadata();
49 // Unique identifier for the plugin.
50 const std::string& identifier() const { return identifier_; }
52 // Human-readable name of the plugin.
53 const base::string16& name() const { return name_; }
55 // If |url_for_display| is false, |plugin_url| is the URL of the download page
56 // for the plugin, which should be opened in a new tab. If it is true,
57 // |plugin_url| is the URL of the plugin installer binary, which can be
58 // directly downloaded.
59 bool url_for_display() const { return url_for_display_; }
60 const GURL& plugin_url() const { return plugin_url_; }
62 // URL to open when the user clicks on the "Problems installing?" link.
63 const GURL& help_url() const { return help_url_; }
65 const std::string& language() const { return language_; }
67 bool HasMimeType(const std::string& mime_type) const;
68 void AddMimeType(const std::string& mime_type);
69 void AddMatchingMimeType(const std::string& mime_type);
71 // Adds information about a plugin version.
72 void AddVersion(const Version& version, SecurityStatus status);
74 // Checks if |plugin| mime types match all |matching_mime_types_|.
75 // If there is no |matching_mime_types_|, |group_name_matcher_| is used
76 // for matching.
77 bool MatchesPlugin(const content::WebPluginInfo& plugin);
79 // If |status_str| describes a valid security status, writes it to |status|
80 // and returns true, else returns false and leaves |status| unchanged.
81 static bool ParseSecurityStatus(const std::string& status_str,
82 SecurityStatus* status);
84 // Returns the security status for the given plugin (i.e. whether it is
85 // considered out-of-date, etc.)
86 SecurityStatus GetSecurityStatus(const content::WebPluginInfo& plugin) const;
88 scoped_ptr<PluginMetadata> Clone() const;
90 private:
91 struct VersionComparator {
92 bool operator() (const Version& lhs, const Version& rhs) const;
95 std::string identifier_;
96 base::string16 name_;
97 base::string16 group_name_matcher_;
98 bool url_for_display_;
99 GURL plugin_url_;
100 GURL help_url_;
101 std::string language_;
102 std::map<Version, SecurityStatus, VersionComparator> versions_;
103 std::vector<std::string> all_mime_types_;
104 std::vector<std::string> matching_mime_types_;
106 DISALLOW_COPY_AND_ASSIGN(PluginMetadata);
109 #endif // CHROME_BROWSER_PLUGINS_PLUGIN_METADATA_H_