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

Unified Diff: blimp/client/app/android/java/src/org/chromium/blimp/BlimpRendererActivity.java

Issue 1687393002: Add assigner support to Blimp (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix evil build break? Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: blimp/client/app/android/java/src/org/chromium/blimp/BlimpRendererActivity.java
diff --git a/blimp/client/app/android/java/src/org/chromium/blimp/BlimpRendererActivity.java b/blimp/client/app/android/java/src/org/chromium/blimp/BlimpRendererActivity.java
index 23d52e68d5f9244885f1ffa0af225003005954c9..35f8e190693d51dd59cfdb6b2808b7c7c33ecd3b 100644
--- a/blimp/client/app/android/java/src/org/chromium/blimp/BlimpRendererActivity.java
+++ b/blimp/client/app/android/java/src/org/chromium/blimp/BlimpRendererActivity.java
@@ -22,12 +22,16 @@ import org.chromium.ui.widget.Toast;
* The {@link Activity} for rendering the main Blimp client. This loads the Blimp rendering stack
* and displays it.
*/
-public class BlimpRendererActivity extends Activity implements BlimpLibraryLoader.Callback,
- TokenSource.Callback {
-
+public class BlimpRendererActivity extends Activity
+ implements BlimpLibraryLoader.Callback, TokenSource.Callback, BlimpClientSession.Callback {
private static final int ACCOUNT_CHOOSER_INTENT_REQUEST_CODE = 100;
private static final String TAG = "Blimp";
+
+ /** Provides user authentication tokens that can be used to query for engine assignments. This
+ * can potentially query GoogleAuthUtil for an OAuth2 authentication token with userinfo.email
+ * privileges for a chosen Android account. */
private TokenSource mTokenSource;
+
private BlimpView mBlimpView;
private Toolbar mToolbar;
private BlimpClientSession mBlimpClientSession;
@@ -37,6 +41,12 @@ public class BlimpRendererActivity extends Activity implements BlimpLibraryLoade
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ // Build a TokenSource that will internally retry accessing the underlying TokenSourceImpl.
+ // This will exponentially backoff while it tries to get the access token. See
+ // {@link RetryingTokenSource} for more information. The underlying
+ // TokenSourceImpl will attempt to query GoogleAuthUtil, but might fail if there is no
+ // account selected, in which case it will ask this Activity to show an account chooser and
+ // notify it of the selection result.
mTokenSource = new RetryingTokenSource(new TokenSourceImpl(this));
mTokenSource.setCallback(this);
mTokenSource.getToken();
@@ -115,8 +125,7 @@ public class BlimpRendererActivity extends Activity implements BlimpLibraryLoade
setContentView(R.layout.blimp_main);
- mBlimpClientSession = new BlimpClientSession();
- mBlimpClientSession.connect();
+ mBlimpClientSession = new BlimpClientSession(this);
mBlimpView = (BlimpView) findViewById(R.id.renderer);
mBlimpView.initializeRenderer(mBlimpClientSession);
@@ -131,8 +140,7 @@ public class BlimpRendererActivity extends Activity implements BlimpLibraryLoade
// TokenSource.Callback implementation.
@Override
public void onTokenReceived(String token) {
- // TODO(dtrainor): Do something with the token and the assigner!
- Toast.makeText(this, R.string.signin_get_token_succeeded, Toast.LENGTH_SHORT).show();
+ if (mBlimpClientSession != null) mBlimpClientSession.connect(token);
}
@Override
@@ -140,11 +148,16 @@ public class BlimpRendererActivity extends Activity implements BlimpLibraryLoade
// Ignore isTransient here because we're relying on the auto-retry TokenSource.
// TODO(dtrainor): Show a better error dialog/message.
Toast.makeText(this, R.string.signin_get_token_failed, Toast.LENGTH_LONG).show();
- finish();
}
@Override
public void onNeedsAccountToBeSelected(Intent suggestedIntent) {
startActivityForResult(suggestedIntent, ACCOUNT_CHOOSER_INTENT_REQUEST_CODE);
}
+
+ // BlimpClientSession.Callback implementation.
+ @Override
+ public void onAssignmentReceived(int result, int suggestedMessageResourceId) {
+ Toast.makeText(this, suggestedMessageResourceId, Toast.LENGTH_LONG).show();
+ }
}

Powered by Google App Engine
This is Rietveld 408576698