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 11 class GURL; 12 13 namespace favicon { 14 15 // The UI origin of an icon request. Used to do metrics recording per UI. 16 enum class HistoryUiFaviconRequestOrigin { 17 // History page. 18 kHistory, 19 // History synced tabs page (desktop only). 20 kHistorySyncedTabs, 21 // Recent tabs user interface. 22 kRecentTabs, 23 }; 24 25 // Keyed service for handling favicon requests made by a history UI, forwarding 26 // them to local storage or Google server accordingly. This service should 27 // only be used by the UIs listed in the HistoryUiFaviconRequestOrigin enum. 28 // Requests must be made by page url, as opposed to icon url. 29 class HistoryUiFaviconRequestHandler : public KeyedService { 30 public: 31 // Requests favicon bitmap at |page_url| of size |desired_size_in_pixel|. 32 // Tries to fetch the icon from local storage and falls back to the Google 33 // favicon server if user settings allow to query it using history data. 34 // If a non-empty |icon_url_for_uma| (optional) is passed, it will be used to 35 // record UMA about the grouping of requests to the favicon server. 36 virtual void GetRawFaviconForPageURL( 37 const GURL& page_url, 38 int desired_size_in_pixel, 39 favicon_base::FaviconRawBitmapCallback callback, 40 HistoryUiFaviconRequestOrigin request_origin_for_uma, 41 const GURL& icon_url_for_uma) = 0; 42 43 // Requests favicon image at |page_url|. The same fallback considerations for 44 // GetRawFaviconForPageURL apply. 45 // This method is only called by desktop code. 46 virtual void GetFaviconImageForPageURL( 47 const GURL& page_url, 48 favicon_base::FaviconImageCallback callback, 49 HistoryUiFaviconRequestOrigin request_origin_for_uma, 50 const GURL& icon_url_for_uma) = 0; 51 }; 52 53 } // namespace favicon 54 55 #endif // COMPONENTS_FAVICON_CORE_HISTORY_UI_FAVICON_REQUEST_HANDLER_H_ 56