chromium/chrome/browser/ui/tab_contents/core_tab_helper.cc

// Copyright 2012 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/tab_contents/core_tab_helper.h"

#include <string>
#include <utility>
#include <vector>

#include "base/command_line.h"
#include "base/functional/bind.h"
#include "base/logging.h"
#include "base/metrics/histogram_macros.h"
#include "base/strings/stringprintf.h"
#include "base/task/bind_post_task.h"
#include "base/task/single_thread_task_runner.h"
#include "base/task/thread_pool.h"
#include "build/branding_buildflags.h"
#include "build/build_config.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/translate/chrome_translate_client.h"
#include "chrome/browser/ui/browser_command_controller.h"
#include "chrome/browser/ui/ui_features.h"
#include "chrome/common/chrome_render_frame.mojom.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/grit/generated_resources.h"
#include "components/lens/buildflags.h"
#include "components/lens/lens_constants.h"
#include "components/lens/lens_entrypoints.h"
#include "components/lens/lens_features.h"
#include "components/lens/lens_rendering_environment.h"
#include "components/lens/lens_url_utils.h"
#include "components/search/search.h"
#include "components/search_engines/template_url.h"
#include "components/search_engines/template_url_service.h"
#include "components/strings/grit/components_strings.h"
#include "components/translate/core/browser/language_state.h"
#include "components/translate/core/common/translate_constants.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_switches.h"
#include "extensions/buildflags/buildflags.h"
#include "net/base/load_states.h"
#include "net/http/http_request_headers.h"
#include "skia/ext/image_operations.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/codec/jpeg_codec.h"
#include "ui/gfx/codec/webp_codec.h"
#include "ui/gfx/image/image_util.h"

#if !BUILDFLAG(IS_ANDROID)
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/views/side_panel/companion/companion_tab_helper.h"
#include "chrome/browser/ui/views/side_panel/companion/companion_utils.h"
#include "chrome/browser/ui/views/side_panel/lens/lens_core_tab_side_panel_helper.h"
#endif

#if BUILDFLAG(ENABLE_EXTENSIONS)
#include "components/guest_view/browser/guest_view_manager.h"
#endif

#if BUILDFLAG(ENABLE_LENS_DESKTOP_GOOGLE_BRANDED_FEATURES)
#include "chrome/browser/ui/views/lens/lens_side_panel_helper.h"
#endif

WebContents;

namespace {

constexpr int kImageSearchThumbnailMinSize =;
constexpr int kImageSearchThumbnailMaxWidth =;
constexpr int kImageSearchThumbnailMaxHeight =;
constexpr char kUnifiedSidePanelVersion[] =;
constexpr int kEncodingQualityJpeg =;
constexpr int kEncodingQualityWebp =;

bool NeedsDownscale(gfx::Image image) {}

gfx::Image DownscaleImage(const gfx::Image& image) {}

#if BUILDFLAG(IS_ANDROID)
bool IsSidePanelEnabledForLens(content::WebContents* contents) {
  return false;
}
bool IsSidePanelEnabledFor3PDse(content::WebContents* contents) {
  return false;
}
#else
bool IsSidePanelEnabledForLens(content::WebContents* contents) {}
bool IsSidePanelEnabledFor3PDse(content::WebContents* contents) {}
#endif

}  // namespace

CoreTabHelper::CoreTabHelper(WebContents* web_contents)
    :{}

CoreTabHelper::~CoreTabHelper() {}

// static
std::u16string CoreTabHelper::GetDefaultTitle() {}

std::u16string CoreTabHelper::GetStatusText() const {}

void CoreTabHelper::UpdateContentRestrictions(int content_restrictions) {}

std::vector<unsigned char> CoreTabHelper::EncodeImage(
    const gfx::Image& image,
    std::string& content_type,
    lens::mojom::ImageFormat& image_format) {}

// static
void CoreTabHelper::DownscaleAndEncodeBitmap(
    const SkBitmap& bitmap,
    int thumbnail_min_area,
    int thumbnail_max_width,
    int thumbnail_max_height,
    DownscaleAndEncodeBitmapCallback callback) {}

// static
lens::mojom::ImageFormat CoreTabHelper::EncodeImageIntoSearchArgs(
    const gfx::Image& image,
    size_t& encoded_size_bytes,
    TemplateURLRef::SearchTermsArgs& search_args) {}

void CoreTabHelper::SearchWithLens(content::RenderFrameHost* render_frame_host,
                                   const GURL& src_url,
                                   lens::EntryPoint entry_point,
                                   bool is_image_translate,
                                   bool force_open_in_new_tab) {}

void CoreTabHelper::SearchWithLens(const gfx::Image& image,
                                   lens::EntryPoint entry_point,
                                   bool force_open_in_new_tab) {}

void CoreTabHelper::SearchByImage(content::RenderFrameHost* render_frame_host,
                                  const GURL& src_url) {}

void CoreTabHelper::SearchByImage(content::RenderFrameHost* render_frame_host,
                                  const GURL& src_url,
                                  bool is_image_translate) {}

void CoreTabHelper::SearchByImage(const gfx::Image& image) {}

void CoreTabHelper::SearchByImageImpl(
    const gfx::Image& original_image,
    const std::string& additional_query_params,
    bool use_side_panel) {}

void CoreTabHelper::SearchByImageImpl(
    content::RenderFrameHost* render_frame_host,
    const GURL& src_url,
    int thumbnail_min_area,
    int thumbnail_max_width,
    int thumbnail_max_height,
    const std::string& additional_query_params,
    bool use_side_panel,
    bool is_image_translate) {}

// static
bool CoreTabHelper::GetStatusTextForWebContents(std::u16string* status_text,
                                                content::WebContents* source) {}

////////////////////////////////////////////////////////////////////////////////
// WebContentsObserver overrides

void CoreTabHelper::DidStartLoading() {}

// Update back/forward buttons for web_contents that are active.
void CoreTabHelper::NavigationEntriesDeleted() {}

// Notify browser commands that depend on whether focus is in the
// web contents or not.
void CoreTabHelper::OnWebContentsFocused(
    content::RenderWidgetHost* render_widget_host) {}

void CoreTabHelper::OnWebContentsLostFocus(
    content::RenderWidgetHost* render_widget_host) {}

void CoreTabHelper::DoSearchByImageWithBitmap(
    mojo::AssociatedRemote<chrome::mojom::ChromeRenderFrame>
        chrome_render_frame,
    const GURL& src_url,
    const std::string& additional_query_params,
    bool use_side_panel,
    bool is_image_translate,
    int thumbnail_min_area,
    int thumbnail_max_width,
    int thumbnail_max_height,
    const SkBitmap& bitmap) {}

void CoreTabHelper::DoSearchByImage(
    const GURL& src_url,
    const std::string& additional_query_params,
    bool use_side_panel,
    bool is_image_translate,
    const std::vector<unsigned char>& thumbnail_data,
    const std::string& content_type,
    const gfx::Size& original_size,
    const gfx::Size& downscaled_size,
    const std::vector<lens::mojom::LatencyLogPtr> log_data) {}

TemplateURLService* CoreTabHelper::GetTemplateURLService() {}

bool CoreTabHelper::IsImageSearchSupportedForCompanion() {}

void CoreTabHelper::MaybeSetSearchArgsForImageTranslate(
    TemplateURLRef::SearchTermsArgs& search_args) {}

void CoreTabHelper::PostContentToURL(TemplateURLRef::PostContent post_content,
                                     GURL url,
                                     bool use_side_panel) {}

WEB_CONTENTS_USER_DATA_KEY_IMPL(CoreTabHelper);