Commit de91eb61 authored by Lei Zhang's avatar Lei Zhang Committed by Commit Bot

Use BUILDFLAG(ENABLE_PLUGINS) in chrome/browser/e*

Guard plugin code with BUILDFLAG(ENABLE_PLUGINS) in enterprise_reporting
and extensions sub-directories. Also exclude
c/b/extensions/plugin_manager.* when plugins are disabled.

Also make modified files lint free.

Bug: 1027360
Change-Id: I60328f7dd8747da65d4ad0ae6507697186bf9af1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1997654
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: default avatarOwen Min <zmin@chromium.org>
Reviewed-by: default avatarDavid Bertoni <dbertoni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#732217}
parent fea88985
......@@ -4,6 +4,9 @@
#include "chrome/browser/enterprise_reporting/browser_report_generator.h"
#include <string>
#include <utility>
#include "base/files/file_path.h"
#include "base/path_service.h"
#include "base/strings/utf_string_conversions.h"
......@@ -15,13 +18,16 @@
#include "components/policy/core/common/cloud/cloud_policy_util.h"
#include "components/version_info/channel.h"
#include "components/version_info/version_info.h"
#include "content/public/browser/plugin_service.h"
#include "content/public/common/webplugininfo.h"
#if defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#endif // defined(OS_CHROMEOS)
#if BUILDFLAG(ENABLE_PLUGINS)
#include "content/public/browser/plugin_service.h"
#endif
namespace {
std::string GetExecutablePath() {
......@@ -48,7 +54,7 @@ void BrowserReportGenerator::Generate(ReportCallback callback) {
// std::move is required here because the function completes the report
// asynchronously.
GeneratePlugins(std::move(report));
GeneratePluginsIfNeeded(std::move(report));
}
void BrowserReportGenerator::GenerateBasicInfos(em::BrowserReport* report) {
......@@ -79,9 +85,9 @@ void BrowserReportGenerator::GenerateProfileInfos(em::BrowserReport* report) {
}
}
void BrowserReportGenerator::GeneratePlugins(
void BrowserReportGenerator::GeneratePluginsIfNeeded(
std::unique_ptr<em::BrowserReport> report) {
#if defined(OS_CHROMEOS)
#if defined(OS_CHROMEOS) || !BUILDFLAG(ENABLE_PLUGINS)
std::move(callback_).Run(std::move(report));
#else
content::PluginService::GetInstance()->GetPlugins(
......@@ -90,6 +96,7 @@ void BrowserReportGenerator::GeneratePlugins(
#endif
}
#if BUILDFLAG(ENABLE_PLUGINS)
void BrowserReportGenerator::OnPluginsReady(
std::unique_ptr<em::BrowserReport> report,
const std::vector<content::WebPluginInfo>& plugins) {
......@@ -103,5 +110,6 @@ void BrowserReportGenerator::OnPluginsReady(
std::move(callback_).Run(std::move(report));
}
#endif // BUILDFLAG(ENABLE_PLUGINS)
} // namespace enterprise_reporting
......@@ -5,9 +5,13 @@
#ifndef CHROME_BROWSER_ENTERPRISE_REPORTING_BROWSER_REPORT_GENERATOR_H_
#define CHROME_BROWSER_ENTERPRISE_REPORTING_BROWSER_REPORT_GENERATOR_H_
#include <memory>
#include <vector>
#include "base/callback.h"
#include "base/memory/weak_ptr.h"
#include "components/policy/proto/device_management_backend.pb.h"
#include "ppapi/buildflags/buildflags.h"
namespace em = enterprise_management;
......@@ -42,12 +46,14 @@ class BrowserReportGenerator {
// Generate user profiles info in the given report instance.
void GenerateProfileInfos(em::BrowserReport* report);
// Generate plugin info in the given report instance. It requires the
// ownership of report instance to pass into ReportCallback method.
void GeneratePlugins(std::unique_ptr<em::BrowserReport> report);
// Generate plugin info in the given report instance, if needed. It requires
// the ownership of report instance to pass into ReportCallback method.
void GeneratePluginsIfNeeded(std::unique_ptr<em::BrowserReport> report);
#if BUILDFLAG(ENABLE_PLUGINS)
void OnPluginsReady(std::unique_ptr<em::BrowserReport> report,
const std::vector<content::WebPluginInfo>& plugins);
#endif
ReportCallback callback_;
......
......@@ -660,8 +660,6 @@ jumbo_static_library("extensions") {
"permissions_based_management_policy_provider.h",
"permissions_updater.cc",
"permissions_updater.h",
"plugin_manager.cc",
"plugin_manager.h",
"policy_extension_reinstaller.cc",
"policy_extension_reinstaller.h",
"policy_handlers.cc",
......@@ -1151,6 +1149,13 @@ jumbo_static_library("extensions") {
]
}
if (enable_plugins) {
sources += [
"plugin_manager.cc",
"plugin_manager.h",
]
}
if (enable_print_preview && !is_chromeos) {
sources += [
"api/cloud_print_private/cloud_print_private_api.cc",
......
......@@ -16,8 +16,6 @@
#include "base/values.h"
#include "chrome/browser/browsing_data/browsing_data_helper.h"
#include "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h"
#include "chrome/browser/plugins/plugin_data_remover_helper.h"
#include "chrome/browser/plugins/plugin_prefs.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/account_reconcilor_factory.h"
#include "chrome/browser/signin/identity_manager_factory.h"
......@@ -27,6 +25,7 @@
#include "chrome/common/chrome_features.h"
#include "chrome/common/pref_names.h"
#include "components/browsing_data/core/pref_names.h"
#include "components/prefs/pref_service.h"
#include "components/signin/public/identity_manager/identity_manager.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
......@@ -36,9 +35,14 @@
#include "extensions/common/extension.h"
#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
using content::BrowserThread;
using browsing_data::ClearBrowsingDataTab;
#if BUILDFLAG(ENABLE_PLUGINS)
#include "chrome/browser/plugins/plugin_data_remover_helper.h"
#include "chrome/browser/plugins/plugin_prefs.h"
#endif
using browsing_data::BrowsingDataType;
using browsing_data::ClearBrowsingDataTab;
using content::BrowserThread;
namespace extension_browsing_data_api_constants {
// Parameter name keys.
......@@ -347,6 +351,7 @@ bool BrowsingDataRemoverFunction::RunAsync() {
return false;
}
#if BUILDFLAG(ENABLE_PLUGINS)
if (removal_mask_ &
ChromeBrowsingDataRemoverDelegate::DATA_TYPE_PLUGIN_DATA) {
// If we're being asked to remove plugin data, check whether it's actually
......@@ -361,6 +366,9 @@ bool BrowsingDataRemoverFunction::RunAsync() {
} else {
StartRemoving();
}
#else
StartRemoving();
#endif
// Will finish asynchronously.
return true;
......@@ -372,6 +380,7 @@ bool BrowsingDataRemoverFunction::IsPauseSyncAllowed() {
return true;
}
#if BUILDFLAG(ENABLE_PLUGINS)
void BrowsingDataRemoverFunction::CheckRemovingPluginDataSupported(
scoped_refptr<PluginPrefs> plugin_prefs) {
if (!PluginDataRemoverHelper::IsSupported(plugin_prefs.get()))
......@@ -381,6 +390,7 @@ void BrowsingDataRemoverFunction::CheckRemovingPluginDataSupported(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(&BrowsingDataRemoverFunction::StartRemoving, this));
}
#endif
void BrowsingDataRemoverFunction::StartRemoving() {
Profile* profile = GetProfile();
......
......@@ -9,7 +9,7 @@
#ifndef CHROME_BROWSER_EXTENSIONS_API_BROWSING_DATA_BROWSING_DATA_API_H_
#define CHROME_BROWSER_EXTENSIONS_API_BROWSING_DATA_BROWSING_DATA_API_H_
#include <string>
#include <memory>
#include <vector>
#include "base/scoped_observer.h"
......@@ -18,6 +18,7 @@
#include "components/signin/core/browser/account_reconcilor.h"
#include "content/public/browser/browsing_data_filter_builder.h"
#include "content/public/browser/browsing_data_remover.h"
#include "ppapi/buildflags/buildflags.h"
class PluginPrefs;
class PrefService;
......@@ -123,10 +124,12 @@ class BrowsingDataRemoverFunction
// pausing Sync would prevent the data from being deleted on the server.
virtual bool IsPauseSyncAllowed();
#if BUILDFLAG(ENABLE_PLUGINS)
// Updates the removal bitmask according to whether removing plugin data is
// supported or not.
void CheckRemovingPluginDataSupported(
scoped_refptr<PluginPrefs> plugin_prefs);
#endif
// Parse the developer-provided |origin_types| object into |origin_type_mask|
// that can be used with the BrowsingDataRemover.
......
......@@ -6,8 +6,8 @@
#include <memory>
#include <set>
#include <string>
#include <utility>
#include <vector>
#include "base/bind.h"
#include "base/command_line.h"
......@@ -24,8 +24,6 @@
#include "chrome/browser/extensions/api/content_settings/content_settings_store.h"
#include "chrome/browser/extensions/api/preference/preference_api_constants.h"
#include "chrome/browser/extensions/api/preference/preference_helpers.h"
#include "chrome/browser/plugins/plugin_finder.h"
#include "chrome/browser/plugins/plugin_installer.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/chrome_switches.h"
......@@ -38,14 +36,18 @@
#include "components/content_settings/core/common/content_settings.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/plugin_service.h"
#include "content/public/common/webplugininfo.h"
#include "extensions/browser/extension_prefs_scope.h"
#include "extensions/browser/extension_util.h"
#include "extensions/common/error_utils.h"
#if BUILDFLAG(ENABLE_PLUGINS)
#include "chrome/browser/plugins/plugin_finder.h"
#include "chrome/browser/plugins/plugin_installer.h"
#include "content/public/browser/plugin_service.h"
#endif
using content::BrowserThread;
using content::PluginService;
namespace Clear = extensions::api::content_settings::ContentSetting::Clear;
namespace Get = extensions::api::content_settings::ContentSetting::Get;
......@@ -320,13 +322,17 @@ bool ContentSettingsContentSettingGetResourceIdentifiersFunction::RunAsync() {
return true;
}
PluginService::GetInstance()->GetPlugins(base::BindOnce(
#if BUILDFLAG(ENABLE_PLUGINS)
content::PluginService::GetInstance()->GetPlugins(base::BindOnce(
&ContentSettingsContentSettingGetResourceIdentifiersFunction::
OnGotPlugins,
this));
#endif
return true;
}
#if BUILDFLAG(ENABLE_PLUGINS)
void ContentSettingsContentSettingGetResourceIdentifiersFunction::OnGotPlugins(
const std::vector<content::WebPluginInfo>& plugins) {
PluginFinder* finder = PluginFinder::GetInstance();
......@@ -354,5 +360,6 @@ void ContentSettingsContentSettingGetResourceIdentifiersFunction::OnGotPlugins(
SendResponse,
this, true));
}
#endif // BUILDFLAG(ENABLE_PLUGINS)
} // namespace extensions
......@@ -5,8 +5,11 @@
#ifndef CHROME_BROWSER_EXTENSIONS_API_CONTENT_SETTINGS_CONTENT_SETTINGS_API_H_
#define CHROME_BROWSER_EXTENSIONS_API_CONTENT_SETTINGS_CONTENT_SETTINGS_API_H_
#include <vector>
#include "base/gtest_prod_util.h"
#include "chrome/browser/extensions/chrome_extension_function.h"
#include "ppapi/buildflags/buildflags.h"
namespace content {
struct WebPluginInfo;
......@@ -63,9 +66,11 @@ class ContentSettingsContentSettingGetResourceIdentifiersFunction
FRIEND_TEST_ALL_PREFIXES(ExtensionApiTest,
ContentSettingsGetResourceIdentifiers);
#if BUILDFLAG(ENABLE_PLUGINS)
// Callback method that gets executed when |plugins|
// are asynchronously fetched.
void OnGotPlugins(const std::vector<content::WebPluginInfo>& plugins);
#endif
};
} // namespace extensions
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment