diff options
-rw-r--r-- | chrome/browser/dom_ui/plugins_ui.cc | 1 | ||||
-rw-r--r-- | chrome/browser/plugin_service.cc | 76 | ||||
-rw-r--r-- | chrome/browser/plugin_service.h | 3 | ||||
-rw-r--r-- | chrome/browser/renderer_host/browser_render_process_host.cc | 1 | ||||
-rw-r--r-- | chrome/common/chrome_plugin_lib.cc | 6 | ||||
-rw-r--r-- | chrome/common/chrome_switches.cc | 3 | ||||
-rw-r--r-- | chrome/common/chrome_switches.h | 1 | ||||
-rw-r--r-- | chrome/common/pref_names.cc | 4 | ||||
-rw-r--r-- | chrome/common/pref_names.h | 1 | ||||
-rw-r--r-- | chrome/renderer/render_process_impl.cc | 32 | ||||
-rw-r--r-- | chrome/renderer/render_view.cc | 11 |
11 files changed, 88 insertions, 51 deletions
diff --git a/chrome/browser/dom_ui/plugins_ui.cc b/chrome/browser/dom_ui/plugins_ui.cc index 77cb0d4..b24a902 100644 --- a/chrome/browser/dom_ui/plugins_ui.cc +++ b/chrome/browser/dom_ui/plugins_ui.cc @@ -318,4 +318,5 @@ void PluginsUI::RegisterUserPrefs(PrefService* prefs) { internal_dir); prefs->RegisterListPref(prefs::kPluginsPluginsList); + prefs->RegisterBooleanPref(prefs::kPluginsEnabledInternalPDF, false); } diff --git a/chrome/browser/plugin_service.cc b/chrome/browser/plugin_service.cc index 5565c0a..d0a56ba 100644 --- a/chrome/browser/plugin_service.cc +++ b/chrome/browser/plugin_service.cc @@ -51,6 +51,7 @@ static void NotifyPluginsOfActivation() { // static bool PluginService::enable_chrome_plugins_ = true; +bool PluginService::enable_internal_pdf_ = false; // static void PluginService::InitGlobalInstance(Profile* profile) { @@ -60,12 +61,30 @@ void PluginService::InitGlobalInstance(Profile* profile) { 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); + if (PathService::Get(chrome::DIR_INTERNAL_PLUGINS, &cur_internal_dir) && + cur_internal_dir != last_internal_dir) { + update_internal_dir = true; + profile->GetPrefs()->SetFilePath( + prefs::kPluginsLastInternalDirectory, cur_internal_dir); + } + + bool found_internal_pdf = false; + bool force_enable_internal_pdf = false; + FilePath pdf_path; + PathService::Get(chrome::FILE_PDF_PLUGIN, &pdf_path); + FilePath::StringType pdf_path_str = pdf_path.value(); + if (enable_internal_pdf_ && + !profile->GetPrefs()->GetBoolean(prefs::kPluginsEnabledInternalPDF)) { + // We switched to the internal pdf plugin being on by default, and so we + // need to force it to be enabled. We only want to do it this once though, + // i.e. we don't want to enable it again if the user disables it afterwards. + profile->GetPrefs()->SetBoolean(prefs::kPluginsEnabledInternalPDF, true); + force_enable_internal_pdf = true; + } // Disable plugins listed as disabled in prefs. - if (const ListValue* saved_plugins_list = - profile->GetPrefs()->GetList(prefs::kPluginsPluginsList)) { + if (ListValue* saved_plugins_list = + profile->GetPrefs()->GetMutableList(prefs::kPluginsPluginsList)) { for (ListValue::const_iterator it = saved_plugins_list->begin(); it != saved_plugins_list->end(); ++it) { @@ -76,23 +95,39 @@ void PluginService::InitGlobalInstance(Profile* profile) { DictionaryValue* plugin = static_cast<DictionaryValue*>(*it); FilePath::StringType path; + if (!plugin->GetString(L"path", &path)) + continue; + bool enabled = true; plugin->GetBoolean(L"enabled", &enabled); - 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())); + if (path == pdf_path_str) { + found_internal_pdf = true; + if (!enabled && force_enable_internal_pdf) { + enabled = true; + plugin->SetBoolean(L"enabled", true); } } + + FilePath plugin_path(path); + if (update_internal_dir && plugin_path.DirName() == last_internal_dir) { + // If the internal plugin directory has changed and if the plugin looks + // internal, update its path in the prefs. + plugin_path = cur_internal_dir.Append(plugin_path.BaseName()); + plugin->SetString(L"path", plugin_path.value()); + } + + if (!enabled) + NPAPI::PluginList::Singleton()->DisablePlugin(plugin_path); } } + if (!enable_internal_pdf_ && !found_internal_pdf) { + // The internal PDF plugin is disabled by default, and the user hasn't + // overridden the default. + NPAPI::PluginList::Singleton()->DisablePlugin(pdf_path); + } + // Have Chrome plugins write their data to the profile directory. GetInstance()->SetChromePluginDataDir(profile->GetPath()); } @@ -116,16 +151,19 @@ PluginService::PluginService() // Load the one specified on the command line as well. const CommandLine* command_line = CommandLine::ForCurrentProcess(); FilePath path = command_line->GetSwitchValuePath(switches::kLoadPlugin); - if (!path.empty()) { + if (!path.empty()) NPAPI::PluginList::Singleton()->AddExtraPluginPath(path); - } - FilePath pdf; - if (command_line->HasSwitch(switches::kInternalPDF) && - PathService::Get(chrome::FILE_PDF_PLUGIN, &pdf)) { - NPAPI::PluginList::Singleton()->AddExtraPluginPath(pdf); + // Register the internal Flash and PDF, if available. + if (!CommandLine::ForCurrentProcess()->HasSwitch( + switches::kDisableInternalFlash) && + PathService::Get(chrome::FILE_FLASH_PLUGIN, &path)) { + NPAPI::PluginList::Singleton()->AddExtraPluginPath(path); } + if (PathService::Get(chrome::FILE_PDF_PLUGIN, &path)) + NPAPI::PluginList::Singleton()->AddExtraPluginPath(path); + #ifndef DISABLE_NACL if (command_line->HasSwitch(switches::kInternalNaCl)) RegisterInternalNaClPlugin(); diff --git a/chrome/browser/plugin_service.h b/chrome/browser/plugin_service.h index bc793bc..3ed6f31 100644 --- a/chrome/browser/plugin_service.h +++ b/chrome/browser/plugin_service.h @@ -153,6 +153,9 @@ class PluginService // Set to true if chrome plugins are enabled. Defaults to true. static bool enable_chrome_plugins_; + // Set to true iff the internal pdf plugin is enabled by default. + static bool enable_internal_pdf_; + DISALLOW_COPY_AND_ASSIGN(PluginService); }; diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc index 19d0c0b..cebc522 100644 --- a/chrome/browser/renderer_host/browser_render_process_host.cc +++ b/chrome/browser/renderer_host/browser_render_process_host.cc @@ -540,7 +540,6 @@ void BrowserRenderProcessHost::PropagateBrowserCommandLineToRenderer( switches::kSimpleDataSource, switches::kEnableBenchmarking, switches::kInternalNaCl, - switches::kInternalPDF, switches::kInternalPepper, switches::kRegisterPepperPlugins, switches::kDisableByteRangeSupport, diff --git a/chrome/common/chrome_plugin_lib.cc b/chrome/common/chrome_plugin_lib.cc index e9d0224..daf6bb7 100644 --- a/chrome/common/chrome_plugin_lib.cc +++ b/chrome/common/chrome_plugin_lib.cc @@ -115,12 +115,6 @@ void ChromePluginLib::RegisterPluginsWithNPAPI() { // Register Gears, if available. if (PathService::Get(chrome::FILE_GEARS_PLUGIN, &path)) NPAPI::PluginList::Singleton()->AddExtraPluginPath(path); - - // Register the internal Flash, if available. - if (!CommandLine::ForCurrentProcess()->HasSwitch( - switches::kDisableInternalFlash) && - PathService::Get(chrome::FILE_FLASH_PLUGIN, &path)) - NPAPI::PluginList::Singleton()->AddExtraPluginPath(path); } static void LogPluginLoadTime(const TimeDelta &time) { diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index ffa3a378..64da0bd 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -496,9 +496,6 @@ const char kIncognito[] = "incognito"; // Runs the Native Client inside the renderer process. const char kInternalNaCl[] = "internal-nacl"; -// Uses internal plugin for displaying PDFs. -const char kInternalPDF[] = "internal-pdf"; - // Runs a trusted Pepper plugin inside the renderer process. const char kInternalPepper[] = "internal-pepper"; diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index d880ad0..26a94f9 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -146,7 +146,6 @@ extern const char kInProcessPlugins[]; extern const char kInProcessWebGL[]; extern const char kIncognito[]; extern const char kInternalNaCl[]; -extern const char kInternalPDF[]; extern const char kInternalPepper[]; extern const char kJavaScriptFlags[]; extern const char kLoadExtension[]; diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc index 4bb20c0..adcf924 100644 --- a/chrome/common/pref_names.cc +++ b/chrome/common/pref_names.cc @@ -328,6 +328,10 @@ const wchar_t kPluginsLastInternalDirectory[] = // List pref containing information (dictionaries) on plugins. const wchar_t kPluginsPluginsList[] = L"plugins.plugins_list"; +// When first shipped, the pdf plugin will be disabled by default. When we +// enable it by default, we'll want to do so only once. +const wchar_t kPluginsEnabledInternalPDF[] = L"plugins.enabled_internal_pdf"; + // Boolean that indicates whether we should check if we are the default browser // on start-up. const wchar_t kCheckDefaultBrowser[] = L"browser.check_default_browser"; diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h index 4b17742..4b968b5 100644 --- a/chrome/common/pref_names.h +++ b/chrome/common/pref_names.h @@ -131,6 +131,7 @@ extern const wchar_t kExtensionsUIDeveloperMode[]; extern const wchar_t kExtensionToolbarSize[]; extern const wchar_t kPluginsLastInternalDirectory[]; extern const wchar_t kPluginsPluginsList[]; +extern const wchar_t kPluginsEnabledInternalPDF[]; extern const wchar_t kCheckDefaultBrowser[]; #if defined(OS_MACOSX) extern const wchar_t kShowUpdatePromotionInfoBar[]; diff --git a/chrome/renderer/render_process_impl.cc b/chrome/renderer/render_process_impl.cc index 321f0d0..02c3697 100644 --- a/chrome/renderer/render_process_impl.cc +++ b/chrome/renderer/render_process_impl.cc @@ -163,26 +163,24 @@ RenderProcessImpl::RenderProcessImpl() #endif // Load the pdf plugin before the sandbox is turned on. - if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kInternalPDF)) { - FilePath pdf; - if (PathService::Get(chrome::FILE_PDF_PLUGIN, &pdf)) { - static scoped_refptr<NPAPI::PluginLib> pdf_lib = - NPAPI::PluginLib::CreatePluginLib(pdf); - // Actually load the plugin. - pdf_lib->NP_Initialize(); - // Keep an instance around to prevent the plugin unloading after a pdf is - // closed. - // Don't use scoped_ptr here because then get asserts on process shut down - // when running in --single-process. - static NPAPI::PluginInstance* instance = pdf_lib->CreateInstance(""); - instance->plugin_lib(); // Quiet unused variable warnings in gcc. + FilePath pdf; + if (PathService::Get(chrome::FILE_PDF_PLUGIN, &pdf)) { + static scoped_refptr<NPAPI::PluginLib> pdf_lib = + NPAPI::PluginLib::CreatePluginLib(pdf); + // Actually load the plugin. + pdf_lib->NP_Initialize(); + // Keep an instance around to prevent the plugin unloading after a pdf is + // closed. + // Don't use scoped_ptr here because then get asserts on process shut down + // when running in --single-process. + static NPAPI::PluginInstance* instance = pdf_lib->CreateInstance(""); + instance->plugin_lib(); // Quiet unused variable warnings in gcc. #if defined(OS_WIN) - g_iat_patch_createdca.Patch( - pdf_lib->plugin_info().path.value().c_str(), - "gdi32.dll", "CreateDCA", CreateDCAPatch); + g_iat_patch_createdca.Patch( + pdf_lib->plugin_info().path.value().c_str(), + "gdi32.dll", "CreateDCA", CreateDCAPatch); #endif - } } } diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index d72b965..e1a0dc3 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -16,6 +16,7 @@ #include "base/compiler_specific.h" #include "base/field_trial.h" #include "base/histogram.h" +#include "base/path_service.h" #include "base/process_util.h" #include "base/singleton.h" #include "base/string_piece.h" @@ -25,8 +26,9 @@ #include "chrome/common/appcache/appcache_dispatcher.h" #include "chrome/common/bindings_policy.h" #include "chrome/common/child_process_logging.h" -#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_constants.h" +#include "chrome/common/chrome_paths.h" +#include "chrome/common/chrome_switches.h" #include "chrome/common/extensions/extension_constants.h" #include "chrome/common/jstemplate_builder.h" #include "chrome/common/page_zoom.h" @@ -3114,6 +3116,9 @@ webkit_glue::WebPluginDelegate* RenderView::CreatePluginDelegate( if (path.value().empty()) return NULL; + FilePath internal_pdf_path; + PathService::Get(chrome::FILE_PDF_PLUGIN, &internal_pdf_path); + const std::string* mime_type_to_use; if (!actual_mime_type->empty()) mime_type_to_use = actual_mime_type; @@ -3133,9 +3138,7 @@ webkit_glue::WebPluginDelegate* RenderView::CreatePluginDelegate( // In process Pepper plugins must be explicitly enabled. return NULL; } - } else if (CommandLine::ForCurrentProcess()-> - HasSwitch(switches::kInternalPDF) && - StartsWithASCII(*mime_type_to_use, "application/pdf", true)) { + } else if (path == internal_pdf_path) { in_process_plugin = true; use_pepper_host = true; } |