chromium/chrome/browser/enterprise/idle/action.cc

// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/enterprise/idle/action.h"

#include <cstring>
#include <utility>

#include "base/callback_list.h"
#include "base/check_is_test.h"
#include "base/containers/flat_map.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/ranges/algorithm.h"
#include "base/scoped_observation.h"
#include "base/task/single_thread_task_runner.h"
#include "chrome/browser/browsing_data/chrome_browsing_data_remover_constants.h"
#include "chrome/browser/enterprise/idle/action_runner.h"
#include "chrome/browser/enterprise/idle/idle_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "components/enterprise/idle/idle_pref_names.h"
#include "components/enterprise/idle/metrics.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/browsing_data_remover.h"
#include "content/public/browser/web_contents.h"

#if BUILDFLAG(IS_ANDROID)
#include "chrome/browser/ui/android/tab_model/tab_model.h"
#include "chrome/browser/ui/android/tab_model/tab_model_list.h"
#else
#include "chrome/browser/enterprise/idle/dialog_manager.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/idle_bubble.h"
#include "chrome/browser/ui/profiles/profile_picker.h"
#endif  // BUILDFLAG(IS_ANDROID)

namespace enterprise_idle {

namespace {

#if !BUILDFLAG(IS_ANDROID)
bool ProfileHasBrowsers(const Profile* profile) {}

// Wrapper Action for DialogManager. Shows a 30s warning dialog, shared across
// profiles.
class ShowDialogAction : public Action {};

// Action that closes all browsers for a Profile.
class CloseBrowsersAction : public Action {};

// Action that shows the Profile Picker.
class ShowProfilePickerAction : public Action {};
#endif  // !BUILDFLAG(IS_ANDROID)

// Action that clears one or more types of data via BrowsingDataRemover.
// Multiple data types may be grouped into a single ClearBrowsingDataAction
// object.
//
// TODO(crbug.com/40840688): Call ChromeBrowsingDataLifetimeManager, instead of
// BrowsingDataRemover directly? Especially if we add a keepalive, or use
// kClearBrowsingDataOnExitDeletionPending...
class ClearBrowsingDataAction : public Action,
                                content::BrowsingDataRemover::Observer {};

class ReloadPagesAction : public Action {};

#if !BUILDFLAG(IS_ANDROID)
// Shows a bubble anchored to the 3-dot menu after other actions are finished.
class ShowBubbleAction : public Action {};
#endif  // !BUILDFLAG(IS_ANDROID)

}  // namespace

Action::Action(int priority) :{}

Action::~Action() = default;

bool ActionFactory::CompareActionsByPriority::operator()(
    const std::unique_ptr<Action>& a,
    const std::unique_ptr<Action>& b) const {}

// static
ActionFactory* ActionFactory::GetInstance() {}

ActionFactory::ActionQueue ActionFactory::Build(
    Profile* profile,
    const std::vector<ActionType>& action_types) {}

ActionFactory::ActionFactory() = default;
ActionFactory::~ActionFactory() = default;

void ActionFactory::SetBrowsingDataRemoverForTesting(
    content::BrowsingDataRemover* remover) {}

#if !BUILDFLAG(IS_ANDROID)
IdleDialog::ActionSet ActionsToActionSet(
    const base::flat_set<ActionType>& action_types) {}
#endif  // !BUILDFLAG(IS_ANDROID)

}  // namespace enterprise_idle