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

Unified Diff: components/devtools_bridge/android/java/src/org/chromium/components/devtools_bridge/apiary/ApiaryClientFactory.java

Issue 677843006: Registration of DevTools bridge in GCD. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gcm-signaling
Patch Set: Created 6 years, 2 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: components/devtools_bridge/android/java/src/org/chromium/components/devtools_bridge/apiary/ApiaryClientFactory.java
diff --git a/components/devtools_bridge/android/java/src/org/chromium/components/devtools_bridge/apiary/ApiaryClientFactory.java b/components/devtools_bridge/android/java/src/org/chromium/components/devtools_bridge/apiary/ApiaryClientFactory.java
new file mode 100644
index 0000000000000000000000000000000000000000..57ef08876b70bed457319dd04fd339ba989d22db
--- /dev/null
+++ b/components/devtools_bridge/android/java/src/org/chromium/components/devtools_bridge/apiary/ApiaryClientFactory.java
@@ -0,0 +1,56 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.components.devtools_bridge.apiary;
+
+import android.net.http.AndroidHttpClient;
+
+/**
+ * Factory for creating clients for external APIs.
+ */
+public abstract class ApiaryClientFactory {
+ private static final String USER_AGENT = "DevTools bridge";
+
+ public static final String OAUTH_SCOPE = "https://www.googleapis.com/auth/clouddevices";
+
+ private final AndroidHttpClient mHttpClient = AndroidHttpClient.newInstance(USER_AGENT);
+
+ /**
+ * Creates a new GCD client with auth token.
+ */
+ public GCDClient newGCDClient(String oAuthToken) {
+ return new GCDClient(mHttpClient, getAPIKey(), oAuthToken);
+ }
+
+ /**
+ * Creates a new anonymous client. GCD requires client been not authenticated by user or
+ * device credentials for finalizing registration.
+ */
+ public GCDClient newAnonymousGCDClient() {
+ return new GCDClient(mHttpClient, getAPIKey());
+ }
+
+ public OAuthClient newOAuthClient() {
+ return new OAuthClient(
+ mHttpClient, OAUTH_SCOPE, getOAuthClientId(), getOAuthClientSecret());
+ }
+
+ public BlockingGCMRegistrar newGCMRegistrar() {
+ return new BlockingGCMRegistrar() {
+ @Override
+ protected String[] getSenderIds() {
+ return getGCMSenderIds();
+ }
+ };
+ }
+
+ public void close() {
+ mHttpClient.close();
+ }
+
+ public abstract String getAPIKey();
+ public abstract String getOAuthClientId();
+ public abstract String getOAuthClientSecret();
+ public abstract String[] getGCMSenderIds();
+}

Powered by Google App Engine
This is Rietveld 408576698