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

Side by Side Diff: chrome/browser/ui/ash/launcher/launcher_favicon_loader.cc

Issue 1998933002: Update shelf spacing in Chrome OS according to the MD specs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix tests Created 4 years, 6 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/ui/ash/launcher/launcher_favicon_loader.h" 5 #include "chrome/browser/ui/ash/launcher/launcher_favicon_loader.h"
6 6
7 #include "ash/common/shelf/shelf_constants.h" 7 #include "ash/common/shelf/shelf_constants.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "content/public/browser/render_view_host.h" 12 #include "content/public/browser/render_view_host.h"
13 #include "content/public/browser/web_contents.h" 13 #include "content/public/browser/web_contents.h"
14 #include "content/public/browser/web_contents_observer.h" 14 #include "content/public/browser/web_contents_observer.h"
15 #include "third_party/skia/include/core/SkBitmap.h" 15 #include "third_party/skia/include/core/SkBitmap.h"
16 #include "url/gurl.h" 16 #include "url/gurl.h"
17 17
18 namespace internal { 18 namespace internal {
19 19
20 const int kMaxBitmapSize = 256; 20 const int kMaxBitmapSize = 256;
21 21
22 //////////////////////////////////////////////////////////////////////////////// 22 ////////////////////////////////////////////////////////////////////////////////
23 // FaviconRawBitmapHandler fetchs all bitmaps with the 'icon' (or 'shortcut 23 // FaviconRawBitmapHandler fetchs all bitmaps with the 'icon' (or 'shortcut
24 // icon') 24 // icon')
25 // link tag, storing the one that best matches ash::kShelfSize. 25 // link tag, storing the one that best matches
James Cook 2016/06/13 21:43:17 rewrap with line above
yiyix 2016/06/14 05:55:26 Done.
26 // ash::ShelfLayoutConstant::SHELF_SIZE.
26 // These icon bitmaps are not resized and are not cached beyond the lifetime 27 // These icon bitmaps are not resized and are not cached beyond the lifetime
27 // of the class. Bitmaps larger than kMaxBitmapSize are ignored. 28 // of the class. Bitmaps larger than kMaxBitmapSize are ignored.
28 29
29 class FaviconRawBitmapHandler : public content::WebContentsObserver { 30 class FaviconRawBitmapHandler : public content::WebContentsObserver {
30 public: 31 public:
31 FaviconRawBitmapHandler(content::WebContents* web_contents, 32 FaviconRawBitmapHandler(content::WebContents* web_contents,
32 LauncherFaviconLoader::Delegate* delegate) 33 LauncherFaviconLoader::Delegate* delegate)
33 : content::WebContentsObserver(web_contents), 34 : content::WebContentsObserver(web_contents),
34 delegate_(delegate), 35 delegate_(delegate),
35 weak_ptr_factory_(this) {} 36 weak_ptr_factory_(this) {}
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 if (!bitmaps.empty()) 139 if (!bitmaps.empty())
139 AddFavicon(image_url, bitmaps[0]); 140 AddFavicon(image_url, bitmaps[0]);
140 } 141 }
141 142
142 void FaviconRawBitmapHandler::AddFavicon(const GURL& image_url, 143 void FaviconRawBitmapHandler::AddFavicon(const GURL& image_url,
143 const SkBitmap& new_bitmap) { 144 const SkBitmap& new_bitmap) {
144 processed_requests_.insert(image_url); 145 processed_requests_.insert(image_url);
145 if (new_bitmap.height() > kMaxBitmapSize || 146 if (new_bitmap.height() > kMaxBitmapSize ||
146 new_bitmap.width() > kMaxBitmapSize) 147 new_bitmap.width() > kMaxBitmapSize)
147 return; 148 return;
148 if (new_bitmap.height() < ash::kShelfSize) 149 if (new_bitmap.height() < ash::GetShelfConstant(ash::SHELF_SIZE))
149 return; 150 return;
150 if (!bitmap_.isNull()) { 151 if (!bitmap_.isNull()) {
151 // We want the smallest icon that is large enough. 152 // We want the smallest icon that is large enough.
152 if (new_bitmap.height() > bitmap_.height()) 153 if (new_bitmap.height() > bitmap_.height())
153 return; 154 return;
154 } 155 }
155 bitmap_url_ = image_url; 156 bitmap_url_ = image_url;
156 bitmap_ = new_bitmap; 157 bitmap_ = new_bitmap;
157 delegate_->FaviconUpdated(); 158 delegate_->FaviconUpdated();
158 } 159 }
(...skipping 12 matching lines...) Expand all
171 LauncherFaviconLoader::~LauncherFaviconLoader() { 172 LauncherFaviconLoader::~LauncherFaviconLoader() {
172 } 173 }
173 174
174 SkBitmap LauncherFaviconLoader::GetFavicon() const { 175 SkBitmap LauncherFaviconLoader::GetFavicon() const {
175 return favicon_handler_->bitmap(); 176 return favicon_handler_->bitmap();
176 } 177 }
177 178
178 bool LauncherFaviconLoader::HasPendingDownloads() const { 179 bool LauncherFaviconLoader::HasPendingDownloads() const {
179 return favicon_handler_->HasPendingDownloads(); 180 return favicon_handler_->HasPendingDownloads();
180 } 181 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698