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

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

Issue 1814693003: Added support to blimp to be usable as a default browser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Handled onNewIntent for new intents Created 4 years, 9 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
« no previous file with comments | « blimp/client/app/android/AndroidManifest.xml.jinja2 ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 23ef8d98c218fcc60ee544a2476506bec80fea47..6213cb63c12cdd1e441b803686705b73e7c9e173 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
@@ -7,6 +7,7 @@ package org.chromium.blimp;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
+import android.text.TextUtils;
import org.chromium.base.Log;
import org.chromium.base.library_loader.ProcessInitException;
@@ -144,7 +145,41 @@ public class BlimpRendererActivity extends Activity
mWebInputBox.initialize(mBlimpClientSession);
mTabControlFeature = new TabControlFeature(mBlimpClientSession, mBlimpView);
- mToolbar.loadUrl("http://www.google.com/");
+
+ handleUrl(getUrlFromIntent(getIntent()));
+ }
+
+ @Override
+ protected void onNewIntent(Intent intent) {
+ super.onNewIntent(intent);
+ handleUrl(getUrlFromIntent(intent));
+ }
+
+ /**
+ * Retrieve the URL from the Intent.
+ * @param intent Intent to examine.
+ * @return URL from the Intent, or null if a valid URL couldn't be found.
+ */
+ private String getUrlFromIntent(Intent intent) {
+ if (intent == null) return null;
+
+ String url = intent.getDataString();
+ if (url == null) return null;
+
+ url = url.trim();
+ return TextUtils.isEmpty(url) ? null : url;
+ }
+
+ /**
+ * Loads the url in the browser.
+ * @param url URL to load. If null, browser loads a default page.
+ */
+ private void handleUrl(String url) {
+ if (url == null) {
+ mToolbar.loadUrl("http://www.google.com/");
+ } else {
+ mToolbar.loadUrl(url);
+ }
}
// TokenSource.Callback implementation.
« no previous file with comments | « blimp/client/app/android/AndroidManifest.xml.jinja2 ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698