Commit fcc9661b authored by Joe Mason's avatar Joe Mason Committed by Commit Bot

Remove ChromeCleanupProtobufIPC feature which is launched to 100%

* Removes the ChromePromptChannelMojo class and supporting code.
* Merges ChromePromptChannelProtobuf into the base ChromePromptChannel.
* Removes ChromePromptActions::PromptAcceptance which duplicated the
  PromptAcceptance enum from the protobuf.

R=proberge

Bug: 969139
Change-Id: I11350428dfddee2ec942ceda2fdb2dbc67aac863
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1903947
Commit-Queue: Joe Mason <joenotcharles@chromium.org>
Reviewed-by: default avatarproberge <proberge@chromium.org>
Cr-Commit-Position: refs/heads/master@{#713456}
parent 0b9effbc
...@@ -3819,7 +3819,6 @@ jumbo_static_library("browser") { ...@@ -3819,7 +3819,6 @@ jumbo_static_library("browser") {
"//components/browser_watcher:browser_watcher_client", "//components/browser_watcher:browser_watcher_client",
"//components/browser_watcher:stability_client", "//components/browser_watcher:stability_client",
"//components/chrome_cleaner/public/constants", "//components/chrome_cleaner/public/constants",
"//components/chrome_cleaner/public/interfaces",
"//components/download/quarantine", "//components/download/quarantine",
"//third_party/crashpad/crashpad/client:client", "//third_party/crashpad/crashpad/client:client",
"//third_party/iaccessible2", "//third_party/iaccessible2",
......
...@@ -22,7 +22,6 @@ source_set("public") { ...@@ -22,7 +22,6 @@ source_set("public") {
deps = [ deps = [
"//base", "//base",
"//components/chrome_cleaner/public/constants", "//components/chrome_cleaner/public/constants",
"//components/chrome_cleaner/public/interfaces",
"//components/variations", "//components/variations",
"//url", "//url",
] ]
...@@ -63,7 +62,6 @@ jumbo_static_library("chrome_cleaner") { ...@@ -63,7 +62,6 @@ jumbo_static_library("chrome_cleaner") {
"//chrome/common", "//chrome/common",
"//chrome/installer/util:with_no_strings", "//chrome/installer/util:with_no_strings",
"//components/chrome_cleaner/public/constants", "//components/chrome_cleaner/public/constants",
"//components/chrome_cleaner/public/interfaces",
"//components/chrome_cleaner/public/proto", "//components/chrome_cleaner/public/proto",
"//components/component_updater", "//components/component_updater",
"//components/crx_file", "//components/crx_file",
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#include "chrome/installer/util/scoped_token_privilege.h" #include "chrome/installer/util/scoped_token_privilege.h"
#include "components/chrome_cleaner/public/constants/constants.h" #include "components/chrome_cleaner/public/constants/constants.h"
#include "components/chrome_cleaner/public/proto/chrome_prompt.pb.h"
#include "components/component_updater/component_updater_service.h" #include "components/component_updater/component_updater_service.h"
#include "components/component_updater/pref_names.h" #include "components/component_updater/pref_names.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
...@@ -53,7 +54,7 @@ namespace safe_browsing { ...@@ -53,7 +54,7 @@ namespace safe_browsing {
namespace { namespace {
using ::content::BrowserThread; using ::content::BrowserThread;
using PromptAcceptance = ChromePromptActions::PromptAcceptance; using PromptUserResponse = chrome_cleaner::PromptUserResponse;
// The global singleton instance. Exposed outside of GetInstance() so that it // The global singleton instance. Exposed outside of GetInstance() so that it
// can be reset by tests. // can be reset by tests.
...@@ -470,11 +471,11 @@ void ChromeCleanerControllerImpl::ReplyWithUserResponse( ...@@ -470,11 +471,11 @@ void ChromeCleanerControllerImpl::ReplyWithUserResponse(
DCHECK(prompt_user_reply_callback_); DCHECK(prompt_user_reply_callback_);
PromptAcceptance acceptance = PromptAcceptance::DENIED; PromptUserResponse::PromptAcceptance acceptance = PromptUserResponse::DENIED;
State new_state = State::kIdle; State new_state = State::kIdle;
switch (user_response) { switch (user_response) {
case UserResponse::kAcceptedWithLogs: case UserResponse::kAcceptedWithLogs:
acceptance = PromptAcceptance::ACCEPTED_WITH_LOGS; acceptance = PromptUserResponse::ACCEPTED_WITH_LOGS;
SetLogsEnabled(profile, true); SetLogsEnabled(profile, true);
RecordCleanerLogsAcceptanceHistogram(true); RecordCleanerLogsAcceptanceHistogram(true);
new_state = State::kCleaning; new_state = State::kCleaning;
...@@ -483,7 +484,7 @@ void ChromeCleanerControllerImpl::ReplyWithUserResponse( ...@@ -483,7 +484,7 @@ void ChromeCleanerControllerImpl::ReplyWithUserResponse(
extension_registry_ = extensions::ExtensionRegistry::Get(profile); extension_registry_ = extensions::ExtensionRegistry::Get(profile);
break; break;
case UserResponse::kAcceptedWithoutLogs: case UserResponse::kAcceptedWithoutLogs:
acceptance = PromptAcceptance::ACCEPTED_WITHOUT_LOGS; acceptance = PromptUserResponse::ACCEPTED_WITHOUT_LOGS;
SetLogsEnabled(profile, false); SetLogsEnabled(profile, false);
RecordCleanerLogsAcceptanceHistogram(false); RecordCleanerLogsAcceptanceHistogram(false);
new_state = State::kCleaning; new_state = State::kCleaning;
...@@ -493,7 +494,7 @@ void ChromeCleanerControllerImpl::ReplyWithUserResponse( ...@@ -493,7 +494,7 @@ void ChromeCleanerControllerImpl::ReplyWithUserResponse(
break; break;
case UserResponse::kDenied: // Fallthrough case UserResponse::kDenied: // Fallthrough
case UserResponse::kDismissed: case UserResponse::kDismissed:
acceptance = PromptAcceptance::DENIED; acceptance = PromptUserResponse::DENIED;
idle_reason_ = IdleReason::kUserDeclinedCleanup; idle_reason_ = IdleReason::kUserDeclinedCleanup;
new_state = State::kIdle; new_state = State::kIdle;
break; break;
...@@ -631,9 +632,9 @@ void ChromeCleanerControllerImpl::WeakOnPromptUser( ...@@ -631,9 +632,9 @@ void ChromeCleanerControllerImpl::WeakOnPromptUser(
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
// If the weak pointer has been invalidated, the controller is no longer able // If the weak pointer has been invalidated, the controller is no longer able
// to receive callbacks, so respond with PromptAcceptance::Denied immediately. // to receive callbacks, so respond with DENIED immediately.
if (!controller) { if (!controller) {
std::move(reply_callback).Run(PromptAcceptance::DENIED); std::move(reply_callback).Run(PromptUserResponse::DENIED);
return; return;
} }
...@@ -656,7 +657,7 @@ void ChromeCleanerControllerImpl::OnPromptUser( ...@@ -656,7 +657,7 @@ void ChromeCleanerControllerImpl::OnPromptUser(
base::Time::Now() - time_scanning_started_); base::Time::Now() - time_scanning_started_);
if (scanner_results.files_to_delete().empty()) { if (scanner_results.files_to_delete().empty()) {
std::move(reply_callback).Run(PromptAcceptance::DENIED); std::move(reply_callback).Run(PromptUserResponse::DENIED);
idle_reason_ = IdleReason::kScanningFoundNothing; idle_reason_ = IdleReason::kScanningFoundNothing;
SetStateAndNotifyObservers(State::kIdle); SetStateAndNotifyObservers(State::kIdle);
RecordPromptNotShownWithReasonHistogram(NO_PROMPT_REASON_NOTHING_FOUND); RecordPromptNotShownWithReasonHistogram(NO_PROMPT_REASON_NOTHING_FOUND);
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "chrome/test/base/testing_profile.h" #include "chrome/test/base/testing_profile.h"
#include "chrome/test/base/testing_profile_manager.h" #include "chrome/test/base/testing_profile_manager.h"
#include "components/chrome_cleaner/public/constants/constants.h" #include "components/chrome_cleaner/public/constants/constants.h"
#include "components/chrome_cleaner/public/proto/chrome_prompt.pb.h"
#include "components/chrome_cleaner/test/test_name_helper.h" #include "components/chrome_cleaner/test/test_name_helper.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/test/browser_task_environment.h" #include "content/public/test/browser_task_environment.h"
...@@ -54,11 +55,9 @@ using ::testing::ValuesIn; ...@@ -54,11 +55,9 @@ using ::testing::ValuesIn;
using CrashPoint = MockChromeCleanerProcess::CrashPoint; using CrashPoint = MockChromeCleanerProcess::CrashPoint;
using ExtensionCleaningFeatureStatus = using ExtensionCleaningFeatureStatus =
MockChromeCleanerProcess::ExtensionCleaningFeatureStatus; MockChromeCleanerProcess::ExtensionCleaningFeatureStatus;
using ProtobufIPCFeatureStatus =
MockChromeCleanerProcess::ProtobufIPCFeatureStatus;
using IdleReason = ChromeCleanerController::IdleReason; using IdleReason = ChromeCleanerController::IdleReason;
using ItemsReporting = MockChromeCleanerProcess::ItemsReporting; using ItemsReporting = MockChromeCleanerProcess::ItemsReporting;
using PromptAcceptance = ChromePromptActions::PromptAcceptance; using PromptUserResponse = chrome_cleaner::PromptUserResponse;
using State = ChromeCleanerController::State; using State = ChromeCleanerController::State;
using UserResponse = ChromeCleanerController::UserResponse; using UserResponse = ChromeCleanerController::UserResponse;
using UwsFoundStatus = MockChromeCleanerProcess::UwsFoundStatus; using UwsFoundStatus = MockChromeCleanerProcess::UwsFoundStatus;
...@@ -66,19 +65,20 @@ using UwsFoundStatus = MockChromeCleanerProcess::UwsFoundStatus; ...@@ -66,19 +65,20 @@ using UwsFoundStatus = MockChromeCleanerProcess::UwsFoundStatus;
// Returns the PromptAcceptance value that ChromeCleanerController is supposed // Returns the PromptAcceptance value that ChromeCleanerController is supposed
// to send to the Chrome Cleaner process when ReplyWithUserResponse() is // to send to the Chrome Cleaner process when ReplyWithUserResponse() is
// called with |user_response|. // called with |user_response|.
PromptAcceptance UserResponseToPromptAcceptance(UserResponse user_response) { PromptUserResponse::PromptAcceptance UserResponseToPromptAcceptance(
UserResponse user_response) {
switch (user_response) { switch (user_response) {
case UserResponse::kAcceptedWithLogs: case UserResponse::kAcceptedWithLogs:
return PromptAcceptance::ACCEPTED_WITH_LOGS; return PromptUserResponse::ACCEPTED_WITH_LOGS;
case UserResponse::kAcceptedWithoutLogs: case UserResponse::kAcceptedWithoutLogs:
return PromptAcceptance::ACCEPTED_WITHOUT_LOGS; return PromptUserResponse::ACCEPTED_WITHOUT_LOGS;
case UserResponse::kDenied: // Fallthrough case UserResponse::kDenied: // Fallthrough
case UserResponse::kDismissed: case UserResponse::kDismissed:
return PromptAcceptance::DENIED; return PromptUserResponse::DENIED;
} }
NOTREACHED(); NOTREACHED();
return PromptAcceptance::UNSPECIFIED; return PromptUserResponse::UNSPECIFIED;
} }
class MockChromeCleanerControllerObserver class MockChromeCleanerControllerObserver
...@@ -232,7 +232,6 @@ typedef std::tuple<CleanerProcessStatus, ...@@ -232,7 +232,6 @@ typedef std::tuple<CleanerProcessStatus,
CrashPoint, CrashPoint,
UwsFoundStatus, UwsFoundStatus,
ExtensionCleaningFeatureStatus, ExtensionCleaningFeatureStatus,
ProtobufIPCFeatureStatus,
ItemsReporting, ItemsReporting,
ItemsReporting, ItemsReporting,
UserResponse> UserResponse>
...@@ -251,9 +250,8 @@ class ChromeCleanerControllerTest ...@@ -251,9 +250,8 @@ class ChromeCleanerControllerTest
void SetUp() override { void SetUp() override {
std::tie(process_status_, crash_point_, uws_found_status_, std::tie(process_status_, crash_point_, uws_found_status_,
extension_cleaning_feature_status_, protobuf_ipc_feature_status_, extension_cleaning_feature_status_, registry_keys_reporting_,
registry_keys_reporting_, extensions_reporting_, user_response_) = extensions_reporting_, user_response_) = GetParam();
GetParam();
std::vector<base::Feature> enabled_features; std::vector<base::Feature> enabled_features;
std::vector<base::Feature> disabled_features; std::vector<base::Feature> disabled_features;
...@@ -263,11 +261,6 @@ class ChromeCleanerControllerTest ...@@ -263,11 +261,6 @@ class ChromeCleanerControllerTest
} else { } else {
disabled_features.push_back(kChromeCleanupExtensionsFeature); disabled_features.push_back(kChromeCleanupExtensionsFeature);
} }
if (protobuf_ipc_feature_status_ == ProtobufIPCFeatureStatus::kEnabled) {
enabled_features.push_back(kChromeCleanupProtobufIPCFeature);
} else {
disabled_features.push_back(kChromeCleanupProtobufIPCFeature);
}
features_.InitWithFeatures(enabled_features, disabled_features); features_.InitWithFeatures(enabled_features, disabled_features);
InitializeEmptyExtensionService(); InitializeEmptyExtensionService();
...@@ -280,7 +273,7 @@ class ChromeCleanerControllerTest ...@@ -280,7 +273,7 @@ class ChromeCleanerControllerTest
cleaner_process_options_.set_crash_point(crash_point_); cleaner_process_options_.set_crash_point(crash_point_);
cleaner_process_options_.set_expected_user_response( cleaner_process_options_.set_expected_user_response(
uws_found_status_ == UwsFoundStatus::kNoUwsFound uws_found_status_ == UwsFoundStatus::kNoUwsFound
? PromptAcceptance::DENIED ? PromptUserResponse::DENIED
: UserResponseToPromptAcceptance(user_response_)); : UserResponseToPromptAcceptance(user_response_));
ChromeCleanerControllerImpl::ResetInstanceForTesting(); ChromeCleanerControllerImpl::ResetInstanceForTesting();
...@@ -471,7 +464,6 @@ class ChromeCleanerControllerTest ...@@ -471,7 +464,6 @@ class ChromeCleanerControllerTest
MockChromeCleanerProcess::CrashPoint crash_point_; MockChromeCleanerProcess::CrashPoint crash_point_;
UwsFoundStatus uws_found_status_; UwsFoundStatus uws_found_status_;
ExtensionCleaningFeatureStatus extension_cleaning_feature_status_; ExtensionCleaningFeatureStatus extension_cleaning_feature_status_;
ProtobufIPCFeatureStatus protobuf_ipc_feature_status_;
ItemsReporting registry_keys_reporting_; ItemsReporting registry_keys_reporting_;
ItemsReporting extensions_reporting_; ItemsReporting extensions_reporting_;
ChromeCleanerController::UserResponse user_response_; ChromeCleanerController::UserResponse user_response_;
...@@ -650,8 +642,6 @@ INSTANTIATE_TEST_SUITE_P( ...@@ -650,8 +642,6 @@ INSTANTIATE_TEST_SUITE_P(
UwsFoundStatus::kUwsFoundNoRebootRequired), UwsFoundStatus::kUwsFoundNoRebootRequired),
Values(ExtensionCleaningFeatureStatus::kEnabled, Values(ExtensionCleaningFeatureStatus::kEnabled,
ExtensionCleaningFeatureStatus::kDisabled), ExtensionCleaningFeatureStatus::kDisabled),
Values(ProtobufIPCFeatureStatus::kEnabled,
ProtobufIPCFeatureStatus::kDisabled),
Values(ItemsReporting::kUnsupported, Values(ItemsReporting::kUnsupported,
ItemsReporting::kNotReported, ItemsReporting::kNotReported,
ItemsReporting::kReported), ItemsReporting::kReported),
...@@ -671,8 +661,6 @@ INSTANTIATE_TEST_SUITE_P( ...@@ -671,8 +661,6 @@ INSTANTIATE_TEST_SUITE_P(
ValuesIn(kCrashPointsAfterStartup), ValuesIn(kCrashPointsAfterStartup),
Values(UwsFoundStatus::kUwsFoundRebootRequired), Values(UwsFoundStatus::kUwsFoundRebootRequired),
Values(ExtensionCleaningFeatureStatus::kEnabled), Values(ExtensionCleaningFeatureStatus::kEnabled),
Values(ProtobufIPCFeatureStatus::kEnabled,
ProtobufIPCFeatureStatus::kDisabled),
Values(ItemsReporting::kReported), Values(ItemsReporting::kReported),
Values(ItemsReporting::kReported), Values(ItemsReporting::kReported),
Values(UserResponse::kDenied, UserResponse::kDismissed)), Values(UserResponse::kDenied, UserResponse::kDismissed)),
...@@ -689,8 +677,6 @@ INSTANTIATE_TEST_SUITE_P( ...@@ -689,8 +677,6 @@ INSTANTIATE_TEST_SUITE_P(
ValuesIn(kCrashPointsAfterStartup), ValuesIn(kCrashPointsAfterStartup),
Values(UwsFoundStatus::kNoUwsFound), Values(UwsFoundStatus::kNoUwsFound),
Values(ExtensionCleaningFeatureStatus::kDisabled), Values(ExtensionCleaningFeatureStatus::kDisabled),
Values(ProtobufIPCFeatureStatus::kEnabled,
ProtobufIPCFeatureStatus::kDisabled),
Values(ItemsReporting::kNotReported), Values(ItemsReporting::kNotReported),
Values(ItemsReporting::kNotReported), Values(ItemsReporting::kNotReported),
Values(UserResponse::kDismissed)), Values(UserResponse::kDismissed)),
...@@ -706,7 +692,6 @@ INSTANTIATE_TEST_SUITE_P( ...@@ -706,7 +692,6 @@ INSTANTIATE_TEST_SUITE_P(
Values(CrashPoint::kNone), Values(CrashPoint::kNone),
Values(UwsFoundStatus::kNoUwsFound), Values(UwsFoundStatus::kNoUwsFound),
Values(ExtensionCleaningFeatureStatus::kDisabled), Values(ExtensionCleaningFeatureStatus::kDisabled),
Values(ProtobufIPCFeatureStatus::kDisabled),
Values(ItemsReporting::kUnsupported), Values(ItemsReporting::kUnsupported),
Values(ItemsReporting::kUnsupported), Values(ItemsReporting::kUnsupported),
Values(UserResponse::kAcceptedWithLogs)), Values(UserResponse::kAcceptedWithLogs)),
...@@ -726,8 +711,6 @@ INSTANTIATE_TEST_SUITE_P( ...@@ -726,8 +711,6 @@ INSTANTIATE_TEST_SUITE_P(
Values(CrashPoint::kOnStartup), Values(CrashPoint::kOnStartup),
Values(UwsFoundStatus::kNoUwsFound), Values(UwsFoundStatus::kNoUwsFound),
Values(ExtensionCleaningFeatureStatus::kDisabled), Values(ExtensionCleaningFeatureStatus::kDisabled),
Values(ProtobufIPCFeatureStatus::kEnabled,
ProtobufIPCFeatureStatus::kDisabled),
Values(ItemsReporting::kUnsupported), Values(ItemsReporting::kUnsupported),
Values(ItemsReporting::kUnsupported), Values(ItemsReporting::kUnsupported),
Values(UserResponse::kAcceptedWithLogs)), Values(UserResponse::kAcceptedWithLogs)),
......
...@@ -29,8 +29,6 @@ ...@@ -29,8 +29,6 @@
#include "chrome/installer/util/install_util.h" #include "chrome/installer/util/install_util.h"
#include "components/chrome_cleaner/public/constants/constants.h" #include "components/chrome_cleaner/public/constants/constants.h"
#include "components/version_info/version_info.h" #include "components/version_info/version_info.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
namespace safe_browsing { namespace safe_browsing {
...@@ -166,30 +164,16 @@ ChromeCleanerRunner::LaunchAndWaitForExitOnBackgroundThread( ...@@ -166,30 +164,16 @@ ChromeCleanerRunner::LaunchAndWaitForExitOnBackgroundThread(
base::BindOnce(&ChromeCleanerRunner::OnPromptUser, base::BindOnce(&ChromeCleanerRunner::OnPromptUser,
base::RetainedRef(this))); base::RetainedRef(this)));
// The channel will make blocking calls to ::WriteFile.
scoped_refptr<base::SequencedTaskRunner> channel_task_runner =
base::CreateSequencedTaskRunner({base::ThreadPool(), base::MayBlock()});
// ChromePromptChannel method calls will be posted to this sequence using // ChromePromptChannel method calls will be posted to this sequence using
// WeakPtr's, so the channel must be deleted on the same sequence. // WeakPtr's, so the channel must be deleted on the same sequence.
scoped_refptr<base::SequencedTaskRunner> channel_task_runner; std::unique_ptr<ChromePromptChannel, base::OnTaskRunnerDeleter> channel(
using ChromePromptChannelPtr = new ChromePromptChannel(std::move(on_connection_closed),
std::unique_ptr<ChromePromptChannel, base::OnTaskRunnerDeleter>; std::move(actions), channel_task_runner),
ChromePromptChannelPtr channel(nullptr, base::OnTaskRunnerDeleter(nullptr)); base::OnTaskRunnerDeleter(channel_task_runner));
if (base::FeatureList::IsEnabled(kChromeCleanupProtobufIPCFeature)) {
// The channel will make blocking calls to ::WriteFile.
channel_task_runner =
base::CreateSequencedTaskRunner({base::ThreadPool(), base::MayBlock()});
channel =
ChromePromptChannelPtr(new ChromePromptChannelProtobuf(
std::move(on_connection_closed),
std::move(actions), channel_task_runner),
base::OnTaskRunnerDeleter(channel_task_runner));
} else {
// Mojo uses the IO thread.
channel_task_runner =
base::CreateSingleThreadTaskRunner({content::BrowserThread::IO});
channel = ChromePromptChannelPtr(
new ChromePromptChannelMojo(std::move(on_connection_closed),
std::move(actions), channel_task_runner),
base::OnTaskRunnerDeleter(channel_task_runner));
}
base::LaunchOptions launch_options; base::LaunchOptions launch_options;
if (!channel->PrepareForCleaner(&cleaner_command_line_, if (!channel->PrepareForCleaner(&cleaner_command_line_,
......
...@@ -98,20 +98,15 @@ class ChromeCleanerRunner ...@@ -98,20 +98,15 @@ class ChromeCleanerRunner
// This function will pass command line flags to the Chrome Cleaner // This function will pass command line flags to the Chrome Cleaner
// executable as appropriate based on the flags in |reporter_invocation| and // executable as appropriate based on the flags in |reporter_invocation| and
// the |metrics_status| parameters. The Cleaner process will communicate with // the |metrics_status| parameters. The Cleaner process will communicate with
// Chrome via a Mojo or protobuf IPC interface and any IPC requests or // Chrome via an IPC interface and any IPC requests or notifications are
// notifications are passed to the caller via the |on_prompt_user| and // passed to the caller via the |on_prompt_user| and |on_connection_closed|
// |on_connection_closed| callbacks. Finally, when the Chrome Cleaner process // callbacks. Finally, when the Chrome Cleaner process terminates, a
// terminates, a ProcessStatus is passed along to |on_process_done|. // ProcessStatus is passed along to |on_process_done|.
// //
// This IPC interface needs the |extension_service| in order to disable // This IPC interface needs the |extension_service| in order to disable
// extensions that the Cleaner process wants to disable. // extensions that the Cleaner process wants to disable.
// //
// The details of the Mojo interface are documented in // See ChromePromptChannel for more details of the IPC interface.
// "components/chrome_cleaner/public/interfaces/chrome_prompt.mojom.h".
//
// TODO(crbug.com/969139): Add a reference to the protobuf interface. Once
// the experiment is over, update this comment to only reference the
// interface that's actually used.
static void RunChromeCleanerAndReplyWithExitCode( static void RunChromeCleanerAndReplyWithExitCode(
extensions::ExtensionService* extension_service, extensions::ExtensionService* extension_service,
extensions::ExtensionRegistry* extension_registry, extensions::ExtensionRegistry* extension_registry,
......
...@@ -41,9 +41,7 @@ using ::testing::Values; ...@@ -41,9 +41,7 @@ using ::testing::Values;
using ChromeMetricsStatus = ChromeCleanerRunner::ChromeMetricsStatus; using ChromeMetricsStatus = ChromeCleanerRunner::ChromeMetricsStatus;
using ExtensionCleaningFeatureStatus = using ExtensionCleaningFeatureStatus =
MockChromeCleanerProcess::ExtensionCleaningFeatureStatus; MockChromeCleanerProcess::ExtensionCleaningFeatureStatus;
using ProtobufIPCFeatureStatus = using PromptUserResponse = chrome_cleaner::PromptUserResponse;
MockChromeCleanerProcess::ProtobufIPCFeatureStatus;
using PromptAcceptance = ChromePromptActions::PromptAcceptance;
using UwsFoundStatus = MockChromeCleanerProcess::UwsFoundStatus; using UwsFoundStatus = MockChromeCleanerProcess::UwsFoundStatus;
enum class ReporterEngine { enum class ReporterEngine {
...@@ -214,11 +212,10 @@ INSTANTIATE_TEST_SUITE_P(All, ...@@ -214,11 +212,10 @@ INSTANTIATE_TEST_SUITE_P(All,
typedef std::tuple<UwsFoundStatus, typedef std::tuple<UwsFoundStatus,
ExtensionCleaningFeatureStatus, ExtensionCleaningFeatureStatus,
ProtobufIPCFeatureStatus,
MockChromeCleanerProcess::ItemsReporting, MockChromeCleanerProcess::ItemsReporting,
MockChromeCleanerProcess::ItemsReporting, MockChromeCleanerProcess::ItemsReporting,
MockChromeCleanerProcess::CrashPoint, MockChromeCleanerProcess::CrashPoint,
PromptAcceptance> PromptUserResponse::PromptAcceptance>
ChromeCleanerRunnerTestParams; ChromeCleanerRunnerTestParams;
// Test fixture for testing ChromeCleanerRunner with a mock Chrome Cleaner // Test fixture for testing ChromeCleanerRunner with a mock Chrome Cleaner
...@@ -243,12 +240,11 @@ class ChromeCleanerRunnerTest ...@@ -243,12 +240,11 @@ class ChromeCleanerRunnerTest
MockChromeCleanerProcess::ItemsReporting extensions_reporting; MockChromeCleanerProcess::ItemsReporting extensions_reporting;
MockChromeCleanerProcess::CrashPoint crash_point; MockChromeCleanerProcess::CrashPoint crash_point;
std::tie(uws_found_state, extension_cleaning_feature_status_, std::tie(uws_found_state, extension_cleaning_feature_status_,
protobuf_ipc_feature_status_, registry_keys_reporting, registry_keys_reporting, extensions_reporting, crash_point,
extensions_reporting, crash_point, prompt_acceptance_to_send_) = prompt_acceptance_to_send_) = GetParam();
GetParam();
ASSERT_FALSE(uws_found_state == UwsFoundStatus::kNoUwsFound && ASSERT_FALSE(uws_found_state == UwsFoundStatus::kNoUwsFound &&
prompt_acceptance_to_send_ != PromptAcceptance::DENIED); prompt_acceptance_to_send_ != PromptUserResponse::DENIED);
std::vector<base::Feature> enabled_features; std::vector<base::Feature> enabled_features;
std::vector<base::Feature> disabled_features; std::vector<base::Feature> disabled_features;
...@@ -258,11 +254,6 @@ class ChromeCleanerRunnerTest ...@@ -258,11 +254,6 @@ class ChromeCleanerRunnerTest
} else { } else {
disabled_features.push_back(kChromeCleanupExtensionsFeature); disabled_features.push_back(kChromeCleanupExtensionsFeature);
} }
if (protobuf_ipc_feature_status_ == ProtobufIPCFeatureStatus::kEnabled) {
enabled_features.push_back(kChromeCleanupProtobufIPCFeature);
} else {
disabled_features.push_back(kChromeCleanupProtobufIPCFeature);
}
features_.InitWithFeatures(enabled_features, disabled_features); features_.InitWithFeatures(enabled_features, disabled_features);
cleaner_process_options_.SetReportedResults( cleaner_process_options_.SetReportedResults(
...@@ -353,9 +344,9 @@ class ChromeCleanerRunnerTest ...@@ -353,9 +344,9 @@ class ChromeCleanerRunnerTest
base::RunLoop run_loop_; base::RunLoop run_loop_;
MockChromeCleanerProcess::Options cleaner_process_options_; MockChromeCleanerProcess::Options cleaner_process_options_;
PromptAcceptance prompt_acceptance_to_send_ = PromptAcceptance::UNSPECIFIED; PromptUserResponse::PromptAcceptance prompt_acceptance_to_send_ =
PromptUserResponse::UNSPECIFIED;
ExtensionCleaningFeatureStatus extension_cleaning_feature_status_; ExtensionCleaningFeatureStatus extension_cleaning_feature_status_;
ProtobufIPCFeatureStatus protobuf_ipc_feature_status_;
// Set by OnProcessDone(). // Set by OnProcessDone().
ChromeCleanerRunner::ProcessStatus process_status_; ChromeCleanerRunner::ProcessStatus process_status_;
...@@ -450,8 +441,6 @@ INSTANTIATE_TEST_SUITE_P( ...@@ -450,8 +441,6 @@ INSTANTIATE_TEST_SUITE_P(
Combine(Values(UwsFoundStatus::kNoUwsFound), Combine(Values(UwsFoundStatus::kNoUwsFound),
// When no UwS is found we don't care about extension removel. // When no UwS is found we don't care about extension removel.
Values(ExtensionCleaningFeatureStatus::kDisabled), Values(ExtensionCleaningFeatureStatus::kDisabled),
// When no UwS is found there is no prompt.
Values(ProtobufIPCFeatureStatus::kDisabled),
Values(MockChromeCleanerProcess::ItemsReporting::kUnsupported, Values(MockChromeCleanerProcess::ItemsReporting::kUnsupported,
MockChromeCleanerProcess::ItemsReporting::kNotReported, MockChromeCleanerProcess::ItemsReporting::kNotReported,
MockChromeCleanerProcess::ItemsReporting::kReported), MockChromeCleanerProcess::ItemsReporting::kReported),
...@@ -459,7 +448,7 @@ INSTANTIATE_TEST_SUITE_P( ...@@ -459,7 +448,7 @@ INSTANTIATE_TEST_SUITE_P(
MockChromeCleanerProcess::ItemsReporting::kNotReported, MockChromeCleanerProcess::ItemsReporting::kNotReported,
MockChromeCleanerProcess::ItemsReporting::kReported), MockChromeCleanerProcess::ItemsReporting::kReported),
Values(MockChromeCleanerProcess::CrashPoint::kNone), Values(MockChromeCleanerProcess::CrashPoint::kNone),
Values(PromptAcceptance::DENIED)), Values(PromptUserResponse::DENIED)),
chrome_cleaner::GetParamNameForTest()); chrome_cleaner::GetParamNameForTest());
INSTANTIATE_TEST_SUITE_P( INSTANTIATE_TEST_SUITE_P(
...@@ -469,15 +458,13 @@ INSTANTIATE_TEST_SUITE_P( ...@@ -469,15 +458,13 @@ INSTANTIATE_TEST_SUITE_P(
Values(UwsFoundStatus::kNoUwsFound), Values(UwsFoundStatus::kNoUwsFound),
// When no UwS is found we don't care about extension removel. // When no UwS is found we don't care about extension removel.
Values(ExtensionCleaningFeatureStatus::kDisabled), Values(ExtensionCleaningFeatureStatus::kDisabled),
// When no UwS is found there is no prompt.
Values(ProtobufIPCFeatureStatus::kDisabled),
Values(MockChromeCleanerProcess::ItemsReporting::kReported), Values(MockChromeCleanerProcess::ItemsReporting::kReported),
Values(MockChromeCleanerProcess::ItemsReporting::kReported), Values(MockChromeCleanerProcess::ItemsReporting::kReported),
Values(MockChromeCleanerProcess::CrashPoint::kOnStartup, Values(MockChromeCleanerProcess::CrashPoint::kOnStartup,
MockChromeCleanerProcess::CrashPoint::kAfterConnection, MockChromeCleanerProcess::CrashPoint::kAfterConnection,
MockChromeCleanerProcess::CrashPoint::kAfterRequestSent, MockChromeCleanerProcess::CrashPoint::kAfterRequestSent,
MockChromeCleanerProcess::CrashPoint::kAfterResponseReceived), MockChromeCleanerProcess::CrashPoint::kAfterResponseReceived),
Values(PromptAcceptance::DENIED)), Values(PromptUserResponse::DENIED)),
chrome_cleaner::GetParamNameForTest()); chrome_cleaner::GetParamNameForTest());
INSTANTIATE_TEST_SUITE_P( INSTANTIATE_TEST_SUITE_P(
...@@ -487,8 +474,6 @@ INSTANTIATE_TEST_SUITE_P( ...@@ -487,8 +474,6 @@ INSTANTIATE_TEST_SUITE_P(
UwsFoundStatus::kUwsFoundNoRebootRequired), UwsFoundStatus::kUwsFoundNoRebootRequired),
Values(ExtensionCleaningFeatureStatus::kEnabled, Values(ExtensionCleaningFeatureStatus::kEnabled,
ExtensionCleaningFeatureStatus::kDisabled), ExtensionCleaningFeatureStatus::kDisabled),
Values(ProtobufIPCFeatureStatus::kEnabled,
ProtobufIPCFeatureStatus::kDisabled),
Values(MockChromeCleanerProcess::ItemsReporting::kUnsupported, Values(MockChromeCleanerProcess::ItemsReporting::kUnsupported,
MockChromeCleanerProcess::ItemsReporting::kNotReported, MockChromeCleanerProcess::ItemsReporting::kNotReported,
MockChromeCleanerProcess::ItemsReporting::kReported), MockChromeCleanerProcess::ItemsReporting::kReported),
...@@ -496,9 +481,9 @@ INSTANTIATE_TEST_SUITE_P( ...@@ -496,9 +481,9 @@ INSTANTIATE_TEST_SUITE_P(
MockChromeCleanerProcess::ItemsReporting::kNotReported, MockChromeCleanerProcess::ItemsReporting::kNotReported,
MockChromeCleanerProcess::ItemsReporting::kReported), MockChromeCleanerProcess::ItemsReporting::kReported),
Values(MockChromeCleanerProcess::CrashPoint::kNone), Values(MockChromeCleanerProcess::CrashPoint::kNone),
Values(PromptAcceptance::DENIED, Values(PromptUserResponse::DENIED,
PromptAcceptance::ACCEPTED_WITH_LOGS, PromptUserResponse::ACCEPTED_WITH_LOGS,
PromptAcceptance::ACCEPTED_WITHOUT_LOGS)), PromptUserResponse::ACCEPTED_WITHOUT_LOGS)),
chrome_cleaner::GetParamNameForTest()); chrome_cleaner::GetParamNameForTest());
INSTANTIATE_TEST_SUITE_P( INSTANTIATE_TEST_SUITE_P(
...@@ -507,15 +492,13 @@ INSTANTIATE_TEST_SUITE_P( ...@@ -507,15 +492,13 @@ INSTANTIATE_TEST_SUITE_P(
Combine( Combine(
Values(UwsFoundStatus::kUwsFoundRebootRequired), Values(UwsFoundStatus::kUwsFoundRebootRequired),
Values(ExtensionCleaningFeatureStatus::kDisabled), Values(ExtensionCleaningFeatureStatus::kDisabled),
Values(ProtobufIPCFeatureStatus::kEnabled,
ProtobufIPCFeatureStatus::kDisabled),
Values(MockChromeCleanerProcess::ItemsReporting::kReported), Values(MockChromeCleanerProcess::ItemsReporting::kReported),
Values(MockChromeCleanerProcess::ItemsReporting::kReported), Values(MockChromeCleanerProcess::ItemsReporting::kReported),
Values(MockChromeCleanerProcess::CrashPoint::kOnStartup, Values(MockChromeCleanerProcess::CrashPoint::kOnStartup,
MockChromeCleanerProcess::CrashPoint::kAfterConnection, MockChromeCleanerProcess::CrashPoint::kAfterConnection,
MockChromeCleanerProcess::CrashPoint::kAfterRequestSent, MockChromeCleanerProcess::CrashPoint::kAfterRequestSent,
MockChromeCleanerProcess::CrashPoint::kAfterResponseReceived), MockChromeCleanerProcess::CrashPoint::kAfterResponseReceived),
Values(PromptAcceptance::ACCEPTED_WITH_LOGS)), Values(PromptUserResponse::ACCEPTED_WITH_LOGS)),
chrome_cleaner::GetParamNameForTest()); chrome_cleaner::GetParamNameForTest());
} // namespace } // namespace
......
...@@ -101,12 +101,4 @@ bool ChromePromptActions::DisableExtensions( ...@@ -101,12 +101,4 @@ bool ChromePromptActions::DisableExtensions(
return result; return result;
} }
// Keep the printable name short since it's used in tests with very long
// parameter lists.
std::ostream& operator<<(
std::ostream& out,
ChromePromptActions::PromptAcceptance prompt_acceptance) {
return out << "Accept" << static_cast<int>(prompt_acceptance);
}
} // namespace safe_browsing } // namespace safe_browsing
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/optional.h" #include "base/optional.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "components/chrome_cleaner/public/proto/chrome_prompt.pb.h"
namespace extensions { namespace extensions {
class ExtensionRegistry; class ExtensionRegistry;
...@@ -30,24 +31,9 @@ class ChromeCleanerScannerResults; ...@@ -30,24 +31,9 @@ class ChromeCleanerScannerResults;
// message received. // message received.
class ChromePromptActions { class ChromePromptActions {
public: public:
// TODO(crbug.com/969139): This mirrors the PromptAcceptance enums from
// chrome_prompt.mojom and chrome_prompt.proto. Once the
// ChromeCleanupProtobufIPC experiment is over remove this and use the proto
// version directly.
enum class PromptAcceptance {
UNSPECIFIED,
// The user explicitly accepted the cleanup operation and cleaner logs
// upload is allowed.
ACCEPTED_WITH_LOGS,
// The user explicitly accepted the cleanup operation and cleaner logs
// upload is not allowed.
ACCEPTED_WITHOUT_LOGS,
// The user explicitly denied the Chrome prompt.
DENIED,
};
// A callback to be called after showing the prompt, with the user's choice. // A callback to be called after showing the prompt, with the user's choice.
using PromptUserReplyCallback = base::OnceCallback<void(PromptAcceptance)>; using PromptUserReplyCallback = base::OnceCallback<void(
chrome_cleaner::PromptUserResponse::PromptAcceptance)>;
// A callback to show the prompt. The ChromeCleanerScannerResults contains // A callback to show the prompt. The ChromeCleanerScannerResults contains
// the items that were detected by the scanner, for display in the prompt. // the items that were detected by the scanner, for display in the prompt.
...@@ -77,9 +63,6 @@ class ChromePromptActions { ...@@ -77,9 +63,6 @@ class ChromePromptActions {
// Deletes the given |extension_ids|. Returns false on an error, including if // Deletes the given |extension_ids|. Returns false on an error, including if
// not all |extension_ids| were displayed to the user in the last PromptUser // not all |extension_ids| were displayed to the user in the last PromptUser
// call. // call.
//
// TODO(crbug.com/969139): Now that we're updating the IPC interface, rename
// this DeleteExtensions to match the implementation.
bool DisableExtensions(const std::vector<base::string16>& extension_ids); bool DisableExtensions(const std::vector<base::string16>& extension_ids);
private: private:
...@@ -102,11 +85,6 @@ class ChromePromptActions { ...@@ -102,11 +85,6 @@ class ChromePromptActions {
std::vector<base::string16> extension_ids_; std::vector<base::string16> extension_ids_;
}; };
// Format for debug output in tests.
std::ostream& operator<<(
std::ostream& out,
ChromePromptActions::PromptAcceptance prompt_acceptance);
} // namespace safe_browsing } // namespace safe_browsing
#endif // CHROME_BROWSER_SAFE_BROWSING_CHROME_CLEANER_CHROME_PROMPT_ACTIONS_WIN_H_ #endif // CHROME_BROWSER_SAFE_BROWSING_CHROME_CLEANER_CHROME_PROMPT_ACTIONS_WIN_H_
...@@ -16,11 +16,7 @@ ...@@ -16,11 +16,7 @@
#include "base/sequenced_task_runner.h" #include "base/sequenced_task_runner.h"
#include "base/win/scoped_handle.h" #include "base/win/scoped_handle.h"
#include "chrome/browser/safe_browsing/chrome_cleaner/chrome_prompt_actions_win.h" #include "chrome/browser/safe_browsing/chrome_cleaner/chrome_prompt_actions_win.h"
#include "components/chrome_cleaner/public/interfaces/chrome_prompt.mojom.h"
#include "components/chrome_cleaner/public/proto/chrome_prompt.pb.h" #include "components/chrome_cleaner/public/proto/chrome_prompt.pb.h"
#include "mojo/public/cpp/platform/platform_channel.h"
#include "mojo/public/cpp/system/invitation.h"
#include "mojo/public/cpp/system/message_pipe.h"
#include "third_party/protobuf/src/google/protobuf/message_lite.h" #include "third_party/protobuf/src/google/protobuf/message_lite.h"
namespace base { namespace base {
...@@ -29,15 +25,18 @@ class CommandLine; ...@@ -29,15 +25,18 @@ class CommandLine;
namespace safe_browsing { namespace safe_browsing {
namespace internal {
class ChromePromptImpl;
} // namespace internal
class ChromePromptActions; class ChromePromptActions;
// Handles IPC to the Chrome Cleaner process. The Chrome Cleaner process will // Handles IPC to the Chrome Cleaner process. The Chrome Cleaner process will
// send requests and ChromePromptChannel will handle the request, often by // send requests and ChromePromptChannel will handle the request, often by
// using ChromePromptActions, and write the response. // using ChromePromptActions, and write the response.
//
// This implementation serializes protobufs over a pipe, instead of using Mojo,
// because the Chrome Cleaner process might be built with a different version
// of Mojo that isn't wire-compatible.
//
// The interface specification is in
// "components/chrome_cleaner/public/proto/chrome_prompt.proto".
class ChromePromptChannel { class ChromePromptChannel {
public: public:
// Gives access to the Chrome Cleaner process that the channel communicates // Gives access to the Chrome Cleaner process that the channel communicates
...@@ -51,91 +50,6 @@ class ChromePromptChannel { ...@@ -51,91 +50,6 @@ class ChromePromptChannel {
virtual void TerminateOnError() const = 0; virtual void TerminateOnError() const = 0;
}; };
// Returns a CleanerProcessDelegate that wraps |process|.
static std::unique_ptr<CleanerProcessDelegate> CreateDelegateForProcess(
const base::Process& process);
// Creates a ChromePromptChannel that calls |on_connection_closed| when the
// IPC channel closes (either normally or on error) and uses |actions| to
// fulfill requests. |task_runner| can be used to run any tasks that must be
// seqeuenced with destruction of the ChromePromptChannel.
ChromePromptChannel(base::OnceClosure on_connection_closed,
std::unique_ptr<ChromePromptActions> actions,
scoped_refptr<base::SequencedTaskRunner> task_runner);
virtual ~ChromePromptChannel();
// Prepares an IPC channel to be used by the cleaner process that is about to
// be launched. Adds all handles used by the channel to |handles_to_inherit|
// so that the cleaner process can access them, and adds switches to
// |command_line| that the cleaner process can use to connect to the channel.
virtual bool PrepareForCleaner(
base::CommandLine* command_line,
base::HandlesToInheritVector* handles_to_inherit) = 0;
// Does any cleanup required if the cleaner process fails to launch after
// PrepareForCleaner was called.
virtual void CleanupAfterCleanerLaunchFailed() = 0;
// Kicks off communication between the IPC channel prepared by
// PrepareForCleaner and the process in |cleaner_process|. If the connection
// fails, |connection_closed_callback_| should be called.
virtual void ConnectToCleaner(
std::unique_ptr<CleanerProcessDelegate> cleaner_process) = 0;
scoped_refptr<base::SequencedTaskRunner> task_runner() const {
return task_runner_;
}
protected:
base::OnceClosure on_connection_closed_;
std::unique_ptr<ChromePromptActions> actions_;
scoped_refptr<base::SequencedTaskRunner> task_runner_;
private:
ChromePromptChannel(const ChromePromptChannel& other) = delete;
ChromePromptChannel& operator=(const ChromePromptChannel& other) = delete;
};
// Handles IPC to the Chrome Cleaner process using Mojo.
class ChromePromptChannelMojo : public ChromePromptChannel {
public:
ChromePromptChannelMojo(base::OnceClosure on_connection_closed,
std::unique_ptr<ChromePromptActions> actions,
scoped_refptr<base::SequencedTaskRunner> task_runner);
~ChromePromptChannelMojo() override;
bool PrepareForCleaner(
base::CommandLine* command_line,
base::HandlesToInheritVector* handles_to_inherit) override;
void CleanupAfterCleanerLaunchFailed() override;
void ConnectToCleaner(
std::unique_ptr<CleanerProcessDelegate> cleaner_process) override;
private:
ChromePromptChannelMojo(const ChromePromptChannelMojo& other) = delete;
ChromePromptChannelMojo& operator=(const ChromePromptChannelMojo& other) =
delete;
void CreateChromePromptImpl(
chrome_cleaner::mojom::ChromePromptRequest chrome_prompt_request);
mojo::OutgoingInvitation invitation_;
mojo::PlatformChannel mojo_channel_;
mojo::ScopedMessagePipeHandle request_pipe_;
std::unique_ptr<internal::ChromePromptImpl> chrome_prompt_impl_;
base::WeakPtrFactory<ChromePromptChannelMojo> weak_factory_{this};
};
// Handles IPC to the Chrome Cleaner process by serializing protobufs over
// a pipe.
class ChromePromptChannelProtobuf : public ChromePromptChannel {
public:
static const char kErrorHistogramName[]; static const char kErrorHistogramName[];
static constexpr uint32_t kMaxMessageLength = 1 * 1024 * 1024; // 1M bytes static constexpr uint32_t kMaxMessageLength = 1 * 1024 * 1024; // 1M bytes
...@@ -193,21 +107,40 @@ class ChromePromptChannelProtobuf : public ChromePromptChannel { ...@@ -193,21 +107,40 @@ class ChromePromptChannelProtobuf : public ChromePromptChannel {
return category_and_code; return category_and_code;
} }
ChromePromptChannelProtobuf( // Returns a CleanerProcessDelegate that wraps |process|.
base::OnceClosure on_connection_closed, static std::unique_ptr<CleanerProcessDelegate> CreateDelegateForProcess(
std::unique_ptr<ChromePromptActions> actions, const base::Process& process);
scoped_refptr<base::SequencedTaskRunner> task_runner);
// Creates a ChromePromptChannel that calls |on_connection_closed| when the
// IPC channel closes (either normally or on error) and uses |actions| to
// fulfill requests. |task_runner| can be used to run any tasks that must be
// seqeuenced with destruction of the ChromePromptChannel.
ChromePromptChannel(base::OnceClosure on_connection_closed,
std::unique_ptr<ChromePromptActions> actions,
scoped_refptr<base::SequencedTaskRunner> task_runner);
~ChromePromptChannelProtobuf() override; ~ChromePromptChannel();
bool PrepareForCleaner( // Prepares an IPC channel to be used by the cleaner process that is about to
base::CommandLine* command_line, // be launched. Adds all handles used by the channel to |handles_to_inherit|
base::HandlesToInheritVector* handles_to_inherit) override; // so that the cleaner process can access them, and adds switches to
// |command_line| that the cleaner process can use to connect to the channel.
bool PrepareForCleaner(base::CommandLine* command_line,
base::HandlesToInheritVector* handles_to_inherit);
void CleanupAfterCleanerLaunchFailed() override; // Does any cleanup required if the cleaner process fails to launch after
// PrepareForCleaner was called.
void CleanupAfterCleanerLaunchFailed();
// Kicks off communication between the IPC channel prepared by
// PrepareForCleaner and the process in |cleaner_process|. If the connection
// fails, |connection_closed_callback_| should be called.
void ConnectToCleaner( void ConnectToCleaner(
std::unique_ptr<CleanerProcessDelegate> cleaner_process) override; std::unique_ptr<CleanerProcessDelegate> cleaner_process);
scoped_refptr<base::SequencedTaskRunner> task_runner() const {
return task_runner_;
}
// Handles |request| and sends a QueryCapabilityResponse in reply. // Handles |request| and sends a QueryCapabilityResponse in reply.
void HandleQueryCapabilityRequest( void HandleQueryCapabilityRequest(
...@@ -226,20 +159,23 @@ class ChromePromptChannelProtobuf : public ChromePromptChannel { ...@@ -226,20 +159,23 @@ class ChromePromptChannelProtobuf : public ChromePromptChannel {
void CloseHandles(); void CloseHandles();
private: private:
ChromePromptChannelProtobuf(const ChromePromptChannelProtobuf& other) = ChromePromptChannel(const ChromePromptChannel& other) = delete;
delete; ChromePromptChannel& operator=(const ChromePromptChannel& other) = delete;
ChromePromptChannelProtobuf& operator=(
const ChromePromptChannelProtobuf& other) = delete;
// Serializes |message| to response_write_handle_. Calls CloseHandles on // Serializes |message| to response_write_handle_. Calls CloseHandles on
// error. // error.
void WriteResponseMessage(const google::protobuf::MessageLite& message); void WriteResponseMessage(const google::protobuf::MessageLite& message);
// Sends a PromptUserResponse with the given |acceptance| value. // Sends a PromptUserResponse with the given |acceptance| value.
void SendPromptUserResponse(ChromePromptActions::PromptAcceptance acceptance); void SendPromptUserResponse(
chrome_cleaner::PromptUserResponse::PromptAcceptance acceptance);
SEQUENCE_CHECKER(sequence_checker_); SEQUENCE_CHECKER(sequence_checker_);
base::OnceClosure on_connection_closed_;
std::unique_ptr<ChromePromptActions> actions_;
scoped_refptr<base::SequencedTaskRunner> task_runner_;
// Requests always flow from the Chrome Cleanup tool to Chrome. // Requests always flow from the Chrome Cleanup tool to Chrome.
// This class owns request_read_handle_ but request_write_handle_ will be // This class owns request_read_handle_ but request_write_handle_ will be
// closed once it is passed to the child process. // closed once it is passed to the child process.
...@@ -252,7 +188,7 @@ class ChromePromptChannelProtobuf : public ChromePromptChannel { ...@@ -252,7 +188,7 @@ class ChromePromptChannelProtobuf : public ChromePromptChannel {
base::win::ScopedHandle response_read_handle_; base::win::ScopedHandle response_read_handle_;
base::win::ScopedHandle response_write_handle_; base::win::ScopedHandle response_write_handle_;
base::WeakPtrFactory<ChromePromptChannelProtobuf> weak_factory_{this}; base::WeakPtrFactory<ChromePromptChannel> weak_factory_{this};
}; };
} // namespace safe_browsing } // namespace safe_browsing
......
...@@ -70,11 +70,6 @@ class MockChromeCleanerProcess { ...@@ -70,11 +70,6 @@ class MockChromeCleanerProcess {
kDisabled, kDisabled,
}; };
enum class ProtobufIPCFeatureStatus {
kEnabled,
kDisabled,
};
static constexpr int kInternalTestFailureExitCode = 100001; static constexpr int kInternalTestFailureExitCode = 100001;
static constexpr int kDeliberateCrashExitCode = 100002; static constexpr int kDeliberateCrashExitCode = 100002;
static constexpr int kNothingFoundExitCode = 2; static constexpr int kNothingFoundExitCode = 2;
...@@ -130,11 +125,13 @@ class MockChromeCleanerProcess { ...@@ -130,11 +125,13 @@ class MockChromeCleanerProcess {
CrashPoint crash_point() const { return crash_point_; } CrashPoint crash_point() const { return crash_point_; }
void set_expected_user_response( void set_expected_user_response(
ChromePromptActions::PromptAcceptance expected_user_response) { chrome_cleaner::PromptUserResponse::PromptAcceptance
expected_user_response) {
expected_user_response_ = expected_user_response; expected_user_response_ = expected_user_response;
} }
ChromePromptActions::PromptAcceptance expected_user_response() const { chrome_cleaner::PromptUserResponse::PromptAcceptance
expected_user_response() const {
return expected_user_response_; return expected_user_response_;
} }
...@@ -146,8 +143,8 @@ class MockChromeCleanerProcess { ...@@ -146,8 +143,8 @@ class MockChromeCleanerProcess {
return extensions_reporting_; return extensions_reporting_;
} }
int ExpectedExitCode( int ExpectedExitCode(chrome_cleaner::PromptUserResponse::PromptAcceptance
ChromePromptActions::PromptAcceptance received_prompt_acceptance) const; received_prompt_acceptance) const;
private: private:
std::vector<base::FilePath> files_to_delete_; std::vector<base::FilePath> files_to_delete_;
...@@ -158,8 +155,9 @@ class MockChromeCleanerProcess { ...@@ -158,8 +155,9 @@ class MockChromeCleanerProcess {
CrashPoint crash_point_ = CrashPoint::kNone; CrashPoint crash_point_ = CrashPoint::kNone;
ItemsReporting registry_keys_reporting_ = ItemsReporting::kUnsupported; ItemsReporting registry_keys_reporting_ = ItemsReporting::kUnsupported;
ItemsReporting extensions_reporting_ = ItemsReporting::kUnsupported; ItemsReporting extensions_reporting_ = ItemsReporting::kUnsupported;
ChromePromptActions::PromptAcceptance expected_user_response_ = chrome_cleaner::PromptUserResponse::PromptAcceptance
ChromePromptActions::PromptAcceptance::UNSPECIFIED; expected_user_response_ =
chrome_cleaner::PromptUserResponse::UNSPECIFIED;
}; };
MockChromeCleanerProcess(); MockChromeCleanerProcess();
...@@ -194,10 +192,6 @@ std::ostream& operator<<( ...@@ -194,10 +192,6 @@ std::ostream& operator<<(
std::ostream& out, std::ostream& out,
MockChromeCleanerProcess::ExtensionCleaningFeatureStatus status); MockChromeCleanerProcess::ExtensionCleaningFeatureStatus status);
std::ostream& operator<<(
std::ostream& out,
MockChromeCleanerProcess::ProtobufIPCFeatureStatus status);
std::ostream& operator<<( std::ostream& operator<<(
std::ostream& out, std::ostream& out,
MockChromeCleanerProcess::ItemsReporting items_reporting); MockChromeCleanerProcess::ItemsReporting items_reporting);
......
...@@ -42,9 +42,6 @@ const base::Feature kChromeCleanupDistributionFeature{ ...@@ -42,9 +42,6 @@ const base::Feature kChromeCleanupDistributionFeature{
const base::Feature kChromeCleanupExtensionsFeature{ const base::Feature kChromeCleanupExtensionsFeature{
"ChromeCleanupExtensions", base::FEATURE_DISABLED_BY_DEFAULT}; "ChromeCleanupExtensions", base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kChromeCleanupProtobufIPCFeature{
"ChromeCleanupProtobufIPC", base::FEATURE_ENABLED_BY_DEFAULT};
bool IsSRTPromptFeatureEnabled() { bool IsSRTPromptFeatureEnabled() {
return base::FeatureList::IsEnabled(kChromeCleanupInBrowserPromptFeature); return base::FeatureList::IsEnabled(kChromeCleanupInBrowserPromptFeature);
} }
......
...@@ -64,11 +64,6 @@ extern const base::Feature kChromeCleanupDistributionFeature; ...@@ -64,11 +64,6 @@ extern const base::Feature kChromeCleanupDistributionFeature;
// for, and cleanup, bad extensions. // for, and cleanup, bad extensions.
extern const base::Feature kChromeCleanupExtensionsFeature; extern const base::Feature kChromeCleanupExtensionsFeature;
// Protobuf IPC feature. When enabled, Chrome Cleaner will communicate by
// serializing protobufs over a custom IPC pipe that isn't tied to the Mojo
// version.
extern const base::Feature kChromeCleanupProtobufIPCFeature;
// Returns true if this Chrome is in a field trial group which shows the SRT // Returns true if this Chrome is in a field trial group which shows the SRT
// prompt. // prompt.
bool IsSRTPromptFeatureEnabled(); bool IsSRTPromptFeatureEnabled();
......
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