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.customtabs; | 5 package org.chromium.chrome.browser.customtabs; |
6 | 6 |
7 import android.app.ActivityManager; | 7 import android.app.ActivityManager; |
8 import android.app.Application; | 8 import android.app.Application; |
9 import android.content.ComponentName; | 9 import android.content.ComponentName; |
10 import android.content.Context; | 10 import android.content.Context; |
11 import android.content.Intent; | 11 import android.content.Intent; |
12 import android.content.ServiceConnection; | 12 import android.content.ServiceConnection; |
13 import android.content.pm.PackageManager; | 13 import android.content.pm.PackageManager; |
14 import android.content.res.Resources; | 14 import android.content.res.Resources; |
15 import android.graphics.Bitmap; | |
15 import android.graphics.Point; | 16 import android.graphics.Point; |
16 import android.net.ConnectivityManager; | 17 import android.net.ConnectivityManager; |
17 import android.net.Uri; | 18 import android.net.Uri; |
18 import android.os.AsyncTask; | 19 import android.os.AsyncTask; |
19 import android.os.Binder; | 20 import android.os.Binder; |
20 import android.os.Build; | 21 import android.os.Build; |
21 import android.os.Bundle; | 22 import android.os.Bundle; |
22 import android.os.IBinder; | 23 import android.os.IBinder; |
23 import android.os.Process; | 24 import android.os.Process; |
24 import android.os.RemoteException; | 25 import android.os.RemoteException; |
25 import android.os.SystemClock; | 26 import android.os.SystemClock; |
27 import android.support.customtabs.CustomTabsCallback; | |
Yusuf
2015/08/21 00:07:37
why is this one needed?
Ian Wen
2015/08/21 17:01:24
Removed.
| |
28 import android.support.customtabs.CustomTabsIntent; | |
26 import android.support.customtabs.ICustomTabsCallback; | 29 import android.support.customtabs.ICustomTabsCallback; |
27 import android.support.customtabs.ICustomTabsService; | 30 import android.support.customtabs.ICustomTabsService; |
28 import android.text.TextUtils; | 31 import android.text.TextUtils; |
29 import android.util.SparseArray; | 32 import android.util.SparseArray; |
30 import android.view.WindowManager; | 33 import android.view.WindowManager; |
31 | 34 |
32 import org.chromium.base.FieldTrialList; | 35 import org.chromium.base.FieldTrialList; |
33 import org.chromium.base.Log; | 36 import org.chromium.base.Log; |
34 import org.chromium.base.ThreadUtils; | 37 import org.chromium.base.ThreadUtils; |
35 import org.chromium.base.VisibleForTesting; | 38 import org.chromium.base.VisibleForTesting; |
36 import org.chromium.base.annotations.SuppressFBWarnings; | 39 import org.chromium.base.annotations.SuppressFBWarnings; |
37 import org.chromium.base.library_loader.ProcessInitException; | 40 import org.chromium.base.library_loader.ProcessInitException; |
38 import org.chromium.base.metrics.RecordHistogram; | 41 import org.chromium.base.metrics.RecordHistogram; |
39 import org.chromium.chrome.R; | 42 import org.chromium.chrome.R; |
40 import org.chromium.chrome.browser.ChromeApplication; | 43 import org.chromium.chrome.browser.ChromeApplication; |
41 import org.chromium.chrome.browser.IntentHandler; | 44 import org.chromium.chrome.browser.IntentHandler; |
42 import org.chromium.chrome.browser.WarmupManager; | 45 import org.chromium.chrome.browser.WarmupManager; |
43 import org.chromium.chrome.browser.device.DeviceClassManager; | 46 import org.chromium.chrome.browser.device.DeviceClassManager; |
44 import org.chromium.chrome.browser.init.ChromeBrowserInitializer; | 47 import org.chromium.chrome.browser.init.ChromeBrowserInitializer; |
45 import org.chromium.chrome.browser.prerender.ExternalPrerenderHandler; | 48 import org.chromium.chrome.browser.prerender.ExternalPrerenderHandler; |
46 import org.chromium.chrome.browser.profiles.Profile; | 49 import org.chromium.chrome.browser.profiles.Profile; |
50 import org.chromium.chrome.browser.util.IntentUtils; | |
47 import org.chromium.content.browser.ChildProcessLauncher; | 51 import org.chromium.content.browser.ChildProcessLauncher; |
48 import org.chromium.content_public.browser.WebContents; | 52 import org.chromium.content_public.browser.WebContents; |
49 import org.chromium.content_public.common.Referrer; | 53 import org.chromium.content_public.common.Referrer; |
50 | 54 |
51 import java.io.BufferedReader; | 55 import java.io.BufferedReader; |
52 import java.io.FileReader; | 56 import java.io.FileReader; |
53 import java.io.IOException; | 57 import java.io.IOException; |
54 import java.util.ArrayList; | 58 import java.util.ArrayList; |
55 import java.util.Arrays; | 59 import java.util.Arrays; |
56 import java.util.HashMap; | 60 import java.util.HashMap; |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
313 } | 317 } |
314 }); | 318 }); |
315 return true; | 319 return true; |
316 } | 320 } |
317 | 321 |
318 @Override | 322 @Override |
319 public Bundle extraCommand(String commandName, Bundle args) { | 323 public Bundle extraCommand(String commandName, Bundle args) { |
320 return null; | 324 return null; |
321 } | 325 } |
322 | 326 |
327 @Override | |
328 public boolean updateToolbarUI(final ICustomTabsCallback callback, Bundle bu ndle) { | |
329 final Bundle actionButtonBundle = IntentUtils.safeGetBundle(bundle, | |
330 CustomTabsIntent.EXTRA_ACTION_BUTTON_BUNDLE); | |
331 if (actionButtonBundle == null) return false; | |
332 | |
333 final Bitmap bitmap = ActionButtonParams.tryParseBitmapFromBundle(mAppli cation, | |
Benoit L
2015/08/21 11:31:15
Can't you do:
final ActionButtonParams actionButt
Ian Wen
2015/08/21 17:01:24
The reason that I cannot construct an actionButton
| |
334 actionButtonBundle); | |
335 final String description = ActionButtonParams | |
336 .tryParseDescriptionFromBundle(actionButtonBundle); | |
337 if (bitmap == null || description == null) return false; | |
338 | |
339 final boolean[] didSucceed = {true}; | |
Yusuf
2015/08/21 00:07:37
use a Callable<Boolean> instead of this.
Benoit L
2015/08/21 11:31:15
Better suggestion than mine, indeed.
Sorry about t
Ian Wen
2015/08/21 17:01:24
Done.
| |
340 | |
341 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | |
342 @Override | |
343 public void run() { | |
344 didSucceed[0] = CustomTabActivity.updateActionButton(callback.as Binder(), bitmap, | |
345 description); | |
346 } | |
347 }); | |
348 return didSucceed[0]; | |
349 } | |
350 | |
323 /** | 351 /** |
324 * Registers a launch of a |url| for a given |session|. | 352 * Registers a launch of a |url| for a given |session|. |
325 * | 353 * |
326 * This is used for accounting. | 354 * This is used for accounting. |
327 */ | 355 */ |
328 void registerLaunch(IBinder session, String url) { | 356 void registerLaunch(IBinder session, String url) { |
329 int outcome; | 357 int outcome; |
330 long elapsedTimeMs = -1; | 358 long elapsedTimeMs = -1; |
331 synchronized (mLock) { | 359 synchronized (mLock) { |
332 SessionParams sessionParams = mSessionParams.get(session); | 360 SessionParams sessionParams = mSessionParams.get(session); |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
655 return screenSize; | 683 return screenSize; |
656 } | 684 } |
657 | 685 |
658 @VisibleForTesting | 686 @VisibleForTesting |
659 void resetThrottling(int uid) { | 687 void resetThrottling(int uid) { |
660 synchronized (mLock) { | 688 synchronized (mLock) { |
661 mUidToPredictionsStats.put(uid, new PredictionStats()); | 689 mUidToPredictionsStats.put(uid, new PredictionStats()); |
662 } | 690 } |
663 } | 691 } |
664 } | 692 } |
OLD | NEW |