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

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

Issue 2915913002: [WebAPKs] Display same text for menu & engagement banner (Closed)
Patch Set: Merge branch 'master' into same_infobar_title Created 3 years, 6 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/location.h" 10 #include "base/location.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 is_waiting_for_web_application_info_ = false; 105 is_waiting_for_web_application_info_ = false;
106 if (!web_contents() || !weak_observer_) 106 if (!web_contents() || !weak_observer_)
107 return; 107 return;
108 108
109 // Sanitize received_web_app_info. 109 // Sanitize received_web_app_info.
110 WebApplicationInfo web_app_info = received_web_app_info; 110 WebApplicationInfo web_app_info = received_web_app_info;
111 web_app_info.title = 111 web_app_info.title =
112 web_app_info.title.substr(0, chrome::kMaxMetaTagAttributeLength); 112 web_app_info.title.substr(0, chrome::kMaxMetaTagAttributeLength);
113 113
114 // Simply set the user-editable title to be the page's title 114 // Simply set the user-editable title to be the page's title
115 shortcut_info_.user_title = web_app_info.title.empty() 115 const base::string16& title = web_app_info.title.empty()
116 ? web_contents()->GetTitle() 116 ? web_contents()->GetTitle()
117 : web_app_info.title; 117 : web_app_info.title;
118 shortcut_info_.short_name = shortcut_info_.user_title; 118 shortcut_info_.short_name = title;
119 shortcut_info_.name = shortcut_info_.user_title; 119 shortcut_info_.name = title;
120 120
121 if (web_app_info.mobile_capable == WebApplicationInfo::MOBILE_CAPABLE || 121 if (web_app_info.mobile_capable == WebApplicationInfo::MOBILE_CAPABLE ||
122 web_app_info.mobile_capable == WebApplicationInfo::MOBILE_CAPABLE_APPLE) { 122 web_app_info.mobile_capable == WebApplicationInfo::MOBILE_CAPABLE_APPLE) {
123 shortcut_info_.display = blink::kWebDisplayModeStandalone; 123 shortcut_info_.display = blink::kWebDisplayModeStandalone;
124 shortcut_info_.UpdateSource( 124 shortcut_info_.UpdateSource(
125 ShortcutInfo::SOURCE_ADD_TO_HOMESCREEN_STANDALONE); 125 ShortcutInfo::SOURCE_ADD_TO_HOMESCREEN_STANDALONE);
126 } 126 }
127 127
128 // Record what type of shortcut was added by the user. 128 // Record what type of shortcut was added by the user.
129 switch (web_app_info.mobile_capable) { 129 switch (web_app_info.mobile_capable) {
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 // Save the splash screen URL for the later download. 237 // Save the splash screen URL for the later download.
238 shortcut_info_.splash_image_url = 238 shortcut_info_.splash_image_url =
239 content::ManifestIconSelector::FindBestMatchingIcon( 239 content::ManifestIconSelector::FindBestMatchingIcon(
240 data.manifest.icons, ideal_splash_image_size_in_px_, 240 data.manifest.icons, ideal_splash_image_size_in_px_,
241 minimum_splash_image_size_in_px_, 241 minimum_splash_image_size_in_px_,
242 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_; 243 shortcut_info_.ideal_splash_image_size_in_px = ideal_splash_image_size_in_px_;
244 shortcut_info_.minimum_splash_image_size_in_px = 244 shortcut_info_.minimum_splash_image_size_in_px =
245 minimum_splash_image_size_in_px_; 245 minimum_splash_image_size_in_px_;
246 246
247 weak_observer_->OnUserTitleAvailable(shortcut_info_.user_title); 247 weak_observer_->OnUserTitleAvailable(shortcut_info_.short_name);
248 248
249 if (data.primary_icon) { 249 if (data.primary_icon) {
250 shortcut_info_.best_primary_icon_url = data.primary_icon_url; 250 shortcut_info_.best_primary_icon_url = data.primary_icon_url;
251 251
252 CreateLauncherIcon(*(data.primary_icon)); 252 CreateLauncherIcon(*(data.primary_icon));
253 return; 253 return;
254 } 254 }
255 255
256 FetchFavicon(); 256 FetchFavicon();
257 } 257 }
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 338
339 void AddToHomescreenDataFetcher::NotifyObserver(const SkBitmap& primary_icon) { 339 void AddToHomescreenDataFetcher::NotifyObserver(const SkBitmap& primary_icon) {
340 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 340 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
341 if (!web_contents() || !weak_observer_ || is_icon_saved_) 341 if (!web_contents() || !weak_observer_ || is_icon_saved_)
342 return; 342 return;
343 343
344 is_icon_saved_ = true; 344 is_icon_saved_ = true;
345 primary_icon_ = primary_icon; 345 primary_icon_ = primary_icon;
346 weak_observer_->OnDataAvailable(shortcut_info_, primary_icon_, badge_icon_); 346 weak_observer_->OnDataAvailable(shortcut_info_, primary_icon_, badge_icon_);
347 } 347 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698