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 #include "chrome/browser/component_updater/flash_component_installer.h" | 5 #include "chrome/browser/component_updater/flash_component_installer.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/base_paths.h" | 11 #include "base/base_paths.h" |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/file_path.h" | 14 #include "base/file_path.h" |
15 #include "base/file_util.h" | 15 #include "base/file_util.h" |
16 #include "base/logging.h" | 16 #include "base/logging.h" |
17 #include "base/path_service.h" | 17 #include "base/path_service.h" |
18 #include "base/string_split.h" | 18 #include "base/string_split.h" |
19 #include "base/string_util.h" | 19 #include "base/string_util.h" |
20 #include "base/stringprintf.h" | 20 #include "base/stringprintf.h" |
21 #include "base/utf_string_conversions.h" | |
21 #include "base/values.h" | 22 #include "base/values.h" |
22 #include "base/version.h" | 23 #include "base/version.h" |
23 #include "build/build_config.h" | 24 #include "build/build_config.h" |
24 #include "chrome/browser/component_updater/component_updater_service.h" | 25 #include "chrome/browser/component_updater/component_updater_service.h" |
25 #include "chrome/browser/plugins/plugin_prefs.h" | 26 #include "chrome/browser/plugins/plugin_prefs.h" |
26 #include "chrome/common/pepper_flash.h" | 27 #include "chrome/common/pepper_flash.h" |
27 #include "chrome/common/chrome_constants.h" | 28 #include "chrome/common/chrome_constants.h" |
28 #include "chrome/common/chrome_paths.h" | 29 #include "chrome/common/chrome_paths.h" |
29 #include "chrome/common/pepper_flash.h" | 30 #include "chrome/common/pepper_flash.h" |
30 #include "content/public/browser/browser_thread.h" | 31 #include "content/public/browser/browser_thread.h" |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
156 kFlashPluginSwfExtension, | 157 kFlashPluginSwfExtension, |
157 kFlashPluginName); | 158 kFlashPluginName); |
158 plugin_info->mime_types.push_back(swf_mime_type); | 159 plugin_info->mime_types.push_back(swf_mime_type); |
159 webkit::WebPluginMimeType spl_mime_type(kFlashPluginSplMimeType, | 160 webkit::WebPluginMimeType spl_mime_type(kFlashPluginSplMimeType, |
160 kFlashPluginSplExtension, | 161 kFlashPluginSplExtension, |
161 kFlashPluginName); | 162 kFlashPluginName); |
162 plugin_info->mime_types.push_back(spl_mime_type); | 163 plugin_info->mime_types.push_back(spl_mime_type); |
163 return true; | 164 return true; |
164 } | 165 } |
165 | 166 |
167 bool IsPepperFlash(const webkit::WebPluginInfo& plugin) { | |
168 return webkit::IsPepperPlugin(plugin) && | |
169 (plugin.pepper_permissions & ppapi::PERMISSION_FLASH); | |
cpu_(ooo_6.6-7.5)
2012/10/09 20:00:36
can you add a comment here about this check. I am
Bernhard Bauer
2012/10/09 20:52:40
Will do. I could also use a different criterion to
| |
170 } | |
171 | |
166 void RegisterPepperFlashWithChrome(const FilePath& path, | 172 void RegisterPepperFlashWithChrome(const FilePath& path, |
167 const Version& version) { | 173 const Version& version) { |
168 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 174 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
169 content::PepperPluginInfo plugin_info; | 175 content::PepperPluginInfo plugin_info; |
170 if (!MakePepperFlashPluginInfo(path, version, true, &plugin_info)) | 176 if (!MakePepperFlashPluginInfo(path, version, true, &plugin_info)) |
171 return; | 177 return; |
178 | |
179 std::vector<webkit::WebPluginInfo> plugins; | |
180 PluginService::GetInstance()->GetInternalPlugins(&plugins); | |
181 for (std::vector<webkit::WebPluginInfo>::const_iterator it = plugins.begin(); | |
182 it != plugins.end(); ++it) { | |
183 if (!IsPepperFlash(*it)) | |
184 continue; | |
cpu_(ooo_6.6-7.5)
2012/10/09 20:00:36
is this doing IO? do we want to call this instead
Bernhard Bauer
2012/10/09 20:52:40
No, it just asks PluginList for its internal plugi
| |
185 | |
186 // If the version we're trying to register is older than the existing one, | |
187 // don't do it. | |
188 if (version.IsOlderThan(UTF16ToUTF8(it->version))) | |
189 return; | |
190 | |
191 // If the version is newer, remove the old one first. | |
192 PluginService::GetInstance()->UnregisterInternalPlugin(it->path); | |
193 break; | |
194 } | |
195 | |
172 bool add_to_front = IsPepperFlashEnabledByDefault(); | 196 bool add_to_front = IsPepperFlashEnabledByDefault(); |
173 PluginService::GetInstance()->RegisterInternalPlugin( | 197 PluginService::GetInstance()->RegisterInternalPlugin( |
174 plugin_info.ToWebPluginInfo(), add_to_front); | 198 plugin_info.ToWebPluginInfo(), add_to_front); |
175 PluginService::GetInstance()->RefreshPlugins(); | 199 PluginService::GetInstance()->RefreshPlugins(); |
176 } | 200 } |
177 | 201 |
178 // Returns true if this browser implements one of the interfaces given in | 202 // Returns true if this browser implements one of the interfaces given in |
179 // |interface_string|, which is a '|'-separated string of interface names. | 203 // |interface_string|, which is a '|'-separated string of interface names. |
180 bool CheckPepperFlashInterfaceString(const std::string& interface_string) { | 204 bool CheckPepperFlashInterfaceString(const std::string& interface_string) { |
181 std::vector<std::string> interface_names; | 205 std::vector<std::string> interface_names; |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
352 #endif // defined(GOOGLE_CHROME_BUILD) | 376 #endif // defined(GOOGLE_CHROME_BUILD) |
353 | 377 |
354 } // namespace | 378 } // namespace |
355 | 379 |
356 void RegisterPepperFlashComponent(ComponentUpdateService* cus) { | 380 void RegisterPepperFlashComponent(ComponentUpdateService* cus) { |
357 #if defined(GOOGLE_CHROME_BUILD) | 381 #if defined(GOOGLE_CHROME_BUILD) |
358 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 382 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
359 base::Bind(&StartPepperFlashUpdateRegistration, cus)); | 383 base::Bind(&StartPepperFlashUpdateRegistration, cus)); |
360 #endif | 384 #endif |
361 } | 385 } |
OLD | NEW |