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

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

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