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

Side by Side Diff: chrome/browser/component_updater/pepper_flash_component_installer.cc

Issue 893823002: Register system Pepper Flash plugin if no packaged Pepper plugin is found. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments. read location of pepperflash from registry. Created 5 years, 10 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 <stdint.h> 5 #include <stdint.h>
6 #include <string.h> 6 #include <string.h>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/base_paths.h" 9 #include "base/base_paths.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/files/file_enumerator.h" 13 #include "base/files/file_enumerator.h"
14 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
15 #include "base/files/file_util.h" 15 #include "base/files/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/strings/string_split.h"
19 #include "base/strings/string_util.h" 18 #include "base/strings/string_util.h"
20 #include "base/strings/stringprintf.h" 19 #include "base/strings/stringprintf.h"
21 #include "base/strings/utf_string_conversions.h" 20 #include "base/strings/utf_string_conversions.h"
22 #include "base/values.h"
23 #include "base/version.h" 21 #include "base/version.h"
24 #include "build/build_config.h" 22 #include "build/build_config.h"
25 #include "chrome/browser/component_updater/flash_component_installer.h" 23 #include "chrome/browser/component_updater/flash_component_installer.h"
26 #include "chrome/browser/component_updater/ppapi_utils.h"
27 #include "chrome/browser/plugins/plugin_prefs.h" 24 #include "chrome/browser/plugins/plugin_prefs.h"
28 #include "chrome/common/chrome_constants.h" 25 #include "chrome/common/chrome_constants.h"
29 #include "chrome/common/chrome_paths.h" 26 #include "chrome/common/chrome_paths.h"
30 #include "chrome/common/chrome_switches.h" 27 #include "chrome/common/chrome_switches.h"
31 #include "chrome/common/pepper_flash.h" 28 #include "chrome/common/pepper_flash.h"
29 #include "chrome/common/ppapi_utils.h"
32 #include "components/component_updater/component_updater_service.h" 30 #include "components/component_updater/component_updater_service.h"
33 #include "components/update_client/update_client.h" 31 #include "components/update_client/update_client.h"
34 #include "content/public/browser/browser_thread.h" 32 #include "content/public/browser/browser_thread.h"
35 #include "content/public/browser/plugin_service.h" 33 #include "content/public/browser/plugin_service.h"
36 #include "content/public/common/content_constants.h" 34 #include "content/public/common/content_constants.h"
37 #include "content/public/common/pepper_plugin_info.h" 35 #include "content/public/common/pepper_plugin_info.h"
38 #include "flapper_version.h" // In SHARED_INTERMEDIATE_DIR. NOLINT 36 #include "flapper_version.h" // In SHARED_INTERMEDIATE_DIR. NOLINT
39 #include "ppapi/c/private/ppb_pdf.h"
40 #include "ppapi/shared_impl/ppapi_permissions.h" 37 #include "ppapi/shared_impl/ppapi_permissions.h"
41 38
42 using content::BrowserThread; 39 using content::BrowserThread;
43 using content::PluginService; 40 using content::PluginService;
44 41
45 namespace component_updater { 42 namespace component_updater {
46 43
47 namespace { 44 namespace {
48 45
49 // File name of the Pepper Flash component manifest on different platforms.
50 const char kPepperFlashManifestName[] = "Flapper";
51
52 #if defined(GOOGLE_CHROME_BUILD) && !defined(OS_LINUX) 46 #if defined(GOOGLE_CHROME_BUILD) && !defined(OS_LINUX)
53 // CRX hash. The extension id is: mimojjlkmoijpicakmndhoigimigcmbb. 47 // CRX hash. The extension id is: mimojjlkmoijpicakmndhoigimigcmbb.
54 const uint8_t kSha2Hash[] = {0xc8, 0xce, 0x99, 0xba, 0xce, 0x89, 0xf8, 0x20, 48 const uint8_t kSha2Hash[] = {0xc8, 0xce, 0x99, 0xba, 0xce, 0x89, 0xf8, 0x20,
55 0xac, 0xd3, 0x7e, 0x86, 0x8c, 0x86, 0x2c, 0x11, 49 0xac, 0xd3, 0x7e, 0x86, 0x8c, 0x86, 0x2c, 0x11,
56 0xb9, 0x40, 0xc5, 0x55, 0xaf, 0x08, 0x63, 0x70, 50 0xb9, 0x40, 0xc5, 0x55, 0xaf, 0x08, 0x63, 0x70,
57 0x54, 0xf9, 0x56, 0xd3, 0xe7, 0x88, 0xba, 0x8c}; 51 0x54, 0xf9, 0x56, 0xd3, 0xe7, 0x88, 0xba, 0x8c};
58 52
59 // If we don't have a Pepper Flash component, this is the version we claim. 53 // If we don't have a Pepper Flash component, this is the version we claim.
60 const char kNullVersion[] = "0.0.0.0"; 54 const char kNullVersion[] = "0.0.0.0";
61 55
62 #endif // defined(GOOGLE_CHROME_BUILD) && !defined(OS_LINUX) 56 #endif // defined(GOOGLE_CHROME_BUILD) && !defined(OS_LINUX)
63 57
64 // Name of the Pepper Flash OS in the component manifest.
65 const char kPepperFlashOperatingSystem[] =
66 #if defined(OS_MACOSX)
67 "mac";
68 #elif defined(OS_WIN)
69 "win";
70 #else // OS_LINUX, etc. TODO(viettrungluu): Separate out Chrome OS and Android?
71 "linux";
72 #endif
73
74 // Name of the Pepper Flash architecture in the component manifest.
75 const char kPepperFlashArch[] =
76 #if defined(ARCH_CPU_X86)
77 "ia32";
78 #elif defined(ARCH_CPU_X86_64)
79 "x64";
80 #else // TODO(viettrungluu): Support an ARM check?
81 "???";
82 #endif
83
84 // The base directory on Windows looks like: 58 // The base directory on Windows looks like:
85 // <profile>\AppData\Local\Google\Chrome\User Data\PepperFlash\. 59 // <profile>\AppData\Local\Google\Chrome\User Data\PepperFlash\.
86 base::FilePath GetPepperFlashBaseDirectory() { 60 base::FilePath GetPepperFlashBaseDirectory() {
87 base::FilePath result; 61 base::FilePath result;
88 PathService::Get(chrome::DIR_COMPONENT_UPDATED_PEPPER_FLASH_PLUGIN, &result); 62 PathService::Get(chrome::DIR_COMPONENT_UPDATED_PEPPER_FLASH_PLUGIN, &result);
89 return result; 63 return result;
90 } 64 }
91 65
92 #if defined(GOOGLE_CHROME_BUILD) && !defined(OS_LINUX) 66 #if defined(GOOGLE_CHROME_BUILD) && !defined(OS_LINUX)
93 // Install directory for pepper flash debugger dlls will be like
94 // c:\windows\system32\macromed\flash\, or basically the Macromed\Flash
95 // subdirectory of the Windows system directory.
96 base::FilePath GetPepperFlashDebuggerDirectory() {
97 base::FilePath result;
98 PathService::Get(chrome::DIR_PEPPER_FLASH_DEBUGGER_PLUGIN, &result);
99 return result;
100 }
101
102 // Pepper Flash plugins have the version encoded in the path itself 67 // Pepper Flash plugins have the version encoded in the path itself
103 // so we need to enumerate the directories to find the full path. 68 // so we need to enumerate the directories to find the full path.
104 // On success, |latest_dir| returns something like: 69 // On success, |latest_dir| returns something like:
105 // <profile>\AppData\Local\Google\Chrome\User Data\PepperFlash\10.3.44.555\. 70 // <profile>\AppData\Local\Google\Chrome\User Data\PepperFlash\10.3.44.555\.
106 // |latest_version| returns the corresponding version number. |older_dirs| 71 // |latest_version| returns the corresponding version number. |older_dirs|
107 // returns directories of all older versions. 72 // returns directories of all older versions.
108 bool GetPepperFlashDirectory(base::FilePath* latest_dir, 73 bool GetPepperFlashDirectory(base::FilePath* latest_dir,
109 Version* latest_version, 74 Version* latest_version,
110 std::vector<base::FilePath>* older_dirs) { 75 std::vector<base::FilePath>* older_dirs) {
111 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 76 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
(...skipping 15 matching lines...) Expand all
127 older_dirs->push_back(path); 92 older_dirs->push_back(path);
128 } 93 }
129 } else { 94 } else {
130 *latest_dir = path; 95 *latest_dir = path;
131 *latest_version = version; 96 *latest_version = version;
132 found = true; 97 found = true;
133 } 98 }
134 } 99 }
135 return found; 100 return found;
136 } 101 }
137
138 #if defined(OS_WIN)
139 const wchar_t kPepperFlashDebuggerDLLSearchString[] =
140 #if defined(ARCH_CPU_X86)
141 L"pepflashplayer32*.dll";
142 #elif defined(ARCH_CPU_X86_64)
143 L"pepflashplayer64*.dll";
144 #else
145 #error Unsupported Windows CPU architecture.
146 #endif // defined(ARCH_CPU_X86)
147 #endif // defined(OS_WIN)
148
149 bool GetPepperFlashDebuggerPath(base::FilePath* dll_path,
150 Version* dll_version) {
151 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
152 base::FilePath debugger_dir = GetPepperFlashDebuggerDirectory();
153 // If path doesn't exist they simply don't have the flash debugger installed.
154 if (!base::PathExists(debugger_dir))
155 return false;
156
157 bool found = false;
158 #if defined(OS_WIN)
159 // Enumerate any DLLs that match the appropriate pattern for this DLL, and
160 // pick the highest version number we find.
161 base::FileEnumerator file_enumerator(debugger_dir,
162 false,
163 base::FileEnumerator::FILES,
164 kPepperFlashDebuggerDLLSearchString);
165 for (base::FilePath path = file_enumerator.Next(); !path.value().empty();
166 path = file_enumerator.Next()) {
167 // Version number is embedded in file name like basename_x_y_z.dll. Extract.
168 std::string file_name(path.BaseName().RemoveExtension().MaybeAsASCII());
169 // file_name should now be basename_x_y_z. Split along '_' for version.
170 std::vector<std::string> components;
171 base::SplitString(file_name, '_', &components);
172 // Should have at least one version number.
173 if (components.size() <= 1)
174 continue;
175 // Meld version components back into a string, now separated by periods, so
176 // Version can parse it.
177 std::string version_string(components[1]);
178 for (size_t i = 2; i < components.size(); ++i) {
179 version_string += "." + components[i];
180 }
181 Version version(version_string);
182 if (!version.IsValid())
183 continue;
184 if (found) {
185 if (version.CompareTo(*dll_version) > 0) {
186 *dll_path = path;
187 *dll_version = version;
188 }
189 } else {
190 *dll_path = path;
191 *dll_version = version;
192 found = true;
193 }
194 }
195 #endif
196 return found;
197 }
198 #endif // defined(GOOGLE_CHROME_BUILD) && !defined(OS_LINUX) 102 #endif // defined(GOOGLE_CHROME_BUILD) && !defined(OS_LINUX)
199 103
200 // Returns true if the Pepper |interface_name| is implemented by this browser.
201 // It does not check if the interface is proxied.
202 bool SupportsPepperInterface(const char* interface_name) {
203 if (IsSupportedPepperInterface(interface_name))
204 return true;
205 // The PDF interface is invisible to SupportsInterface() on the browser
206 // process because it is provided using PpapiInterfaceFactoryManager. We need
207 // to check for that as well.
208 // TODO(cpu): make this more sane.
209 return (strcmp(interface_name, PPB_PDF_INTERFACE) == 0);
210 }
211
212 bool MakePepperFlashPluginInfo(const base::FilePath& flash_path, 104 bool MakePepperFlashPluginInfo(const base::FilePath& flash_path,
213 const Version& flash_version, 105 const Version& flash_version,
214 bool out_of_process, 106 bool out_of_process,
215 bool is_debugger,
216 content::PepperPluginInfo* plugin_info) { 107 content::PepperPluginInfo* plugin_info) {
217 if (!flash_version.IsValid()) 108 if (!flash_version.IsValid())
218 return false; 109 return false;
219 const std::vector<uint16_t> ver_nums = flash_version.components(); 110 const std::vector<uint16_t> ver_nums = flash_version.components();
220 if (ver_nums.size() < 3) 111 if (ver_nums.size() < 3)
221 return false; 112 return false;
222 113
223 plugin_info->is_internal = false; 114 plugin_info->is_internal = false;
224 plugin_info->is_out_of_process = out_of_process; 115 plugin_info->is_out_of_process = out_of_process;
225 plugin_info->path = flash_path; 116 plugin_info->path = flash_path;
226 plugin_info->name = content::kFlashPluginName; 117 plugin_info->name = content::kFlashPluginName;
227 plugin_info->permissions = kPepperFlashPermissions; 118 plugin_info->permissions = chrome::kPepperFlashPermissions;
228 119
229 // The description is like "Shockwave Flash 10.2 r154". 120 // The description is like "Shockwave Flash 10.2 r154".
230 plugin_info->description = base::StringPrintf("%s %d.%d r%d", 121 plugin_info->description = base::StringPrintf("%s %d.%d r%d",
231 content::kFlashPluginName, 122 content::kFlashPluginName,
232 ver_nums[0], 123 ver_nums[0],
233 ver_nums[1], 124 ver_nums[1],
234 ver_nums[2]); 125 ver_nums[2]);
235 126
236 plugin_info->version = flash_version.GetString(); 127 plugin_info->version = flash_version.GetString();
237 128
(...skipping 10 matching lines...) Expand all
248 139
249 bool IsPepperFlash(const content::WebPluginInfo& plugin) { 140 bool IsPepperFlash(const content::WebPluginInfo& plugin) {
250 // We try to recognize Pepper Flash by the following criteria: 141 // We try to recognize Pepper Flash by the following criteria:
251 // * It is a Pepper plug-in. 142 // * It is a Pepper plug-in.
252 // * It has the special Flash permissions. 143 // * It has the special Flash permissions.
253 return plugin.is_pepper_plugin() && 144 return plugin.is_pepper_plugin() &&
254 (plugin.pepper_permissions & ppapi::PERMISSION_FLASH); 145 (plugin.pepper_permissions & ppapi::PERMISSION_FLASH);
255 } 146 }
256 147
257 void RegisterPepperFlashWithChrome(const base::FilePath& path, 148 void RegisterPepperFlashWithChrome(const base::FilePath& path,
258 const Version& version, 149 const Version& version) {
259 bool is_debugger) {
260 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 150 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
261 content::PepperPluginInfo plugin_info; 151 content::PepperPluginInfo plugin_info;
262 if (!MakePepperFlashPluginInfo( 152 if (!MakePepperFlashPluginInfo(path, version, true, &plugin_info))
263 path, version, true, is_debugger, &plugin_info))
264 return; 153 return;
265 154
266 // If this is the non-debugger version, we enumerate any installed versions of 155 std::vector<content::WebPluginInfo> plugins;
267 // pepper flash to make sure we only replace the installed version with a 156 PluginService::GetInstance()->GetInternalPlugins(&plugins);
268 // newer version. 157 for (std::vector<content::WebPluginInfo>::const_iterator it =
269 if (!is_debugger) { 158 plugins.begin();
270 std::vector<content::WebPluginInfo> plugins; 159 it != plugins.end();
271 PluginService::GetInstance()->GetInternalPlugins(&plugins); 160 ++it) {
272 for (std::vector<content::WebPluginInfo>::const_iterator it = 161 if (!IsPepperFlash(*it))
273 plugins.begin(); 162 continue;
274 it != plugins.end();
275 ++it) {
276 if (!IsPepperFlash(*it))
277 continue;
278 163
279 // Do it only if the version we're trying to register is newer. 164 // Do it only if the version we're trying to register is newer.
280 Version registered_version(base::UTF16ToUTF8(it->version)); 165 Version registered_version(base::UTF16ToUTF8(it->version));
281 if (registered_version.IsValid() && 166 if (registered_version.IsValid() &&
282 version.CompareTo(registered_version) <= 0) { 167 version.CompareTo(registered_version) <= 0) {
283 return; 168 return;
284 } 169 }
285 170
286 // If the version is newer, remove the old one first. 171 // If the version is newer, remove the old one first.
287 PluginService::GetInstance()->UnregisterInternalPlugin(it->path); 172 PluginService::GetInstance()->UnregisterInternalPlugin(it->path);
288 break; 173 break;
289 }
290 } 174 }
291 175
292 // We only ask for registration at the beginning for the non-debugger plugin,
293 // that way the debugger plugin doesn't automatically clobber the built-in or
294 // updated non-debugger version.
295 PluginService::GetInstance()->RegisterInternalPlugin( 176 PluginService::GetInstance()->RegisterInternalPlugin(
296 plugin_info.ToWebPluginInfo(), !is_debugger); 177 plugin_info.ToWebPluginInfo(), true);
297 PluginService::GetInstance()->RefreshPlugins(); 178 PluginService::GetInstance()->RefreshPlugins();
298 } 179 }
299 180
300 // Returns true if this browser implements one of the interfaces given in
301 // |interface_string|, which is a '|'-separated string of interface names.
302 bool CheckPepperFlashInterfaceString(const std::string& interface_string) {
303 std::vector<std::string> interface_names;
304 base::SplitString(interface_string, '|', &interface_names);
305 for (size_t i = 0; i < interface_names.size(); i++) {
306 if (SupportsPepperInterface(interface_names[i].c_str()))
307 return true;
308 }
309 return false;
310 }
311
312 // Returns true if this browser implements all the interfaces that Flash
313 // specifies in its component installer manifest.
314 bool CheckPepperFlashInterfaces(const base::DictionaryValue& manifest) {
315 const base::ListValue* interface_list = NULL;
316
317 // We don't *require* an interface list, apparently.
318 if (!manifest.GetList("x-ppapi-required-interfaces", &interface_list))
319 return true;
320
321 for (size_t i = 0; i < interface_list->GetSize(); i++) {
322 std::string interface_string;
323 if (!interface_list->GetString(i, &interface_string))
324 return false;
325 if (!CheckPepperFlashInterfaceString(interface_string))
326 return false;
327 }
328
329 return true;
330 }
331
332 } // namespace 181 } // namespace
333 182
334 class PepperFlashComponentInstaller : public update_client::ComponentInstaller { 183 class PepperFlashComponentInstaller : public update_client::ComponentInstaller {
335 public: 184 public:
336 explicit PepperFlashComponentInstaller(const Version& version); 185 explicit PepperFlashComponentInstaller(const Version& version);
337 186
338 // ComponentInstaller implementation: 187 // ComponentInstaller implementation:
339 void OnUpdateError(int error) override; 188 void OnUpdateError(int error) override;
340 189
341 bool Install(const base::DictionaryValue& manifest, 190 bool Install(const base::DictionaryValue& manifest,
(...skipping 17 matching lines...) Expand all
359 } 208 }
360 209
361 void PepperFlashComponentInstaller::OnUpdateError(int error) { 210 void PepperFlashComponentInstaller::OnUpdateError(int error) {
362 NOTREACHED() << "Pepper Flash update error: " << error; 211 NOTREACHED() << "Pepper Flash update error: " << error;
363 } 212 }
364 213
365 bool PepperFlashComponentInstaller::Install( 214 bool PepperFlashComponentInstaller::Install(
366 const base::DictionaryValue& manifest, 215 const base::DictionaryValue& manifest,
367 const base::FilePath& unpack_path) { 216 const base::FilePath& unpack_path) {
368 Version version; 217 Version version;
369 if (!CheckPepperFlashManifest(manifest, &version)) 218 if (!chrome::CheckPepperFlashManifest(manifest, &version))
370 return false; 219 return false;
371 if (current_version_.CompareTo(version) > 0) 220 if (current_version_.CompareTo(version) > 0)
372 return false; 221 return false;
373 if (!base::PathExists(unpack_path.Append(chrome::kPepperFlashPluginFilename))) 222 if (!base::PathExists(unpack_path.Append(chrome::kPepperFlashPluginFilename)))
374 return false; 223 return false;
375 // Passed the basic tests. Time to install it. 224 // Passed the basic tests. Time to install it.
376 base::FilePath path = 225 base::FilePath path =
377 GetPepperFlashBaseDirectory().AppendASCII(version.GetString()); 226 GetPepperFlashBaseDirectory().AppendASCII(version.GetString());
378 if (base::PathExists(path)) 227 if (base::PathExists(path))
379 return false; 228 return false;
380 if (!base::Move(unpack_path, path)) 229 if (!base::Move(unpack_path, path))
381 return false; 230 return false;
382 // Installation is done. Now tell the rest of chrome. Both the path service 231 // Installation is done. Now tell the rest of chrome. Both the path service
383 // and to the plugin service. 232 // and to the plugin service.
384 current_version_ = version; 233 current_version_ = version;
385 PathService::Override(chrome::DIR_PEPPER_FLASH_PLUGIN, path); 234 PathService::Override(chrome::DIR_PEPPER_FLASH_PLUGIN, path);
386 path = path.Append(chrome::kPepperFlashPluginFilename); 235 path = path.Append(chrome::kPepperFlashPluginFilename);
387 BrowserThread::PostTask( 236 BrowserThread::PostTask(
388 BrowserThread::UI, 237 BrowserThread::UI,
389 FROM_HERE, 238 FROM_HERE,
390 base::Bind(&RegisterPepperFlashWithChrome, path, version, false)); 239 base::Bind(&RegisterPepperFlashWithChrome, path, version));
391 return true; 240 return true;
392 } 241 }
393 242
394 bool PepperFlashComponentInstaller::GetInstalledFile( 243 bool PepperFlashComponentInstaller::GetInstalledFile(
395 const std::string& file, 244 const std::string& file,
396 base::FilePath* installed_file) { 245 base::FilePath* installed_file) {
397 return false; 246 return false;
398 } 247 }
399 248
400 bool PepperFlashComponentInstaller::Uninstall() { 249 bool PepperFlashComponentInstaller::Uninstall() {
401 return false; 250 return false;
402 } 251 }
403 252
404 bool CheckPepperFlashManifest(const base::DictionaryValue& manifest,
405 Version* version_out) {
406 std::string name;
407 manifest.GetStringASCII("name", &name);
408 // TODO(viettrungluu): Support WinFlapper for now, while we change the format
409 // of the manifest. (Should be safe to remove checks for "WinFlapper" in, say,
410 // Nov. 2011.) crbug.com/98458
411 if (name != kPepperFlashManifestName && name != "WinFlapper")
412 return false;
413 253
414 std::string proposed_version;
415 manifest.GetStringASCII("version", &proposed_version);
416 Version version(proposed_version.c_str());
417 if (!version.IsValid())
418 return false;
419
420 if (!CheckPepperFlashInterfaces(manifest))
421 return false;
422
423 // TODO(viettrungluu): See above TODO.
424 if (name == "WinFlapper") {
425 *version_out = version;
426 return true;
427 }
428
429 std::string os;
430 manifest.GetStringASCII("x-ppapi-os", &os);
431 if (os != kPepperFlashOperatingSystem)
432 return false;
433
434 std::string arch;
435 manifest.GetStringASCII("x-ppapi-arch", &arch);
436 if (arch != kPepperFlashArch)
437 return false;
438
439 *version_out = version;
440 return true;
441 }
442 254
443 namespace { 255 namespace {
444 256
445 #if defined(GOOGLE_CHROME_BUILD) && !defined(OS_LINUX) 257 #if defined(GOOGLE_CHROME_BUILD) && !defined(OS_LINUX)
446 void FinishPepperFlashUpdateRegistration(ComponentUpdateService* cus, 258 void FinishPepperFlashUpdateRegistration(ComponentUpdateService* cus,
447 const Version& version) { 259 const Version& version) {
448 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 260 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
449 update_client::CrxComponent pepflash; 261 update_client::CrxComponent pepflash;
450 pepflash.name = "pepper_flash"; 262 pepflash.name = "pepper_flash";
451 pepflash.installer = new PepperFlashComponentInstaller(version); 263 pepflash.installer = new PepperFlashComponentInstaller(version);
(...skipping 15 matching lines...) Expand all
467 } 279 }
468 280
469 Version version(kNullVersion); 281 Version version(kNullVersion);
470 std::vector<base::FilePath> older_dirs; 282 std::vector<base::FilePath> older_dirs;
471 if (GetPepperFlashDirectory(&path, &version, &older_dirs)) { 283 if (GetPepperFlashDirectory(&path, &version, &older_dirs)) {
472 path = path.Append(chrome::kPepperFlashPluginFilename); 284 path = path.Append(chrome::kPepperFlashPluginFilename);
473 if (base::PathExists(path)) { 285 if (base::PathExists(path)) {
474 BrowserThread::PostTask( 286 BrowserThread::PostTask(
475 BrowserThread::UI, 287 BrowserThread::UI,
476 FROM_HERE, 288 FROM_HERE,
477 base::Bind(&RegisterPepperFlashWithChrome, path, version, false)); 289 base::Bind(&RegisterPepperFlashWithChrome, path, version));
478 } else { 290 } else {
479 version = Version(kNullVersion); 291 version = Version(kNullVersion);
480 } 292 }
481 } 293 }
482 294
483 BrowserThread::PostTask( 295 BrowserThread::PostTask(
484 BrowserThread::UI, 296 BrowserThread::UI,
485 FROM_HERE, 297 FROM_HERE,
486 base::Bind(&FinishPepperFlashUpdateRegistration, cus, version)); 298 base::Bind(&FinishPepperFlashUpdateRegistration, cus, version));
487 299
488 // Remove older versions of Pepper Flash. 300 // Remove older versions of Pepper Flash.
489 for (std::vector<base::FilePath>::iterator iter = older_dirs.begin(); 301 for (std::vector<base::FilePath>::iterator iter = older_dirs.begin();
490 iter != older_dirs.end(); 302 iter != older_dirs.end();
491 ++iter) { 303 ++iter) {
492 base::DeleteFile(*iter, true); 304 base::DeleteFile(*iter, true);
493 } 305 }
494
495 // Check for Debugging version of Flash and register if present.
496 base::FilePath debugger_path;
497 Version debugger_version(kNullVersion);
498 if (GetPepperFlashDebuggerPath(&debugger_path, &debugger_version)) {
499 BrowserThread::PostTask(BrowserThread::UI,
500 FROM_HERE,
501 base::Bind(&RegisterPepperFlashWithChrome,
502 debugger_path,
503 debugger_version,
504 true));
505 }
506 } 306 }
507 #endif // defined(GOOGLE_CHROME_BUILD) && !defined(OS_LINUX) 307 #endif // defined(GOOGLE_CHROME_BUILD) && !defined(OS_LINUX)
508 308
509 } // namespace 309 } // namespace
510 310
511 void RegisterPepperFlashComponent(ComponentUpdateService* cus) { 311 void RegisterPepperFlashComponent(ComponentUpdateService* cus) {
512 #if defined(GOOGLE_CHROME_BUILD) && !defined(OS_LINUX) 312 #if defined(GOOGLE_CHROME_BUILD) && !defined(OS_LINUX)
513 // Component updated flash supersedes bundled flash therefore if that one 313 // Component updated flash supersedes bundled flash therefore if that one
514 // is disabled then this one should never install. 314 // is disabled then this one should never install.
515 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); 315 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess();
516 if (cmd_line->HasSwitch(switches::kDisableBundledPpapiFlash)) 316 if (cmd_line->HasSwitch(switches::kDisableBundledPpapiFlash))
517 return; 317 return;
518 BrowserThread::PostTask(BrowserThread::FILE, 318 BrowserThread::PostTask(BrowserThread::FILE,
519 FROM_HERE, 319 FROM_HERE,
520 base::Bind(&StartPepperFlashUpdateRegistration, cus)); 320 base::Bind(&StartPepperFlashUpdateRegistration, cus));
521 #endif 321 #endif
522 } 322 }
523 323
524 } // namespace component_updater 324 } // namespace component_updater
OLDNEW
« no previous file with comments | « chrome/browser/component_updater/flash_component_installer.h ('k') | chrome/browser/component_updater/ppapi_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698