| 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.content.ComponentName; | 7 import android.content.ComponentName; |
| 8 import android.content.Context; | 8 import android.content.Context; |
| 9 import android.content.Intent; | 9 import android.content.Intent; |
| 10 import android.content.ServiceConnection; | 10 import android.content.ServiceConnection; |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 /** | 486 /** |
| 487 * Get the speculation mode to be used by default for the given session. | 487 * Get the speculation mode to be used by default for the given session. |
| 488 * If no value has been set will default to PRERENDER mode. | 488 * If no value has been set will default to PRERENDER mode. |
| 489 */ | 489 */ |
| 490 public synchronized int getSpeculationModeForSession(CustomTabsSessionToken
session) { | 490 public synchronized int getSpeculationModeForSession(CustomTabsSessionToken
session) { |
| 491 SessionParams params = mSessionParams.get(session); | 491 SessionParams params = mSessionParams.get(session); |
| 492 return params == null ? CustomTabsConnection.SpeculationParams.PRERENDER | 492 return params == null ? CustomTabsConnection.SpeculationParams.PRERENDER |
| 493 : params.mSpeculationMode; | 493 : params.mSpeculationMode; |
| 494 } | 494 } |
| 495 | 495 |
| 496 /** |
| 497 * Returns whether an origin is first-party with respect to a session, that
is if the |
| 498 * application linked to the session has a relation with the provided origin
. This does not |
| 499 * calls OriginVerifier, but only checks the cached relations. |
| 500 * |
| 501 * @param session The session. |
| 502 * @param origin Origin to verify |
| 503 */ |
| 504 public synchronized boolean isFirstPartyOriginForSession( |
| 505 CustomTabsSessionToken session, Uri origin) { |
| 506 SessionParams params = mSessionParams.get(session); |
| 507 return params == null ? false : OriginVerifier.isValidOrigin(params.pack
ageName, origin); |
| 508 } |
| 509 |
| 496 /** Tries to bind to a client to keep it alive, and returns true for success
. */ | 510 /** Tries to bind to a client to keep it alive, and returns true for success
. */ |
| 497 public synchronized boolean keepAliveForSession(CustomTabsSessionToken sessi
on, Intent intent) { | 511 public synchronized boolean keepAliveForSession(CustomTabsSessionToken sessi
on, Intent intent) { |
| 498 // When an application is bound to a service, its priority is raised to | 512 // When an application is bound to a service, its priority is raised to |
| 499 // be at least equal to the application's one. This binds to a dummy | 513 // be at least equal to the application's one. This binds to a dummy |
| 500 // service (no calls to this service are made). | 514 // service (no calls to this service are made). |
| 501 if (intent == null || intent.getComponent() == null) return false; | 515 if (intent == null || intent.getComponent() == null) return false; |
| 502 SessionParams params = mSessionParams.get(session); | 516 SessionParams params = mSessionParams.get(session); |
| 503 if (params == null) return false; | 517 if (params == null) return false; |
| 504 | 518 |
| 505 KeepAliveServiceConnection connection = params.getKeepAliveConnection(); | 519 KeepAliveServiceConnection connection = params.getKeepAliveConnection(); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 564 SessionParams params = mSessionParams.get(session); | 578 SessionParams params = mSessionParams.get(session); |
| 565 if (params == null) return; | 579 if (params == null) return; |
| 566 mSessionParams.remove(session); | 580 mSessionParams.remove(session); |
| 567 if (params.postMessageHandler != null) { | 581 if (params.postMessageHandler != null) { |
| 568 params.postMessageHandler.cleanup(mContext); | 582 params.postMessageHandler.cleanup(mContext); |
| 569 } | 583 } |
| 570 if (params.disconnectCallback != null) params.disconnectCallback.run(ses
sion); | 584 if (params.disconnectCallback != null) params.disconnectCallback.run(ses
sion); |
| 571 mUidHasCalledWarmup.delete(params.uid); | 585 mUidHasCalledWarmup.delete(params.uid); |
| 572 } | 586 } |
| 573 } | 587 } |
| OLD | NEW |