| 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 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 void SetActiveFaviconURL(const GURL& favicon_url) override { | 240 void SetActiveFaviconURL(const GURL& favicon_url) override { |
| 241 favicon_url_ = favicon_url; | 241 favicon_url_ = favicon_url; |
| 242 } | 242 } |
| 243 | 243 |
| 244 gfx::Image GetActiveFaviconImage() { return image_; } | 244 gfx::Image GetActiveFaviconImage() { return image_; } |
| 245 | 245 |
| 246 void SetActiveFaviconImage(const gfx::Image& image) override { | 246 void SetActiveFaviconImage(const gfx::Image& image) override { |
| 247 image_ = image; | 247 image_ = image; |
| 248 } | 248 } |
| 249 | 249 |
| 250 bool ShouldSendFaviconAvailableNotifications() override { return true; } |
| 251 |
| 250 void OnFaviconAvailable(const gfx::Image& image, | 252 void OnFaviconAvailable(const gfx::Image& image, |
| 251 const GURL& icon_url, | 253 const GURL& icon_url, |
| 252 bool update_active_favicon) override { | 254 bool update_active_favicon) override { |
| 253 ++num_favicon_available_; | 255 ++num_favicon_available_; |
| 254 available_image_ = image; | 256 available_image_ = image; |
| 255 available_icon_url_ = icon_url; | 257 available_icon_url_ = icon_url; |
| 256 update_active_favicon_ = update_active_favicon; | 258 update_active_favicon_ = update_active_favicon; |
| 257 if (!update_active_favicon) | 259 if (!update_active_favicon) |
| 258 return; | 260 return; |
| 259 | 261 |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 const GURL& icon_url, | 393 const GURL& icon_url, |
| 392 favicon_base::IconType icon_type, | 394 favicon_base::IconType icon_type, |
| 393 const gfx::Image& image) override { | 395 const gfx::Image& image) override { |
| 394 scoped_refptr<base::RefCountedMemory> bytes = image.As1xPNGBytes(); | 396 scoped_refptr<base::RefCountedMemory> bytes = image.As1xPNGBytes(); |
| 395 std::vector<unsigned char> bitmap_data(bytes->front(), | 397 std::vector<unsigned char> bitmap_data(bytes->front(), |
| 396 bytes->front() + bytes->size()); | 398 bytes->front() + bytes->size()); |
| 397 history_handler_.reset(new HistoryRequestHandler( | 399 history_handler_.reset(new HistoryRequestHandler( |
| 398 page_url, icon_url, icon_type, bitmap_data, image.Size())); | 400 page_url, icon_url, icon_type, bitmap_data, image.Size())); |
| 399 } | 401 } |
| 400 | 402 |
| 401 bool ShouldSaveFavicon(const GURL& url) override { return true; } | 403 bool ShouldSaveFavicon() override { return true; } |
| 402 | 404 |
| 403 GURL page_url_; | 405 GURL page_url_; |
| 404 | 406 |
| 405 private: | 407 private: |
| 406 | 408 |
| 407 // The unique id of a download request. It will be returned to a | 409 // The unique id of a download request. It will be returned to a |
| 408 // FaviconHandler. | 410 // FaviconHandler. |
| 409 int download_id_; | 411 int download_id_; |
| 410 | 412 |
| 411 scoped_ptr<DownloadHandler> download_handler_; | 413 scoped_ptr<DownloadHandler> download_handler_; |
| (...skipping 1286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1698 EXPECT_FALSE(driver1.update_active_favicon()); | 1700 EXPECT_FALSE(driver1.update_active_favicon()); |
| 1699 EXPECT_EQ(3u, driver1.num_favicon_available()); | 1701 EXPECT_EQ(3u, driver1.num_favicon_available()); |
| 1700 } | 1702 } |
| 1701 | 1703 |
| 1702 INSTANTIATE_TEST_CASE_P(FaviconHandlerTestActiveFaviconValidityTrueOrFalse, | 1704 INSTANTIATE_TEST_CASE_P(FaviconHandlerTestActiveFaviconValidityTrueOrFalse, |
| 1703 FaviconHandlerActiveFaviconValidityParamTest, | 1705 FaviconHandlerActiveFaviconValidityParamTest, |
| 1704 ::testing::Bool()); | 1706 ::testing::Bool()); |
| 1705 | 1707 |
| 1706 } // namespace | 1708 } // namespace |
| 1707 } // namespace favicon | 1709 } // namespace favicon |
| OLD | NEW |