1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31

ash / birch / birch_icon_cache.cc [blame]

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

#include "ash/birch/birch_icon_cache.h"

#include <string>

#include "base/containers/flat_map.h"
#include "ui/gfx/image/image_skia.h"

namespace ash {

BirchIconCache::BirchIconCache() = default;

BirchIconCache::~BirchIconCache() = default;

gfx::ImageSkia BirchIconCache::Get(const std::string& url) {
  auto it = map_.find(url);
  if (it == map_.end()) {
    // Return a null image if the URL was not found.
    return gfx::ImageSkia();
  }
  return it->second;
}

void BirchIconCache::Put(const std::string& url, const gfx::ImageSkia& icon) {
  map_[url] = icon;
}

}  // namespace ash