chromium/chrome/browser/ui/views/translate/partial_translate_bubble_view.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/ui/views/translate/partial_translate_bubble_view.h"

#include <stddef.h>

#include <algorithm>
#include <memory>
#include <string>
#include <utility>
#include <vector>

#include "base/functional/bind.h"
#include "base/i18n/rtl.h"
#include "base/i18n/string_compare.h"
#include "base/memory/singleton.h"
#include "base/metrics/field_trial_params.h"
#include "base/metrics/histogram_macros.h"
#include "base/strings/utf_string_conversions.h"
#include "build/branding_buildflags.h"
#include "build/build_config.h"
#include "chrome/app/vector_icons/vector_icons.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/platform_util.h"
#include "chrome/browser/translate/chrome_translate_client.h"
#include "chrome/browser/translate/translate_service.h"
#include "chrome/browser/ui/chrome_pages.h"
#include "chrome/browser/ui/translate/partial_translate_bubble_model.h"
#include "chrome/browser/ui/translate/partial_translate_bubble_ui_action_logger.h"
#include "chrome/browser/ui/views/chrome_layout_provider.h"
#include "chrome/browser/ui/views/translate/translate_icon_view.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/grit/theme_resources.h"
#include "components/prefs/pref_service.h"
#include "components/strings/grit/components_strings.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/browser/translate_prefs.h"
#include "components/translate/core/browser/translate_ui_delegate.h"
#include "components/translate/core/common/translate_constants.h"
#include "components/vector_icons/vector_icons.h"
#include "content/public/browser/web_contents.h"
#include "ui/base/interaction/element_identifier.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/metadata/metadata_header_macros.h"
#include "ui/base/metadata/metadata_impl_macros.h"
#include "ui/base/models/combobox_model.h"
#include "ui/base/models/simple_combobox_model.h"
#include "ui/base/mojom/dialog_button.mojom.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/gfx/text_constants.h"
#include "ui/strings/grit/ui_strings.h"
#include "ui/views/accessibility/view_accessibility.h"
#include "ui/views/border.h"
#include "ui/views/bubble/bubble_frame_view.h"
#include "ui/views/controls/button/checkbox.h"
#include "ui/views/controls/button/image_button.h"
#include "ui/views/controls/button/image_button_factory.h"
#include "ui/views/controls/button/label_button.h"
#include "ui/views/controls/button/md_text_button.h"
#include "ui/views/controls/button/md_text_button_with_down_arrow.h"
#include "ui/views/controls/button/menu_button.h"
#include "ui/views/controls/combobox/combobox.h"
#include "ui/views/controls/highlight_path_generator.h"
#include "ui/views/controls/label.h"
#include "ui/views/controls/link.h"
#include "ui/views/controls/styled_label.h"
#include "ui/views/controls/tabbed_pane/tabbed_pane.h"
#include "ui/views/layout/box_layout.h"
#include "ui/views/layout/box_layout_view.h"
#include "ui/views/layout/flex_layout.h"
#include "ui/views/layout/flex_layout_types.h"
#include "ui/views/layout/flex_layout_view.h"
#include "ui/views/layout/layout_types.h"
#include "ui/views/style/platform_style.h"
#include "ui/views/style/typography.h"
#include "ui/views/view_class_properties.h"
#include "ui/views/widget/widget.h"

namespace {

bool UseGoogleTranslateBranding() {}

std::unique_ptr<views::View> CreateWordmarkView() {}

}  // namespace

PartialTranslateBubbleView::~PartialTranslateBubbleView() {}

DEFINE_CLASS_ELEMENT_IDENTIFIER_VALUE(PartialTranslateBubbleView, kIdentifier);
DEFINE_CLASS_ELEMENT_IDENTIFIER_VALUE(PartialTranslateBubbleView,
                                      kSourceLanguageTab);
DEFINE_CLASS_ELEMENT_IDENTIFIER_VALUE(PartialTranslateBubbleView,
                                      kTargetLanguageTab);
DEFINE_CLASS_ELEMENT_IDENTIFIER_VALUE(PartialTranslateBubbleView, kCloseButton);
DEFINE_CLASS_ELEMENT_IDENTIFIER_VALUE(PartialTranslateBubbleView,
                                      kOptionsMenuButton);
DEFINE_CLASS_ELEMENT_IDENTIFIER_VALUE(PartialTranslateBubbleView,
                                      kChangeTargetLanguage);
DEFINE_CLASS_ELEMENT_IDENTIFIER_VALUE(PartialTranslateBubbleView,
                                      kTargetLanguageCombobox);
DEFINE_CLASS_ELEMENT_IDENTIFIER_VALUE(PartialTranslateBubbleView,
                                      kTargetLanguageDoneButton);
DEFINE_CLASS_ELEMENT_IDENTIFIER_VALUE(PartialTranslateBubbleView,
                                      kChangeSourceLanguage);
DEFINE_CLASS_ELEMENT_IDENTIFIER_VALUE(PartialTranslateBubbleView,
                                      kSourceLanguageCombobox);
DEFINE_CLASS_ELEMENT_IDENTIFIER_VALUE(PartialTranslateBubbleView,
                                      kSourceLanguageDoneButton);
DEFINE_CLASS_ELEMENT_IDENTIFIER_VALUE(PartialTranslateBubbleView,
                                      kErrorMessage);

void PartialTranslateBubbleView::CloseBubble() {}

void PartialTranslateBubbleView::TabSelectedAt(int index) {}

void PartialTranslateBubbleView::Init() {}

views::View* PartialTranslateBubbleView::GetInitiallyFocusedView() {}

bool PartialTranslateBubbleView::ShouldShowCloseButton() const {}

bool PartialTranslateBubbleView::ShouldShowWindowTitle() const {}

bool PartialTranslateBubbleView::DidLanguageSelectionChange(
    PartialTranslateBubbleModel::ViewState view_state) {}

void PartialTranslateBubbleView::ResetLanguage() {}

void PartialTranslateBubbleView::WindowClosing() {}

bool PartialTranslateBubbleView::AcceleratorPressed(
    const ui::Accelerator& accelerator) {}

gfx::Size PartialTranslateBubbleView::CalculatePreferredSize(
    const views::SizeBounds& available_size) const {}

// Create the menu items for the dropdown options menu under TAB UI.
void PartialTranslateBubbleView::ShowOptionsMenu(views::Button* source) {}

void PartialTranslateBubbleView::ExecuteCommand(int command_id,
                                                int event_flags) {}

void PartialTranslateBubbleView::OnWidgetDestroying(views::Widget* widget) {}

PartialTranslateBubbleModel::ViewState
PartialTranslateBubbleView::GetViewState() const {}

void PartialTranslateBubbleView::SetViewState(
    PartialTranslateBubbleModel::ViewState view_state,
    translate::TranslateErrors error_type) {}

PartialTranslateBubbleView::PartialTranslateBubbleView(
    views::View* anchor_view,
    std::unique_ptr<PartialTranslateBubbleModel> model,
    content::WebContents* web_contents,
    base::OnceClosure on_closing)
    :{}

views::View* PartialTranslateBubbleView::GetCurrentView() const {}

void PartialTranslateBubbleView::ShowTranslated() {}

void PartialTranslateBubbleView::ShowOriginal() {}

void PartialTranslateBubbleView::ConfirmAdvancedOptions() {}

void PartialTranslateBubbleView::UpdateLanguageTabNames() {}

void PartialTranslateBubbleView::SourceLanguageChanged() {}

void PartialTranslateBubbleView::TargetLanguageChanged() {}

void PartialTranslateBubbleView::UpdateChildVisibilities() {}

std::unique_ptr<views::View> PartialTranslateBubbleView::CreateEmptyPane() {}

std::unique_ptr<views::View> PartialTranslateBubbleView::CreateView() {}

// TODO(crbug.com/40335010): Revise this later to show a specific message for
// each error.
std::unique_ptr<views::View> PartialTranslateBubbleView::CreateViewError() {}

std::unique_ptr<views::View> PartialTranslateBubbleView::CreateViewErrorNoTitle(
    std::unique_ptr<views::Button> button) {}

std::unique_ptr<views::View> PartialTranslateBubbleView::CreateViewWaiting() {}

// TODO(cuianthony): The code for advanced view creation for
// PartialTranslateBubbleView is a near duplicate of the code for
// TranslateBubbleView. This should be refactored to share the view creation
// code between the two bubbles.
std::unique_ptr<views::View>
PartialTranslateBubbleView::CreateViewAdvancedSource() {}

std::unique_ptr<views::View>
PartialTranslateBubbleView::CreateViewAdvancedTarget() {}

std::unique_ptr<views::View> PartialTranslateBubbleView::CreateViewAdvanced(
    std::unique_ptr<views::Combobox> combobox,
    std::unique_ptr<views::Label> language_title_label,
    std::unique_ptr<views::Button> advanced_reset_button,
    std::unique_ptr<views::Button> advanced_done_button) {}

std::unique_ptr<views::ImageView>
PartialTranslateBubbleView::CreateTranslateIcon() {}

std::unique_ptr<views::Button>
PartialTranslateBubbleView::CreateOptionsMenuButton() {}

std::unique_ptr<views::Button> PartialTranslateBubbleView::CreateCloseButton() {}

void PartialTranslateBubbleView::SetWindowTitle(
    PartialTranslateBubbleModel::ViewState view_state) {}

void PartialTranslateBubbleView::ComputeLargestViewStateWidth() {}

void PartialTranslateBubbleView::UpdateViewState(
    PartialTranslateBubbleModel::ViewState view_state) {}

void PartialTranslateBubbleView::SwitchView(
    PartialTranslateBubbleModel::ViewState view_state) {}

void PartialTranslateBubbleView::UpdateTextForViewState(
    PartialTranslateBubbleModel::ViewState view_state) {}

void PartialTranslateBubbleView::MaybeUpdateSourceLanguageCombobox() {}

void PartialTranslateBubbleView::AnnounceForAccessibility(
    PartialTranslateBubbleModel::ViewState view_state) {}
void PartialTranslateBubbleView::SwitchTabForViewState(
    PartialTranslateBubbleModel::ViewState view_state) {}

void PartialTranslateBubbleView::SwitchToErrorView(
    translate::TranslateErrors error_type) {}

void PartialTranslateBubbleView::UpdateAdvancedView() {}

void PartialTranslateBubbleView::UpdateInsets(
    PartialTranslateBubbleModel::ViewState state) {}

void PartialTranslateBubbleView::TranslateFullPage() {}

void PartialTranslateBubbleView::SetTextAlignmentForLocaleTextDirection(
    std::string locale) {}

BEGIN_METADATA()