#include "chrome/browser/ui/translate/partial_translate_bubble_model_impl.h"
#include <string>
#include <utility>
#include "base/metrics/histogram_functions.h"
#include "base/metrics/metrics_hashes.h"
#include "base/time/time.h"
#include "chrome/browser/translate/chrome_translate_client.h"
#include "chrome/browser/ui/translate/partial_translate_bubble_model.h"
#include "components/translate/content/browser/partial_translate_manager.h"
#include "components/translate/core/browser/translate_manager.h"
#include "components/translate/core/browser/translate_ui_languages_manager.h"
#include "components/translate/core/common/translate_constants.h"
#include "components/translate/core/common/translate_errors.h"
namespace {
const char kTranslatePartialTranslationSourceLanguage[] = …;
const char kTranslatePartialTranslationTargetLanguage[] = …;
const char kTranslatePartialTranslationResponseTime[] = …;
const char kTranslatePartialTranslationTranslationStatus[] = …;
const char kTranslatePartialTranslationTranslatedCharacterCount[] = …;
}
PartialTranslateBubbleModelImpl::PartialTranslateBubbleModelImpl(
ViewState view_state,
translate::TranslateErrors error_type,
const std::u16string& source_text,
const std::u16string& target_text,
std::unique_ptr<PartialTranslateManager> partial_translate_manager,
std::unique_ptr<translate::TranslateUILanguagesManager>
ui_languages_manager)
: … { … }
PartialTranslateBubbleModelImpl::~PartialTranslateBubbleModelImpl() = default;
void PartialTranslateBubbleModelImpl::AddObserver(
PartialTranslateBubbleModel::Observer* obs) { … }
void PartialTranslateBubbleModelImpl::RemoveObserver(
PartialTranslateBubbleModel::Observer* obs) { … }
PartialTranslateBubbleModelImpl::ViewState
PartialTranslateBubbleModelImpl::GetViewState() const { … }
void PartialTranslateBubbleModelImpl::SetViewState(
PartialTranslateBubbleModelImpl::ViewState view_state) { … }
void PartialTranslateBubbleModelImpl::SetSourceLanguage(
const std::string& language_code) { … }
void PartialTranslateBubbleModelImpl::SetTargetLanguage(
const std::string& language_code) { … }
void PartialTranslateBubbleModelImpl::SetSourceText(
const std::u16string& text) { … }
std::u16string PartialTranslateBubbleModelImpl::GetSourceText() const { … }
void PartialTranslateBubbleModelImpl::SetTargetText(
const std::u16string& text) { … }
std::u16string PartialTranslateBubbleModelImpl::GetTargetText() const { … }
void PartialTranslateBubbleModelImpl::SetError(
translate::TranslateErrors error_type) { … }
translate::TranslateErrors PartialTranslateBubbleModelImpl::GetError() const { … }
int PartialTranslateBubbleModelImpl::GetNumberOfSourceLanguages() const { … }
int PartialTranslateBubbleModelImpl::GetNumberOfTargetLanguages() const { … }
std::u16string PartialTranslateBubbleModelImpl::GetSourceLanguageNameAt(
int index) const { … }
std::u16string PartialTranslateBubbleModelImpl::GetTargetLanguageNameAt(
int index) const { … }
int PartialTranslateBubbleModelImpl::GetSourceLanguageIndex() const { … }
void PartialTranslateBubbleModelImpl::UpdateSourceLanguageIndex(int index) { … }
int PartialTranslateBubbleModelImpl::GetTargetLanguageIndex() const { … }
void PartialTranslateBubbleModelImpl::UpdateTargetLanguageIndex(int index) { … }
std::string PartialTranslateBubbleModelImpl::GetSourceLanguageCode() const { … }
std::string PartialTranslateBubbleModelImpl::GetTargetLanguageCode() const { … }
void PartialTranslateBubbleModelImpl::Translate(
content::WebContents* web_contents) { … }
void PartialTranslateBubbleModelImpl::TranslateFullPage(
content::WebContents* web_contents) { … }
void PartialTranslateBubbleModelImpl::SetSourceTextTruncated(
bool is_truncated) { … }
void PartialTranslateBubbleModelImpl::OnPartialTranslateResponse(
const PartialTranslateRequest& request,
const PartialTranslateResponse& response) { … }
void PartialTranslateBubbleModelImpl::
RecordHistogramsOnPartialTranslateStart() { … }
void PartialTranslateBubbleModelImpl::
RecordHistogramsOnPartialTranslateComplete(bool status_error) { … }