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

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

Issue 2362813003: Make it clear that AddToHomescreenDataFetcher ignores WebApplicationInfo for WebAPK compatible pages (Closed)
Patch Set: Created 4 years, 3 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 void AddToHomescreenDataFetcher::OnDidGetWebApplicationInfo( 106 void AddToHomescreenDataFetcher::OnDidGetWebApplicationInfo(
107 const WebApplicationInfo& received_web_app_info) { 107 const WebApplicationInfo& received_web_app_info) {
108 is_waiting_for_web_application_info_ = false; 108 is_waiting_for_web_application_info_ = false;
109 if (!web_contents() || !weak_observer_) 109 if (!web_contents() || !weak_observer_)
110 return; 110 return;
111 111
112 // Sanitize received_web_app_info. 112 // Sanitize received_web_app_info.
113 WebApplicationInfo web_app_info = received_web_app_info; 113 WebApplicationInfo web_app_info = received_web_app_info;
114 web_app_info.title = 114 web_app_info.title =
115 web_app_info.title.substr(0, chrome::kMaxMetaTagAttributeLength); 115 web_app_info.title.substr(0, chrome::kMaxMetaTagAttributeLength);
116 web_app_info.description =
117 web_app_info.description.substr(0, chrome::kMaxMetaTagAttributeLength);
Xi Han 2016/09/26 17:48:12 Doesn't regular web app still need this?
pkotwicz 2016/09/26 20:13:47 |web_app_info| is a variable which is local to the
Xi Han 2016/09/26 20:15:41 Acknowledged.
118 116
119 // Simply set the user-editable title to be the page's title 117 // Simply set the user-editable title to be the page's title
120 shortcut_info_.user_title = web_app_info.title.empty() 118 shortcut_info_.user_title = web_app_info.title.empty()
121 ? web_contents()->GetTitle() 119 ? web_contents()->GetTitle()
122 : web_app_info.title; 120 : web_app_info.title;
123 shortcut_info_.short_name = shortcut_info_.user_title; 121 shortcut_info_.short_name = shortcut_info_.user_title;
124 shortcut_info_.name = shortcut_info_.user_title; 122 shortcut_info_.name = shortcut_info_.user_title;
125 123
126 if (web_app_info.mobile_capable == WebApplicationInfo::MOBILE_CAPABLE || 124 if (web_app_info.mobile_capable == WebApplicationInfo::MOBILE_CAPABLE ||
127 web_app_info.mobile_capable == WebApplicationInfo::MOBILE_CAPABLE_APPLE) { 125 web_app_info.mobile_capable == WebApplicationInfo::MOBILE_CAPABLE_APPLE) {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 CreateLauncherIcon(SkBitmap()); 196 CreateLauncherIcon(SkBitmap());
199 } 197 }
200 198
201 void AddToHomescreenDataFetcher::OnDidPerformInstallableCheck( 199 void AddToHomescreenDataFetcher::OnDidPerformInstallableCheck(
202 const InstallableData& data) { 200 const InstallableData& data) {
203 if (!web_contents() || !weak_observer_) 201 if (!web_contents() || !weak_observer_)
204 return; 202 return;
205 203
206 is_installable_check_complete_ = true; 204 is_installable_check_complete_ = true;
207 205
208 if (check_webapk_compatibility_) 206 bool webapk_compatible = false;
209 weak_observer_->OnDidDetermineWebApkCompatibility(data.is_installable); 207 if (check_webapk_compatibility_) {
208 webapk_compatible = data.is_installable;
209 weak_observer_->OnDidDetermineWebApkCompatibility(webapk_compatible);
210 }
211
212 // WebAPKs are wholly defined by the Web Manifest. Ignore the <meta> tag
213 // data received in OnDidGetWebApplicationInfo().
214 if (webapk_compatible) {
215 shortcut_info_ = ShortcutInfo(GURL());
dominickn 2016/09/27 01:51:28 Nit: remove braces. Also, move this check into the
216 }
210 217
211 if (!data.manifest.IsEmpty()) { 218 if (!data.manifest.IsEmpty()) {
212 content::RecordAction( 219 content::RecordAction(
213 base::UserMetricsAction("webapps.AddShortcut.Manifest")); 220 base::UserMetricsAction("webapps.AddShortcut.Manifest"));
214 shortcut_info_.UpdateFromManifest(data.manifest); 221 shortcut_info_.UpdateFromManifest(data.manifest);
215 shortcut_info_.manifest_url = data.manifest_url; 222 shortcut_info_.manifest_url = data.manifest_url;
216 } 223 }
217 224
218 // Save the splash screen URL for the later download. 225 // Save the splash screen URL for the later download.
219 splash_screen_url_ = ManifestIconSelector::FindBestMatchingIcon( 226 splash_screen_url_ = ManifestIconSelector::FindBestMatchingIcon(
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 void AddToHomescreenDataFetcher::NotifyObserver(const SkBitmap& icon) { 326 void AddToHomescreenDataFetcher::NotifyObserver(const SkBitmap& icon) {
320 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 327 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
321 if (!web_contents() || !weak_observer_ || is_icon_saved_) 328 if (!web_contents() || !weak_observer_ || is_icon_saved_)
322 return; 329 return;
323 330
324 is_icon_saved_ = true; 331 is_icon_saved_ = true;
325 shortcut_icon_ = icon; 332 shortcut_icon_ = icon;
326 is_ready_ = true; 333 is_ready_ = true;
327 weak_observer_->OnDataAvailable(shortcut_info_, shortcut_icon_); 334 weak_observer_->OnDataAvailable(shortcut_info_, shortcut_icon_);
328 } 335 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698