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

Side by Side Diff: chrome/browser/win/jumplist.cc

Issue 2665623002: Fix Jumplist favicons to have high resolution in HDPI Windows displays (Closed)
Patch Set: Get bitmap of suitable size. Created 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/win/jumplist.h" 5 #include "chrome/browser/win/jumplist.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 23 matching lines...) Expand all
34 #include "components/history/core/browser/page_usage_data.h" 34 #include "components/history/core/browser/page_usage_data.h"
35 #include "components/history/core/browser/top_sites.h" 35 #include "components/history/core/browser/top_sites.h"
36 #include "components/prefs/pref_change_registrar.h" 36 #include "components/prefs/pref_change_registrar.h"
37 #include "components/sessions/core/session_types.h" 37 #include "components/sessions/core/session_types.h"
38 #include "components/sessions/core/tab_restore_service.h" 38 #include "components/sessions/core/tab_restore_service.h"
39 #include "components/strings/grit/components_strings.h" 39 #include "components/strings/grit/components_strings.h"
40 #include "content/public/browser/browser_thread.h" 40 #include "content/public/browser/browser_thread.h"
41 #include "content/public/browser/notification_registrar.h" 41 #include "content/public/browser/notification_registrar.h"
42 #include "content/public/browser/notification_source.h" 42 #include "content/public/browser/notification_source.h"
43 #include "ui/base/l10n/l10n_util.h" 43 #include "ui/base/l10n/l10n_util.h"
44 #include "ui/display/display.h"
45 #include "ui/display/screen.h"
44 #include "ui/gfx/codec/png_codec.h" 46 #include "ui/gfx/codec/png_codec.h"
45 #include "ui/gfx/favicon_size.h" 47 #include "ui/gfx/favicon_size.h"
46 #include "ui/gfx/icon_util.h" 48 #include "ui/gfx/icon_util.h"
47 #include "ui/gfx/image/image_family.h" 49 #include "ui/gfx/image/image_family.h"
50 #include "ui/gfx/image/image_skia.h"
48 #include "url/gurl.h" 51 #include "url/gurl.h"
49 52
50 using content::BrowserThread; 53 using content::BrowserThread;
51 using JumpListData = JumpList::JumpListData; 54 using JumpListData = JumpList::JumpListData;
52 55
53 namespace { 56 namespace {
54 57
55 // Delay jumplist updates to allow collapsing of redundant update requests. 58 // Delay jumplist updates to allow collapsing of redundant update requests.
56 const int kDelayForJumplistUpdateInMS = 3500; 59 const int kDelayForJumplistUpdateInMS = 3500;
57 60
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 537
535 // If there is currently a favicon request in progress, it is now outdated, 538 // If there is currently a favicon request in progress, it is now outdated,
536 // as we have received another, so nullify the handle from the old request. 539 // as we have received another, so nullify the handle from the old request.
537 task_id_ = base::CancelableTaskTracker::kBadTaskId; 540 task_id_ = base::CancelableTaskTracker::kBadTaskId;
538 // Lock the list to set icon data and pop the url. 541 // Lock the list to set icon data and pop the url.
539 { 542 {
540 JumpListData* data = &jumplist_data_->data; 543 JumpListData* data = &jumplist_data_->data;
541 base::AutoLock auto_lock(data->list_lock_); 544 base::AutoLock auto_lock(data->list_lock_);
542 // Attach the received data to the ShellLinkItem object. 545 // Attach the received data to the ShellLinkItem object.
543 // This data will be decoded by the RunUpdateOnFileThread method. 546 // This data will be decoded by the RunUpdateOnFileThread method.
544 if (!image_result.image.IsEmpty()) { 547 if (!image_result.image.IsEmpty() && !data->icon_urls_.empty() &&
545 if (!data->icon_urls_.empty() && data->icon_urls_.front().second.get()) 548 data->icon_urls_.front().second.get()) {
546 data->icon_urls_.front().second->set_icon_data( 549 const gfx::ImageSkia* imageskia = image_result.image.ToImageSkia();
sky 2017/02/04 00:01:59 The check you want is if (!image_result.image.IsEm
chengx 2017/02/04 00:18:59 This check is already used in Line 547 above. Or d
sky 2017/02/06 16:50:46 Because of the IsEmpty() check you shouldn't need
547 image_result.image.AsBitmap()); 550 if (imageskia) {
551 float scale = 1.0;
552 display::Screen* screen = display::Screen::GetScreen();
553 if (screen) {
554 const std::vector<display::Display> displays(
555 screen->GetAllDisplays());
556 for (auto& display : displays)
557 scale = std::max(scale, display.device_scale_factor());
558 }
559 gfx::ImageSkiaRep imageSkiaRep = imageskia->GetRepresentation(scale);
560 if (!imageSkiaRep.is_null()) {
561 data->icon_urls_.front().second->set_icon_data(
562 imageSkiaRep.sk_bitmap());
563 }
564 }
548 } 565 }
549 566
550 if (!data->icon_urls_.empty()) 567 if (!data->icon_urls_.empty())
551 data->icon_urls_.pop_front(); 568 data->icon_urls_.pop_front();
552 } 569 }
553 // Check whether we need to load more favicons. 570 // Check whether we need to load more favicons.
554 StartLoadingFavicon(); 571 StartLoadingFavicon();
555 } 572 }
556 573
557 void JumpList::OnIncognitoAvailabilityChanged() { 574 void JumpList::OnIncognitoAvailabilityChanged() {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 void JumpList::TopSitesLoaded(history::TopSites* top_sites) { 625 void JumpList::TopSitesLoaded(history::TopSites* top_sites) {
609 } 626 }
610 627
611 void JumpList::TopSitesChanged(history::TopSites* top_sites, 628 void JumpList::TopSitesChanged(history::TopSites* top_sites,
612 ChangeReason change_reason) { 629 ChangeReason change_reason) {
613 top_sites->GetMostVisitedURLs( 630 top_sites->GetMostVisitedURLs(
614 base::Bind(&JumpList::OnMostVisitedURLsAvailable, 631 base::Bind(&JumpList::OnMostVisitedURLsAvailable,
615 weak_ptr_factory_.GetWeakPtr()), 632 weak_ptr_factory_.GetWeakPtr()),
616 false); 633 false);
617 } 634 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698