OLD | NEW |
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 "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
9 #include "chrome/browser/ui/ash/launcher/browser_launcher_item_controller.h" | 9 #include "chrome/browser/ui/ash/launcher/browser_launcher_item_controller.h" |
10 #include "content/public/browser/render_view_host.h" | 10 #include "content/public/browser/render_view_host.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 | 41 |
42 // content::WebContentObserver implementation. | 42 // content::WebContentObserver implementation. |
43 virtual void DidUpdateFaviconURL( | 43 virtual void DidUpdateFaviconURL( |
44 int32 page_id, | 44 int32 page_id, |
45 const std::vector<content::FaviconURL>& candidates) OVERRIDE; | 45 const std::vector<content::FaviconURL>& candidates) OVERRIDE; |
46 | 46 |
47 private: | 47 private: |
48 void DidDownloadFavicon( | 48 void DidDownloadFavicon( |
49 int id, | 49 int id, |
50 const GURL& image_url, | 50 const GURL& image_url, |
51 bool errored, | |
52 int requested_size, | 51 int requested_size, |
53 const std::vector<SkBitmap>& bitmaps); | 52 const std::vector<SkBitmap>& bitmaps); |
54 | 53 |
55 void AddFavicon(const GURL& image_url, const SkBitmap& new_bitmap); | 54 void AddFavicon(const GURL& image_url, const SkBitmap& new_bitmap); |
56 | 55 |
57 LauncherFaviconLoader::Delegate* delegate_; | 56 LauncherFaviconLoader::Delegate* delegate_; |
58 | 57 |
59 content::WebContents* web_contents_; | 58 content::WebContents* web_contents_; |
60 | 59 |
61 typedef std::set<GURL> UrlSet; | 60 typedef std::set<GURL> UrlSet; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 } | 115 } |
117 } | 116 } |
118 | 117 |
119 bool FaviconBitmapHandler::HasPendingDownloads() const { | 118 bool FaviconBitmapHandler::HasPendingDownloads() const { |
120 return !pending_requests_.empty(); | 119 return !pending_requests_.empty(); |
121 } | 120 } |
122 | 121 |
123 void FaviconBitmapHandler::DidDownloadFavicon( | 122 void FaviconBitmapHandler::DidDownloadFavicon( |
124 int id, | 123 int id, |
125 const GURL& image_url, | 124 const GURL& image_url, |
126 bool errored, | |
127 int requested_size, | 125 int requested_size, |
128 const std::vector<SkBitmap>& bitmaps) { | 126 const std::vector<SkBitmap>& bitmaps) { |
129 UrlSet::iterator iter = pending_requests_.find(image_url); | 127 UrlSet::iterator iter = pending_requests_.find(image_url); |
130 if (iter == pending_requests_.end()) { | 128 if (iter == pending_requests_.end()) { |
131 // Updates are received for all downloads; ignore unrequested urls. | 129 // Updates are received for all downloads; ignore unrequested urls. |
132 return; | 130 return; |
133 } | 131 } |
134 pending_requests_.erase(iter); | 132 pending_requests_.erase(iter); |
135 | 133 |
136 // Favicon bitmaps are ordered by decreasing width. | 134 // Favicon bitmaps are ordered by decreasing width. |
137 if (!errored && !bitmaps.empty()) | 135 if (!bitmaps.empty()) |
138 AddFavicon(image_url, bitmaps[0]); | 136 AddFavicon(image_url, bitmaps[0]); |
139 } | 137 } |
140 | 138 |
141 void FaviconBitmapHandler::AddFavicon(const GURL& image_url, | 139 void FaviconBitmapHandler::AddFavicon(const GURL& image_url, |
142 const SkBitmap& new_bitmap) { | 140 const SkBitmap& new_bitmap) { |
143 processed_requests_.insert(image_url); | 141 processed_requests_.insert(image_url); |
144 if (new_bitmap.height() > kMaxBitmapSize || | 142 if (new_bitmap.height() > kMaxBitmapSize || |
145 new_bitmap.width() > kMaxBitmapSize) | 143 new_bitmap.width() > kMaxBitmapSize) |
146 return; | 144 return; |
147 if (new_bitmap.height() < ash::kLauncherPreferredSize) | 145 if (new_bitmap.height() < ash::kLauncherPreferredSize) |
(...skipping 22 matching lines...) Expand all Loading... |
170 LauncherFaviconLoader::~LauncherFaviconLoader() { | 168 LauncherFaviconLoader::~LauncherFaviconLoader() { |
171 } | 169 } |
172 | 170 |
173 SkBitmap LauncherFaviconLoader::GetFavicon() const { | 171 SkBitmap LauncherFaviconLoader::GetFavicon() const { |
174 return favicon_handler_->bitmap(); | 172 return favicon_handler_->bitmap(); |
175 } | 173 } |
176 | 174 |
177 bool LauncherFaviconLoader::HasPendingDownloads() const { | 175 bool LauncherFaviconLoader::HasPendingDownloads() const { |
178 return favicon_handler_->HasPendingDownloads(); | 176 return favicon_handler_->HasPendingDownloads(); |
179 } | 177 } |
OLD | NEW |