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

Side by Side Diff: chrome/browser/android/webapps/add_to_homescreen_data_fetcher.cc

Issue 2671853002: Rename best icon to best primary icon in Web app related code. (Closed)
Patch Set: Created 3 years, 10 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 #include "chrome/browser/android/webapps/add_to_homescreen_data_fetcher.h" 5 #include "chrome/browser/android/webapps/add_to_homescreen_data_fetcher.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 } 155 }
156 156
157 bool AddToHomescreenDataFetcher::OnMessageReceived( 157 bool AddToHomescreenDataFetcher::OnMessageReceived(
158 const IPC::Message& message) { 158 const IPC::Message& message) {
159 if (!is_waiting_for_web_application_info_) 159 if (!is_waiting_for_web_application_info_)
160 return false; 160 return false;
161 161
162 bool handled = true; 162 bool handled = true;
163 163
164 IPC_BEGIN_MESSAGE_MAP(AddToHomescreenDataFetcher, message) 164 IPC_BEGIN_MESSAGE_MAP(AddToHomescreenDataFetcher, message)
165 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_DidGetWebApplicationInfo, 165 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_DidGetWebApplicationInfo,
dominickn 2017/02/02 23:34:13 The standard Chromium style is to have IPC_MESSAGE
F 2017/02/03 00:47:15 Running clang-format restored the old formatting.
166 OnDidGetWebApplicationInfo) 166 OnDidGetWebApplicationInfo)
167 IPC_MESSAGE_UNHANDLED(handled = false) 167 IPC_MESSAGE_UNHANDLED(handled = false)
168 IPC_END_MESSAGE_MAP() 168 IPC_END_MESSAGE_MAP()
169 169
170 return handled; 170 return handled;
171 } 171 }
172 172
173 void AddToHomescreenDataFetcher::OnDataTimedout() { 173 void AddToHomescreenDataFetcher::OnDataTimedout() {
174 if (!web_contents() || !weak_observer_) 174 if (!web_contents() || !weak_observer_)
175 return; 175 return;
176 176
177 if (!is_installable_check_complete_) { 177 if (!is_installable_check_complete_) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 213
214 // Save the splash screen URL for the later download. 214 // Save the splash screen URL for the later download.
215 splash_screen_url_ = ManifestIconSelector::FindBestMatchingIcon( 215 splash_screen_url_ = ManifestIconSelector::FindBestMatchingIcon(
216 data.manifest.icons, ideal_splash_image_size_in_px_, 216 data.manifest.icons, ideal_splash_image_size_in_px_,
217 minimum_splash_image_size_in_px_, 217 minimum_splash_image_size_in_px_,
218 content::Manifest::Icon::IconPurpose::ANY); 218 content::Manifest::Icon::IconPurpose::ANY);
219 219
220 weak_observer_->OnUserTitleAvailable(shortcut_info_.user_title); 220 weak_observer_->OnUserTitleAvailable(shortcut_info_.user_title);
221 221
222 if (data.primary_icon) { 222 if (data.primary_icon) {
223 shortcut_info_.best_icon_url = data.primary_icon_url; 223 shortcut_info_.best_primary_icon_url = data.primary_icon_url;
224 224
225 CreateLauncherIcon(*(data.primary_icon)); 225 CreateLauncherIcon(*(data.primary_icon));
226 return; 226 return;
227 } 227 }
228 228
229 FetchFavicon(); 229 FetchFavicon();
230 } 230 }
231 231
232 void AddToHomescreenDataFetcher::FetchFavicon() { 232 void AddToHomescreenDataFetcher::FetchFavicon() {
233 if (!web_contents() || !weak_observer_) 233 if (!web_contents() || !weak_observer_)
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 void AddToHomescreenDataFetcher::CreateLauncherIconFromFaviconInBackground( 269 void AddToHomescreenDataFetcher::CreateLauncherIconFromFaviconInBackground(
270 const favicon_base::FaviconRawBitmapResult& bitmap_result) { 270 const favicon_base::FaviconRawBitmapResult& bitmap_result) {
271 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); 271 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
272 272
273 SkBitmap raw_icon; 273 SkBitmap raw_icon;
274 if (bitmap_result.is_valid()) { 274 if (bitmap_result.is_valid()) {
275 gfx::PNGCodec::Decode(bitmap_result.bitmap_data->front(), 275 gfx::PNGCodec::Decode(bitmap_result.bitmap_data->front(),
276 bitmap_result.bitmap_data->size(), &raw_icon); 276 bitmap_result.bitmap_data->size(), &raw_icon);
277 } 277 }
278 278
279 shortcut_info_.best_icon_url = bitmap_result.icon_url; 279 shortcut_info_.best_primary_icon_url = bitmap_result.icon_url;
280 CreateLauncherIconInBackground(raw_icon); 280 CreateLauncherIconInBackground(raw_icon);
281 } 281 }
282 282
283 void AddToHomescreenDataFetcher::CreateLauncherIcon(const SkBitmap& raw_icon) { 283 void AddToHomescreenDataFetcher::CreateLauncherIcon(const SkBitmap& raw_icon) {
284 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 284 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
285 content::BrowserThread::GetBlockingPool() 285 content::BrowserThread::GetBlockingPool()->PostWorkerTaskWithShutdownBehavior(
286 ->PostWorkerTaskWithShutdownBehavior( 286 FROM_HERE,
287 FROM_HERE, 287 base::Bind(&AddToHomescreenDataFetcher::CreateLauncherIconInBackground,
288 base::Bind( 288 this, raw_icon),
289 &AddToHomescreenDataFetcher::CreateLauncherIconInBackground, 289 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN);
290 this, raw_icon),
291 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN);
292 } 290 }
293 291
294 void AddToHomescreenDataFetcher::CreateLauncherIconInBackground( 292 void AddToHomescreenDataFetcher::CreateLauncherIconInBackground(
295 const SkBitmap& raw_icon) { 293 const SkBitmap& raw_icon) {
296 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); 294 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
297 295
298 SkBitmap icon; 296 SkBitmap icon;
299 bool is_generated = false; 297 bool is_generated = false;
300 if (weak_observer_) { 298 if (weak_observer_) {
301 icon = weak_observer_->FinalizeLauncherIconInBackground( 299 icon = weak_observer_->FinalizeLauncherIconInBackground(
302 raw_icon, shortcut_info_.url, &is_generated); 300 raw_icon, shortcut_info_.url, &is_generated);
303 } 301 }
304 302
305 if (is_generated) 303 if (is_generated)
306 shortcut_info_.best_icon_url = GURL(); 304 shortcut_info_.best_primary_icon_url = GURL();
307 305
308 content::BrowserThread::PostTask( 306 content::BrowserThread::PostTask(
309 content::BrowserThread::UI, FROM_HERE, 307 content::BrowserThread::UI, FROM_HERE,
310 base::Bind(&AddToHomescreenDataFetcher::NotifyObserver, this, icon)); 308 base::Bind(&AddToHomescreenDataFetcher::NotifyObserver, this, icon));
311 } 309 }
312 310
313 void AddToHomescreenDataFetcher::NotifyObserver(const SkBitmap& icon) { 311 void AddToHomescreenDataFetcher::NotifyObserver(const SkBitmap& icon) {
314 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 312 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
315 if (!web_contents() || !weak_observer_ || is_icon_saved_) 313 if (!web_contents() || !weak_observer_ || is_icon_saved_)
316 return; 314 return;
317 315
318 is_icon_saved_ = true; 316 is_icon_saved_ = true;
319 shortcut_icon_ = icon; 317 shortcut_icon_ = icon;
320 is_ready_ = true; 318 is_ready_ = true;
321 weak_observer_->OnDataAvailable(shortcut_info_, shortcut_icon_); 319 weak_observer_->OnDataAvailable(shortcut_info_, shortcut_icon_);
322 } 320 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698