#include "chrome/browser/ui/tabs/organization/request_factory.h"
#include <iterator>
#include <memory>
#include <string>
#include <vector>
#include "base/command_line.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/optimization_guide/optimization_guide_keyed_service.h"
#include "chrome/browser/optimization_guide/optimization_guide_keyed_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/tabs/organization/logging_util.h"
#include "chrome/browser/ui/tabs/organization/tab_organization_request.h"
#include "chrome/browser/ui/tabs/organization/tab_organization_session.h"
#include "chrome/browser/ui/tabs/tab_group_model.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/ui_features.h"
#include "components/optimization_guide/core/model_quality/feature_type_map.h"
#include "components/optimization_guide/core/model_quality/model_quality_log_entry.h"
#include "components/optimization_guide/core/optimization_guide_features.h"
#include "components/optimization_guide/core/optimization_guide_model_executor.h"
#include "components/optimization_guide/core/optimization_guide_switches.h"
#include "components/optimization_guide/core/optimization_guide_util.h"
#include "components/optimization_guide/proto/features/tab_organization.pb.h"
#include "components/tab_groups/tab_group_id.h"
#include "content/public/browser/web_contents.h"
namespace {
bool CanUseOptimizationGuide(Profile* profile) { … }
void OnLogResults(
Profile* profile,
std::unique_ptr<optimization_guide::ModelQualityLogEntry> log_entry,
const TabOrganizationSession* session) { … }
void OnTabOrganizationModelExecutionResult(
Profile* profile,
TabOrganizationRequest::BackendCompletionCallback on_completion,
TabOrganizationRequest::BackendFailureCallback on_failure,
optimization_guide::OptimizationGuideModelExecutionResult result,
std::unique_ptr<optimization_guide::ModelQualityLogEntry> log_entry) { … }
void PerformTabOrganizationExecution(
Profile* profile,
const TabOrganizationRequest* request,
TabOrganizationRequest::BackendCompletionCallback on_completion,
TabOrganizationRequest::BackendFailureCallback on_failure) { … }
}
TabOrganizationRequestFactory::~TabOrganizationRequestFactory() = default;
std::unique_ptr<TabOrganizationRequestFactory>
TabOrganizationRequestFactory::GetForProfile(Profile* profile) { … }
TwoTabsRequestFactory::~TwoTabsRequestFactory() = default;
std::unique_ptr<TabOrganizationRequest> TwoTabsRequestFactory::CreateRequest(
Profile* profile) { … }
OptimizationGuideTabOrganizationRequestFactory::
~OptimizationGuideTabOrganizationRequestFactory() = default;
std::unique_ptr<TabOrganizationRequest>
OptimizationGuideTabOrganizationRequestFactory::CreateRequest(
Profile* profile) { … }