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

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

Issue 2724723002: [WebAPKs]: Reduce the parameters of ShortcutHelper::AddToLauncherWithSkBitmap() (Closed)
Patch Set: Merge branch 'master' into refactor_shortcut_helper2 Created 3 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
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"
11 #include "base/location.h" 10 #include "base/location.h"
12 #include "base/strings/string16.h" 11 #include "base/strings/string16.h"
13 #include "base/task_runner_util.h" 12 #include "base/task_runner_util.h"
14 #include "base/threading/sequenced_worker_pool.h" 13 #include "base/threading/sequenced_worker_pool.h"
15 #include "chrome/browser/android/offline_pages/offline_page_utils.h" 14 #include "chrome/browser/android/offline_pages/offline_page_utils.h"
16 #include "chrome/browser/android/shortcut_helper.h" 15 #include "chrome/browser/android/shortcut_helper.h"
17 #include "chrome/browser/android/webapk/webapk_web_manifest_checker.h" 16 #include "chrome/browser/android/webapk/webapk_web_manifest_checker.h"
18 #include "chrome/browser/favicon/favicon_service_factory.h" 17 #include "chrome/browser/favicon/favicon_service_factory.h"
19 #include "chrome/browser/installable/installable_manager.h" 18 #include "chrome/browser/installable/installable_manager.h"
20 #include "chrome/browser/manifest/manifest_icon_selector.h" 19 #include "chrome/browser/manifest/manifest_icon_selector.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 is_installable_check_complete_(false), 92 is_installable_check_complete_(false),
94 is_icon_saved_(false), 93 is_icon_saved_(false),
95 is_ready_(false) { 94 is_ready_(false) {
96 DCHECK(minimum_icon_size_in_px <= ideal_icon_size_in_px); 95 DCHECK(minimum_icon_size_in_px <= ideal_icon_size_in_px);
97 DCHECK(minimum_splash_image_size_in_px <= ideal_splash_image_size_in_px); 96 DCHECK(minimum_splash_image_size_in_px <= ideal_splash_image_size_in_px);
98 97
99 // Send a message to the renderer to retrieve information about the page. 98 // Send a message to the renderer to retrieve information about the page.
100 Send(new ChromeViewMsg_GetWebApplicationInfo(routing_id())); 99 Send(new ChromeViewMsg_GetWebApplicationInfo(routing_id()));
101 } 100 }
102 101
103 base::Closure AddToHomescreenDataFetcher::FetchSplashScreenImageCallback(
104 const std::string& webapp_id) {
105 return base::Bind(&ShortcutHelper::FetchSplashScreenImage, web_contents(),
106 splash_screen_url_, ideal_splash_image_size_in_px_,
107 minimum_splash_image_size_in_px_, webapp_id);
108 }
109
110 void AddToHomescreenDataFetcher::OnDidGetWebApplicationInfo( 102 void AddToHomescreenDataFetcher::OnDidGetWebApplicationInfo(
111 const WebApplicationInfo& received_web_app_info) { 103 const WebApplicationInfo& received_web_app_info) {
112 is_waiting_for_web_application_info_ = false; 104 is_waiting_for_web_application_info_ = false;
113 if (!web_contents() || !weak_observer_) 105 if (!web_contents() || !weak_observer_)
114 return; 106 return;
115 107
116 // Sanitize received_web_app_info. 108 // Sanitize received_web_app_info.
117 WebApplicationInfo web_app_info = received_web_app_info; 109 WebApplicationInfo web_app_info = received_web_app_info;
118 web_app_info.title = 110 web_app_info.title =
119 web_app_info.title.substr(0, chrome::kMaxMetaTagAttributeLength); 111 web_app_info.title.substr(0, chrome::kMaxMetaTagAttributeLength);
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 shortcut_info_.UpdateSource(ShortcutInfo::SOURCE_ADD_TO_HOMESCREEN_PWA); 229 shortcut_info_.UpdateSource(ShortcutInfo::SOURCE_ADD_TO_HOMESCREEN_PWA);
238 230
239 if (data.badge_icon && !data.badge_icon->drawsNothing()) { 231 if (data.badge_icon && !data.badge_icon->drawsNothing()) {
240 shortcut_info_.best_badge_icon_url = data.badge_icon_url; 232 shortcut_info_.best_badge_icon_url = data.badge_icon_url;
241 badge_icon_ = *data.badge_icon; 233 badge_icon_ = *data.badge_icon;
242 } 234 }
243 } 235 }
244 } 236 }
245 237
246 // Save the splash screen URL for the later download. 238 // Save the splash screen URL for the later download.
247 splash_screen_url_ = ManifestIconSelector::FindBestMatchingIcon( 239 shortcut_info_.splash_image_url = ManifestIconSelector::FindBestMatchingIcon(
248 data.manifest.icons, ideal_splash_image_size_in_px_, 240 data.manifest.icons, ideal_splash_image_size_in_px_,
249 minimum_splash_image_size_in_px_, 241 minimum_splash_image_size_in_px_,
250 content::Manifest::Icon::IconPurpose::ANY); 242 content::Manifest::Icon::IconPurpose::ANY);
243 shortcut_info_.ideal_splash_image_size_in_px = ideal_splash_image_size_in_px_;
244 shortcut_info_.minimum_splash_image_size_in_px =
245 minimum_splash_image_size_in_px_;
251 246
252 weak_observer_->OnUserTitleAvailable(shortcut_info_.user_title); 247 weak_observer_->OnUserTitleAvailable(shortcut_info_.user_title);
253 248
254 if (data.primary_icon) { 249 if (data.primary_icon) {
255 shortcut_info_.best_primary_icon_url = data.primary_icon_url; 250 shortcut_info_.best_primary_icon_url = data.primary_icon_url;
256 251
257 CreateLauncherIcon(*(data.primary_icon)); 252 CreateLauncherIcon(*(data.primary_icon));
258 return; 253 return;
259 } 254 }
260 255
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 void AddToHomescreenDataFetcher::NotifyObserver(const SkBitmap& primary_icon) { 339 void AddToHomescreenDataFetcher::NotifyObserver(const SkBitmap& primary_icon) {
345 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 340 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
346 if (!web_contents() || !weak_observer_ || is_icon_saved_) 341 if (!web_contents() || !weak_observer_ || is_icon_saved_)
347 return; 342 return;
348 343
349 is_icon_saved_ = true; 344 is_icon_saved_ = true;
350 primary_icon_ = primary_icon; 345 primary_icon_ = primary_icon;
351 is_ready_ = true; 346 is_ready_ = true;
352 weak_observer_->OnDataAvailable(shortcut_info_, primary_icon_, badge_icon_); 347 weak_observer_->OnDataAvailable(shortcut_info_, primary_icon_, badge_icon_);
353 } 348 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698