diff options
-rw-r--r-- | chrome/browser/dom_ui/plugins_ui.cc | 18 | ||||
-rw-r--r-- | chrome/browser/plugin_service.cc | 21 | ||||
-rw-r--r-- | chrome/common/chrome_paths.cc | 4 | ||||
-rw-r--r-- | chrome/common/chrome_paths.h | 1 | ||||
-rw-r--r-- | chrome/common/pref_names.cc | 5 | ||||
-rw-r--r-- | chrome/common/pref_names.h | 1 |
6 files changed, 46 insertions, 4 deletions
diff --git a/chrome/browser/dom_ui/plugins_ui.cc b/chrome/browser/dom_ui/plugins_ui.cc index fcaf606..77cb0d4 100644 --- a/chrome/browser/dom_ui/plugins_ui.cc +++ b/chrome/browser/dom_ui/plugins_ui.cc @@ -11,6 +11,7 @@ #include "app/l10n_util.h" #include "app/resource_bundle.h" #include "base/message_loop.h" +#include "base/path_service.h" #include "base/singleton.h" #include "base/values.h" #include "chrome/browser/browser.h" @@ -19,6 +20,7 @@ #include "chrome/browser/dom_ui/chrome_url_data_manager.h" #include "chrome/browser/pref_service.h" #include "chrome/browser/profile.h" +#include "chrome/common/chrome_paths.h" #include "chrome/common/jstemplate_builder.h" #include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" @@ -258,9 +260,16 @@ DictionaryValue* PluginsDOMHandler::CreatePluginSummaryValue( return plugin_data; } +// TODO(viettrungluu): move this (and the registration of the prefs into the +// plugins service. void PluginsDOMHandler::UpdatePreferences() { - ListValue* plugins_list = dom_ui_->GetProfile()->GetPrefs()->GetMutableList( - prefs::kPluginsPluginsList); + PrefService* prefs = dom_ui_->GetProfile()->GetPrefs(); + + FilePath internal_dir; + if (PathService::Get(chrome::DIR_INTERNAL_PLUGINS, &internal_dir)) + prefs->SetFilePath(prefs::kPluginsLastInternalDirectory, internal_dir); + + ListValue* plugins_list = prefs->GetMutableList(prefs::kPluginsPluginsList); plugins_list->Clear(); std::vector<WebPluginInfo> plugins; @@ -303,5 +312,10 @@ RefCountedMemory* PluginsUI::GetFaviconResourceBytes() { // static void PluginsUI::RegisterUserPrefs(PrefService* prefs) { + FilePath internal_dir; + PathService::Get(chrome::DIR_INTERNAL_PLUGINS, &internal_dir); + prefs->RegisterFilePathPref(prefs::kPluginsLastInternalDirectory, + internal_dir); + prefs->RegisterListPref(prefs::kPluginsPluginsList); } diff --git a/chrome/browser/plugin_service.cc b/chrome/browser/plugin_service.cc index 12739c8..5565c0a 100644 --- a/chrome/browser/plugin_service.cc +++ b/chrome/browser/plugin_service.cc @@ -56,6 +56,13 @@ bool PluginService::enable_chrome_plugins_ = true; void PluginService::InitGlobalInstance(Profile* profile) { DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); + bool update_internal_dir = false; + FilePath last_internal_dir = + profile->GetPrefs()->GetFilePath(prefs::kPluginsLastInternalDirectory); + FilePath cur_internal_dir; + if (PathService::Get(chrome::DIR_INTERNAL_PLUGINS, &cur_internal_dir)) + update_internal_dir = (cur_internal_dir != last_internal_dir); + // Disable plugins listed as disabled in prefs. if (const ListValue* saved_plugins_list = profile->GetPrefs()->GetList(prefs::kPluginsPluginsList)) { @@ -71,8 +78,18 @@ void PluginService::InitGlobalInstance(Profile* profile) { FilePath::StringType path; bool enabled = true; plugin->GetBoolean(L"enabled", &enabled); - if (!enabled && plugin->GetString(L"path", &path)) - NPAPI::PluginList::Singleton()->DisablePlugin(FilePath(path)); + if (!enabled && plugin->GetString(L"path", &path)) { + FilePath plugin_path(path); + NPAPI::PluginList::Singleton()->DisablePlugin(plugin_path); + + // If the internal plugin directory has changed and if the plugin looks + // internal, also disable it in the current internal plugins directory. + if (update_internal_dir && + plugin_path.DirName() == last_internal_dir) { + NPAPI::PluginList::Singleton()->DisablePlugin( + cur_internal_dir.Append(plugin_path.BaseName())); + } + } } } diff --git a/chrome/common/chrome_paths.cc b/chrome/common/chrome_paths.cc index aefcebc..6a6c232 100644 --- a/chrome/common/chrome_paths.cc +++ b/chrome/common/chrome_paths.cc @@ -192,6 +192,10 @@ bool PathProvider(int key, FilePath* result) { cur = cur.Append(FILE_PATH_LITERAL("Temp")); create_dir = true; break; + case chrome::DIR_INTERNAL_PLUGINS: + if (!GetInternalPluginsDirectory(&cur)) + return false; + break; case chrome::FILE_LOCAL_STATE: if (!PathService::Get(chrome::DIR_USER_DATA, &cur)) return false; diff --git a/chrome/common/chrome_paths.h b/chrome/common/chrome_paths.h index 9ed8057..482e5da 100644 --- a/chrome/common/chrome_paths.h +++ b/chrome/common/chrome_paths.h @@ -36,6 +36,7 @@ enum { // this when a temporary file or directory will // be moved into the profile, to avoid issues // moving across volumes. See crbug.com/13044 . + DIR_INTERNAL_PLUGINS, // Directory where internal plugins reside. FILE_RESOURCE_MODULE, // Full path and filename of the module that // contains embedded resources (version, // strings, images, etc.). diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc index 40bd9f4..3f40b8f 100644 --- a/chrome/common/pref_names.cc +++ b/chrome/common/pref_names.cc @@ -326,6 +326,11 @@ const wchar_t kExtensionsUIDeveloperMode[] = L"extensions.ui.developer_mode"; // actions toolbar. const wchar_t kExtensionToolbarSize[] = L"extensions.toolbarsize"; +// Pref containing the directory for internal plugins as written to the plugins +// list (below). +const wchar_t kPluginsLastInternalDirectory[] = + L"plugins.last_internal_directory"; + // List pref containing information (dictionaries) on plugins. const wchar_t kPluginsPluginsList[] = L"plugins.plugins_list"; diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h index 6a22114..b9d4161 100644 --- a/chrome/common/pref_names.h +++ b/chrome/common/pref_names.h @@ -130,6 +130,7 @@ extern const wchar_t kCurrentThemeTints[]; extern const wchar_t kCurrentThemeDisplayProperties[]; extern const wchar_t kExtensionsUIDeveloperMode[]; extern const wchar_t kExtensionToolbarSize[]; +extern const wchar_t kPluginsLastInternalDirectory[]; extern const wchar_t kPluginsPluginsList[]; extern const wchar_t kCheckDefaultBrowser[]; #if defined(OS_MACOSX) |