Credential Manager API shouldn't save passwords from incognito.
[chromium-blink-merge.git] / components / favicon_base / select_favicon_frames.h
blob81d39d85328b92d8ddee1542e44aed96308f065b
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_FAVICON_BASE_SELECT_FAVICON_FRAMES_H_
6 #define COMPONENTS_FAVICON_BASE_SELECT_FAVICON_FRAMES_H_
8 #include <vector>
10 #include "base/basictypes.h"
12 class SkBitmap;
14 namespace gfx {
15 class ImageSkia;
16 class Size;
19 // Score which is smaller than the minimum score returned by
20 // SelectFaviconFrames() or SelectFaviconFrameIndices().
21 extern const float kSelectFaviconFramesInvalidScore;
23 // Takes a list of all bitmaps found in a .ico file, and creates an
24 // ImageSkia that's |desired_size_in_dip| x |desired_size_in_dip| big.
25 // Bitmaps are selected by using |SelectFaviconFrameIndices| and the
26 // platform's supported favicon scales (favicon_base::GetFaviconScales()).
27 // If |desired_size_in_dip| is 0, the largest bitmap is returned unmodified.
28 // |original_sizes| are the original sizes of the bitmaps. (For instance,
29 // WebContents::DownloadImage() does resampling if it is passed a max size.)
30 // If score is non-NULL, it receives a score between 0 (bad) and 1 (good)
31 // that describes how well |bitmaps| were able to produce an image at
32 // |desired_size_in_dip| for |favicon_scales|.
33 // The score is arbitrary, but it's best for exact size matches,
34 // and gets worse the more resampling needs to happen.
35 // If the resampling algorithm is modified, the resampling done in
36 // FaviconUtil::SelectFaviconFramesFromPNGs() should probably be modified too as
37 // it inspired by this method.
38 // If an unsupported scale (not in the favicon_base::GetFaviconScales())
39 // is requested, the ImageSkia will automatically scales using lancoz3.
40 gfx::ImageSkia CreateFaviconImageSkia(
41 const std::vector<SkBitmap>& bitmaps,
42 const std::vector<gfx::Size>& original_sizes,
43 int desired_size_in_dip,
44 float* score);
46 // Takes a list of the pixel sizes of a favicon's favicon bitmaps and returns
47 // the indices of the best sizes to use to create an ImageSkia with
48 // ImageSkiaReps with edge sizes |desired_sizes|. If '0' is one of
49 // |desired_sizes|, the index of the largest size is returned. If |score| is
50 // non-NULL, |score| is set to a value between 0 (bad) and 1 (good) that
51 // describes how well the bitmap data with the sizes at |best_indices| will
52 // produce the ImageSkia. The score is arbitrary, but it's best for exact
53 // matches, and gets worse the more resampling needs to happen.
54 // TODO(pkotwicz): Change API so that |desired_sizes| being empty indicates
55 // that the index of the largest size is requested.
56 // TODO(pkotwicz): Remove callers of this method for which |frame_pixel_sizes|
57 // are the sizes of the favicon bitmaps after they were resized.
58 void SelectFaviconFrameIndices(const std::vector<gfx::Size>& frame_pixel_sizes,
59 const std::vector<int>& desired_sizes,
60 std::vector<size_t>* best_indices,
61 float* score);
63 #endif // COMPONENTS_FAVICON_BASE_SELECT_FAVICON_FRAMES_H_