OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #ifndef CHROME_BROWSER_UI_WEBUI_LARGE_ICON_SOURCE_H_ | |
6 #define CHROME_BROWSER_UI_WEBUI_LARGE_ICON_SOURCE_H_ | |
7 | |
8 #include <memory> | |
9 #include <string> | |
10 | |
11 #include "base/macros.h" | |
12 #include "base/task/cancelable_task_tracker.h" | |
13 #include "content/public/browser/url_data_source.h" | |
14 | |
15 namespace favicon { | |
16 class LargeIconService; | |
17 } | |
18 | |
19 namespace favicon_base { | |
20 struct LargeIconResult; | |
21 } | |
22 | |
23 // LargeIconSource services explicit chrome:// requests for large icons. | |
24 // | |
25 // Format: | |
26 // chrome://large-icon/size/url | |
27 // | |
28 // Parameter: | |
29 // 'size' Required (including trailing '/') | |
30 // Positive integer to specify the large icon's size in pixels. | |
31 // 'url' Optional | |
32 // String to specify the page URL of the large icon. | |
33 // | |
34 // Example: chrome://large-icon/48/http://www.google.com/ | |
35 // This requests a 48x48 large icon for http://www.google.com. | |
36 class LargeIconSource : public content::URLDataSource { | |
37 public: | |
38 // |large_icon_service| is owned by caller and may be null. | |
39 explicit LargeIconSource(favicon::LargeIconService* large_icon_service); | |
40 | |
41 ~LargeIconSource() override; | |
42 | |
43 // content::URLDataSource implementation. | |
44 std::string GetSource() const override; | |
45 void StartDataRequest( | |
46 const std::string& path, | |
47 const content::ResourceRequestInfo::WebContentsGetter& wc_getter, | |
48 const content::URLDataSource::GotDataCallback& callback) override; | |
49 std::string GetMimeType(const std::string&) const override; | |
50 bool AllowCaching() const override; | |
51 bool ShouldReplaceExistingSource() const override; | |
52 bool ShouldServiceRequest(const GURL& url, | |
53 content::ResourceContext* resource_context, | |
54 int render_process_id) const override; | |
55 | |
56 private: | |
57 // Called with results of large icon retrieval request. | |
58 void OnLargeIconDataAvailable( | |
59 const content::URLDataSource::GotDataCallback& callback, | |
60 const GURL& url, | |
61 int size, | |
62 const favicon_base::LargeIconResult& bitmap_result); | |
63 | |
64 // Returns null to trigger "Not Found" response. | |
65 void SendNotFoundResponse( | |
66 const content::URLDataSource::GotDataCallback& callback); | |
67 | |
68 base::CancelableTaskTracker cancelable_task_tracker_; | |
69 | |
70 // Owned by client. | |
71 favicon::LargeIconService* large_icon_service_; | |
72 | |
73 DISALLOW_COPY_AND_ASSIGN(LargeIconSource); | |
74 }; | |
75 | |
76 #endif // CHROME_BROWSER_UI_WEBUI_LARGE_ICON_SOURCE_H_ | |
OLD | NEW |