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

Side by Side Diff: webkit/glue/plugins/webplugininfo.cc

Issue 5699005: Policy: Re-enabled plugin still disabled (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make windows compiler even happier. Created 10 years 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #include "webkit/glue/plugins/webplugininfo.h" 5 #include "webkit/glue/plugins/webplugininfo.h"
6 6
7 #include "base/logging.h"
8 #include "net/base/mime_util.h"
9
10 const int WebPluginInfo::USER = 1;
11 const int WebPluginInfo::MANAGED = 2;
12
7 WebPluginMimeType::WebPluginMimeType() {} 13 WebPluginMimeType::WebPluginMimeType() {}
8 14
9 WebPluginMimeType::~WebPluginMimeType() {} 15 WebPluginMimeType::~WebPluginMimeType() {}
10 16
11 WebPluginInfo::WebPluginInfo() : enabled(false) {} 17 WebPluginInfo::WebPluginInfo()
18 : enabled(false),
19 reason(USER),
20 priority(0) {
21 }
12 22
13 WebPluginInfo::WebPluginInfo(const WebPluginInfo& rhs) 23 WebPluginInfo::WebPluginInfo(const WebPluginInfo& rhs)
14 : name(rhs.name), 24 : name(rhs.name),
15 path(rhs.path), 25 path(rhs.path),
16 version(rhs.version), 26 version(rhs.version),
17 desc(rhs.desc), 27 desc(rhs.desc),
18 mime_types(rhs.mime_types), 28 mime_types(rhs.mime_types),
19 enabled(rhs.enabled) { 29 enabled(rhs.enabled),
30 reason(rhs.reason),
31 priority(rhs.priority) {
20 } 32 }
21 33
22 WebPluginInfo::~WebPluginInfo() {} 34 WebPluginInfo::~WebPluginInfo() {}
23 35
24 WebPluginInfo& WebPluginInfo::operator=(const WebPluginInfo& rhs) { 36 WebPluginInfo& WebPluginInfo::operator=(const WebPluginInfo& rhs) {
25 name = rhs.name; 37 name = rhs.name;
26 path = rhs.path; 38 path = rhs.path;
27 version = rhs.version; 39 version = rhs.version;
28 desc = rhs.desc; 40 desc = rhs.desc;
29 mime_types = rhs.mime_types; 41 mime_types = rhs.mime_types;
30 enabled = rhs.enabled; 42 enabled = rhs.enabled;
43 reason = rhs.reason;
44 priority = rhs.priority;
31 return *this; 45 return *this;
32 } 46 }
33 47
34 WebPluginInfo::WebPluginInfo(const string16& fake_name, 48 WebPluginInfo::WebPluginInfo(const string16& fake_name,
49 const FilePath& fake_path,
35 const string16& fake_version, 50 const string16& fake_version,
36 const string16& fake_desc) 51 const string16& fake_desc)
37 : name(fake_name), 52 : name(fake_name),
38 path(), 53 path(fake_path),
39 version(fake_version), 54 version(fake_version),
40 desc(fake_desc), 55 desc(fake_desc),
41 mime_types(), 56 mime_types(),
42 enabled(true) { 57 enabled(true),
58 reason(USER),
59 priority(0) {
43 } 60 }
44 61
62 bool WebPluginInfo::Enable(int new_reason) {
63 // If already enabled just upgrade the reason.
64 if (enabled) {
65 reason |= new_reason;
66 return true;
67 } else {
68 // Only changeable if not managed.
69 if (IsManaged(reason)) return false;
70 enabled = true;
71 reason = new_reason;
72 }
73 return true;
74 }
75
76 bool WebPluginInfo::Disable(int new_reason) {
77 // If already disabled just upgrade the reason.
78 if (!enabled) {
79 reason |= new_reason;
80 return true;
81 } else {
82 // Only changeable if not managed.
83 if (IsManaged(reason)) return false;
Bernhard Bauer 2010/12/17 18:50:59 Nit: The coding style says it's okay, but personal
pastarmovj 2010/12/20 19:57:37 Done.
84 enabled = false;
85 reason = new_reason;
86 }
87 return true;
88 }
89
90 bool WebPluginInfo::SupportsType(const std::string& mime_type,
91 bool allow_wildcard) const {
92 // Webkit will ask for a plugin to handle empty mime types.
93 if (mime_type.empty())
94 return false;
95
96 for (size_t i = 0; i < mime_types.size(); ++i) {
97 const WebPluginMimeType& mime_info = mime_types[i];
98 if (net::MatchesMimeType(mime_info.mime_type, mime_type)) {
99 if (!allow_wildcard && mime_info.mime_type == "*") {
Bernhard Bauer 2010/12/17 18:50:59 Nit: Braces unnecessary.
pastarmovj 2010/12/20 19:57:37 Done. This is legacy code just moved here but I tu
100 continue;
101 }
102 return true;
103 }
104 }
105 return false;
106 }
107
108 bool WebPluginInfo::SupportsExtension(const std::string& extension,
109 std::string* actual_mime_type) const {
110 for (size_t i = 0; i < mime_types.size(); ++i) {
111 const WebPluginMimeType& mime_type = mime_types[i];
112 for (size_t j = 0; j < mime_type.file_extensions.size(); ++j) {
113 if (mime_type.file_extensions[j] == extension) {
114 if (actual_mime_type)
115 *actual_mime_type = mime_type.mime_type;
116 return true;
117 }
118 }
119 }
120
121 return false;
122 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698