1 // Copyright 2019 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef COMPONENTS_FAVICON_CORE_HISTORY_UI_FAVICON_REQUEST_HANDLER_H_ 6 #define COMPONENTS_FAVICON_CORE_HISTORY_UI_FAVICON_REQUEST_HANDLER_H_ 7 8 #include "components/favicon_base/favicon_callback.h" 9 #include "components/keyed_service/core/keyed_service.h" 10 #include "url/gurl.h" 11 12 namespace favicon { 13 14 // The UI origin of an icon request. Used to do metrics recording per UI. 15 enum class HistoryUiFaviconRequestOrigin { 16 // History page. 17 kHistory, 18 // History synced tabs page (desktop only). 19 kHistorySyncedTabs, 20 // Recent tabs user interface. 21 kRecentTabs, 22 }; 23 24 // Keyed service for handling favicon requests made by a history UI, forwarding 25 // them to local storage or Google server accordingly. This service should 26 // only be used by the UIs listed in the HistoryUiFaviconRequestOrigin enum. 27 // Requests must be made by page url, as opposed to icon url. 28 class HistoryUiFaviconRequestHandler : public KeyedService { 29 public: 30 // Requests favicon bitmap at |page_url| of size |desired_size_in_pixel|. 31 // Tries to fetch the icon from local storage and falls back to the Google 32 // favicon server if user settings allow to query it using history data. 33 virtual void GetRawFaviconForPageURL( 34 const GURL& page_url, 35 int desired_size_in_pixel, 36 favicon_base::FaviconRawBitmapCallback callback, 37 HistoryUiFaviconRequestOrigin request_origin_for_uma) = 0; 38 39 // Requests favicon image at |page_url|. The same fallback considerations for 40 // GetRawFaviconForPageURL apply. 41 // This method is only called by desktop code. 42 virtual void GetFaviconImageForPageURL( 43 const GURL& page_url, 44 favicon_base::FaviconImageCallback callback, 45 HistoryUiFaviconRequestOrigin request_origin_for_uma) = 0; 46 }; 47 48 } // namespace favicon 49 50 #endif // COMPONENTS_FAVICON_CORE_HISTORY_UI_FAVICON_REQUEST_HANDLER_H_ 51