Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Side by Side Diff: chrome/browser/manifest/manifest_icon_downloader.cc

Issue 1608733002: Remove ui/gfx/screen_type_delegate.h (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@metro-mode-4
Patch Set: and another rebase Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/manifest/manifest_icon_downloader.h" 5 #include "chrome/browser/manifest/manifest_icon_downloader.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <limits> 9 #include <limits>
10 10
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 bool ManifestIconDownloader::Download( 48 bool ManifestIconDownloader::Download(
49 content::WebContents* web_contents, 49 content::WebContents* web_contents,
50 const GURL& icon_url, 50 const GURL& icon_url,
51 int ideal_icon_size_in_dp, 51 int ideal_icon_size_in_dp,
52 int minimum_icon_size_in_dp, 52 int minimum_icon_size_in_dp,
53 const ManifestIconDownloader::IconFetchCallback& callback) { 53 const ManifestIconDownloader::IconFetchCallback& callback) {
54 DCHECK(minimum_icon_size_in_dp <= ideal_icon_size_in_dp); 54 DCHECK(minimum_icon_size_in_dp <= ideal_icon_size_in_dp);
55 if (!web_contents || !icon_url.is_valid()) 55 if (!web_contents || !icon_url.is_valid())
56 return false; 56 return false;
57 57
58 const gfx::Screen* screen =
59 gfx::Screen::GetScreenFor(web_contents->GetNativeView());
60
61 const float device_scale_factor = 58 const float device_scale_factor =
62 screen->GetPrimaryDisplay().device_scale_factor(); 59 gfx::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor();
63 const int ideal_icon_size_in_px = 60 const int ideal_icon_size_in_px =
64 static_cast<int>(round(ideal_icon_size_in_dp * device_scale_factor)); 61 static_cast<int>(round(ideal_icon_size_in_dp * device_scale_factor));
65 const int minimum_icon_size_in_px = 62 const int minimum_icon_size_in_px =
66 static_cast<int>(round(minimum_icon_size_in_dp * device_scale_factor)); 63 static_cast<int>(round(minimum_icon_size_in_dp * device_scale_factor));
67 64
68 web_contents->DownloadImage( 65 web_contents->DownloadImage(
69 icon_url, 66 icon_url,
70 false, // is_favicon 67 false, // is_favicon
71 0, // max_bitmap_size - 0 means no maximum size. 68 0, // max_bitmap_size - 0 means no maximum size.
72 false, // bypass_cache 69 false, // bypass_cache
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 float ratio = height / width; 193 float ratio = height / width;
197 float ratio_difference = fabs(ratio - 1); 194 float ratio_difference = fabs(ratio - 1);
198 if (ratio_difference < best_ratio_difference) { 195 if (ratio_difference < best_ratio_difference) {
199 best_index = i; 196 best_index = i;
200 best_ratio_difference = ratio_difference; 197 best_ratio_difference = ratio_difference;
201 } 198 }
202 } 199 }
203 200
204 return best_index; 201 return best_index;
205 } 202 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/display_info_provider_win.cc ('k') | chrome/browser/manifest/manifest_icon_selector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698