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

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

Issue 1920263003: Rename gfx::Display/Screen to display::Display/Screen in chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
11 #include "chrome/browser/manifest/manifest_icon_selector.h" 11 #include "chrome/browser/manifest/manifest_icon_selector.h"
12 #include "content/public/browser/browser_thread.h" 12 #include "content/public/browser/browser_thread.h"
13 #include "content/public/browser/render_frame_host.h" 13 #include "content/public/browser/render_frame_host.h"
14 #include "content/public/browser/web_contents.h" 14 #include "content/public/browser/web_contents.h"
15 #include "content/public/browser/web_contents_observer.h" 15 #include "content/public/browser/web_contents_observer.h"
16 #include "content/public/common/console_message_level.h" 16 #include "content/public/common/console_message_level.h"
17 #include "skia/ext/image_operations.h" 17 #include "skia/ext/image_operations.h"
18 #include "ui/gfx/screen.h" 18 #include "ui/display/screen.h"
19 19
20 // DevToolsConsoleHelper is a class that holds a WebContents in order to be able 20 // DevToolsConsoleHelper is a class that holds a WebContents in order to be able
21 // to send a message to the WebContents' main frame. It is used so 21 // to send a message to the WebContents' main frame. It is used so
22 // ManifestIconDownloader and the callers do not have to worry about 22 // ManifestIconDownloader and the callers do not have to worry about
23 // |web_contents| lifetime. If the |web_contents| is invalidated before the 23 // |web_contents| lifetime. If the |web_contents| is invalidated before the
24 // message can be sent, the message will simply be ignored. 24 // message can be sent, the message will simply be ignored.
25 class ManifestIconDownloader::DevToolsConsoleHelper 25 class ManifestIconDownloader::DevToolsConsoleHelper
26 : public content::WebContentsObserver { 26 : public content::WebContentsObserver {
27 public: 27 public:
28 explicit DevToolsConsoleHelper(content::WebContents* web_contents); 28 explicit DevToolsConsoleHelper(content::WebContents* web_contents);
(...skipping 20 matching lines...) Expand all
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 float device_scale_factor = 58 const float device_scale_factor =
59 gfx::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor(); 59 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor();
60 const int ideal_icon_size_in_px = 60 const int ideal_icon_size_in_px =
61 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));
62 const int minimum_icon_size_in_px = 62 const int minimum_icon_size_in_px =
63 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));
64 64
65 web_contents->DownloadImage( 65 web_contents->DownloadImage(
66 icon_url, 66 icon_url,
67 false, // is_favicon 67 false, // is_favicon
68 0, // max_bitmap_size - 0 means no maximum size. 68 0, // max_bitmap_size - 0 means no maximum size.
69 false, // bypass_cache 69 false, // bypass_cache
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 float ratio = height / width; 193 float ratio = height / width;
194 float ratio_difference = fabs(ratio - 1); 194 float ratio_difference = fabs(ratio - 1);
195 if (ratio_difference < best_ratio_difference) { 195 if (ratio_difference < best_ratio_difference) {
196 best_index = i; 196 best_index = i;
197 best_ratio_difference = ratio_difference; 197 best_ratio_difference = ratio_difference;
198 } 198 }
199 } 199 }
200 200
201 return best_index; 201 return best_index;
202 } 202 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/display_info_provider_win.cc ('k') | chrome/browser/manifest/manifest_icon_selector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698