| 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 "components/favicon/core/favicon_handler.h" | 5 #include "components/favicon/core/favicon_handler.h" |
| 6 | 6 |
| 7 #include<set> | 7 #include<set> |
| 8 #include<vector> | 8 #include<vector> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 void SetActiveFaviconURL(const GURL& favicon_url) override { | 245 void SetActiveFaviconURL(const GURL& favicon_url) override { |
| 246 favicon_url_ = favicon_url; | 246 favicon_url_ = favicon_url; |
| 247 } | 247 } |
| 248 | 248 |
| 249 gfx::Image GetActiveFaviconImage() { return image_; } | 249 gfx::Image GetActiveFaviconImage() { return image_; } |
| 250 | 250 |
| 251 void SetActiveFaviconImage(const gfx::Image& image) override { | 251 void SetActiveFaviconImage(const gfx::Image& image) override { |
| 252 image_ = image; | 252 image_ = image; |
| 253 } | 253 } |
| 254 | 254 |
| 255 bool ShouldSendFaviconAvailableNotifications() override { return true; } |
| 256 |
| 255 void OnFaviconAvailable(const gfx::Image& image, | 257 void OnFaviconAvailable(const gfx::Image& image, |
| 256 const GURL& icon_url, | 258 const GURL& icon_url, |
| 257 bool update_active_favicon) override { | 259 bool update_active_favicon) override { |
| 258 ++num_favicon_available_; | 260 ++num_favicon_available_; |
| 259 available_image_ = image; | 261 available_image_ = image; |
| 260 available_icon_url_ = icon_url; | 262 available_icon_url_ = icon_url; |
| 261 update_active_favicon_ = update_active_favicon; | 263 update_active_favicon_ = update_active_favicon; |
| 262 if (!update_active_favicon) | 264 if (!update_active_favicon) |
| 263 return; | 265 return; |
| 264 | 266 |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 const GURL& icon_url, | 398 const GURL& icon_url, |
| 397 favicon_base::IconType icon_type, | 399 favicon_base::IconType icon_type, |
| 398 const gfx::Image& image) override { | 400 const gfx::Image& image) override { |
| 399 scoped_refptr<base::RefCountedMemory> bytes = image.As1xPNGBytes(); | 401 scoped_refptr<base::RefCountedMemory> bytes = image.As1xPNGBytes(); |
| 400 std::vector<unsigned char> bitmap_data(bytes->front(), | 402 std::vector<unsigned char> bitmap_data(bytes->front(), |
| 401 bytes->front() + bytes->size()); | 403 bytes->front() + bytes->size()); |
| 402 history_handler_.reset(new HistoryRequestHandler( | 404 history_handler_.reset(new HistoryRequestHandler( |
| 403 page_url, icon_url, icon_type, bitmap_data, image.Size())); | 405 page_url, icon_url, icon_type, bitmap_data, image.Size())); |
| 404 } | 406 } |
| 405 | 407 |
| 406 bool ShouldSaveFavicon(const GURL& url) override { return true; } | 408 bool ShouldSaveFavicon() override { return true; } |
| 407 | 409 |
| 408 GURL page_url_; | 410 GURL page_url_; |
| 409 | 411 |
| 410 private: | 412 private: |
| 411 | 413 |
| 412 // The unique id of a download request. It will be returned to a | 414 // The unique id of a download request. It will be returned to a |
| 413 // FaviconHandler. | 415 // FaviconHandler. |
| 414 int download_id_; | 416 int download_id_; |
| 415 | 417 |
| 416 scoped_ptr<DownloadHandler> download_handler_; | 418 scoped_ptr<DownloadHandler> download_handler_; |
| (...skipping 1286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1703 EXPECT_FALSE(driver1.update_active_favicon()); | 1705 EXPECT_FALSE(driver1.update_active_favicon()); |
| 1704 EXPECT_EQ(3u, driver1.num_favicon_available()); | 1706 EXPECT_EQ(3u, driver1.num_favicon_available()); |
| 1705 } | 1707 } |
| 1706 | 1708 |
| 1707 INSTANTIATE_TEST_CASE_P(FaviconHandlerTestActiveFaviconValidityTrueOrFalse, | 1709 INSTANTIATE_TEST_CASE_P(FaviconHandlerTestActiveFaviconValidityTrueOrFalse, |
| 1708 FaviconHandlerActiveFaviconValidityParamTest, | 1710 FaviconHandlerActiveFaviconValidityParamTest, |
| 1709 ::testing::Bool()); | 1711 ::testing::Bool()); |
| 1710 | 1712 |
| 1711 } // namespace | 1713 } // namespace |
| 1712 } // namespace favicon | 1714 } // namespace favicon |
| OLD | NEW |