chromium/components/safe_browsing/content/common/visual_utils.cc

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

#include "components/safe_browsing/content/common/visual_utils.h"

#include <unordered_map>
#include <vector>

#include "base/check_op.h"
#include "base/feature_list.h"
#include "base/numerics/checked_math.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
#include "components/safe_browsing/buildflags.h"
#include "components/safe_browsing/core/common/features.h"
#include "components/safe_browsing/core/common/proto/client_model.pb.h"
#include "components/safe_browsing/core/common/proto/csd.pb.h"
#include "skia/ext/image_operations.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkColorPriv.h"
#include "third_party/skia/include/core/SkColorSpace.h"
#include "third_party/skia/include/core/SkPixmap.h"
#include "ui/gfx/color_utils.h"

namespace safe_browsing::visual_utils {

namespace {

// WARNING: The following parameters are highly privacy and performance
// sensitive. These should not be changed without thorough review.
#if BUILDFLAG(IS_ANDROID)
const int kPHashDownsampleWidth = 108;
const int kPHashDownsampleHeight = 192;
const int kMinWidthForVisualFeatures = 258;
const int kMinHeightForVisualFeatures = 258;
#else
const int kPHashDownsampleWidth =;
const int kPHashDownsampleHeight =;
const int kMinWidthForVisualFeatures =;
const int kMinHeightForVisualFeatures =;
#endif
const int kPHashBlockSize =;

#if BUILDFLAG(FULL_SAFE_BROWSING)
// Parameters chosen to ensure privacy is preserved by visual features.
const float kMaxZoomForVisualFeatures =;
#endif  // BUILDFLAG(FULL_SAFE_BROWSING)

int GetPHashDownsampleWidth() {}

int GetPHashDownsampleHeight() {}

int GetMinWidthForVisualFeatures() {}

int GetMinHeightForVisualFeatures() {}

}  // namespace

bool GetBlurredImage(const SkBitmap& image,
                     VisualFeatures::BlurredImage* blurred_image) {}

std::unique_ptr<SkBitmap> BlockMeanAverage(const SkBitmap& image,
                                           int block_size) {}

#if BUILDFLAG(IS_ANDROID)
CanExtractVisualFeaturesResult CanExtractVisualFeatures(
    bool is_extended_reporting,
    bool is_off_the_record,
    gfx::Size size) {
#else
CanExtractVisualFeaturesResult CanExtractVisualFeatures(
    bool is_extended_reporting,
    bool is_off_the_record,
    gfx::Size size,
    double zoom_level) {}

std::unique_ptr<VisualFeatures> ExtractVisualFeatures(
    const SkBitmap& screenshot) {}

}  // namespace safe_browsing::visual_utils