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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabsConnectionService.java

Issue 2174453002: Don't require FRE for connecting to custom tabs service (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nits Created 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 package org.chromium.chrome.browser.customtabs; 5 package org.chromium.chrome.browser.customtabs;
6 6
7 import android.content.Intent; 7 import android.content.Intent;
8 import android.net.Uri; 8 import android.net.Uri;
9 import android.os.Bundle; 9 import android.os.Bundle;
10 import android.os.IBinder; 10 import android.os.IBinder;
11 import android.support.customtabs.CustomTabsService; 11 import android.support.customtabs.CustomTabsService;
12 import android.support.customtabs.CustomTabsSessionToken; 12 import android.support.customtabs.CustomTabsSessionToken;
13 13
14 import org.chromium.chrome.browser.firstrun.FirstRunFlowSequencer; 14 import org.chromium.chrome.browser.firstrun.FirstRunFlowSequencer;
15 15
16 import java.util.List; 16 import java.util.List;
17 17
18 /** 18 /**
19 * Custom tabs connection service, used by the embedded Chrome activities. 19 * Custom tabs connection service, used by the embedded Chrome activities.
20 */ 20 */
21 public class CustomTabsConnectionService extends CustomTabsService { 21 public class CustomTabsConnectionService extends CustomTabsService {
22 private CustomTabsConnection mConnection; 22 private CustomTabsConnection mConnection;
23 private Intent mBindIntent;
23 24
24 @Override 25 @Override
25 public IBinder onBind(Intent intent) { 26 public IBinder onBind(Intent intent) {
26 boolean firstRunNecessary = FirstRunFlowSequencer 27 mBindIntent = intent;
27 .checkIfFirstRunIsNecessary(getApplicationContext(), intent) != null;
28 if (firstRunNecessary) return null;
29 mConnection = CustomTabsConnection.getInstance(getApplication()); 28 mConnection = CustomTabsConnection.getInstance(getApplication());
30 mConnection.logCall("Service#onBind()", true); 29 mConnection.logCall("Service#onBind()", true);
31 return super.onBind(intent); 30 return super.onBind(intent);
32 } 31 }
33 32
34 @Override 33 @Override
35 public boolean onUnbind(Intent intent) { 34 public boolean onUnbind(Intent intent) {
36 super.onUnbind(intent); 35 super.onUnbind(intent);
37 if (mConnection != null) mConnection.logCall("Service#onUnbind()", true) ; 36 if (mConnection != null) mConnection.logCall("Service#onUnbind()", true) ;
38 return false; // No support for onRebind(). 37 return false; // No support for onRebind().
39 } 38 }
40 39
41 @Override 40 @Override
42 protected boolean warmup(long flags) { 41 protected boolean warmup(long flags) {
42 if (!isFirstRunDone()) return false;
43 return mConnection.warmup(flags); 43 return mConnection.warmup(flags);
44 } 44 }
45 45
46 @Override 46 @Override
47 protected boolean newSession(CustomTabsSessionToken sessionToken) { 47 protected boolean newSession(CustomTabsSessionToken sessionToken) {
48 return mConnection.newSession(sessionToken); 48 return mConnection.newSession(sessionToken);
49 } 49 }
50 50
51 @Override 51 @Override
52 protected boolean mayLaunchUrl(CustomTabsSessionToken sessionToken, Uri url, Bundle extras, 52 protected boolean mayLaunchUrl(CustomTabsSessionToken sessionToken, Uri url, Bundle extras,
53 List<Bundle> otherLikelyBundles) { 53 List<Bundle> otherLikelyBundles) {
54 if (!isFirstRunDone()) return false;
54 return mConnection.mayLaunchUrl(sessionToken, url, extras, otherLikelyBu ndles); 55 return mConnection.mayLaunchUrl(sessionToken, url, extras, otherLikelyBu ndles);
55 } 56 }
56 57
57 @Override 58 @Override
58 protected Bundle extraCommand(String commandName, Bundle args) { 59 protected Bundle extraCommand(String commandName, Bundle args) {
59 return mConnection.extraCommand(commandName, args); 60 return mConnection.extraCommand(commandName, args);
60 } 61 }
61 62
62 @Override 63 @Override
63 protected boolean updateVisuals(CustomTabsSessionToken sessionToken, Bundle bundle) { 64 protected boolean updateVisuals(CustomTabsSessionToken sessionToken, Bundle bundle) {
65 if (!isFirstRunDone()) return false;
64 return mConnection.updateVisuals(sessionToken, bundle); 66 return mConnection.updateVisuals(sessionToken, bundle);
65 } 67 }
66 68
67 @Override 69 @Override
68 protected boolean cleanUpSession(CustomTabsSessionToken sessionToken) { 70 protected boolean cleanUpSession(CustomTabsSessionToken sessionToken) {
69 mConnection.cleanUpSession(sessionToken); 71 mConnection.cleanUpSession(sessionToken);
70 return super.cleanUpSession(sessionToken); 72 return super.cleanUpSession(sessionToken);
71 } 73 }
74
75 private boolean isFirstRunDone() {
76 if (mBindIntent == null) return true;
77 boolean firstRunNecessary = FirstRunFlowSequencer
78 .checkIfFirstRunIsNecessary(getApplicationContext(), mBindIntent ) != null;
79 if (!firstRunNecessary) {
80 mBindIntent = null;
81 return true;
82 }
83 return false;
84 }
72 } 85 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698