chromium/extensions/browser/api/guest_view/web_view/web_view_internal_api.cc

// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "extensions/browser/api/guest_view/web_view/web_view_internal_api.h"

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

#include "base/check_deref.h"
#include "base/functional/bind.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/single_thread_task_runner.h"
#include "base/task/thread_pool.h"
#include "base/types/optional_util.h"
#include "base/uuid.h"
#include "base/values.h"
#include "components/crash/core/common/crash_key.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/stop_find_action.h"
#include "extensions/browser/extensions_browser_client.h"
#include "extensions/browser/guest_view/web_view/controlled_frame_embedder_url_fetcher.h"
#include "extensions/browser/guest_view/web_view/web_view_constants.h"
#include "extensions/browser/guest_view/web_view/web_view_content_script_manager.h"
#include "extensions/common/api/web_view_internal.h"
#include "extensions/common/error_utils.h"
#include "extensions/common/manifest_constants.h"
#include "extensions/common/mojom/run_location.mojom-shared.h"
#include "extensions/common/permissions/permissions_data.h"
#include "extensions/common/script_constants.h"
#include "extensions/common/user_script.h"
#include "third_party/skia/include/core/SkBitmap.h"

WebContents;
ExtensionResource;
ContentScriptDetails;
InjectionItems;
Params;
InjectDetails;
UserScript;
ZoomController;
// error messages for content scripts:
errors;
web_view_internal;

namespace {

const char kCacheKey[] =;
const char kCookiesKey[] =;
const char kSessionCookiesKey[] =;
const char kPersistentCookiesKey[] =;
const char kFileSystemsKey[] =;
const char kIndexedDBKey[] =;
const char kLocalStorageKey[] =;
const char kWebSQLKey[] =;
const char kSinceKey[] =;
const char kLoadFileError[] =;
const char kHostIDError[] =;
const char kViewInstanceIdError[] =;
const char kDuplicatedContentScriptNamesError[] =;

const char kGeneratedScriptFilePrefix[] =;

uint32_t MaskForKey(const char* key) {}

std::optional<extensions::mojom::HostID> GenerateHostIDFromEmbedder(
    const extensions::Extension* extension,
    content::RenderFrameHost* embedder_rfh) {}

// Creates content script files when parsing InjectionItems of "js" or "css"
// proterties, and stores them in the `contents`.
void ParseScriptFiles(const GURL& owner_base_url,
                      const extensions::Extension* extension,
                      const InjectionItems& items,
                      UserScript::ContentList* contents) {}

// Parses the values stored in ContentScriptDetails, and constructs a
// user script.
std::unique_ptr<extensions::UserScript> ParseContentScript(
    const ContentScriptDetails& script_value,
    const extensions::Extension* extension,
    const GURL& owner_base_url,
    std::string* error) {}

std::unique_ptr<extensions::UserScriptList> ParseContentScripts(
    const std::vector<ContentScriptDetails>& content_script_list,
    const extensions::Extension* extension,
    const extensions::mojom::HostID& host_id,
    bool incognito_enabled,
    const GURL& owner_base_url,
    std::string* error) {}

}  // namespace

namespace extensions {

bool WebViewInternalExtensionFunction::PreRunValidation(std::string* error) {}

WebViewGuest& WebViewInternalExtensionFunction::GetGuest() {}

WebViewInternalCaptureVisibleRegionFunction::
    WebViewInternalCaptureVisibleRegionFunction()
    :{}

ExtensionFunction::ResponseAction
WebViewInternalCaptureVisibleRegionFunction::Run() {}

void WebViewInternalCaptureVisibleRegionFunction::GetQuotaLimitHeuristics(
    QuotaLimitHeuristics* heuristics) const {}

WebContentsCaptureClient::ScreenshotAccess
WebViewInternalCaptureVisibleRegionFunction::GetScreenshotAccess(
    content::WebContents* web_contents) const {}

bool WebViewInternalCaptureVisibleRegionFunction::ClientAllowsTransparency() {}

void WebViewInternalCaptureVisibleRegionFunction::OnCaptureSuccess(
    const SkBitmap& bitmap) {}

void WebViewInternalCaptureVisibleRegionFunction::EncodeBitmapOnWorkerThread(
    scoped_refptr<base::TaskRunner> reply_task_runner,
    const SkBitmap& bitmap) {}

void WebViewInternalCaptureVisibleRegionFunction::OnBitmapEncodedOnUIThread(
    bool success,
    std::string base64_result) {}

void WebViewInternalCaptureVisibleRegionFunction::OnCaptureFailure(
    CaptureResult result) {}

std::string WebViewInternalCaptureVisibleRegionFunction::GetErrorMessage(
    CaptureResult result) {}

ExtensionFunction::ResponseAction WebViewInternalNavigateFunction::Run() {}

WebViewInternalExecuteCodeFunction::WebViewInternalExecuteCodeFunction()
    :{}

WebViewInternalExecuteCodeFunction::~WebViewInternalExecuteCodeFunction() {}

ExecuteCodeFunction::InitResult WebViewInternalExecuteCodeFunction::Init() {}

bool WebViewInternalExecuteCodeFunction::ShouldInsertCSS() const {}

bool WebViewInternalExecuteCodeFunction::ShouldRemoveCSS() const {}

bool WebViewInternalExecuteCodeFunction::CanExecuteScriptOnPage(
    std::string* error) {}

extensions::ScriptExecutor*
WebViewInternalExecuteCodeFunction::GetScriptExecutor(std::string* error) {}

bool WebViewInternalExecuteCodeFunction::IsWebView() const {}

const GURL& WebViewInternalExecuteCodeFunction::GetWebViewSrc() const {}

bool WebViewInternalExecuteCodeFunction::LoadFileForEmbedder(
    const std::string& file_src,
    LoadFileCallback callback) {}

void WebViewInternalExecuteCodeFunction::DidLoadFileForEmbedder(
    const std::string& file,
    bool success,
    std::unique_ptr<std::string> data) {}

bool WebViewInternalExecuteCodeFunction::LoadFile(const std::string& file,
                                                  std::string* error) {}

WebViewInternalExecuteScriptFunction::WebViewInternalExecuteScriptFunction() {}

WebViewInternalInsertCSSFunction::WebViewInternalInsertCSSFunction() {}

bool WebViewInternalInsertCSSFunction::ShouldInsertCSS() const {}

WebViewInternalAddContentScriptsFunction::
    WebViewInternalAddContentScriptsFunction() {}

WebViewInternalAddContentScriptsFunction::
    ~WebViewInternalAddContentScriptsFunction() {}

ExecuteCodeFunction::ResponseAction
WebViewInternalAddContentScriptsFunction::Run() {}

WebViewInternalRemoveContentScriptsFunction::
    WebViewInternalRemoveContentScriptsFunction() {}

WebViewInternalRemoveContentScriptsFunction::
    ~WebViewInternalRemoveContentScriptsFunction() {}

ExecuteCodeFunction::ResponseAction
WebViewInternalRemoveContentScriptsFunction::Run() {}

WebViewInternalSetNameFunction::WebViewInternalSetNameFunction() {}

WebViewInternalSetNameFunction::~WebViewInternalSetNameFunction() {}

ExtensionFunction::ResponseAction WebViewInternalSetNameFunction::Run() {}

WebViewInternalSetAllowTransparencyFunction::
WebViewInternalSetAllowTransparencyFunction() {}

WebViewInternalSetAllowTransparencyFunction::
~WebViewInternalSetAllowTransparencyFunction() {}

ExtensionFunction::ResponseAction
WebViewInternalSetAllowTransparencyFunction::Run() {}

WebViewInternalSetAllowScalingFunction::
    WebViewInternalSetAllowScalingFunction() {}

WebViewInternalSetAllowScalingFunction::
    ~WebViewInternalSetAllowScalingFunction() {}

ExtensionFunction::ResponseAction
WebViewInternalSetAllowScalingFunction::Run() {}

WebViewInternalSetZoomFunction::WebViewInternalSetZoomFunction() {}

WebViewInternalSetZoomFunction::~WebViewInternalSetZoomFunction() {}

ExtensionFunction::ResponseAction WebViewInternalSetZoomFunction::Run() {}

WebViewInternalGetZoomFunction::WebViewInternalGetZoomFunction() {}

WebViewInternalGetZoomFunction::~WebViewInternalGetZoomFunction() {}

ExtensionFunction::ResponseAction WebViewInternalGetZoomFunction::Run() {}

WebViewInternalSetZoomModeFunction::WebViewInternalSetZoomModeFunction() {}

WebViewInternalSetZoomModeFunction::~WebViewInternalSetZoomModeFunction() {}

ExtensionFunction::ResponseAction WebViewInternalSetZoomModeFunction::Run() {}

WebViewInternalGetZoomModeFunction::WebViewInternalGetZoomModeFunction() {}

WebViewInternalGetZoomModeFunction::~WebViewInternalGetZoomModeFunction() {}

ExtensionFunction::ResponseAction WebViewInternalGetZoomModeFunction::Run() {}

WebViewInternalFindFunction::WebViewInternalFindFunction() {}

WebViewInternalFindFunction::~WebViewInternalFindFunction() {}

void WebViewInternalFindFunction::ForwardResponse(base::Value::Dict results) {}

ExtensionFunction::ResponseAction WebViewInternalFindFunction::Run() {}

WebViewInternalStopFindingFunction::WebViewInternalStopFindingFunction() {}

WebViewInternalStopFindingFunction::~WebViewInternalStopFindingFunction() {}

ExtensionFunction::ResponseAction WebViewInternalStopFindingFunction::Run() {}

WebViewInternalLoadDataWithBaseUrlFunction::
    WebViewInternalLoadDataWithBaseUrlFunction() {}

WebViewInternalLoadDataWithBaseUrlFunction::
    ~WebViewInternalLoadDataWithBaseUrlFunction() {}

ExtensionFunction::ResponseAction
WebViewInternalLoadDataWithBaseUrlFunction::Run() {}

WebViewInternalGoFunction::WebViewInternalGoFunction() {}

WebViewInternalGoFunction::~WebViewInternalGoFunction() {}

ExtensionFunction::ResponseAction WebViewInternalGoFunction::Run() {}

WebViewInternalReloadFunction::WebViewInternalReloadFunction() {}

WebViewInternalReloadFunction::~WebViewInternalReloadFunction() {}

ExtensionFunction::ResponseAction WebViewInternalReloadFunction::Run() {}

WebViewInternalSetPermissionFunction::WebViewInternalSetPermissionFunction() {}

WebViewInternalSetPermissionFunction::~WebViewInternalSetPermissionFunction() {}

ExtensionFunction::ResponseAction WebViewInternalSetPermissionFunction::Run() {}

WebViewInternalOverrideUserAgentFunction::
    WebViewInternalOverrideUserAgentFunction() {}

WebViewInternalOverrideUserAgentFunction::
    ~WebViewInternalOverrideUserAgentFunction() {}

ExtensionFunction::ResponseAction
WebViewInternalOverrideUserAgentFunction::Run() {}

WebViewInternalStopFunction::WebViewInternalStopFunction() {}

WebViewInternalStopFunction::~WebViewInternalStopFunction() {}

ExtensionFunction::ResponseAction WebViewInternalStopFunction::Run() {}

WebViewInternalSetAudioMutedFunction::WebViewInternalSetAudioMutedFunction() =
    default;

WebViewInternalSetAudioMutedFunction::~WebViewInternalSetAudioMutedFunction() =
    default;

ExtensionFunction::ResponseAction WebViewInternalSetAudioMutedFunction::Run() {}

WebViewInternalIsAudioMutedFunction::WebViewInternalIsAudioMutedFunction() =
    default;

WebViewInternalIsAudioMutedFunction::~WebViewInternalIsAudioMutedFunction() =
    default;

ExtensionFunction::ResponseAction WebViewInternalIsAudioMutedFunction::Run() {}

WebViewInternalGetAudioStateFunction::WebViewInternalGetAudioStateFunction() =
    default;

WebViewInternalGetAudioStateFunction::~WebViewInternalGetAudioStateFunction() =
    default;

ExtensionFunction::ResponseAction WebViewInternalGetAudioStateFunction::Run() {}

WebViewInternalTerminateFunction::WebViewInternalTerminateFunction() {}

WebViewInternalTerminateFunction::~WebViewInternalTerminateFunction() {}

ExtensionFunction::ResponseAction WebViewInternalTerminateFunction::Run() {}

WebViewInternalClearDataFunction::WebViewInternalClearDataFunction()
    :{}

WebViewInternalClearDataFunction::~WebViewInternalClearDataFunction() {}

WebViewInternalSetSpatialNavigationEnabledFunction::
    WebViewInternalSetSpatialNavigationEnabledFunction() {}

WebViewInternalSetSpatialNavigationEnabledFunction::
    ~WebViewInternalSetSpatialNavigationEnabledFunction() {}

ExtensionFunction::ResponseAction
WebViewInternalSetSpatialNavigationEnabledFunction::Run() {}

WebViewInternalIsSpatialNavigationEnabledFunction::
    WebViewInternalIsSpatialNavigationEnabledFunction() {}

WebViewInternalIsSpatialNavigationEnabledFunction::
    ~WebViewInternalIsSpatialNavigationEnabledFunction() {}

ExtensionFunction::ResponseAction
WebViewInternalIsSpatialNavigationEnabledFunction::Run() {}

// Parses the |dataToRemove| argument to generate the remove mask. Sets
// |bad_message_| (like EXTENSION_FUNCTION_VALIDATE would if this were a bool
// method) if 'dataToRemove' is not present.
uint32_t WebViewInternalClearDataFunction::GetRemovalMask() {}

// TODO(lazyboy): Parameters in this extension function are similar (or a
// sub-set) to BrowsingDataRemoverFunction. How can we share this code?
ExtensionFunction::ResponseAction WebViewInternalClearDataFunction::Run() {}

void WebViewInternalClearDataFunction::ClearDataDone() {}

}  // namespace extensions