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

Side by Side Diff: chrome/common/chrome_content_client.cc

Issue 1918023003: Merge M51: Prefer System Flash over non-local component updated Flash. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: Created 4 years, 7 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) 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/common/chrome_content_client.h" 5 #include "chrome/common/chrome_content_client.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/crash_logging.h" 10 #include "base/debug/crash_logging.h"
11 #include "base/files/file_util.h" 11 #include "base/files/file_util.h"
12 #include "base/json/json_reader.h" 12 #include "base/json/json_reader.h"
13 #include "base/memory/scoped_vector.h" 13 #include "base/memory/scoped_vector.h"
14 #include "base/path_service.h" 14 #include "base/path_service.h"
15 #include "base/strings/string16.h" 15 #include "base/strings/string16.h"
16 #include "base/strings/string_number_conversions.h" 16 #include "base/strings/string_number_conversions.h"
17 #include "base/strings/string_split.h" 17 #include "base/strings/string_split.h"
18 #include "base/strings/string_util.h" 18 #include "base/strings/string_util.h"
19 #include "base/strings/stringprintf.h" 19 #include "base/strings/stringprintf.h"
20 #include "base/strings/utf_string_conversions.h" 20 #include "base/strings/utf_string_conversions.h"
21 #include "base/tuple.h"
21 #include "build/build_config.h" 22 #include "build/build_config.h"
22 #include "chrome/common/child_process_logging.h" 23 #include "chrome/common/child_process_logging.h"
23 #include "chrome/common/chrome_constants.h" 24 #include "chrome/common/chrome_constants.h"
24 #include "chrome/common/chrome_paths.h" 25 #include "chrome/common/chrome_paths.h"
25 #include "chrome/common/chrome_switches.h" 26 #include "chrome/common/chrome_switches.h"
26 #include "chrome/common/crash_keys.h" 27 #include "chrome/common/crash_keys.h"
27 #include "chrome/common/pepper_flash.h" 28 #include "chrome/common/pepper_flash.h"
28 #include "chrome/common/secure_origin_whitelist.h" 29 #include "chrome/common/secure_origin_whitelist.h"
29 #include "chrome/common/url_constants.h" 30 #include "chrome/common/url_constants.h"
30 #include "chrome/grit/common_resources.h" 31 #include "chrome/grit/common_resources.h"
(...skipping 12 matching lines...) Expand all
43 #include "ui/base/resource/resource_bundle.h" 44 #include "ui/base/resource/resource_bundle.h"
44 45
45 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. 46 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
46 47
47 #if defined(OS_LINUX) 48 #if defined(OS_LINUX)
48 #include <fcntl.h> 49 #include <fcntl.h>
49 #include "chrome/common/component_flash_hint_file_linux.h" 50 #include "chrome/common/component_flash_hint_file_linux.h"
50 #endif // defined(OS_LINUX) 51 #endif // defined(OS_LINUX)
51 52
52 #if defined(OS_WIN) 53 #if defined(OS_WIN)
53 #include "base/win/registry.h"
54 #include "base/win/windows_version.h" 54 #include "base/win/windows_version.h"
55 #endif 55 #endif
56 56
57 #if !defined(DISABLE_NACL) 57 #if !defined(DISABLE_NACL)
58 #include "components/nacl/common/nacl_constants.h" 58 #include "components/nacl/common/nacl_constants.h"
59 #include "components/nacl/common/nacl_process_type.h" 59 #include "components/nacl/common/nacl_process_type.h"
60 #include "components/nacl/common/nacl_sandbox_type.h" 60 #include "components/nacl/common/nacl_sandbox_type.h"
61 #endif 61 #endif
62 62
63 #if defined(ENABLE_EXTENSIONS) 63 #if defined(ENABLE_EXTENSIONS)
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 widevine_cdm.permissions = kWidevineCdmPluginPermissions; 190 widevine_cdm.permissions = kWidevineCdmPluginPermissions;
191 plugins->push_back(widevine_cdm); 191 plugins->push_back(widevine_cdm);
192 192
193 skip_widevine_cdm_file_check = true; 193 skip_widevine_cdm_file_check = true;
194 } 194 }
195 } 195 }
196 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && 196 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) &&
197 // !defined(WIDEVINE_CDM_IS_COMPONENT) 197 // !defined(WIDEVINE_CDM_IS_COMPONENT)
198 } 198 }
199 199
200 // Creates a PepperPluginInfo for the specified plugin.
201 // |path| is the full path to the plugin.
202 // |version| is a string representation of the plugin version.
203 // |is_debug| is whether the plugin is the debug version or not.
204 // |is_external| is whether the plugin is supplied external to Chrome e.g. a
205 // system installation of Adobe Flash.
206 // |is_bundled| distinguishes between component updated plugin and a bundled
207 // plugin.
200 content::PepperPluginInfo CreatePepperFlashInfo(const base::FilePath& path, 208 content::PepperPluginInfo CreatePepperFlashInfo(const base::FilePath& path,
201 const std::string& version, 209 const std::string& version,
202 bool is_debug) { 210 bool is_debug,
211 bool is_external,
212 bool is_bundled) {
203 content::PepperPluginInfo plugin; 213 content::PepperPluginInfo plugin;
204 214
205 plugin.is_out_of_process = true; 215 plugin.is_out_of_process = true;
206 plugin.name = content::kFlashPluginName; 216 plugin.name = content::kFlashPluginName;
207 plugin.path = path; 217 plugin.path = path;
218 #if defined(OS_WIN)
219 plugin.is_on_local_drive = !base::IsOnNetworkDrive(path);
220 #endif
208 plugin.permissions = chrome::kPepperFlashPermissions; 221 plugin.permissions = chrome::kPepperFlashPermissions;
209 plugin.is_debug = is_debug; 222 plugin.is_debug = is_debug;
223 plugin.is_external = is_external;
224 plugin.is_bundled = is_bundled;
210 225
211 std::vector<std::string> flash_version_numbers = base::SplitString( 226 std::vector<std::string> flash_version_numbers = base::SplitString(
212 version, ".", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); 227 version, ".", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
213 if (flash_version_numbers.size() < 1) 228 if (flash_version_numbers.size() < 1)
214 flash_version_numbers.push_back("11"); 229 flash_version_numbers.push_back("11");
215 if (flash_version_numbers.size() < 2) 230 if (flash_version_numbers.size() < 2)
216 flash_version_numbers.push_back("2"); 231 flash_version_numbers.push_back("2");
217 if (flash_version_numbers.size() < 3) 232 if (flash_version_numbers.size() < 3)
218 flash_version_numbers.push_back("999"); 233 flash_version_numbers.push_back("999");
219 if (flash_version_numbers.size() < 4) 234 if (flash_version_numbers.size() < 4)
(...skipping 22 matching lines...) Expand all
242 if (flash_path.empty()) 257 if (flash_path.empty())
243 return; 258 return;
244 259
245 // Also get the version from the command-line. Should be something like 11.2 260 // Also get the version from the command-line. Should be something like 11.2
246 // or 11.2.123.45. 261 // or 11.2.123.45.
247 std::string flash_version = 262 std::string flash_version =
248 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 263 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
249 switches::kPpapiFlashVersion); 264 switches::kPpapiFlashVersion);
250 265
251 plugins->push_back( 266 plugins->push_back(
252 CreatePepperFlashInfo(base::FilePath(flash_path), flash_version, false)); 267 CreatePepperFlashInfo(base::FilePath(flash_path),
268 flash_version, false, true, false));
253 } 269 }
254 270
255 #if defined(OS_LINUX) 271 #if defined(OS_LINUX)
256 // This function tests if DIR_USER_DATA can be accessed, as a simple check to 272 // This function tests if DIR_USER_DATA can be accessed, as a simple check to
257 // see if the zygote has been sandboxed at this point. 273 // see if the zygote has been sandboxed at this point.
258 bool IsUserDataDirAvailable() { 274 bool IsUserDataDirAvailable() {
259 base::FilePath user_data_dir; 275 base::FilePath user_data_dir;
260 return PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); 276 return PathService::Get(chrome::DIR_USER_DATA, &user_data_dir);
261 } 277 }
262 278
(...skipping 13 matching lines...) Expand all
276 &version)) { 292 &version)) {
277 // Test if the file can be mapped as executable. If the user's home 293 // Test if the file can be mapped as executable. If the user's home
278 // directory is mounted noexec, the component flash plugin will not load. 294 // directory is mounted noexec, the component flash plugin will not load.
279 // By testing for this, Chrome can fallback to the bundled flash plugin. 295 // By testing for this, Chrome can fallback to the bundled flash plugin.
280 if (!component_flash_hint_file::TestExecutableMapping(flash_path)) { 296 if (!component_flash_hint_file::TestExecutableMapping(flash_path)) {
281 LOG(WARNING) << "The component updated flash plugin could not be " 297 LOG(WARNING) << "The component updated flash plugin could not be "
282 "mapped as executable. Attempting to fallback to the " 298 "mapped as executable. Attempting to fallback to the "
283 "bundled or system plugin."; 299 "bundled or system plugin.";
284 return false; 300 return false;
285 } 301 }
286 *plugin = CreatePepperFlashInfo(flash_path, version, false); 302 *plugin = CreatePepperFlashInfo(flash_path, version, false, false, false);
287 return true; 303 return true;
288 } 304 }
289 LOG(ERROR) 305 LOG(ERROR)
290 << "Failed to locate and load the component updated flash plugin."; 306 << "Failed to locate and load the component updated flash plugin.";
291 } 307 }
292 #endif // defined(FLAPPER_AVAILABLE) 308 #endif // defined(FLAPPER_AVAILABLE)
293 return false; 309 return false;
294 } 310 }
295 #endif // defined(OS_LINUX) 311 #endif // defined(OS_LINUX)
296 312
297 bool GetBundledPepperFlash(content::PepperPluginInfo* plugin) { 313 bool GetBundledPepperFlash(content::PepperPluginInfo* plugin) {
298 #if defined(FLAPPER_AVAILABLE) 314 #if defined(FLAPPER_AVAILABLE)
299 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 315 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
300 316
301 // Ignore bundled Pepper Flash if there is Pepper Flash specified from the 317 // Ignore bundled Pepper Flash if there is Pepper Flash specified from the
302 // command-line. 318 // command-line.
303 if (command_line->HasSwitch(switches::kPpapiFlashPath)) 319 if (command_line->HasSwitch(switches::kPpapiFlashPath))
304 return false; 320 return false;
305 321
306 bool force_disable = 322 bool force_disable =
307 command_line->HasSwitch(switches::kDisableBundledPpapiFlash); 323 command_line->HasSwitch(switches::kDisableBundledPpapiFlash);
308 if (force_disable) 324 if (force_disable)
309 return false; 325 return false;
310 326
311 base::FilePath flash_path; 327 base::FilePath flash_path;
312 if (!PathService::Get(chrome::FILE_PEPPER_FLASH_PLUGIN, &flash_path)) 328 if (!PathService::Get(chrome::FILE_PEPPER_FLASH_PLUGIN, &flash_path))
313 return false; 329 return false;
314 330
315 *plugin = CreatePepperFlashInfo(flash_path, FLAPPER_VERSION_STRING, false); 331 *plugin = CreatePepperFlashInfo(flash_path, FLAPPER_VERSION_STRING, false,
332 false, true);
316 return true; 333 return true;
317 #else 334 #else
318 return false; 335 return false;
319 #endif // FLAPPER_AVAILABLE 336 #endif // FLAPPER_AVAILABLE
320 } 337 }
321 338
322 bool IsSystemFlashScriptDebuggerPresent() {
323 #if defined(OS_WIN)
324 const wchar_t kFlashRegistryRoot[] =
325 L"SOFTWARE\\Macromedia\\FlashPlayerPepper";
326 const wchar_t kIsDebuggerValueName[] = L"isScriptDebugger";
327
328 base::win::RegKey path_key(HKEY_LOCAL_MACHINE, kFlashRegistryRoot, KEY_READ);
329 DWORD debug_value;
330 if (path_key.ReadValueDW(kIsDebuggerValueName, &debug_value) != ERROR_SUCCESS)
331 return false;
332
333 return (debug_value == 1);
334 #else
335 // TODO(wfh): implement this on OS X and Linux. crbug.com/497996.
336 return false;
337 #endif
338 }
339
340 bool GetSystemPepperFlash(content::PepperPluginInfo* plugin) { 339 bool GetSystemPepperFlash(content::PepperPluginInfo* plugin) {
341 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 340 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
342 bool system_flash_is_debug = IsSystemFlashScriptDebuggerPresent();
343
344 #if defined(FLAPPER_AVAILABLE)
345 // If flapper is available, only try the system plugin if either:
346 // --disable-bundled-ppapi-flash is specified, or the system debugger is the
347 // Flash Script Debugger.
348 if (!(command_line->HasSwitch(switches::kDisableBundledPpapiFlash) ||
349 system_flash_is_debug)) {
350 return false;
351 }
352 #endif // defined(FLAPPER_AVAILABLE)
353
354 // Do not try and find System Pepper Flash if there is a specific path on 341 // Do not try and find System Pepper Flash if there is a specific path on
355 // the commmand-line. 342 // the commmand-line.
356 if (command_line->HasSwitch(switches::kPpapiFlashPath)) 343 if (command_line->HasSwitch(switches::kPpapiFlashPath))
357 return false; 344 return false;
358 345
359 base::FilePath flash_filename; 346 base::FilePath flash_filename;
360 if (!PathService::Get(chrome::FILE_PEPPER_FLASH_SYSTEM_PLUGIN, 347 if (!PathService::Get(chrome::FILE_PEPPER_FLASH_SYSTEM_PLUGIN,
361 &flash_filename)) 348 &flash_filename))
362 return false; 349 return false;
363 350
(...skipping 11 matching lines...) Expand all
375 if (!manifest_value.get()) 362 if (!manifest_value.get())
376 return false; 363 return false;
377 base::DictionaryValue* manifest = NULL; 364 base::DictionaryValue* manifest = NULL;
378 if (!manifest_value->GetAsDictionary(&manifest)) 365 if (!manifest_value->GetAsDictionary(&manifest))
379 return false; 366 return false;
380 367
381 Version version; 368 Version version;
382 if (!chrome::CheckPepperFlashManifest(*manifest, &version)) 369 if (!chrome::CheckPepperFlashManifest(*manifest, &version))
383 return false; 370 return false;
384 371
385 *plugin = CreatePepperFlashInfo(flash_filename, version.GetString(), 372 *plugin = CreatePepperFlashInfo(flash_filename,
386 system_flash_is_debug); 373 version.GetString(),
374 chrome::IsSystemFlashScriptDebuggerPresent(),
375 true,
376 false);
387 return true; 377 return true;
388 } 378 }
389 #endif // defined(ENABLE_PLUGINS) 379 #endif // defined(ENABLE_PLUGINS)
390 380
391 std::string GetProduct() { 381 std::string GetProduct() {
392 return version_info::GetProductNameAndVersionForUserAgent(); 382 return version_info::GetProductNameAndVersionForUserAgent();
393 } 383 }
394 384
395 } // namespace 385 } // namespace
396 386
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 #elif defined(OS_POSIX) 446 #elif defined(OS_POSIX)
457 base::debug::SetCrashKeyValue(crash_keys::kGPUVendor, gpu_info.gl_vendor); 447 base::debug::SetCrashKeyValue(crash_keys::kGPUVendor, gpu_info.gl_vendor);
458 base::debug::SetCrashKeyValue(crash_keys::kGPURenderer, gpu_info.gl_renderer); 448 base::debug::SetCrashKeyValue(crash_keys::kGPURenderer, gpu_info.gl_renderer);
459 #endif 449 #endif
460 } 450 }
461 451
462 #if defined(ENABLE_PLUGINS) 452 #if defined(ENABLE_PLUGINS)
463 // static 453 // static
464 content::PepperPluginInfo* ChromeContentClient::FindMostRecentPlugin( 454 content::PepperPluginInfo* ChromeContentClient::FindMostRecentPlugin(
465 const std::vector<content::PepperPluginInfo*>& plugins) { 455 const std::vector<content::PepperPluginInfo*>& plugins) {
466 auto it = std::max_element( 456 if (plugins.empty())
467 plugins.begin(), plugins.end(), 457 return nullptr;
468 [](content::PepperPluginInfo* x, content::PepperPluginInfo* y) { 458
469 Version version_x(x->version); 459 using PluginSortKey = base::Tuple<base::Version, bool, bool, bool, bool>;
Will Harris 2016/04/25 23:49:07 note: changed this back to base::Tuple as std::tup
470 Version version_y(y->version); 460
471 DCHECK(version_x.IsValid() && version_y.IsValid()); 461 std::map<PluginSortKey, content::PepperPluginInfo*> plugin_map;
472 if (version_x == version_y) 462
473 return !x->is_debug && y->is_debug; 463 for (const auto& plugin : plugins) {
474 return version_x < version_y; 464 Version version(plugin->version);
475 }); 465 DCHECK(version.IsValid());
476 return it != plugins.end() ? *it : nullptr; 466 plugin_map[PluginSortKey(version, plugin->is_debug,
467 plugin->is_bundled, plugin->is_on_local_drive,
468 !plugin->is_external)] = plugin;
469 }
470
471 return plugin_map.rbegin()->second;
477 } 472 }
478 #endif // defined(ENABLE_PLUGINS) 473 #endif // defined(ENABLE_PLUGINS)
479 474
480 void ChromeContentClient::AddPepperPlugins( 475 void ChromeContentClient::AddPepperPlugins(
481 std::vector<content::PepperPluginInfo>* plugins) { 476 std::vector<content::PepperPluginInfo>* plugins) {
482 #if defined(ENABLE_PLUGINS) 477 #if defined(ENABLE_PLUGINS)
483 ComputeBuiltInPlugins(plugins); 478 ComputeBuiltInPlugins(plugins);
484 AddPepperFlashFromCommandLine(plugins); 479 AddPepperFlashFromCommandLine(plugins);
485 480
486 #if defined(OS_LINUX) 481 #if defined(OS_LINUX)
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 #if defined(ENABLE_EXTENSIONS) 634 #if defined(ENABLE_EXTENSIONS)
640 return extensions::IsIsolateExtensionsEnabled(); 635 return extensions::IsIsolateExtensionsEnabled();
641 #else 636 #else
642 return false; 637 return false;
643 #endif 638 #endif
644 } 639 }
645 640
646 base::StringPiece ChromeContentClient::GetOriginTrialPublicKey() { 641 base::StringPiece ChromeContentClient::GetOriginTrialPublicKey() {
647 return origin_trial_key_manager_.GetPublicKey(); 642 return origin_trial_key_manager_.GetPublicKey();
648 } 643 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/plugins/plugins_handler.cc ('k') | chrome/common/chrome_content_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698