| OLD | NEW | 
|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 IOS_CHROME_BROWSER_UI_WEBUI_HISTORY_FAVICON_SOURCE_H_ | 5 #ifndef IOS_CHROME_BROWSER_UI_WEBUI_HISTORY_FAVICON_SOURCE_H_ | 
| 6 #define IOS_CHROME_BROWSER_UI_WEBUI_HISTORY_FAVICON_SOURCE_H_ | 6 #define IOS_CHROME_BROWSER_UI_WEBUI_HISTORY_FAVICON_SOURCE_H_ | 
| 7 | 7 | 
| 8 #include <map> | 8 #include <map> | 
| 9 #include <string> | 9 #include <string> | 
| 10 | 10 | 
| 11 #include "base/macros.h" | 11 #include "base/macros.h" | 
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" | 
| 13 #include "base/task/cancelable_task_tracker.h" | 13 #include "base/task/cancelable_task_tracker.h" | 
| 14 #include "components/favicon/core/favicon_service.h" | 14 #include "components/favicon/core/favicon_service.h" | 
| 15 #include "ios/web/public/url_data_source_ios.h" | 15 #include "ios/web/public/url_data_source_ios.h" | 
| 16 #include "ui/gfx/favicon_size.h" | 16 #include "ui/gfx/favicon_size.h" | 
| 17 | 17 | 
| 18 namespace favicon { | 18 namespace favicon { | 
| 19 class FaviconService; | 19 class FaviconService; | 
| 20 } | 20 } | 
| 21 | 21 | 
| 22 namespace history { | 22 namespace history { | 
| 23 class TopSites; | 23 class TopSites; | 
| 24 } | 24 } | 
| 25 | 25 | 
| 26 namespace sync_driver { | 26 namespace syncer { | 
| 27 class SyncService; | 27 class SyncService; | 
| 28 } | 28 } | 
| 29 | 29 | 
| 30 // FaviconSource is the gateway between network-level chrome: | 30 // FaviconSource is the gateway between network-level chrome: | 
| 31 // requests for favicons and the history backend that serves these. | 31 // requests for favicons and the history backend that serves these. | 
| 32 // | 32 // | 
| 33 // Format: | 33 // Format: | 
| 34 //   chrome://favicon/size&scalefactor/urlmodifier/url | 34 //   chrome://favicon/size&scalefactor/urlmodifier/url | 
| 35 // Some parameters are optional as described below. However, the order of the | 35 // Some parameters are optional as described below. However, the order of the | 
| 36 // parameters is not interchangeable. | 36 // parameters is not interchangeable. | 
| (...skipping 26 matching lines...) Expand all  Loading... | 
| 63 //    Examples: | 63 //    Examples: | 
| 64 //      chrome://favicon/origin/http://example.com/a | 64 //      chrome://favicon/origin/http://example.com/a | 
| 65 //      chrome://favicon/origin/example.com | 65 //      chrome://favicon/origin/example.com | 
| 66 //        Both URLs request the favicon for http://example.com from the | 66 //        Both URLs request the favicon for http://example.com from the | 
| 67 //        favicon service. | 67 //        favicon service. | 
| 68 class FaviconSource : public web::URLDataSourceIOS { | 68 class FaviconSource : public web::URLDataSourceIOS { | 
| 69  public: | 69  public: | 
| 70   // |favicon_service|, |top_sites| and |sync_service| can be null. | 70   // |favicon_service|, |top_sites| and |sync_service| can be null. | 
| 71   FaviconSource(favicon::FaviconService* favicon_service, | 71   FaviconSource(favicon::FaviconService* favicon_service, | 
| 72                 const scoped_refptr<history::TopSites>& top_sites, | 72                 const scoped_refptr<history::TopSites>& top_sites, | 
| 73                 sync_driver::SyncService* sync_service); | 73                 syncer::SyncService* sync_service); | 
| 74 | 74 | 
| 75   ~FaviconSource() override; | 75   ~FaviconSource() override; | 
| 76 | 76 | 
| 77   // web::URLDataSourceIOS implementation. | 77   // web::URLDataSourceIOS implementation. | 
| 78   std::string GetSource() const override; | 78   std::string GetSource() const override; | 
| 79   void StartDataRequest( | 79   void StartDataRequest( | 
| 80       const std::string& path, | 80       const std::string& path, | 
| 81       const web::URLDataSourceIOS::GotDataCallback& callback) override; | 81       const web::URLDataSourceIOS::GotDataCallback& callback) override; | 
| 82   std::string GetMimeType(const std::string&) const override; | 82   std::string GetMimeType(const std::string&) const override; | 
| 83   bool ShouldReplaceExistingSource() const override; | 83   bool ShouldReplaceExistingSource() const override; | 
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 115 | 115 | 
| 116   // Sends the 16x16 DIP 1x default favicon. | 116   // Sends the 16x16 DIP 1x default favicon. | 
| 117   void SendDefaultResponse( | 117   void SendDefaultResponse( | 
| 118       const web::URLDataSourceIOS::GotDataCallback& callback); | 118       const web::URLDataSourceIOS::GotDataCallback& callback); | 
| 119 | 119 | 
| 120   // Sends the default favicon. | 120   // Sends the default favicon. | 
| 121   void SendDefaultResponse(const IconRequest& request); | 121   void SendDefaultResponse(const IconRequest& request); | 
| 122 | 122 | 
| 123   favicon::FaviconService* favicon_service_; | 123   favicon::FaviconService* favicon_service_; | 
| 124   scoped_refptr<history::TopSites> top_sites_; | 124   scoped_refptr<history::TopSites> top_sites_; | 
| 125   sync_driver::SyncService* sync_service_; | 125   syncer::SyncService* sync_service_; | 
| 126 | 126 | 
| 127   base::CancelableTaskTracker cancelable_task_tracker_; | 127   base::CancelableTaskTracker cancelable_task_tracker_; | 
| 128 | 128 | 
| 129   // Raw PNG representations of favicons of each size to show when the favicon | 129   // Raw PNG representations of favicons of each size to show when the favicon | 
| 130   // database doesn't have a favicon for a webpage. Indexed by IconSize values. | 130   // database doesn't have a favicon for a webpage. Indexed by IconSize values. | 
| 131   scoped_refptr<base::RefCountedMemory> default_favicons_[NUM_SIZES]; | 131   scoped_refptr<base::RefCountedMemory> default_favicons_[NUM_SIZES]; | 
| 132 | 132 | 
| 133   DISALLOW_COPY_AND_ASSIGN(FaviconSource); | 133   DISALLOW_COPY_AND_ASSIGN(FaviconSource); | 
| 134 }; | 134 }; | 
| 135 | 135 | 
| 136 #endif  // IOS_CHROME_BROWSER_UI_WEBUI_HISTORY_FAVICON_SOURCE_H_ | 136 #endif  // IOS_CHROME_BROWSER_UI_WEBUI_HISTORY_FAVICON_SOURCE_H_ | 
| OLD | NEW | 
|---|