Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(378)

Side by Side Diff: chrome/browser/ui/webui/large_icon_source.h

Issue 1092873002: [Icons NTP] Refactor large_icon_source to extract the logic shared between desktop and Android to f… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_UI_WEBUI_LARGE_ICON_SOURCE_H_ 5 #ifndef CHROME_BROWSER_UI_WEBUI_LARGE_ICON_SOURCE_H_
6 #define CHROME_BROWSER_UI_WEBUI_LARGE_ICON_SOURCE_H_ 6 #define CHROME_BROWSER_UI_WEBUI_LARGE_ICON_SOURCE_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector>
10 9
11 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
12 #include "base/task/cancelable_task_tracker.h" 11 #include "base/task/cancelable_task_tracker.h"
13 #include "components/favicon/core/fallback_icon_service.h" 12 #include "components/favicon/core/fallback_icon_service.h"
14 #include "components/favicon_base/favicon_types.h" 13 #include "components/favicon_base/favicon_types.h"
15 #include "content/public/browser/url_data_source.h" 14 #include "content/public/browser/url_data_source.h"
16 #include "third_party/skia/include/core/SkColor.h"
17 15
18 namespace favicon { 16 namespace favicon {
19 class FallbackIconService; 17 class FallbackIconService;
20 class FaviconService; 18 class FaviconService;
21 } 19 }
22 20
23 // LargeIconSource services explicit chrome:// requests for large icons. 21 // LargeIconSource services explicit chrome:// requests for large icons.
24 // 22 //
25 // Format: 23 // Format:
26 // chrome://large-icon/size/url 24 // chrome://large-icon/size/url
(...skipping 19 matching lines...) Expand all
46 std::string GetSource() const override; 44 std::string GetSource() const override;
47 void StartDataRequest( 45 void StartDataRequest(
48 const std::string& path, 46 const std::string& path,
49 int render_process_id, 47 int render_process_id,
50 int render_frame_id, 48 int render_frame_id,
51 const content::URLDataSource::GotDataCallback& callback) override; 49 const content::URLDataSource::GotDataCallback& callback) override;
52 std::string GetMimeType(const std::string&) const override; 50 std::string GetMimeType(const std::string&) const override;
53 bool ShouldReplaceExistingSource() const override; 51 bool ShouldReplaceExistingSource() const override;
54 bool ShouldServiceRequest(const net::URLRequest* request) const override; 52 bool ShouldServiceRequest(const net::URLRequest* request) const override;
55 53
56 protected:
57 struct IconRequest {
58 IconRequest();
59 IconRequest(const content::URLDataSource::GotDataCallback& callback_in,
60 const GURL& path_in,
61 int size_in);
62 ~IconRequest();
63
64 content::URLDataSource::GotDataCallback callback;
65 GURL url;
66 int size;
67 };
68
69 private: 54 private:
70 // Callback for icon data retrieval request. 55 // Callback for icon data retrieval request.
71 void OnIconDataAvailable( 56 void OnIconDataAvailable(
72 const IconRequest& request, 57 const content::URLDataSource::GotDataCallback& callback,
73 const favicon_base::FaviconRawBitmapResult& bitmap_result); 58 const GURL& url,
74 59 int size,
75 // Renders and sends a default fallback icon. This is used when there is no 60 const favicon_base::LargeIconResult& bitmap_result);
76 // known text and/or foreground color to use for the generated icon (it
77 // defaults to a light text color on a dark gray background).
78 void SendDefaultFallbackIcon(const IconRequest& request);
79
80 // Renders and sends a fallback icon using the given colors.
81 void SendFallbackIcon(const IconRequest& request,
82 SkColor text_color,
83 SkColor background_color);
84 61
85 // Returns null to trigger "Not Found" response. 62 // Returns null to trigger "Not Found" response.
86 void SendNotFoundResponse( 63 void SendNotFoundResponse(
87 const content::URLDataSource::GotDataCallback& callback); 64 const content::URLDataSource::GotDataCallback& callback);
88 65
89 base::CancelableTaskTracker cancelable_task_tracker_; 66 base::CancelableTaskTracker cancelable_task_tracker_;
90 67
91 favicon::FaviconService* favicon_service_; 68 favicon::FaviconService* favicon_service_;
92 69
93 favicon::FallbackIconService* fallback_icon_service_; 70 favicon::FallbackIconService* fallback_icon_service_;
94 71
95 // A pre-populated list of the types of icon files to consider when looking
96 // for the largest matching icon.
97 // Note: this is simply an optimization over populating an icon type vector
98 // on each request.
99 std::vector<int> large_icon_types_;
100
101 DISALLOW_COPY_AND_ASSIGN(LargeIconSource); 72 DISALLOW_COPY_AND_ASSIGN(LargeIconSource);
102 }; 73 };
103 74
104 #endif // CHROME_BROWSER_UI_WEBUI_LARGE_ICON_SOURCE_H_ 75 #endif // CHROME_BROWSER_UI_WEBUI_LARGE_ICON_SOURCE_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/webui/large_icon_source.cc » ('j') | chrome/browser/ui/webui/large_icon_source.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698