chromium/chrome/browser/search/background/ntp_custom_background_service.cc

// Copyright 2021 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/search/background/ntp_custom_background_service.h"

#include <optional>
#include <string>

#include "base/barrier_callback.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/metrics/histogram_macros.h"
#include "base/observer_list.h"
#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
#include "base/task/thread_pool.h"
#include "base/time/clock.h"
#include "base/time/default_clock.h"
#include "base/time/time.h"
#include "base/token.h"
#include "base/values.h"
#include "chrome/browser/image_fetcher/image_decoder_impl.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search/background/ntp_background_service_factory.h"
#include "chrome/browser/search/background/ntp_custom_background_service_constants.h"
#include "chrome/browser/search/background/ntp_custom_background_service_observer.h"
#include "chrome/browser/search/background/wallpaper_search/wallpaper_search_background_manager.h"
#include "chrome/browser/themes/theme_service_factory.h"
#include "chrome/browser/themes/theme_syncable_service.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/search/instant_types.h"
#include "chrome/common/url_constants.h"
#include "components/optimization_guide/core/optimization_guide_features.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/pref_service.h"
#include "components/search/ntp_features.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/storage_partition.h"
#include "net/http/http_status_code.h"
#include "services/network/public/cpp/resource_request.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "skia/ext/image_operations.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/base/mojom/themes.mojom.h"
#include "ui/gfx/color_analysis.h"
#include "ui/gfx/image/image.h"
#include "url/gurl.h"

namespace {

constexpr char kSidePanelSnapshotImageOptions[] =;

base::Value::Dict GetBackgroundInfoAsDict(
    const GURL& background_url,
    const std::string& attribution_line_1,
    const std::string& attribution_line_2,
    const GURL& action_url,
    const std::optional<std::string>& collection_id,
    const std::optional<std::string>& resume_token,
    const std::optional<int> refresh_timestamp) {}

base::Value::Dict GetBackgroundInfoWithColor(
    const base::Value::Dict* background_info,
    const SkColor color) {}

base::Value::Dict NtpCustomBackgroundDefaults() {}

void CopyFileToProfilePath(const base::FilePath& from_path,
                           const base::FilePath& profile_path) {}

std::string ReadFileToString(const base::FilePath& path) {}

void RemoveLocalBackgroundImageCopy(Profile* profile) {}

// |GetBitmapMainColor| just wraps |CalculateKMeanColorOfBitmap|.
// As |CalculateKMeanColorOfBitmap| is overloaded, it cannot be bind for async
// call.
SkColor GetBitmapMainColor(const SkBitmap& bitmap) {}

}  // namespace

// static
void NtpCustomBackgroundService::RegisterProfilePrefs(
    PrefRegistrySimple* registry) {}

// static
void NtpCustomBackgroundService::ResetNtpTheme(Profile* profile) {}

// static
void NtpCustomBackgroundService::ResetProfilePrefs(Profile* profile) {}

NtpCustomBackgroundService::NtpCustomBackgroundService(Profile* profile)
    :{}

NtpCustomBackgroundService::~NtpCustomBackgroundService() = default;

void NtpCustomBackgroundService::OnCollectionInfoAvailable() {}

void NtpCustomBackgroundService::OnCollectionImagesAvailable() {}

void NtpCustomBackgroundService::OnNextCollectionImageAvailable() {}

void NtpCustomBackgroundService::OnNtpBackgroundServiceShuttingDown() {}

void NtpCustomBackgroundService::OnThemeChanged() {}

void NtpCustomBackgroundService::OnCustomNtpBackgroundObsolete() {}

void NtpCustomBackgroundService::UpdateBackgroundFromSync() {}

void NtpCustomBackgroundService::ResetCustomBackgroundInfo() {}

void NtpCustomBackgroundService::SetCustomBackgroundInfo(
    const GURL& background_url,
    const GURL& thumbnail_url,
    const std::string& attribution_line_1,
    const std::string& attribution_line_2,
    const GURL& action_url,
    const std::string& collection_id) {}

void NtpCustomBackgroundService::UpdateLocalCustomBackgroundPrefsWithColor(
    SkColor color) {}

void NtpCustomBackgroundService::UpdateCustomLocalBackgroundColorAsync(
    const gfx::Image& image) {}

void NtpCustomBackgroundService::ProcessLocalImageData(std::string image_data) {}

void NtpCustomBackgroundService::SelectLocalBackgroundImage(
    const base::FilePath& path) {}

void NtpCustomBackgroundService::RefreshBackgroundIfNeeded() {}

void NtpCustomBackgroundService::RevertBackgroundChanges() {}

void NtpCustomBackgroundService::ConfirmBackgroundChanges() {}

std::optional<CustomBackground>
NtpCustomBackgroundService::GetCustomBackground() {}

void NtpCustomBackgroundService::AddObserver(
    NtpCustomBackgroundServiceObserver* observer) {}

void NtpCustomBackgroundService::RemoveObserver(
    NtpCustomBackgroundServiceObserver* observer) {}

bool NtpCustomBackgroundService::IsCustomBackgroundDisabledByPolicy() {}

bool NtpCustomBackgroundService::IsCustomBackgroundSet() {}

void NtpCustomBackgroundService::AddValidBackdropUrlForTesting(
    const GURL& url) const {}

void NtpCustomBackgroundService::SetClockForTesting(base::Clock* clock) {}

void NtpCustomBackgroundService::UpdateCustomBackgroundColorAsync(
    const GURL& image_url,
    const gfx::Image& fetched_image,
    const image_fetcher::RequestMetadata& metadata) {}

void NtpCustomBackgroundService::VerifyCustomBackgroundImageURL() {}

void NtpCustomBackgroundService::SetBackgroundToLocalResource() {}

void NtpCustomBackgroundService::SetBackgroundToLocalResourceWithId(
    const base::Token& id,
    bool is_inspiration_image) {}

void NtpCustomBackgroundService::ForceRefreshBackground() {}

bool NtpCustomBackgroundService::IsCustomBackgroundPrefValid() {}

void NtpCustomBackgroundService::NotifyAboutBackgrounds() {}

void NtpCustomBackgroundService::UpdateCustomBackgroundPrefsWithColor(
    const GURL& image_url,
    SkColor color) {}

void NtpCustomBackgroundService::FetchCustomBackgroundAndExtractBackgroundColor(
    const GURL& image_url,
    const GURL& fetch_url) {}

void NtpCustomBackgroundService::OnCustomBackgroundURLHeadersReceived(
    const GURL& verified_custom_background_url,
    int headers_response_code) {}