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

Side by Side Diff: content/renderer/favicon_helper.cc

Issue 12945007: Fix Notifications Icon loading. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tiny fix Created 7 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "content/renderer/favicon_helper.h" 5 #include "content/renderer/favicon_helper.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "content/common/icon_messages.h" 10 #include "content/common/icon_messages.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 ToFaviconType(icon_urls[i].iconType()))); 78 ToFaviconType(icon_urls[i].iconType())));
79 } 79 }
80 SendUpdateFaviconURL(routing_id(), render_view()->GetPageId(), urls); 80 SendUpdateFaviconURL(routing_id(), render_view()->GetPageId(), urls);
81 } 81 }
82 82
83 FaviconHelper::~FaviconHelper() { 83 FaviconHelper::~FaviconHelper() {
84 } 84 }
85 85
86 void FaviconHelper::OnDownloadFavicon(int id, 86 void FaviconHelper::OnDownloadFavicon(int id,
87 const GURL& image_url, 87 const GURL& image_url,
88 bool is_favicon,
88 int image_size) { 89 int image_size) {
89 std::vector<SkBitmap> result_images; 90 std::vector<SkBitmap> result_images;
90 if (image_url.SchemeIs("data")) { 91 if (image_url.SchemeIs("data")) {
91 SkBitmap data_image = ImageFromDataUrl(image_url); 92 SkBitmap data_image = ImageFromDataUrl(image_url);
92 if (!data_image.empty()) 93 if (!data_image.empty())
93 result_images.push_back(data_image); 94 result_images.push_back(data_image);
94 } else { 95 } else {
95 if (DownloadFavicon(id, image_url, image_size)) { 96 if (DownloadFavicon(id, image_url, is_favicon, image_size)) {
96 // Will complete asynchronously via FaviconHelper::DidDownloadFavicon 97 // Will complete asynchronously via FaviconHelper::DidDownloadFavicon
97 return; 98 return;
98 } 99 }
99 } 100 }
100 101
101 Send(new IconHostMsg_DidDownloadFavicon(routing_id(), 102 Send(new IconHostMsg_DidDownloadFavicon(routing_id(),
102 id, 103 id,
103 image_url, 104 image_url,
104 image_size, 105 image_size,
105 result_images)); 106 result_images));
106 } 107 }
107 108
108 bool FaviconHelper::DownloadFavicon(int id, 109 bool FaviconHelper::DownloadFavicon(int id,
109 const GURL& image_url, 110 const GURL& image_url,
111 bool is_favicon,
110 int image_size) { 112 int image_size) {
111 // Make sure webview was not shut down. 113 // Make sure webview was not shut down.
112 if (!render_view()->GetWebView()) 114 if (!render_view()->GetWebView())
113 return false; 115 return false;
114 // Create an image resource fetcher and assign it with a call back object. 116 // Create an image resource fetcher and assign it with a call back object.
115 image_fetchers_.push_back(new MultiResolutionImageResourceFetcher( 117 image_fetchers_.push_back(new MultiResolutionImageResourceFetcher(
116 image_url, render_view()->GetWebView()->mainFrame(), id, 118 image_url,
117 WebURLRequest::TargetIsFavicon, 119 render_view()->GetWebView()->mainFrame(),
120 id,
121 is_favicon ? WebURLRequest::TargetIsFavicon :
122 WebURLRequest::TargetIsImage,
118 base::Bind(&FaviconHelper::DidDownloadFavicon, 123 base::Bind(&FaviconHelper::DidDownloadFavicon,
119 base::Unretained(this), image_size))); 124 base::Unretained(this), image_size)));
120 return true; 125 return true;
121 } 126 }
122 127
123 void FaviconHelper::DidDownloadFavicon( 128 void FaviconHelper::DidDownloadFavicon(
124 int requested_size, 129 int requested_size,
125 MultiResolutionImageResourceFetcher* fetcher, 130 MultiResolutionImageResourceFetcher* fetcher,
126 const std::vector<SkBitmap>& images) { 131 const std::vector<SkBitmap>& images) {
127 // Notify requester of image download status. 132 // Notify requester of image download status.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 std::vector<FaviconURL> urls; 187 std::vector<FaviconURL> urls;
183 for (size_t i = 0; i < icon_urls.size(); i++) { 188 for (size_t i = 0; i < icon_urls.size(); i++) {
184 WebURL url = icon_urls[i].iconURL(); 189 WebURL url = icon_urls[i].iconURL();
185 if (!url.isEmpty()) 190 if (!url.isEmpty())
186 urls.push_back(FaviconURL(url, ToFaviconType(icon_urls[i].iconType()))); 191 urls.push_back(FaviconURL(url, ToFaviconType(icon_urls[i].iconType())));
187 } 192 }
188 SendUpdateFaviconURL(routing_id(), render_view()->GetPageId(), urls); 193 SendUpdateFaviconURL(routing_id(), render_view()->GetPageId(), urls);
189 } 194 }
190 195
191 } // namespace content 196 } // namespace content
OLDNEW
« content/renderer/favicon_helper.h ('K') | « content/renderer/favicon_helper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698