
Automated patch, intended to be effectively a no-op. Context: https://groups.google.com/a/chromium.org/g/cxx/c/nBD_1LaanTc/m/ghh-ZZhWAwAJ?utm_medium=email&utm_source=footer As of https://crrev.com/1204351, absl::optional is now a type alias for std::optional. We should migrate toward it. Script: ``` function replace { echo "Replacing $1 by $2" git grep -l "$1" \ | cut -f1 -d: \ | grep \ -e "^content" \ | sort \ | uniq \ | grep \ -e "\.h" \ -e "\.cc" \ -e "\.mm" \ -e "\.py" \ | xargs sed -i "s/$1/$2/g" } replace "absl::make_optional" "std::make_optional" replace "absl::optional" "std::optional" replace "absl::nullopt" "std::nullopt" replace "absl::in_place" "std::in_place" replace "absl::in_place_t" "std::in_place_t" replace "\"third_party\/abseil-cpp\/absl\/types\/optional.h\"" "<optional>" git cl format ``` # Skipping unrelated "check_network_annotation" errors. NOTRY=True Bug: chromium:1500249 Change-Id: Icfd31a71d8faf63a2e8d5401127e7ee74cc1c413 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5185537 Auto-Submit: Arthur Sonzogni <arthursonzogni@chromium.org> Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org> Owners-Override: Avi Drissman <avi@chromium.org> Reviewed-by: Avi Drissman <avi@chromium.org> Reviewed-by: danakj <danakj@chromium.org> Cr-Commit-Position: refs/heads/main@{#1245739}
142 lines
5.4 KiB
C++
142 lines
5.4 KiB
C++
// Copyright 2012 The Chromium Authors
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#ifndef CONTENT_BROWSER_PLUGIN_SERVICE_IMPL_H_
|
|
#define CONTENT_BROWSER_PLUGIN_SERVICE_IMPL_H_
|
|
|
|
#include <map>
|
|
#include <optional>
|
|
#include <vector>
|
|
|
|
#include "base/memory/raw_ptr.h"
|
|
#include "base/memory/singleton.h"
|
|
#include "base/time/time.h"
|
|
#include "build/build_config.h"
|
|
#include "content/common/content_export.h"
|
|
#include "content/public/browser/plugin_service.h"
|
|
#include "ppapi/buildflags/buildflags.h"
|
|
#include "url/gurl.h"
|
|
#include "url/origin.h"
|
|
|
|
#if !BUILDFLAG(ENABLE_PLUGINS)
|
|
#error "Plugins should be enabled"
|
|
#endif
|
|
|
|
#if BUILDFLAG(ENABLE_PPAPI)
|
|
#include "content/browser/ppapi_plugin_process_host.h"
|
|
#endif
|
|
|
|
namespace content {
|
|
class PluginServiceFilter;
|
|
struct ContentPluginInfo;
|
|
|
|
// This class responds to requests from renderers for the list of plugins, and
|
|
// also a proxy object for plugin instances. It lives on the UI thread.
|
|
class CONTENT_EXPORT PluginServiceImpl : public PluginService {
|
|
public:
|
|
// Returns the PluginServiceImpl singleton.
|
|
static PluginServiceImpl* GetInstance();
|
|
|
|
PluginServiceImpl(const PluginServiceImpl&) = delete;
|
|
PluginServiceImpl& operator=(const PluginServiceImpl&) = delete;
|
|
|
|
// PluginService implementation:
|
|
void Init() override;
|
|
bool GetPluginInfoArray(const GURL& url,
|
|
const std::string& mime_type,
|
|
bool allow_wildcard,
|
|
std::vector<WebPluginInfo>* info,
|
|
std::vector<std::string>* actual_mime_types) override;
|
|
bool GetPluginInfo(content::BrowserContext* browser_context,
|
|
const GURL& url,
|
|
const std::string& mime_type,
|
|
bool allow_wildcard,
|
|
bool* is_stale,
|
|
WebPluginInfo* info,
|
|
std::string* actual_mime_type) override;
|
|
bool GetPluginInfoByPath(const base::FilePath& plugin_path,
|
|
WebPluginInfo* info) override;
|
|
std::u16string GetPluginDisplayNameByPath(
|
|
const base::FilePath& path) override;
|
|
void GetPlugins(GetPluginsCallback callback) override;
|
|
std::vector<WebPluginInfo> GetPluginsSynchronous() override;
|
|
const ContentPluginInfo* GetRegisteredPluginInfo(
|
|
const base::FilePath& plugin_path) override;
|
|
void SetFilter(PluginServiceFilter* filter) override;
|
|
PluginServiceFilter* GetFilter() override;
|
|
bool IsPluginUnstable(const base::FilePath& plugin_path) override;
|
|
void RefreshPlugins() override;
|
|
void RegisterInternalPlugin(const WebPluginInfo& info,
|
|
bool add_at_beginning) override;
|
|
void UnregisterInternalPlugin(const base::FilePath& path) override;
|
|
void GetInternalPlugins(std::vector<WebPluginInfo>* plugins) override;
|
|
bool PpapiDevChannelSupported(BrowserContext* browser_context,
|
|
const GURL& document_url) override;
|
|
|
|
#if BUILDFLAG(ENABLE_PPAPI)
|
|
// Returns the plugin process host corresponding to the plugin process that
|
|
// has been started by this service. This will start a process to host the
|
|
// 'plugin_path' if needed. If the process fails to start, the return value
|
|
// is NULL.
|
|
PpapiPluginProcessHost* FindOrStartPpapiPluginProcess(
|
|
int render_process_id,
|
|
const base::FilePath& plugin_path,
|
|
const base::FilePath& profile_data_directory,
|
|
const std::optional<url::Origin>& origin_lock);
|
|
|
|
// Opens a channel to a plugin process for the given mime type, starting
|
|
// a new plugin process if necessary.
|
|
void OpenChannelToPpapiPlugin(int render_process_id,
|
|
const base::FilePath& plugin_path,
|
|
const base::FilePath& profile_data_directory,
|
|
const std::optional<url::Origin>& origin_lock,
|
|
PpapiPluginProcessHost::PluginClient* client);
|
|
#endif // BUILDFLAG(ENABLE_PPAPI)
|
|
|
|
// Used to monitor plugin stability.
|
|
void RegisterPluginCrash(const base::FilePath& plugin_path);
|
|
|
|
// For testing without creating many, many processes.
|
|
void SetMaxPpapiProcessesPerProfileForTesting(int number) {
|
|
max_ppapi_processes_per_profile_ = number;
|
|
}
|
|
|
|
private:
|
|
friend struct base::DefaultSingletonTraits<PluginServiceImpl>;
|
|
|
|
// Pulled out of the air, seems reasonable.
|
|
static constexpr int kDefaultMaxPpapiProcessesPerProfile = 15;
|
|
|
|
// Creates the PluginServiceImpl object, but doesn't actually build the plugin
|
|
// list yet. It's generated lazily.
|
|
PluginServiceImpl();
|
|
~PluginServiceImpl() override;
|
|
|
|
#if BUILDFLAG(ENABLE_PPAPI)
|
|
// Returns the plugin process host corresponding to the plugin process that
|
|
// has been started by this service. Returns NULL if no process has been
|
|
// started.
|
|
PpapiPluginProcessHost* FindPpapiPluginProcess(
|
|
const base::FilePath& plugin_path,
|
|
const base::FilePath& profile_data_directory,
|
|
const std::optional<url::Origin>& origin_lock);
|
|
#endif // BUILDFLAG(ENABLE_PPAPI)
|
|
|
|
void RegisterPlugins();
|
|
|
|
std::vector<ContentPluginInfo> plugins_;
|
|
|
|
int max_ppapi_processes_per_profile_ = kDefaultMaxPpapiProcessesPerProfile;
|
|
|
|
// Weak pointer; set during the startup and must outlive us.
|
|
raw_ptr<PluginServiceFilter, DanglingUntriaged> filter_ = nullptr;
|
|
|
|
// Used to detect if a given plugin is crashing over and over.
|
|
std::map<base::FilePath, std::vector<base::Time>> crash_times_;
|
|
};
|
|
|
|
} // namespace content
|
|
|
|
#endif // CONTENT_BROWSER_PLUGIN_SERVICE_IMPL_H_
|