chromium/chrome/renderer/searchbox/searchbox_extension.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/renderer/searchbox/searchbox_extension.h"

#include <stddef.h>
#include <stdint.h>

#include <string>
#include <string_view>
#include <vector>

#include "base/containers/flat_map.h"
#include "base/i18n/rtl.h"
#include "base/json/json_writer.h"
#include "base/json/string_escape.h"
#include "base/metrics/histogram_macros.h"
#include "base/metrics/user_metrics.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "chrome/common/search/instant_types.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/renderer_resources.h"
#include "chrome/renderer/searchbox/searchbox.h"
#include "components/crx_file/id_util.h"
#include "components/ntp_tiles/features.h"
#include "components/ntp_tiles/ntp_tile_impression.h"
#include "components/ntp_tiles/tile_source.h"
#include "components/ntp_tiles/tile_visual_type.h"
#include "content/public/common/url_constants.h"
#include "content/public/renderer/chrome_object_extensions_utils.h"
#include "content/public/renderer/render_frame.h"
#include "content/public/renderer/render_thread.h"
#include "gin/data_object_builder.h"
#include "gin/handle.h"
#include "gin/object_template_builder.h"
#include "gin/wrappable.h"
#include "third_party/blink/public/common/page/page_zoom.h"
#include "third_party/blink/public/platform/scheduler/web_agent_group_scheduler.h"
#include "third_party/blink/public/platform/web_string.h"
#include "third_party/blink/public/platform/web_url_request.h"
#include "third_party/blink/public/web/web_document.h"
#include "third_party/blink/public/web/web_frame_widget.h"
#include "third_party/blink/public/web/web_local_frame.h"
#include "third_party/blink/public/web/web_script_source.h"
#include "third_party/blink/public/web/web_view.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/window_open_disposition.h"
#include "ui/events/keycodes/keyboard_codes.h"
#include "ui/gfx/color_utils.h"
#include "ui/gfx/text_constants.h"
#include "ui/gfx/text_elider.h"
#include "url/gurl.h"
#include "url/url_constants.h"
#include "v8/include/v8.h"

namespace {

const char kCSSBackgroundImageFormat[] =;

const char kCSSBackgroundPositionCenter[] =;
const char kCSSBackgroundPositionLeft[] =;
const char kCSSBackgroundPositionTop[] =;
const char kCSSBackgroundPositionRight[] =;
const char kCSSBackgroundPositionBottom[] =;

const char kCSSBackgroundRepeatNo[] =;
const char kCSSBackgroundRepeatX[] =;
const char kCSSBackgroundRepeatY[] =;
const char kCSSBackgroundRepeat[] =;

const char kThemeAttributionFormat[] =;

const char kLTRHtmlTextDirection[] =;
const char kRTLHtmlTextDirection[] =;

void Dispatch(blink::WebLocalFrame* frame, const blink::WebString& script) {}

// Populates a Javascript MostVisitedItem object for returning from
// newTabPage.mostVisited. This does not include private data such as "url" or
// "title".
v8::Local<v8::Object> GenerateMostVisitedItem(
    v8::Isolate* isolate,
    float device_pixel_ratio,
    const blink::LocalFrameToken& frame_token,
    InstantRestrictedID restricted_id) {}

// Populates a Javascript MostVisitedItem object appropriate for returning from
// newTabPage.getMostVisitedItemData.
// NOTE: Includes private data such as "url" and "title", so this should not be
// returned to the host page (via newTabPage.mostVisited). It is only accessible
// to most-visited iframes via getMostVisitedItemData.
v8::Local<v8::Object> GenerateMostVisitedItemData(
    v8::Isolate* isolate,
    InstantRestrictedID restricted_id,
    const InstantMostVisitedItem& mv_item) {}

std::optional<int> CoerceToInt(v8::Isolate* isolate, v8::Value* value) {}

// Returns an array with the RGBA color components.
v8::Local<v8::Value> SkColorToArray(v8::Isolate* isolate,
                                    const SkColor& color) {}

v8::Local<v8::Object> GenerateNtpTheme(v8::Isolate* isolate,
                                       const NtpTheme& theme) {}

content::RenderFrame* GetMainRenderFrameForCurrentContext() {}

SearchBox* GetSearchBoxForCurrentContext() {}

static const char kDispatchFocusChangedScript[] =;

static const char kDispatchInputCancelScript[] =;

static const char kDispatchInputStartScript[] =;

static const char kDispatchKeyCaptureChangeScript[] =;

static const char kDispatchMostVisitedChangedScript[] =;

static const char kDispatchThemeChangeEventScript[] =;

// ----------------------------------------------------------------------------

class SearchBoxBindings : public gin::Wrappable<SearchBoxBindings> {};

gin::WrapperInfo SearchBoxBindings::kWrapperInfo =;

SearchBoxBindings::SearchBoxBindings() = default;

SearchBoxBindings::~SearchBoxBindings() = default;

gin::ObjectTemplateBuilder SearchBoxBindings::GetObjectTemplateBuilder(
    v8::Isolate* isolate) {}

// static
bool SearchBoxBindings::IsFocused() {}

// static
bool SearchBoxBindings::IsKeyCaptureEnabled() {}

// static
void SearchBoxBindings::StartCapturingKeyStrokes() {}

// static
void SearchBoxBindings::StopCapturingKeyStrokes() {}

class NewTabPageBindings : public gin::Wrappable<NewTabPageBindings> {};

gin::WrapperInfo NewTabPageBindings::kWrapperInfo =;

NewTabPageBindings::NewTabPageBindings() = default;

NewTabPageBindings::~NewTabPageBindings() = default;

gin::ObjectTemplateBuilder NewTabPageBindings::GetObjectTemplateBuilder(
    v8::Isolate* isolate) {}

// static
bool NewTabPageBindings::HasOrigin(const GURL& origin) {}

// static
bool NewTabPageBindings::IsInputInProgress() {}

// static
v8::Local<v8::Value> NewTabPageBindings::GetMostVisited(v8::Isolate* isolate) {}

// static
bool NewTabPageBindings::GetMostVisitedAvailable(v8::Isolate* isolate) {}

// static
v8::Local<v8::Value> NewTabPageBindings::GetNtpTheme(v8::Isolate* isolate) {}

// static
void NewTabPageBindings::DeleteMostVisitedItem(v8::Isolate* isolate,
                                               v8::Local<v8::Value> rid_value) {}

// static
void NewTabPageBindings::UndoAllMostVisitedDeletions() {}

// static
void NewTabPageBindings::UndoMostVisitedDeletion(
    v8::Isolate* isolate,
    v8::Local<v8::Value> rid_value) {}

// static
v8::Local<v8::Value> NewTabPageBindings::GetMostVisitedItemData(
    v8::Isolate* isolate,
    int rid) {}

}  // namespace

// static
void SearchBoxExtension::Install(blink::WebLocalFrame* frame) {}

// static
void SearchBoxExtension::DispatchFocusChange(blink::WebLocalFrame* frame) {}

// static
void SearchBoxExtension::DispatchInputCancel(blink::WebLocalFrame* frame) {}

// static
void SearchBoxExtension::DispatchInputStart(blink::WebLocalFrame* frame) {}

// static
void SearchBoxExtension::DispatchKeyCaptureChange(blink::WebLocalFrame* frame) {}

// static
void SearchBoxExtension::DispatchMostVisitedChanged(
    blink::WebLocalFrame* frame) {}

// static
void SearchBoxExtension::DispatchThemeChange(blink::WebLocalFrame* frame) {}