#include "chrome/browser/ui/views/translate/translate_bubble_controller.h"
#include <memory>
#include "base/functional/bind.h"
#include "base/metrics/histogram_functions.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/ui/translate/partial_translate_bubble_model.h"
#include "chrome/browser/ui/translate/partial_translate_bubble_model_impl.h"
#include "chrome/browser/ui/translate/partial_translate_bubble_ui_action_logger.h"
#include "chrome/browser/ui/translate/translate_bubble_model_impl.h"
#include "chrome/browser/ui/views/translate/partial_translate_bubble_view.h"
#include "components/contextual_search/core/browser/contextual_search_delegate_impl.h"
#include "components/translate/content/browser/partial_translate_manager.h"
#include "components/translate/core/browser/translate_language_list.h"
#include "components/translate/core/browser/translate_manager.h"
#include "components/translate/core/browser/translate_ui_delegate.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"
#include "components/translate/core/common/translate_util.h"
#include "content/public/browser/web_contents.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "ui/gfx/text_constants.h"
#include "ui/gfx/text_elider.h"
namespace {
const char kTranslatePartialTranslationSelectionCharacterCount[] = …;
}
TranslateBubbleController::~TranslateBubbleController() = default;
TranslateBubbleController* TranslateBubbleController::GetOrCreate(
content::WebContents* web_contents) { … }
views::Widget* TranslateBubbleController::ShowTranslateBubble(
views::View* anchor_view,
views::Button* highlighted_button,
translate::TranslateStep step,
const std::string& source_language,
const std::string& target_language,
translate::TranslateErrors error_type,
LocationBarBubbleDelegateView::DisplayReason reason) { … }
void TranslateBubbleController::StartPartialTranslate(
views::View* anchor_view,
views::Button* highlighted_button,
const std::string& source_language,
const std::string& target_language,
const std::u16string& text_selection) { … }
void TranslateBubbleController::OnPartialTranslateWaitExpired() { … }
void TranslateBubbleController::OnPartialTranslateComplete() { … }
void TranslateBubbleController::CreatePartialTranslateBubble(
views::View* anchor_view,
views::Button* highlighted_button,
PartialTranslateBubbleModel::ViewState view_state,
const std::string& source_language,
const std::string& target_language,
const std::u16string& source_text,
const std::u16string& target_text,
translate::TranslateErrors error_type) { … }
void TranslateBubbleController::CloseBubble() { … }
TranslateBubbleView* TranslateBubbleController::GetTranslateBubble() const { … }
PartialTranslateBubbleView*
TranslateBubbleController::GetPartialTranslateBubble() const { … }
void TranslateBubbleController::SetTranslateBubbleModelFactory(
base::RepeatingCallback<std::unique_ptr<TranslateBubbleModel>()> callback) { … }
void TranslateBubbleController::SetPartialTranslateBubbleModelFactory(
base::RepeatingCallback<std::unique_ptr<PartialTranslateBubbleModel>()>
callback) { … }
base::OnceClosure
TranslateBubbleController::GetOnTranslateBubbleClosedCallback() { … }
base::OnceClosure
TranslateBubbleController::GetOnPartialTranslateBubbleClosedCallback() { … }
void TranslateBubbleController::OnTranslateBubbleClosed() { … }
void TranslateBubbleController::OnPartialTranslateBubbleClosed() { … }
TranslateBubbleController::TranslateBubbleController(
content::WebContents* web_contents)
: … { … }
WEB_CONTENTS_USER_DATA_KEY_IMPL(TranslateBubbleController);