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

Side by Side Diff: content/common/pepper_plugin_registry.cc

Issue 7670003: Wire experimental Flapper part two (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 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
« no previous file with comments | « content/common/pepper_plugin_registry.h ('k') | content/renderer/pepper_plugin_delegate_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "content/common/pepper_plugin_registry.h" 5 #include "content/common/pepper_plugin_registry.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/native_library.h" 9 #include "base/native_library.h"
10 #include "base/string_split.h" 10 #include "base/string_split.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 71
72 plugins->push_back(plugin); 72 plugins->push_back(plugin);
73 } 73 }
74 } 74 }
75 75
76 } // namespace 76 } // namespace
77 77
78 webkit::WebPluginInfo PepperPluginInfo::ToWebPluginInfo() const { 78 webkit::WebPluginInfo PepperPluginInfo::ToWebPluginInfo() const {
79 webkit::WebPluginInfo info; 79 webkit::WebPluginInfo info;
80 80
81 info.name = name.empty() ? path.BaseName().LossyDisplayName() : 81 info.type = is_out_of_process ?
82 ASCIIToUTF16(name); 82 webkit::WebPluginInfo::PLUGIN_TYPE_PEPPER_OUT_OF_PROCESS :
83 webkit::WebPluginInfo::PLUGIN_TYPE_PEPPER_IN_PROCESS;
84
85 info.name = name.empty() ?
86 path.BaseName().LossyDisplayName() : UTF8ToUTF16(name);
83 info.path = path; 87 info.path = path;
84 info.version = ASCIIToUTF16(version); 88 info.version = ASCIIToUTF16(version);
85 info.desc = ASCIIToUTF16(description); 89 info.desc = ASCIIToUTF16(description);
86 info.mime_types = mime_types; 90 info.mime_types = mime_types;
87 91
88 webkit::WebPluginInfo::EnabledStates enabled_state = 92 webkit::WebPluginInfo::EnabledStates enabled_state =
89 webkit::WebPluginInfo::USER_ENABLED_POLICY_UNMANAGED; 93 webkit::WebPluginInfo::USER_ENABLED_POLICY_UNMANAGED;
90 94
91 if (!enabled) { 95 if (!enabled) {
92 enabled_state = 96 enabled_state =
93 webkit::WebPluginInfo::USER_DISABLED_POLICY_UNMANAGED; 97 webkit::WebPluginInfo::USER_DISABLED_POLICY_UNMANAGED;
94 } 98 }
95 99
96 info.enabled = enabled_state; 100 info.enabled = enabled_state;
97 return info; 101 return info;
98 } 102 }
99 103
100 PepperPluginInfo::PepperPluginInfo() 104 PepperPluginInfo::PepperPluginInfo()
101 : is_internal(false), 105 : is_internal(false),
102 is_out_of_process(false), 106 is_out_of_process(false),
103 enabled(true) { 107 enabled(true) {
104 } 108 }
105 109
106 PepperPluginInfo::~PepperPluginInfo() { 110 PepperPluginInfo::~PepperPluginInfo() {
107 } 111 }
108 112
113 bool MakePepperPluginInfo(const webkit::WebPluginInfo& webplugin_info,
114 PepperPluginInfo* pepper_info) {
115 if (!webkit::IsPepperPlugin(webplugin_info))
116 return false;
117
118 pepper_info->is_out_of_process =
119 webplugin_info.type ==
120 webkit::WebPluginInfo::PLUGIN_TYPE_PEPPER_OUT_OF_PROCESS;
121
122 pepper_info->enabled = webkit::IsPluginEnabled(webplugin_info);
123 pepper_info->path = FilePath(webplugin_info.path);
124 pepper_info->name = UTF16ToASCII(webplugin_info.name);
125 pepper_info->description = UTF16ToASCII(webplugin_info.desc);
126 pepper_info->version = UTF16ToASCII(webplugin_info.version);
127 pepper_info->mime_types = webplugin_info.mime_types;
128 return true;
129 }
130
109 // static 131 // static
110 PepperPluginRegistry* PepperPluginRegistry::GetInstance() { 132 PepperPluginRegistry* PepperPluginRegistry::GetInstance() {
111 static PepperPluginRegistry* registry = NULL; 133 static PepperPluginRegistry* registry = NULL;
112 // This object leaks. It is a temporary hack to work around a crash. 134 // This object leaks. It is a temporary hack to work around a crash.
113 // http://code.google.com/p/chromium/issues/detail?id=63234 135 // http://code.google.com/p/chromium/issues/detail?id=63234
114 if (!registry) 136 if (!registry)
115 registry = new PepperPluginRegistry; 137 registry = new PepperPluginRegistry;
116 return registry; 138 return registry;
117 } 139 }
118 140
(...skipping 13 matching lines...) Expand all
132 base::NativeLibrary library = base::LoadNativeLibrary(plugins[i].path, 154 base::NativeLibrary library = base::LoadNativeLibrary(plugins[i].path,
133 &error); 155 &error);
134 LOG_IF(WARNING, !library) << "Unable to load plugin " 156 LOG_IF(WARNING, !library) << "Unable to load plugin "
135 << plugins[i].path.value() << " " 157 << plugins[i].path.value() << " "
136 << error; 158 << error;
137 } 159 }
138 } 160 }
139 } 161 }
140 162
141 const PepperPluginInfo* PepperPluginRegistry::GetInfoForPlugin( 163 const PepperPluginInfo* PepperPluginRegistry::GetInfoForPlugin(
142 const FilePath& path) const { 164 const webkit::WebPluginInfo& info) {
143 for (size_t i = 0; i < plugin_list_.size(); ++i) { 165 for (size_t i = 0; i < plugin_list_.size(); ++i) {
144 if (path == plugin_list_[i].path) 166 if (info.path == plugin_list_[i].path)
145 return &plugin_list_[i]; 167 return &plugin_list_[i];
146 } 168 }
147 return NULL; 169 // We did not find the plugin in our list. But wait! the plugin can also
170 // be a latecomer, as it happens with pepper flash. This information
171 // is actually in |info| and we can use it to construct it and add it to
172 // the list. This same deal needs to be done in the browser side in
173 // PluginService.
174 PepperPluginInfo plugin;
175 if (!MakePepperPluginInfo(info, &plugin))
176 return NULL;
177
178 plugin_list_.push_back(plugin);
179 return &plugin_list_[plugin_list_.size() - 1];
148 } 180 }
149 181
150 webkit::ppapi::PluginModule* PepperPluginRegistry::GetLiveModule( 182 webkit::ppapi::PluginModule* PepperPluginRegistry::GetLiveModule(
151 const FilePath& path) { 183 const FilePath& path) {
152 NonOwningModuleMap::iterator it = live_modules_.find(path); 184 NonOwningModuleMap::iterator it = live_modules_.find(path);
153 if (it == live_modules_.end()) 185 if (it == live_modules_.end())
154 return NULL; 186 return NULL;
155 return it->second; 187 return it->second;
156 } 188 }
157 189
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 base::MessageLoopProxy* PepperPluginRegistry::GetIPCMessageLoop() { 253 base::MessageLoopProxy* PepperPluginRegistry::GetIPCMessageLoop() {
222 // This is called only in the renderer so we know we have a child process. 254 // This is called only in the renderer so we know we have a child process.
223 DCHECK(ChildProcess::current()) << "Must be in the renderer."; 255 DCHECK(ChildProcess::current()) << "Must be in the renderer.";
224 return ChildProcess::current()->io_message_loop_proxy(); 256 return ChildProcess::current()->io_message_loop_proxy();
225 } 257 }
226 258
227 base::WaitableEvent* PepperPluginRegistry::GetShutdownEvent() { 259 base::WaitableEvent* PepperPluginRegistry::GetShutdownEvent() {
228 DCHECK(ChildProcess::current()) << "Must be in the renderer."; 260 DCHECK(ChildProcess::current()) << "Must be in the renderer.";
229 return ChildProcess::current()->GetShutDownEvent(); 261 return ChildProcess::current()->GetShutDownEvent();
230 } 262 }
OLDNEW
« no previous file with comments | « content/common/pepper_plugin_registry.h ('k') | content/renderer/pepper_plugin_delegate_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698