| 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 #ifndef CHROME_BROWSER_UI_WEBUI_FAVICON_SOURCE_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_FAVICON_SOURCE_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_FAVICON_SOURCE_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_FAVICON_SOURCE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 virtual std::string GetMimeType(const std::string&) const OVERRIDE; | 44 virtual std::string GetMimeType(const std::string&) const OVERRIDE; |
| 45 | 45 |
| 46 virtual bool ShouldReplaceExistingSource() const OVERRIDE; | 46 virtual bool ShouldReplaceExistingSource() const OVERRIDE; |
| 47 | 47 |
| 48 protected: | 48 protected: |
| 49 virtual ~FaviconSource(); | 49 virtual ~FaviconSource(); |
| 50 | 50 |
| 51 Profile* profile_; | 51 Profile* profile_; |
| 52 | 52 |
| 53 private: | 53 private: |
| 54 |
| 55 struct IconRequest { |
| 56 IconRequest() |
| 57 : request_id(0), |
| 58 pixel_size(16), |
| 59 scale_factor(ui::SCALE_FACTOR_NONE) { |
| 60 } |
| 61 IconRequest(int id, int size, ui::ScaleFactor scale) |
| 62 : request_id(id), |
| 63 pixel_size(size), |
| 64 scale_factor(scale) { |
| 65 } |
| 66 int request_id; |
| 67 int pixel_size; |
| 68 ui::ScaleFactor scale_factor; |
| 69 }; |
| 70 |
| 54 void Init(Profile* profile, IconType type); | 71 void Init(Profile* profile, IconType type); |
| 55 | 72 |
| 56 // Called when favicon data is available from the history backend. | 73 // Called when favicon data is available from the history backend. |
| 57 void OnFaviconDataAvailable( | 74 void OnFaviconDataAvailable( |
| 58 FaviconService::Handle request_handle, | 75 FaviconService::Handle request_handle, |
| 59 const history::FaviconBitmapResult& bitmap_result); | 76 const history::FaviconBitmapResult& bitmap_result); |
| 60 | 77 |
| 61 // Sends the default favicon. | 78 // Sends the default favicon. |
| 62 void SendDefaultResponse(int request_id); | 79 void SendDefaultResponse(const IconRequest& request); |
| 63 | 80 |
| 64 CancelableRequestConsumerT<int, 0> cancelable_consumer_; | 81 CancelableRequestConsumerTSimple<IconRequest> cancelable_consumer_; |
| 65 | |
| 66 // Map from request ID to size requested (in pixels). TODO(estade): Get rid of | |
| 67 // this map when we properly support multiple favicon sizes. | |
| 68 std::map<int, int> request_size_map_; | |
| 69 | 82 |
| 70 // Raw PNG representation of the favicon to show when the favicon | 83 // Raw PNG representation of the favicon to show when the favicon |
| 71 // database doesn't have a favicon for a webpage. | 84 // database doesn't have a favicon for a webpage. |
| 72 // 16x16 | 85 // 16x16 |
| 73 scoped_refptr<base::RefCountedMemory> default_favicon_; | 86 scoped_refptr<base::RefCountedMemory> default_favicon_; |
| 74 // 32x32 | 87 // 32x32 |
| 75 scoped_refptr<base::RefCountedMemory> default_favicon_large_; | 88 scoped_refptr<base::RefCountedMemory> default_favicon_large_; |
| 76 | 89 |
| 77 // The history::IconTypes of icon that this FaviconSource handles. | 90 // The history::IconTypes of icon that this FaviconSource handles. |
| 78 int icon_types_; | 91 int icon_types_; |
| 79 | 92 |
| 80 DISALLOW_COPY_AND_ASSIGN(FaviconSource); | 93 DISALLOW_COPY_AND_ASSIGN(FaviconSource); |
| 81 }; | 94 }; |
| 82 | 95 |
| 83 #endif // CHROME_BROWSER_UI_WEBUI_FAVICON_SOURCE_H_ | 96 #endif // CHROME_BROWSER_UI_WEBUI_FAVICON_SOURCE_H_ |
| OLD | NEW |