<commit_before>// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "webkit/glue/plugins/plugin_list.h"

#include "base/command_line.h"
#include "base/file_util.h"
#include "base/path_service.h"
#include "base/string_util.h"
#include "build/build_config.h"

namespace {

// Return true if we're in debug-plugin-loading mode.
bool DebugPluginLoading() {
  static const char kDebugPluginLoading[] = "debug-plugin-loading";
  return CommandLine::ForCurrentProcess()->HasSwitch(kDebugPluginLoading);
}

// Shorthand way of logging plugin load status.
#define PLUG_LOG if (DebugPluginLoading()) LOG(INFO)

// We build up a list of files and mtimes so we can sort them.
typedef std::pair<FilePath, base::Time> FileAndTime;
typedef std::vector<FileAndTime> FileTimeList;

// Comparator used to sort by descending mtime then ascending filename.
bool CompareTime(const FileAndTime& a, const FileAndTime& b) {
  if (a.second == b.second) {
    // Fall back on filename sorting, just to make the predicate valid.
    return a.first < b.first;
  }

  // Sort by mtime, descending.
  return a.second > b.second;
}

// Some plugins are shells around other plugins; we prefer to use the
// real plugin directly, if it's available.  This function returns
// true if we should prefer other plugins over this one.  We'll still
// use a "undesirable" plugin if no other option is available.
bool IsUndesirablePlugin(const WebPluginInfo& info) {
  std::string filename = info.path.BaseName().value();
  return (filename.find("npcxoffice") != std::string::npos || // Crossover
          filename.find("npwrapper") != std::string::npos);   // nspluginwrapper
}

// Return true if we shouldn't load a plugin at all.
// This is an ugly hack to blacklist Adobe Acrobat due to not supporting
// its Xt-based mainloop.
// http://code.google.com/p/chromium/issues/detail?id=38229
bool IsBlacklistedPlugin(const WebPluginInfo& info) {
  std::string filename = info.path.BaseName().value();
  return filename.find("nppdf.so") != std::string::npos;
}<commit_msg>Linux: Blacklist the gecko-mediaplayer plugin. It sometimes hangs/crashes the browser.<commit_after>// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "webkit/glue/plugins/plugin_list.h"

#include "base/command_line.h"
#include "base/file_util.h"
#include "base/path_service.h"
#include "base/string_util.h"
#include "build/build_config.h"

namespace {

// Return true if we're in debug-plugin-loading mode.
bool DebugPluginLoading() {
  static const char kDebugPluginLoading[] = "debug-plugin-loading";
  return CommandLine::ForCurrentProcess()->HasSwitch(kDebugPluginLoading);
}

// Shorthand way of logging plugin load status.
#define PLUG_LOG if (DebugPluginLoading()) LOG(INFO)

// We build up a list of files and mtimes so we can sort them.
typedef std::pair<FilePath, base::Time> FileAndTime;
typedef std::vector<FileAndTime> FileTimeList;

// Comparator used to sort by descending mtime then ascending filename.
bool CompareTime(const FileAndTime& a, const FileAndTime& b) {
  if (a.second == b.second) {
    // Fall back on filename sorting, just to make the predicate valid.
    return a.first < b.first;
  }

  // Sort by mtime, descending.
  return a.second > b.second;
}

// Some plugins are shells around other plugins; we prefer to use the
// real plugin directly, if it's available.  This function returns
// true if we should prefer other plugins over this one.  We'll still
// use a "undesirable" plugin if no other option is available.
bool IsUndesirablePlugin(const WebPluginInfo& info) {
  std::string filename = info.path.BaseName().value();
  const char* kUndesiredPlugins[] = {
    "npcxoffice",  // Crossover
    "npwrapper",   // nspluginwrapper
  };
  for (size_t i = 0; i < arraysize(kUndesiredPlugins); i++) {
    if (filename.find(kUndesiredPlugins[i]) != std::string::npos) {
      return true;
    }
  }
  return false;
}

// Return true if we shouldn't load a plugin at all.
// This is an ugly hack to blacklist Adobe Acrobat due to not supporting
// its Xt-based mainloop.
// http://code.google.com/p/chromium/issues/detail?id=38229
// The gecko-mediaplayer plugins also crashes the entire browser sometimes.
// http://code.google.com/p/chromium/issues/detail?id=24507
bool IsBlacklistedPlugin(const WebPluginInfo& info) {
  const char* kBlackListedPlugins[] = {
    "nppdf.so",           // Adobe PDF
    "gecko-mediaplayer",  // Gecko Media Player
  };
  std::string filename = info.path.BaseName().value();
  for (size_t i = 0; i < arraysize(kBlackListedPlugins); i++) {
    if (filename.find(kBlackListedPlugins[i]) != std::string::npos) {
      return true;
    }
  }
  return false;
}
{'fraction_non_alphanumeric': 0.11692809126094927, 'fraction_numerical': 0.005092686901609289, 'mean_word_length': 3.984771573604061, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2480698', 'n_tokens_mistral': 1568, 'n_tokens_neox': 1490, 'n_words': 506}