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 package org.chromium.chrome.browser.webapps; | 5 package org.chromium.chrome.browser.webapps; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 import android.content.Intent; | 8 import android.content.Intent; |
9 import android.graphics.Bitmap; | 9 import android.graphics.Bitmap; |
10 import android.net.Uri; | 10 import android.net.Uri; |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 | 251 |
252 @Override | 252 @Override |
253 public void onFaviconUpdated(Tab tab) { | 253 public void onFaviconUpdated(Tab tab) { |
254 if (!isWebappDomain()) return; | 254 if (!isWebappDomain()) return; |
255 updateTaskDescription(); | 255 updateTaskDescription(); |
256 } | 256 } |
257 }; | 257 }; |
258 } | 258 } |
259 | 259 |
260 private void updateTaskDescription() { | 260 private void updateTaskDescription() { |
261 String title = mWebappInfo.title() == null | 261 String title = mWebappInfo.shortName() == null |
262 ? getActivityTab().getTitle() : mWebappInfo.title(); | 262 ? getActivityTab().getTitle() : mWebappInfo.shortName(); |
263 Bitmap icon = mWebappInfo.icon() == null | 263 Bitmap icon = mWebappInfo.icon() == null |
264 ? getActivityTab().getFavicon() : mWebappInfo.icon(); | 264 ? getActivityTab().getFavicon() : mWebappInfo.icon(); |
265 int color = mBrandColor == null | 265 int color = mBrandColor == null |
266 ? getResources().getColor(R.color.default_primary_color) : mBran
dColor; | 266 ? getResources().getColor(R.color.default_primary_color) : mBran
dColor; |
267 | 267 |
268 DocumentUtils.updateTaskDescription(this, title, icon, color, mBrandColo
r == null); | 268 DocumentUtils.updateTaskDescription(this, title, icon, color, mBrandColo
r == null); |
269 } | 269 } |
270 | 270 |
271 /** | 271 /** |
272 * Get the active directory by this web app. | 272 * Get the active directory by this web app. |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 protected boolean isContextualSearchAllowed() { | 319 protected boolean isContextualSearchAllowed() { |
320 return false; | 320 return false; |
321 } | 321 } |
322 | 322 |
323 /** | 323 /** |
324 * Launches the URL in its own WebappActivity. | 324 * Launches the URL in its own WebappActivity. |
325 * @param context Context to use for launching the webapp. | 325 * @param context Context to use for launching the webapp. |
326 * @param id ID of the webapp. | 326 * @param id ID of the webapp. |
327 * @param url URL for the webapp. | 327 * @param url URL for the webapp. |
328 * @param icon Base64 encoded Bitmap representing the webapp. | 328 * @param icon Base64 encoded Bitmap representing the webapp. |
329 * @param title String to show in Recents. | 329 * @param name String to show on the splash screen. |
| 330 * @param shortName String to show on the recents menu |
330 * @param orientation Default orientation for the activity. | 331 * @param orientation Default orientation for the activity. |
331 */ | 332 */ |
332 public static void launchInstance(Context context, String id, String url, St
ring icon, | 333 public static void launchInstance(Context context, String id, String url, St
ring icon, |
333 String title, int orientation, int source) { | 334 String name, String shortName, int orientation, int source) { |
334 String activityName = WebappActivity.class.getName(); | 335 String activityName = WebappActivity.class.getName(); |
335 if (!FeatureUtilities.isDocumentModeEligible(context)) { | 336 if (!FeatureUtilities.isDocumentModeEligible(context)) { |
336 // Specifically assign the app to a particular WebappActivity instan
ce. | 337 // Specifically assign the app to a particular WebappActivity instan
ce. |
337 int activityIndex = ActivityAssigner.instance(context).assign(id); | 338 int activityIndex = ActivityAssigner.instance(context).assign(id); |
338 activityName += String.valueOf(activityIndex); | 339 activityName += String.valueOf(activityIndex); |
339 } | 340 } |
340 | 341 |
341 // Fire an intent to launch the Webapp in an unmapped Activity. | 342 // Fire an intent to launch the Webapp in an unmapped Activity. |
342 Intent webappIntent = new Intent(); | 343 Intent webappIntent = new Intent(); |
343 webappIntent.setClassName(context, activityName); | 344 webappIntent.setClassName(context, activityName); |
344 webappIntent.putExtra(ShortcutHelper.EXTRA_ICON, icon); | 345 webappIntent.putExtra(ShortcutHelper.EXTRA_ICON, icon); |
345 webappIntent.putExtra(ShortcutHelper.EXTRA_ID, id); | 346 webappIntent.putExtra(ShortcutHelper.EXTRA_ID, id); |
346 webappIntent.putExtra(ShortcutHelper.EXTRA_URL, url); | 347 webappIntent.putExtra(ShortcutHelper.EXTRA_URL, url); |
347 webappIntent.putExtra(ShortcutHelper.EXTRA_TITLE, title); | 348 webappIntent.putExtra(ShortcutHelper.EXTRA_NAME, name); |
| 349 webappIntent.putExtra(ShortcutHelper.EXTRA_SHORT_NAME, shortName); |
348 webappIntent.putExtra(ShortcutHelper.EXTRA_ORIENTATION, orientation); | 350 webappIntent.putExtra(ShortcutHelper.EXTRA_ORIENTATION, orientation); |
349 webappIntent.putExtra(ShortcutHelper.EXTRA_SOURCE, source); | 351 webappIntent.putExtra(ShortcutHelper.EXTRA_SOURCE, source); |
350 | 352 |
351 // On L, firing intents with the exact same data should relaunch a parti
cular Activity. | 353 // On L, firing intents with the exact same data should relaunch a parti
cular Activity. |
352 webappIntent.setAction(Intent.ACTION_VIEW); | 354 webappIntent.setAction(Intent.ACTION_VIEW); |
353 webappIntent.setData(Uri.parse(WEBAPP_SCHEME + "://" + id)); | 355 webappIntent.setData(Uri.parse(WEBAPP_SCHEME + "://" + id)); |
354 webappIntent.setFlags(ApiCompatibilityUtils.getActivityNewDocumentFlag()
); | 356 webappIntent.setFlags(ApiCompatibilityUtils.getActivityNewDocumentFlag()
); |
355 | 357 |
356 context.startActivity(webappIntent); | 358 context.startActivity(webappIntent); |
357 } | 359 } |
358 } | 360 } |
OLD | NEW |