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

Side by Side Diff: chrome/browser/plugins/plugin_prefs.cc

Issue 12388012: Ignore the disabled state of component-updated PPAPI Flash for once. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 9 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 | « no previous file | chrome/browser/plugins/plugin_prefs_factory.cc » ('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) 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/plugins/plugin_prefs.h" 5 #include "chrome/browser/plugins/plugin_prefs.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 25 matching lines...) Expand all
36 36
37 using content::BrowserThread; 37 using content::BrowserThread;
38 using content::PluginService; 38 using content::PluginService;
39 39
40 namespace { 40 namespace {
41 41
42 // How long to wait to save the plugin enabled information, which might need to 42 // How long to wait to save the plugin enabled information, which might need to
43 // go to disk. 43 // go to disk.
44 const int64 kPluginUpdateDelayMs = 60 * 1000; 44 const int64 kPluginUpdateDelayMs = 60 * 1000;
45 45
46 bool IsComponentUpdatedPepperFlash(const base::FilePath& plugin) {
47 if (plugin.BaseName().value() == chrome::kPepperFlashPluginFilename) {
48 base::FilePath component_updated_pepper_flash_dir;
49 if (PathService::Get(chrome::DIR_COMPONENT_UPDATED_PEPPER_FLASH_PLUGIN,
50 &component_updated_pepper_flash_dir) &&
51 component_updated_pepper_flash_dir.IsParent(plugin)) {
52 return true;
53 }
54 }
55
56 return false;
57 }
58
46 } // namespace 59 } // namespace
47 60
48 PluginPrefs::PluginState::PluginState() { 61 PluginPrefs::PluginState::PluginState() {
49 } 62 }
50 63
51 PluginPrefs::PluginState::~PluginState() { 64 PluginPrefs::PluginState::~PluginState() {
52 } 65 }
53 66
54 bool PluginPrefs::PluginState::Get(const base::FilePath& plugin, 67 bool PluginPrefs::PluginState::Get(const base::FilePath& plugin,
55 bool* enabled) const { 68 bool* enabled) const {
56 base::FilePath key = ConvertMapKey(plugin); 69 base::FilePath key = ConvertMapKey(plugin);
57 std::map<base::FilePath, bool>::const_iterator iter = state_.find(key); 70 std::map<base::FilePath, bool>::const_iterator iter = state_.find(key);
58 if (iter != state_.end()) { 71 if (iter != state_.end()) {
59 *enabled = iter->second; 72 *enabled = iter->second;
60 return true; 73 return true;
61 } 74 }
62 return false; 75 return false;
63 } 76 }
64 77
65 void PluginPrefs::PluginState::Set(const base::FilePath& plugin, bool enabled) { 78 void PluginPrefs::PluginState::Set(const base::FilePath& plugin, bool enabled) {
66 state_[ConvertMapKey(plugin)] = enabled; 79 state_[ConvertMapKey(plugin)] = enabled;
67 } 80 }
68 81
69 base::FilePath PluginPrefs::PluginState::ConvertMapKey( 82 base::FilePath PluginPrefs::PluginState::ConvertMapKey(
70 const base::FilePath& plugin) const { 83 const base::FilePath& plugin) const {
71 // Keep the state of component-updated and bundled Pepper Flash in sync. 84 // Keep the state of component-updated and bundled Pepper Flash in sync.
72 if (plugin.BaseName().value() == chrome::kPepperFlashPluginFilename) { 85 if (IsComponentUpdatedPepperFlash(plugin)) {
73 base::FilePath component_updated_pepper_flash_dir; 86 base::FilePath bundled_pepper_flash;
74 if (PathService::Get(chrome::DIR_COMPONENT_UPDATED_PEPPER_FLASH_PLUGIN, 87 if (PathService::Get(chrome::FILE_PEPPER_FLASH_PLUGIN,
75 &component_updated_pepper_flash_dir) && 88 &bundled_pepper_flash)) {
76 component_updated_pepper_flash_dir.IsParent(plugin)) { 89 return bundled_pepper_flash;
77 base::FilePath bundled_pepper_flash;
78 if (PathService::Get(chrome::FILE_PEPPER_FLASH_PLUGIN,
79 &bundled_pepper_flash)) {
80 return bundled_pepper_flash;
81 }
82 } 90 }
83 } 91 }
84 92
85 return plugin; 93 return plugin;
86 } 94 }
87 95
88 // static 96 // static
89 scoped_refptr<PluginPrefs> PluginPrefs::GetForProfile(Profile* profile) { 97 scoped_refptr<PluginPrefs> PluginPrefs::GetForProfile(Profile* profile) {
90 return PluginPrefsFactory::GetPrefsForProfile(profile); 98 return PluginPrefsFactory::GetPrefsForProfile(profile);
91 } 99 }
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 if (!prefs_->GetBoolean(prefs::kPluginsEnabledNaCl)) { 354 if (!prefs_->GetBoolean(prefs::kPluginsEnabledNaCl)) {
347 // We switched to the nacl plugin being on by default, and so we need to 355 // We switched to the nacl plugin being on by default, and so we need to
348 // force it to be enabled. We only want to do it this once though, i.e. 356 // force it to be enabled. We only want to do it this once though, i.e.
349 // we don't want to enable it again if the user disables it afterwards. 357 // we don't want to enable it again if the user disables it afterwards.
350 prefs_->SetBoolean(prefs::kPluginsEnabledNaCl, true); 358 prefs_->SetBoolean(prefs::kPluginsEnabledNaCl, true);
351 force_enable_nacl = true; 359 force_enable_nacl = true;
352 } 360 }
353 361
354 bool migrate_to_pepper_flash = false; 362 bool migrate_to_pepper_flash = false;
355 #if defined(OS_WIN) || defined(OS_MACOSX) 363 #if defined(OS_WIN) || defined(OS_MACOSX)
356 // If bundled NPAPI Flash is enabled while Peppper Flash is disabled, we 364 // If bundled NPAPI Flash is enabled while Pepper Flash is disabled, we
357 // would like to turn Pepper Flash on. And we only want to do it once. 365 // would like to turn Pepper Flash on. And we only want to do it once.
358 // TODO(yzshen): Remove all |migrate_to_pepper_flash|-related code after it 366 // TODO(yzshen): Remove all |migrate_to_pepper_flash|-related code after it
359 // has been run once by most users. (Maybe Chrome 24 or Chrome 25.) 367 // has been run once by most users. (Maybe Chrome 24 or Chrome 25.)
360 // NOTE(shess): Keep in mind that Mac is on a different schedule. 368 // NOTE(shess): Keep in mind that Mac is on a different schedule.
361 if (!prefs_->GetBoolean(prefs::kPluginsMigratedToPepperFlash)) { 369 if (!prefs_->GetBoolean(prefs::kPluginsMigratedToPepperFlash)) {
362 prefs_->SetBoolean(prefs::kPluginsMigratedToPepperFlash, true); 370 prefs_->SetBoolean(prefs::kPluginsMigratedToPepperFlash, true);
363 migrate_to_pepper_flash = true; 371 migrate_to_pepper_flash = true;
364 } 372 }
365 #endif 373 #endif
366 374
375 bool remove_component_pepper_flash_settings = false;
376 // If component-updated Pepper Flash is disabled, we would like to remove that
377 // settings item. And we only want to do it once. (Please see the comments of
378 // kPluginsRemovedOldComponentPepperFlashSettings for why.)
379 // TODO(yzshen): Remove all |remove_component_pepper_flash_settings|-related
380 // code after it has been run once by most users.
381 if (!prefs_->GetBoolean(
382 prefs::kPluginsRemovedOldComponentPepperFlashSettings)) {
383 prefs_->SetBoolean(prefs::kPluginsRemovedOldComponentPepperFlashSettings,
384 true);
385 remove_component_pepper_flash_settings = true;
386 }
387
367 { // Scoped update of prefs::kPluginsPluginsList. 388 { // Scoped update of prefs::kPluginsPluginsList.
368 ListPrefUpdate update(prefs_, prefs::kPluginsPluginsList); 389 ListPrefUpdate update(prefs_, prefs::kPluginsPluginsList);
369 ListValue* saved_plugins_list = update.Get(); 390 ListValue* saved_plugins_list = update.Get();
370 if (saved_plugins_list && !saved_plugins_list->empty()) { 391 if (saved_plugins_list && !saved_plugins_list->empty()) {
371 // The following four variables are only valid when 392 // The following four variables are only valid when
372 // |migrate_to_pepper_flash| is set to true. 393 // |migrate_to_pepper_flash| is set to true.
373 base::FilePath npapi_flash; 394 base::FilePath npapi_flash;
374 base::FilePath pepper_flash; 395 base::FilePath pepper_flash;
375 DictionaryValue* pepper_flash_node = NULL; 396 DictionaryValue* pepper_flash_node = NULL;
376 bool npapi_flash_enabled = false; 397 bool npapi_flash_enabled = false;
377 if (migrate_to_pepper_flash) { 398 if (migrate_to_pepper_flash) {
378 PathService::Get(chrome::FILE_FLASH_PLUGIN, &npapi_flash); 399 PathService::Get(chrome::FILE_FLASH_PLUGIN, &npapi_flash);
379 PathService::Get(chrome::FILE_PEPPER_FLASH_PLUGIN, &pepper_flash); 400 PathService::Get(chrome::FILE_PEPPER_FLASH_PLUGIN, &pepper_flash);
380 } 401 }
381 402
382 for (ListValue::const_iterator it = saved_plugins_list->begin(); 403 // Used when |remove_component_pepper_flash_settings| is set to true.
404 ListValue::iterator component_pepper_flash_node =
405 saved_plugins_list->end();
406
407 for (ListValue::iterator it = saved_plugins_list->begin();
383 it != saved_plugins_list->end(); 408 it != saved_plugins_list->end();
384 ++it) { 409 ++it) {
385 if (!(*it)->IsType(Value::TYPE_DICTIONARY)) { 410 if (!(*it)->IsType(Value::TYPE_DICTIONARY)) {
386 LOG(WARNING) << "Invalid entry in " << prefs::kPluginsPluginsList; 411 LOG(WARNING) << "Invalid entry in " << prefs::kPluginsPluginsList;
387 continue; // Oops, don't know what to do with this item. 412 continue; // Oops, don't know what to do with this item.
388 } 413 }
389 414
390 DictionaryValue* plugin = static_cast<DictionaryValue*>(*it); 415 DictionaryValue* plugin = static_cast<DictionaryValue*>(*it);
391 string16 group_name; 416 string16 group_name;
392 bool enabled; 417 bool enabled;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 } 479 }
455 } else if (migrate_to_pepper_flash && 480 } else if (migrate_to_pepper_flash &&
456 base::FilePath::CompareEqualIgnoreCase( 481 base::FilePath::CompareEqualIgnoreCase(
457 path, npapi_flash.value())) { 482 path, npapi_flash.value())) {
458 npapi_flash_enabled = enabled; 483 npapi_flash_enabled = enabled;
459 } else if (migrate_to_pepper_flash && 484 } else if (migrate_to_pepper_flash &&
460 base::FilePath::CompareEqualIgnoreCase( 485 base::FilePath::CompareEqualIgnoreCase(
461 path, pepper_flash.value())) { 486 path, pepper_flash.value())) {
462 if (!enabled) 487 if (!enabled)
463 pepper_flash_node = plugin; 488 pepper_flash_node = plugin;
489 } else if (remove_component_pepper_flash_settings &&
490 IsComponentUpdatedPepperFlash(plugin_path)) {
491 if (!enabled) {
492 component_pepper_flash_node = it;
493 // Skip setting |enabled| into |plugin_state_|.
494 continue;
495 }
464 } 496 }
465 497
466 plugin_state_.Set(plugin_path, enabled); 498 plugin_state_.Set(plugin_path, enabled);
467 } else if (!enabled && plugin->GetString("name", &group_name)) { 499 } else if (!enabled && plugin->GetString("name", &group_name)) {
468 // Don't disable this group if it's for the pdf or nacl plugins and 500 // Don't disable this group if it's for the pdf or nacl plugins and
469 // we just forced it on. 501 // we just forced it on.
470 if (force_enable_internal_pdf && pdf_group_name == group_name) 502 if (force_enable_internal_pdf && pdf_group_name == group_name)
471 continue; 503 continue;
472 if (force_enable_nacl && (nacl_group_name == group_name || 504 if (force_enable_nacl && (nacl_group_name == group_name ||
473 old_nacl_group_name == group_name)) 505 old_nacl_group_name == group_name))
474 continue; 506 continue;
475 507
476 // Otherwise this is a list of groups. 508 // Otherwise this is a list of groups.
477 plugin_group_state_[group_name] = false; 509 plugin_group_state_[group_name] = false;
478 } 510 }
479 } 511 }
480 512
481 if (npapi_flash_enabled && pepper_flash_node) { 513 if (npapi_flash_enabled && pepper_flash_node) {
482 DCHECK(migrate_to_pepper_flash); 514 DCHECK(migrate_to_pepper_flash);
483 pepper_flash_node->SetBoolean("enabled", true); 515 pepper_flash_node->SetBoolean("enabled", true);
484 plugin_state_.Set(pepper_flash, true); 516 plugin_state_.Set(pepper_flash, true);
485 } 517 }
518
519 if (component_pepper_flash_node != saved_plugins_list->end()) {
520 DCHECK(remove_component_pepper_flash_settings);
521 saved_plugins_list->Erase(component_pepper_flash_node, NULL);
522 }
486 } else { 523 } else {
487 // If the saved plugin list is empty, then the call to UpdatePreferences() 524 // If the saved plugin list is empty, then the call to UpdatePreferences()
488 // below failed in an earlier run, possibly because the user closed the 525 // below failed in an earlier run, possibly because the user closed the
489 // browser too quickly. Try to force enable the internal PDF and nacl 526 // browser too quickly. Try to force enable the internal PDF and nacl
490 // plugins again. 527 // plugins again.
491 force_enable_internal_pdf = true; 528 force_enable_internal_pdf = true;
492 force_enable_nacl = true; 529 force_enable_nacl = true;
493 } 530 }
494 } // Scoped update of prefs::kPluginsPluginsList. 531 } // Scoped update of prefs::kPluginsPluginsList.
495 532
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 } 665 }
629 } 666 }
630 667
631 void PluginPrefs::NotifyPluginStatusChanged() { 668 void PluginPrefs::NotifyPluginStatusChanged() {
632 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 669 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
633 content::NotificationService::current()->Notify( 670 content::NotificationService::current()->Notify(
634 chrome::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED, 671 chrome::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED,
635 content::Source<Profile>(profile_), 672 content::Source<Profile>(profile_),
636 content::NotificationService::NoDetails()); 673 content::NotificationService::NoDetails());
637 } 674 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/plugins/plugin_prefs_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698