| 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_FAVICON_FAVICON_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_FAVICON_FAVICON_SERVICE_H_ |
| 6 #define CHROME_BROWSER_FAVICON_FAVICON_SERVICE_H_ | 6 #define CHROME_BROWSER_FAVICON_FAVICON_SERVICE_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "chrome/browser/cancelable_request.h" | 12 #include "chrome/browser/cancelable_request.h" |
| 13 #include "chrome/browser/history/history_types.h" | 13 #include "chrome/browser/history/history_types.h" |
| 14 #include "chrome/browser/profiles/profile_keyed_service.h" |
| 14 #include "chrome/common/ref_counted_util.h" | 15 #include "chrome/common/ref_counted_util.h" |
| 15 | 16 |
| 16 class GURL; | 17 class GURL; |
| 18 class HistoryService; |
| 17 class Profile; | 19 class Profile; |
| 18 | 20 |
| 19 // The favicon service provides methods to access favicons. It calls the history | 21 // The favicon service provides methods to access favicons. It calls the history |
| 20 // backend behind the scenes. | 22 // backend behind the scenes. |
| 21 // | 23 // |
| 22 // This service is thread safe. Each request callback is invoked in the | 24 // This service is thread safe. Each request callback is invoked in the |
| 23 // thread that made the request. | 25 // thread that made the request. |
| 24 class FaviconService : public CancelableRequestProvider { | 26 class FaviconService : public CancelableRequestProvider, |
| 27 public ProfileKeyedService { |
| 25 public: | 28 public: |
| 26 explicit FaviconService(Profile* profile); | 29 // FIXME: We should not take a Profile pointer here. |
| 30 // We do this now because we need to pass a Profile pointer to |
| 31 // ChromeWebUIControllerFactory::GetFaviconForURL() until that |
| 32 // component gets untangled too. |
| 33 FaviconService(scoped_refptr<HistoryService>, Profile*); |
| 27 | 34 |
| 28 virtual ~FaviconService(); | 35 virtual ~FaviconService(); |
| 29 | 36 |
| 30 // Callback for GetFavicon. If we have previously inquired about the favicon | 37 // Callback for GetFavicon. If we have previously inquired about the favicon |
| 31 // for this URL, |know_favicon| will be true, and the rest of the fields will | 38 // for this URL, |know_favicon| will be true, and the rest of the fields will |
| 32 // be valid (otherwise they will be ignored). | 39 // be valid (otherwise they will be ignored). |
| 33 // | 40 // |
| 34 // On |know_favicon| == true, |data| will either contain the PNG encoded | 41 // On |know_favicon| == true, |data| will either contain the PNG encoded |
| 35 // favicon data, or it will be NULL to indicate that the site does not have | 42 // favicon data, or it will be NULL to indicate that the site does not have |
| 36 // a favicon (in other words, we know the site doesn't have a favicon, as | 43 // a favicon (in other words, we know the site doesn't have a favicon, as |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 // must exist, any favicon sets for unknown pages will be discarded. Existing | 103 // must exist, any favicon sets for unknown pages will be discarded. Existing |
| 97 // favicons will not be overwritten. | 104 // favicons will not be overwritten. |
| 98 void SetImportedFavicons( | 105 void SetImportedFavicons( |
| 99 const std::vector<history::ImportedFaviconUsage>& favicon_usage); | 106 const std::vector<history::ImportedFaviconUsage>& favicon_usage); |
| 100 | 107 |
| 101 // Sets the favicon for a page. | 108 // Sets the favicon for a page. |
| 102 void SetFavicon(const GURL& page_url, | 109 void SetFavicon(const GURL& page_url, |
| 103 const GURL& icon_url, | 110 const GURL& icon_url, |
| 104 const std::vector<unsigned char>& image_data, | 111 const std::vector<unsigned char>& image_data, |
| 105 history::IconType icon_type); | 112 history::IconType icon_type); |
| 106 | |
| 107 private: | 113 private: |
| 114 scoped_refptr<HistoryService> history_service_; |
| 115 // FIXME: remove this member variable. See comment in the constructor. |
| 108 Profile* profile_; | 116 Profile* profile_; |
| 109 | |
| 110 // Helper to forward an empty result if we cannot get the history service. | 117 // Helper to forward an empty result if we cannot get the history service. |
| 111 void ForwardEmptyResultAsync(GetFaviconRequest* request); | 118 void ForwardEmptyResultAsync(GetFaviconRequest* request); |
| 112 | 119 |
| 113 DISALLOW_COPY_AND_ASSIGN(FaviconService); | 120 DISALLOW_COPY_AND_ASSIGN(FaviconService); |
| 114 }; | 121 }; |
| 115 | 122 |
| 116 #endif // CHROME_BROWSER_FAVICON_FAVICON_SERVICE_H_ | 123 #endif // CHROME_BROWSER_FAVICON_FAVICON_SERVICE_H_ |
| OLD | NEW |