#include "components/translate/content/browser/content_translate_driver.h"
#include <memory>
#include <string>
#include <utility>
#include "base/check.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/notreached.h"
#include "base/observer_list.h"
#include "base/strings/utf_string_conversions.h"
#include "base/supports_user_data.h"
#include "base/task/single_thread_task_runner.h"
#include "components/google/core/common/google_util.h"
#include "components/language/core/browser/url_language_histogram.h"
#include "components/translate/content/browser/content_record_page_language.h"
#include "components/translate/core/browser/translate_download_manager.h"
#include "components/translate/core/browser/translate_manager.h"
#include "components/translate/core/browser/translate_metrics_logger.h"
#include "components/translate/core/common/translate_metrics.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/navigation_details.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/page_navigator.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/referrer.h"
#include "net/http/http_response_headers.h"
#include "net/http/http_status_code.h"
#include "services/metrics/public/cpp/ukm_source_id.h"
#include "url/gurl.h"
namespace translate {
namespace {
const int kMaxTranslateLoadCheckAttempts = …;
BASE_FEATURE(…);
}
ContentTranslateDriver::ContentTranslateDriver(
content::WebContents& web_contents,
language::UrlLanguageHistogram* url_language_histogram)
: … { … }
ContentTranslateDriver::~ContentTranslateDriver() = default;
void ContentTranslateDriver::AddTranslationObserver(
TranslationObserver* observer) { … }
void ContentTranslateDriver::RemoveTranslationObserver(
TranslationObserver* observer) { … }
void ContentTranslateDriver::InitiateTranslation(const std::string& page_lang,
int attempt) { … }
bool ContentTranslateDriver::IsLinkNavigation() { … }
void ContentTranslateDriver::OnTranslateEnabledChanged() { … }
void ContentTranslateDriver::OnIsPageTranslatedChanged() { … }
void ContentTranslateDriver::TranslatePage(int page_seq_no,
const std::string& translate_script,
const std::string& source_lang,
const std::string& target_lang) { … }
void ContentTranslateDriver::RevertTranslation(int page_seq_no) { … }
bool ContentTranslateDriver::IsIncognito() const { … }
const std::string& ContentTranslateDriver::GetContentsMimeType() { … }
const GURL& ContentTranslateDriver::GetLastCommittedURL() const { … }
const GURL& ContentTranslateDriver::GetVisibleURL() { … }
ukm::SourceId ContentTranslateDriver::GetUkmSourceId() { … }
bool ContentTranslateDriver::HasCurrentPage() const { … }
void ContentTranslateDriver::InitiateTranslationIfReload(
content::NavigationHandle* navigation_handle) { … }
void ContentTranslateDriver::DidFinishNavigation(
content::NavigationHandle* navigation_handle) { … }
bool ContentTranslateDriver::IsAutoHrefTranslateAllOriginsEnabled() const { … }
void ContentTranslateDriver::OnPageAway(int page_seq_no) { … }
void ContentTranslateDriver::AddReceiver(
mojo::PendingReceiver<translate::mojom::ContentTranslateDriver> receiver) { … }
void ContentTranslateDriver::RegisterPage(
mojo::PendingRemote<translate::mojom::TranslateAgent> translate_agent,
const translate::LanguageDetectionDetails& details,
const bool page_level_translation_criteria_met) { … }
void ContentTranslateDriver::OnPageTranslated(
bool cancelled,
const std::string& source_lang,
const std::string& translated_lang,
TranslateErrors error_type) { … }
}