1 // Copyright 2015 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.
5 #ifndef CHROME_BROWSER_UI_WEBUI_LARGE_ICON_SOURCE_H_
6 #define CHROME_BROWSER_UI_WEBUI_LARGE_ICON_SOURCE_H_
10 #include "base/memory/scoped_ptr.h"
11 #include "base/task/cancelable_task_tracker.h"
12 #include "components/favicon/core/fallback_icon_service.h"
13 #include "content/public/browser/url_data_source.h"
16 class FallbackIconService
;
17 class LargeIconService
;
20 namespace favicon_base
{
21 struct LargeIconResult
;
24 // LargeIconSource services explicit chrome:// requests for large icons.
27 // chrome://large-icon/size/url
30 // 'size' Required (including trailing '/')
31 // Positive integer to specify the large icon's size in pixels.
33 // String to specify the page URL of the large icon.
35 // Example: chrome://large-icon/48/http://www.google.com/
36 // This requests a 48x48 large icon for http://www.google.com.
37 class LargeIconSource
: public content::URLDataSource
{
39 // |fallback_icon_service| and |large_icon_service| are owned by caller and
41 LargeIconSource(favicon::FallbackIconService
* fallback_icon_service
,
42 favicon::LargeIconService
* large_icon_service
);
44 ~LargeIconSource() override
;
46 // content::URLDataSource implementation.
47 std::string
GetSource() const override
;
48 void StartDataRequest(
49 const std::string
& path
,
50 int render_process_id
,
52 const content::URLDataSource::GotDataCallback
& callback
) override
;
53 std::string
GetMimeType(const std::string
&) const override
;
54 bool ShouldReplaceExistingSource() const override
;
55 bool ShouldServiceRequest(const net::URLRequest
* request
) const override
;
58 // Called with results of large icon retrieval request.
59 void OnLargeIconDataAvailable(
60 const content::URLDataSource::GotDataCallback
& callback
,
63 const favicon_base::LargeIconResult
& bitmap_result
);
65 // Returns null to trigger "Not Found" response.
66 void SendNotFoundResponse(
67 const content::URLDataSource::GotDataCallback
& callback
);
69 base::CancelableTaskTracker cancelable_task_tracker_
;
72 favicon::FallbackIconService
* fallback_icon_service_
;
75 favicon::LargeIconService
* large_icon_service_
;
77 DISALLOW_COPY_AND_ASSIGN(LargeIconSource
);
80 #endif // CHROME_BROWSER_UI_WEBUI_LARGE_ICON_SOURCE_H_