| OLD | NEW |
| 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 void AddToHomescreenDataFetcher::OnDidGetWebApplicationInfo( | 107 void AddToHomescreenDataFetcher::OnDidGetWebApplicationInfo( |
| 108 const WebApplicationInfo& received_web_app_info) { | 108 const WebApplicationInfo& received_web_app_info) { |
| 109 is_waiting_for_web_application_info_ = false; | 109 is_waiting_for_web_application_info_ = false; |
| 110 if (!web_contents() || !weak_observer_) | 110 if (!web_contents() || !weak_observer_) |
| 111 return; | 111 return; |
| 112 | 112 |
| 113 // Sanitize received_web_app_info. | 113 // Sanitize received_web_app_info. |
| 114 WebApplicationInfo web_app_info = received_web_app_info; | 114 WebApplicationInfo web_app_info = received_web_app_info; |
| 115 web_app_info.title = | 115 web_app_info.title = |
| 116 web_app_info.title.substr(0, chrome::kMaxMetaTagAttributeLength); | 116 web_app_info.title.substr(0, chrome::kMaxMetaTagAttributeLength); |
| 117 web_app_info.description = | |
| 118 web_app_info.description.substr(0, chrome::kMaxMetaTagAttributeLength); | |
| 119 | 117 |
| 120 // Simply set the user-editable title to be the page's title | 118 // Simply set the user-editable title to be the page's title |
| 121 shortcut_info_.user_title = web_app_info.title.empty() | 119 shortcut_info_.user_title = web_app_info.title.empty() |
| 122 ? web_contents()->GetTitle() | 120 ? web_contents()->GetTitle() |
| 123 : web_app_info.title; | 121 : web_app_info.title; |
| 124 shortcut_info_.short_name = shortcut_info_.user_title; | 122 shortcut_info_.short_name = shortcut_info_.user_title; |
| 125 shortcut_info_.name = shortcut_info_.user_title; | 123 shortcut_info_.name = shortcut_info_.user_title; |
| 126 | 124 |
| 127 if (web_app_info.mobile_capable == WebApplicationInfo::MOBILE_CAPABLE || | 125 if (web_app_info.mobile_capable == WebApplicationInfo::MOBILE_CAPABLE || |
| 128 web_app_info.mobile_capable == WebApplicationInfo::MOBILE_CAPABLE_APPLE) { | 126 web_app_info.mobile_capable == WebApplicationInfo::MOBILE_CAPABLE_APPLE) { |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 if (!web_contents() || !weak_observer_) | 202 if (!web_contents() || !weak_observer_) |
| 205 return; | 203 return; |
| 206 | 204 |
| 207 is_installable_check_complete_ = true; | 205 is_installable_check_complete_ = true; |
| 208 | 206 |
| 209 if (check_webapk_compatibility_) { | 207 if (check_webapk_compatibility_) { |
| 210 bool webapk_compatible = | 208 bool webapk_compatible = |
| 211 (data.error_code == NO_ERROR_DETECTED && | 209 (data.error_code == NO_ERROR_DETECTED && |
| 212 AreWebManifestUrlsWebApkCompatible(data.manifest)); | 210 AreWebManifestUrlsWebApkCompatible(data.manifest)); |
| 213 weak_observer_->OnDidDetermineWebApkCompatibility(webapk_compatible); | 211 weak_observer_->OnDidDetermineWebApkCompatibility(webapk_compatible); |
| 212 |
| 213 // WebAPKs are wholly defined by the Web Manifest. Ignore the <meta> tag |
| 214 // data received in OnDidGetWebApplicationInfo(). |
| 215 if (webapk_compatible) |
| 216 shortcut_info_ = ShortcutInfo(GURL()); |
| 214 } | 217 } |
| 215 | 218 |
| 216 if (!data.manifest.IsEmpty()) { | 219 if (!data.manifest.IsEmpty()) { |
| 217 content::RecordAction( | 220 content::RecordAction( |
| 218 base::UserMetricsAction("webapps.AddShortcut.Manifest")); | 221 base::UserMetricsAction("webapps.AddShortcut.Manifest")); |
| 219 shortcut_info_.UpdateFromManifest(data.manifest); | 222 shortcut_info_.UpdateFromManifest(data.manifest); |
| 220 shortcut_info_.manifest_url = data.manifest_url; | 223 shortcut_info_.manifest_url = data.manifest_url; |
| 221 } | 224 } |
| 222 | 225 |
| 223 // Save the splash screen URL for the later download. | 226 // Save the splash screen URL for the later download. |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 void AddToHomescreenDataFetcher::NotifyObserver(const SkBitmap& icon) { | 327 void AddToHomescreenDataFetcher::NotifyObserver(const SkBitmap& icon) { |
| 325 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 328 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 326 if (!web_contents() || !weak_observer_ || is_icon_saved_) | 329 if (!web_contents() || !weak_observer_ || is_icon_saved_) |
| 327 return; | 330 return; |
| 328 | 331 |
| 329 is_icon_saved_ = true; | 332 is_icon_saved_ = true; |
| 330 shortcut_icon_ = icon; | 333 shortcut_icon_ = icon; |
| 331 is_ready_ = true; | 334 is_ready_ = true; |
| 332 weak_observer_->OnDataAvailable(shortcut_info_, shortcut_icon_); | 335 weak_observer_->OnDataAvailable(shortcut_info_, shortcut_icon_); |
| 333 } | 336 } |
| OLD | NEW |