| 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 "ash/shelf/shelf_constants.h" | 7 #include "ash/shelf/shelf_constants.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "content/public/browser/render_view_host.h" | 10 #include "content/public/browser/render_view_host.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 } | 34 } |
| 35 | 35 |
| 36 virtual ~FaviconBitmapHandler() {} | 36 virtual ~FaviconBitmapHandler() {} |
| 37 | 37 |
| 38 const SkBitmap& bitmap() const { return bitmap_; } | 38 const SkBitmap& bitmap() const { return bitmap_; } |
| 39 | 39 |
| 40 bool HasPendingDownloads() const; | 40 bool HasPendingDownloads() const; |
| 41 | 41 |
| 42 // content::WebContentObserver implementation. | 42 // content::WebContentObserver implementation. |
| 43 virtual void DidUpdateFaviconURL( | 43 virtual void DidUpdateFaviconURL( |
| 44 int32 page_id, | |
| 45 const std::vector<content::FaviconURL>& candidates) OVERRIDE; | 44 const std::vector<content::FaviconURL>& candidates) OVERRIDE; |
| 46 | 45 |
| 47 private: | 46 private: |
| 48 void DidDownloadFavicon( | 47 void DidDownloadFavicon( |
| 49 int id, | 48 int id, |
| 50 int http_status_code, | 49 int http_status_code, |
| 51 const GURL& image_url, | 50 const GURL& image_url, |
| 52 const std::vector<SkBitmap>& bitmaps, | 51 const std::vector<SkBitmap>& bitmaps, |
| 53 const std::vector<gfx::Size>& original_bitmap_sizes); | 52 const std::vector<gfx::Size>& original_bitmap_sizes); |
| 54 | 53 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 66 // Current bitmap and source url. | 65 // Current bitmap and source url. |
| 67 SkBitmap bitmap_; | 66 SkBitmap bitmap_; |
| 68 GURL bitmap_url_; | 67 GURL bitmap_url_; |
| 69 | 68 |
| 70 base::WeakPtrFactory<FaviconBitmapHandler> weak_ptr_factory_; | 69 base::WeakPtrFactory<FaviconBitmapHandler> weak_ptr_factory_; |
| 71 | 70 |
| 72 DISALLOW_COPY_AND_ASSIGN(FaviconBitmapHandler); | 71 DISALLOW_COPY_AND_ASSIGN(FaviconBitmapHandler); |
| 73 }; | 72 }; |
| 74 | 73 |
| 75 void FaviconBitmapHandler::DidUpdateFaviconURL( | 74 void FaviconBitmapHandler::DidUpdateFaviconURL( |
| 76 int32 page_id, | |
| 77 const std::vector<content::FaviconURL>& candidates) { | 75 const std::vector<content::FaviconURL>& candidates) { |
| 78 // This function receives a complete list of faviocn urls for the page. | 76 // This function receives a complete list of faviocn urls for the page. |
| 79 // It may get called multiple times with the same list, and will also get | 77 // It may get called multiple times with the same list, and will also get |
| 80 // called any time an item is added or removed. As such, we track processed | 78 // called any time an item is added or removed. As such, we track processed |
| 81 // and pending urls, but only until they are removed from the list. | 79 // and pending urls, but only until they are removed from the list. |
| 82 UrlSet new_pending, new_processed; | 80 UrlSet new_pending, new_processed; |
| 83 // Create a map of valid favicon urls. | 81 // Create a map of valid favicon urls. |
| 84 std::set<GURL> urls; | 82 std::set<GURL> urls; |
| 85 std::vector<content::FaviconURL>::const_iterator iter; | 83 std::vector<content::FaviconURL>::const_iterator iter; |
| 86 for (iter = candidates.begin(); iter != candidates.end(); ++iter) { | 84 for (iter = candidates.begin(); iter != candidates.end(); ++iter) { |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 LauncherFaviconLoader::~LauncherFaviconLoader() { | 171 LauncherFaviconLoader::~LauncherFaviconLoader() { |
| 174 } | 172 } |
| 175 | 173 |
| 176 SkBitmap LauncherFaviconLoader::GetFavicon() const { | 174 SkBitmap LauncherFaviconLoader::GetFavicon() const { |
| 177 return favicon_handler_->bitmap(); | 175 return favicon_handler_->bitmap(); |
| 178 } | 176 } |
| 179 | 177 |
| 180 bool LauncherFaviconLoader::HasPendingDownloads() const { | 178 bool LauncherFaviconLoader::HasPendingDownloads() const { |
| 181 return favicon_handler_->HasPendingDownloads(); | 179 return favicon_handler_->HasPendingDownloads(); |
| 182 } | 180 } |
| OLD | NEW |