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

Side by Side Diff: chrome/browser/android/shortcut_data_fetcher.cc

Issue 1224273003: webapps: propogate name and shortName from manifest to Java (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix cl issues Created 5 years, 5 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/shortcut_data_fetcher.h" 5 #include "chrome/browser/android/shortcut_data_fetcher.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/strings/string16.h" 9 #include "base/strings/string16.h"
10 #include "base/task/cancelable_task_tracker.h" 10 #include "base/task/cancelable_task_tracker.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 is_waiting_for_web_application_info_ = false; 58 is_waiting_for_web_application_info_ = false;
59 if (!web_contents() || !weak_observer_) return; 59 if (!web_contents() || !weak_observer_) return;
60 60
61 // Sanitize received_web_app_info. 61 // Sanitize received_web_app_info.
62 WebApplicationInfo web_app_info = received_web_app_info; 62 WebApplicationInfo web_app_info = received_web_app_info;
63 web_app_info.title = 63 web_app_info.title =
64 web_app_info.title.substr(0, chrome::kMaxMetaTagAttributeLength); 64 web_app_info.title.substr(0, chrome::kMaxMetaTagAttributeLength);
65 web_app_info.description = 65 web_app_info.description =
66 web_app_info.description.substr(0, chrome::kMaxMetaTagAttributeLength); 66 web_app_info.description.substr(0, chrome::kMaxMetaTagAttributeLength);
67 67
68 shortcut_info_.title = web_app_info.title.empty() ? web_contents()->GetTitle() 68 // Simply set the user editable title to be the page's title
gone 2015/07/20 22:19:12 nit:user-editable
Lalit Maganti 2015/07/21 09:07:27 Done.
69 : web_app_info.title; 69 shortcut_info_.user_title = web_app_info.title.empty()
70 ? web_contents()->GetTitle()
71 : web_app_info.title;
70 72
71 if (web_app_info.mobile_capable == WebApplicationInfo::MOBILE_CAPABLE || 73 if (web_app_info.mobile_capable == WebApplicationInfo::MOBILE_CAPABLE ||
72 web_app_info.mobile_capable == WebApplicationInfo::MOBILE_CAPABLE_APPLE) { 74 web_app_info.mobile_capable == WebApplicationInfo::MOBILE_CAPABLE_APPLE) {
73 shortcut_info_.display = content::Manifest::DISPLAY_MODE_STANDALONE; 75 shortcut_info_.display = content::Manifest::DISPLAY_MODE_STANDALONE;
74 } 76 }
75 77
76 // Record what type of shortcut was added by the user. 78 // Record what type of shortcut was added by the user.
77 switch (web_app_info.mobile_capable) { 79 switch (web_app_info.mobile_capable) {
78 case WebApplicationInfo::MOBILE_CAPABLE: 80 case WebApplicationInfo::MOBILE_CAPABLE:
79 content::RecordAction( 81 content::RecordAction(
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 false, 116 false,
115 preferred_icon_size_in_px_, 117 preferred_icon_size_in_px_,
116 false, 118 false,
117 base::Bind(&ShortcutDataFetcher::OnManifestIconFetched, 119 base::Bind(&ShortcutDataFetcher::OnManifestIconFetched,
118 this)); 120 this));
119 } else { 121 } else {
120 // Grab the best favicon for the page. 122 // Grab the best favicon for the page.
121 FetchFavicon(); 123 FetchFavicon();
122 } 124 }
123 125
124 weak_observer_->OnTitleAvailable(shortcut_info_.title); 126 weak_observer_->OnUserTitleAvailable(shortcut_info_.user_title);
125 127
126 // Kick off a timeout for downloading the icon. If an icon isn't set within 128 // Kick off a timeout for downloading the icon. If an icon isn't set within
127 // the timeout, fall back to using a dynamically-generated launcher icon. 129 // the timeout, fall back to using a dynamically-generated launcher icon.
128 icon_timeout_timer_.Start(FROM_HERE, 130 icon_timeout_timer_.Start(FROM_HERE,
129 base::TimeDelta::FromMilliseconds(3000), 131 base::TimeDelta::FromMilliseconds(3000),
130 base::Bind(&ShortcutDataFetcher::OnFaviconFetched, 132 base::Bind(&ShortcutDataFetcher::OnFaviconFetched,
131 this, 133 this,
132 favicon_base::FaviconRawBitmapResult())); 134 favicon_base::FaviconRawBitmapResult()));
133 } 135 }
134 136
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 void ShortcutDataFetcher::NotifyObserver(const SkBitmap& bitmap) { 248 void ShortcutDataFetcher::NotifyObserver(const SkBitmap& bitmap) {
247 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 249 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
248 if (!web_contents() || !weak_observer_ || is_icon_saved_) 250 if (!web_contents() || !weak_observer_ || is_icon_saved_)
249 return; 251 return;
250 252
251 is_icon_saved_ = true; 253 is_icon_saved_ = true;
252 shortcut_icon_ = bitmap; 254 shortcut_icon_ = bitmap;
253 is_ready_ = true; 255 is_ready_ = true;
254 weak_observer_->OnDataAvailable(shortcut_info_, shortcut_icon_); 256 weak_observer_->OnDataAvailable(shortcut_info_, shortcut_icon_);
255 } 257 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698