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

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

Issue 10388036: Adds the option of aligning the launcher to the left or right. There (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compile Created 8 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 | Annotate | Revision Log
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/views/ash/launcher/launcher_favicon_loader.h" 5 #include "chrome/browser/ui/views/ash/launcher/launcher_favicon_loader.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/browser/ui/views/ash/launcher/browser_launcher_item_controller. h" 8 #include "chrome/browser/ui/views/ash/launcher/browser_launcher_item_controller. h"
9 #include "chrome/common/favicon_url.h" 9 #include "chrome/common/favicon_url.h"
10 #include "chrome/common/icon_messages.h" 10 #include "chrome/common/icon_messages.h"
11 #include "content/public/browser/render_view_host.h" 11 #include "content/public/browser/render_view_host.h"
12 #include "content/public/browser/web_contents.h" 12 #include "content/public/browser/web_contents.h"
13 #include "content/public/browser/web_contents_delegate.h" 13 #include "content/public/browser/web_contents_delegate.h"
14 #include "googleurl/src/gurl.h" 14 #include "googleurl/src/gurl.h"
15 #include "third_party/skia/include/core/SkBitmap.h" 15 #include "third_party/skia/include/core/SkBitmap.h"
16 16
17 namespace internal { 17 namespace internal {
18 18
19 const int kMaxBitmapSize = 256; 19 const int kMaxBitmapSize = 256;
20 20
21 //////////////////////////////////////////////////////////////////////////////// 21 ////////////////////////////////////////////////////////////////////////////////
22 // FaviconBitmapHandler fetchs all bitmaps with the 'icon' (or 'shortcut icon') 22 // FaviconBitmapHandler fetchs all bitmaps with the 'icon' (or 'shortcut icon')
23 // link tag, storing the one that best matches ash::kLauncherPreferredHeight. 23 // link tag, storing the one that best matches ash::kLauncherPreferredSize.
24 // These icon bitmaps are not resized and are not cached beyond the lifetime 24 // These icon bitmaps are not resized and are not cached beyond the lifetime
25 // of the class. Bitmaps larger than kMaxBitmapSize are ignored. 25 // of the class. Bitmaps larger than kMaxBitmapSize are ignored.
26 26
27 class FaviconBitmapHandler { 27 class FaviconBitmapHandler {
28 public: 28 public:
29 FaviconBitmapHandler(content::WebContents* web_contents, 29 FaviconBitmapHandler(content::WebContents* web_contents,
30 LauncherFaviconLoader::Delegate* delegate) 30 LauncherFaviconLoader::Delegate* delegate)
31 : web_contents_(web_contents), 31 : web_contents_(web_contents),
32 delegate_(delegate) { 32 delegate_(delegate) {
33 } 33 }
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 if (!errored) 128 if (!errored)
129 AddFavicon(image_url, bitmap); 129 AddFavicon(image_url, bitmap);
130 } 130 }
131 131
132 void FaviconBitmapHandler::AddFavicon(const GURL& image_url, 132 void FaviconBitmapHandler::AddFavicon(const GURL& image_url,
133 const SkBitmap& new_bitmap) { 133 const SkBitmap& new_bitmap) {
134 processed_requests_.insert(image_url); 134 processed_requests_.insert(image_url);
135 if (new_bitmap.height() > kMaxBitmapSize || 135 if (new_bitmap.height() > kMaxBitmapSize ||
136 new_bitmap.width() > kMaxBitmapSize) 136 new_bitmap.width() > kMaxBitmapSize)
137 return; 137 return;
138 if (new_bitmap.height() < ash::kLauncherPreferredHeight) 138 if (new_bitmap.height() < ash::kLauncherPreferredSize)
139 return; 139 return;
140 if (!bitmap_.isNull()) { 140 if (!bitmap_.isNull()) {
141 // We want the smallest icon that is large enough. 141 // We want the smallest icon that is large enough.
142 if (new_bitmap.height() > bitmap_.height()) 142 if (new_bitmap.height() > bitmap_.height())
143 return; 143 return;
144 } 144 }
145 bitmap_url_ = image_url; 145 bitmap_url_ = image_url;
146 bitmap_ = new_bitmap; 146 bitmap_ = new_bitmap;
147 delegate_->FaviconUpdated(); 147 delegate_->FaviconUpdated();
148 } 148 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 const std::vector<FaviconURL>& candidates) { 180 const std::vector<FaviconURL>& candidates) {
181 favicon_handler_->OnUpdateFaviconURL(page_id, candidates); 181 favicon_handler_->OnUpdateFaviconURL(page_id, candidates);
182 } 182 }
183 183
184 void LauncherFaviconLoader::OnDidDownloadFavicon(int id, 184 void LauncherFaviconLoader::OnDidDownloadFavicon(int id,
185 const GURL& image_url, 185 const GURL& image_url,
186 bool errored, 186 bool errored,
187 const SkBitmap& bitmap) { 187 const SkBitmap& bitmap) {
188 favicon_handler_->OnDidDownloadFavicon(id, image_url, errored, bitmap); 188 favicon_handler_->OnDidDownloadFavicon(id, image_url, errored, bitmap);
189 } 189 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698