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_BIG_ICON_SOURCE_H_ | |
6 #define CHROME_BROWSER_UI_WEBUI_BIG_ICON_SOURCE_H_ | |
7 | |
8 #include "base/memory/scoped_ptr.h" | |
9 #include "base/task/cancelable_task_tracker.h" | |
10 #include "components/favicon_base/fallback_icon_service.h" | |
11 #include "components/favicon_base/favicon_types.h" | |
12 #include "content/public/browser/url_data_source.h" | |
13 | |
14 class Profile; | |
15 | |
16 // BigIconSource services explicit chrome:// requests for big icons. | |
17 // | |
18 // Format: | |
19 // chrome://big-icon/size/url | |
20 // All of the parameters except for the url are optional. However, the order of | |
21 // | |
22 // Parameter: | |
23 // 'size' | |
24 // Positive integer to specify the big icon's size in pixels. | |
25 // 'url' | |
26 // String to specify the page URL of the big icon. | |
27 // | |
28 // Example: chrome://big-icon/48/http://www.google.com/ | |
29 // This requests a 48x48 big icon for http://www.google.com. | |
30 class BigIconSource : public content::URLDataSource { | |
Roger McFarlane (Chromium)
2015/03/16 19:00:59
nit: I prefer "large" over "big" in the nomenclatu
huangs
2015/03/17 01:43:52
Done.
| |
31 public: | |
32 explicit BigIconSource(Profile* profile); | |
33 | |
34 ~BigIconSource() override; | |
35 | |
36 // content::URLDataSource implementation. | |
37 std::string GetSource() const override; | |
38 void StartDataRequest( | |
39 const std::string& path, | |
40 int render_process_id, | |
41 int render_frame_id, | |
42 const content::URLDataSource::GotDataCallback& callback) override; | |
43 std::string GetMimeType(const std::string&) const override; | |
44 bool ShouldReplaceExistingSource() const override; | |
45 bool ShouldServiceRequest(const net::URLRequest* request) const override; | |
46 | |
47 protected: | |
48 struct IconRequest { | |
49 IconRequest(); | |
50 IconRequest(const content::URLDataSource::GotDataCallback& callback_in, | |
51 const GURL& path_in, | |
52 int size_in); | |
53 ~IconRequest(); | |
54 | |
55 content::URLDataSource::GotDataCallback callback; | |
56 GURL path; | |
57 int size; | |
58 }; | |
59 | |
60 private: | |
61 bool HandleMissingResource(const IconRequest& request); | |
62 | |
63 void OnBigIconDataAvailable( | |
64 IconRequest request, | |
65 const favicon_base::FaviconRawBitmapResult& bitmap_result); | |
66 | |
67 void SendFallbackIcon( | |
68 const GURL& url, | |
69 const content::URLDataSource::GotDataCallback& callback); | |
70 | |
71 void SendDefaultResponse( | |
72 const content::URLDataSource::GotDataCallback& callback); | |
73 | |
74 Profile* profile_; | |
75 | |
76 base::CancelableTaskTracker cancelable_task_tracker_; | |
77 | |
78 scoped_ptr<favicon_base::FallbackIconService> fallback_icon_service_; | |
79 | |
80 bool render_fallback_on_failure_; | |
81 | |
82 DISALLOW_COPY_AND_ASSIGN(BigIconSource); | |
83 }; | |
84 | |
85 #endif // CHROME_BROWSER_UI_WEBUI_BIG_ICON_SOURCE_H_ | |
OLD | NEW |