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

Side by Side Diff: chrome/android/java_staging/src/org/chromium/chrome/browser/ChromeServiceTabLauncher.java

Issue 1141283003: Upstream oodles of Chrome for Android code into Chromium. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: final patch? Created 5 years, 7 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
(Empty)
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
3 // found in the LICENSE file.
4
5 package org.chromium.chrome.browser;
6
7 import android.content.Context;
8 import android.content.Intent;
9 import android.net.Uri;
10
11 import org.chromium.chrome.browser.document.ChromeLauncherActivity;
12 import org.chromium.chrome.browser.document.DocumentMetricIds;
13 import org.chromium.chrome.browser.document.PendingDocumentData;
14 import org.chromium.chrome.browser.util.FeatureUtilities;
15 import org.chromium.components.service_tab_launcher.ServiceTabLauncher;
16 import org.chromium.content_public.common.Referrer;
17 import org.chromium.ui.base.PageTransition;
18
19 /**
20 * Service Tab Launcher implementation for Chrome. Provides the ability for Andr oid Services
21 * running in Chrome to launch tabs, without having access to an activity.
22 *
23 * This class is referred to from the ServiceTabLauncher implementation in Chrom ium using a
24 * meta-data value in the Android manifest file. The ServiceTabLauncher class ha s more
25 * documentation about why this is necessary.
26 *
27 * TODO(peter): after upstreaming, merge this with ServiceTabLauncher and remove reflection calls
28 * in ServiceTabLauncher.
29 */
30 public class ChromeServiceTabLauncher extends ServiceTabLauncher {
31 @Override
32 public void launchTab(Context context, int requestId, boolean incognito, Str ing url,
33 int disposition, String referrerUrl, int referrerPolic y,
34 String extraHeaders, byte[] postData) {
35 // TODO(peter): Determine the intent source based on the |disposition| w ith which the
36 // tab is being launched. Right now this is gated by a check in the nati ve implementation.
37 int intentSource = DocumentMetricIds.STARTED_BY_WINDOW_OPEN;
38
39 if (FeatureUtilities.isDocumentMode(context)) {
40 PendingDocumentData data = new PendingDocumentData();
41 data.url = url;
42 data.postData = postData;
43 data.extraHeaders = extraHeaders;
44 data.referrer = new Referrer(referrerUrl, referrerPolicy);
45 data.requestId = requestId;
46
47 ChromeLauncherActivity.launchDocumentInstance(null /* activity */, i ncognito,
48 ChromeLauncherActivity.LAUNCH_MODE_FOREGROUND, url, intentSo urce,
49 PageTransition.LINK, false /* useDesktopUserAgent */, data);
50 return;
51 }
52
53 Intent intent = new Intent(context, ChromeLauncherActivity.class);
54 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
55 intent.setAction(Intent.ACTION_VIEW);
56
57 intent.putExtra(IntentHandler.EXTRA_OPEN_NEW_INCOGNITO_TAB, incognito);
58 intent.putExtra(IntentHandler.EXTRA_PAGE_TRANSITION_TYPE, PageTransition .LINK);
59 intent.putExtra(IntentHandler.EXTRA_STARTED_BY, intentSource);
60 intent.putExtra(IntentHandler.EXTRA_USE_DESKTOP_USER_AGENT, false);
61
62 intent.putExtra(ServiceTabLauncher.LAUNCH_REQUEST_ID_EXTRA, requestId);
63
64 // TODO(peter): We should include the referrer, extra headers and the po st data in the
65 // new tab request where supported by the tabbed activity.
66
67 intent.setData(Uri.parse(url));
68
69 IntentHandler.addTrustedIntentExtras(intent, context);
70
71 context.startActivity(intent);
72 }
73 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698