From f15b130cbbb3194c02e32e96d6758d76ec5c61db Mon Sep 17 00:00:00 2001 From: Jim Chen Date: Tue, 18 Apr 2017 17:44:57 -0400 Subject: [PATCH] Bug 1322581 - 1. Remove GeckoView.ChromeDelegate; r=snorp Remove the old ChromeDelegate interface, to be replaced by PromptDelegate in a future patch. --- mobile/android/base/moz.build | 1 - .../java/org/mozilla/gecko/GeckoView.java | 76 ------------------- .../org/mozilla/gecko/GeckoViewChrome.java | 58 -------------- .../geckoview_example/GeckoViewActivity.java | 43 ----------- 4 files changed, 178 deletions(-) delete mode 100644 mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoViewChrome.java diff --git a/mobile/android/base/moz.build b/mobile/android/base/moz.build index 13a436af5f40..d0cc58216f22 100644 --- a/mobile/android/base/moz.build +++ b/mobile/android/base/moz.build @@ -369,7 +369,6 @@ gvjar.sources += [geckoview_source_dir + 'java/org/mozilla/gecko/' + x 'GeckoSharedPrefs.java', 'GeckoThread.java', 'GeckoView.java', - 'GeckoViewChrome.java', 'GeckoViewFragment.java', 'GeckoViewSettings.java', 'gfx/BitmapUtils.java', diff --git a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoView.java b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoView.java index b875fa983356..7bd9b29fc5bc 100644 --- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoView.java +++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoView.java @@ -70,7 +70,6 @@ public class GeckoView extends LayerView private final EventDispatcher mEventDispatcher = new EventDispatcher(mNativeQueue); - private ChromeDelegate mChromeDelegate; /* package */ ContentListener mContentListener; /* package */ NavigationListener mNavigationListener; /* package */ ProgressListener mProgressListener; @@ -504,15 +503,6 @@ public class GeckoView extends LayerView throw new IllegalArgumentException("Must import script from 'resources://android/assets/' location."); } - /** - * Set the chrome callback handler. - * This will replace the current handler. - * @param chrome An implementation of GeckoViewChrome. - */ - public void setChromeDelegate(ChromeDelegate chrome) { - mChromeDelegate = chrome; - } - /** * Set the content callback handler. * This will replace the current handler. @@ -594,72 +584,6 @@ public class GeckoView extends LayerView return mEventDispatcher; } - /* Provides a means for the client to indicate whether a JavaScript - * dialog request should proceed. An instance of this class is passed to - * various GeckoViewChrome callback actions. - */ - public class PromptResult { - public PromptResult() { - } - - /** - * Handle a confirmation response from the user. - */ - public void confirm() { - } - - /** - * Handle a confirmation response from the user. - * @param value String value to return to the browser context. - */ - public void confirmWithValue(String value) { - } - - /** - * Handle a cancellation response from the user. - */ - public void cancel() { - } - } - - public interface ChromeDelegate { - /** - * Tell the host application to display an alert dialog. - * @param view The GeckoView that initiated the callback. - * @param message The string to display in the dialog. - * @param result A PromptResult used to send back the result without blocking. - * Defaults to cancel requests. - */ - void onAlert(GeckoView view, String message, GeckoView.PromptResult result); - - /** - * Tell the host application to display a confirmation dialog. - * @param view The GeckoView that initiated the callback. - * @param message The string to display in the dialog. - * @param result A PromptResult used to send back the result without blocking. - * Defaults to cancel requests. - */ - void onConfirm(GeckoView view, String message, GeckoView.PromptResult result); - - /** - * Tell the host application to display an input prompt dialog. - * @param view The GeckoView that initiated the callback. - * @param message The string to display in the dialog. - * @param defaultValue The string to use as default input. - * @param result A PromptResult used to send back the result without blocking. - * Defaults to cancel requests. - */ - void onPrompt(GeckoView view, String message, String defaultValue, GeckoView.PromptResult result); - - /** - * Tell the host application to display a remote debugging request dialog. - * @param view The GeckoView that initiated the callback. - * @param result A PromptResult used to send back the result without blocking. - * Defaults to cancel requests. - */ - void onDebugRequest(GeckoView view, GeckoView.PromptResult result); - } - public interface ProgressListener { static final int STATE_IS_BROKEN = 1; static final int STATE_IS_SECURE = 2; diff --git a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoViewChrome.java b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoViewChrome.java deleted file mode 100644 index 674d5fa76340..000000000000 --- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoViewChrome.java +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -package org.mozilla.gecko; - -import android.os.Bundle; - -public class GeckoViewChrome implements GeckoView.ChromeDelegate { - /** - * Tell the host application to display an alert dialog. - * @param view The GeckoView that initiated the callback. - * @param message The string to display in the dialog. - * @param result A PromptResult used to send back the result without blocking. - * Defaults to cancel requests. - */ - @Override - public void onAlert(GeckoView view, String message, GeckoView.PromptResult result) { - result.cancel(); - } - - /** - * Tell the host application to display a confirmation dialog. - * @param view The GeckoView that initiated the callback. - * @param message The string to display in the dialog. - * @param result A PromptResult used to send back the result without blocking. - * Defaults to cancel requests. - */ - @Override - public void onConfirm(GeckoView view, String message, GeckoView.PromptResult result) { - result.cancel(); - } - - /** - * Tell the host application to display an input prompt dialog. - * @param view The GeckoView that initiated the callback. - * @param message The string to display in the dialog. - * @param defaultValue The string to use as default input. - * @param result A PromptResult used to send back the result without blocking. - * Defaults to cancel requests. - */ - @Override - public void onPrompt(GeckoView view, String message, String defaultValue, GeckoView.PromptResult result) { - result.cancel(); - } - - /** - * Tell the host application to display a remote debugging request dialog. - * @param view The GeckoView that initiated the callback. - * @param result A PromptResult used to send back the result without blocking. - * Defaults to cancel requests. - */ - @Override - public void onDebugRequest(GeckoView view, GeckoView.PromptResult result) { - result.cancel(); - } -} diff --git a/mobile/android/geckoview_example/src/main/java/org/mozilla/geckoview_example/GeckoViewActivity.java b/mobile/android/geckoview_example/src/main/java/org/mozilla/geckoview_example/GeckoViewActivity.java index b14316fef37f..aa128a91020b 100644 --- a/mobile/android/geckoview_example/src/main/java/org/mozilla/geckoview_example/GeckoViewActivity.java +++ b/mobile/android/geckoview_example/src/main/java/org/mozilla/geckoview_example/GeckoViewActivity.java @@ -36,7 +36,6 @@ public class GeckoViewActivity extends Activity { setContentView(R.layout.geckoview_activity); mGeckoView = (GeckoView) findViewById(R.id.gecko_view); - mGeckoView.setChromeDelegate(new MyGeckoViewChrome()); mGeckoView.setContentListener(new MyGeckoViewContent()); mGeckoView.setProgressListener(new MyGeckoViewProgress()); @@ -63,48 +62,6 @@ public class GeckoViewActivity extends Activity { } } - private class MyGeckoViewChrome implements GeckoView.ChromeDelegate { - @Override - public void onAlert(GeckoView view, String message, GeckoView.PromptResult result) { - Log.i(LOGTAG, "Alert!"); - result.confirm(); - Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG).show(); - } - - @Override - public void onConfirm(GeckoView view, String message, final GeckoView.PromptResult result) { - Log.i(LOGTAG, "Confirm!"); - new AlertDialog.Builder(GeckoViewActivity.this) - .setTitle("javaScript dialog") - .setMessage(message) - .setPositiveButton(android.R.string.ok, - new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int which) { - result.confirm(); - } - }) - .setNegativeButton(android.R.string.cancel, - new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int which) { - result.cancel(); - } - }) - .create() - .show(); - } - - @Override - public void onPrompt(GeckoView view, String message, String defaultValue, GeckoView.PromptResult result) { - result.cancel(); - } - - @Override - public void onDebugRequest(GeckoView view, GeckoView.PromptResult result) { - Log.i(LOGTAG, "Remote Debug!"); - result.confirm(); - } - } - private class MyGeckoViewContent implements GeckoView.ContentListener { @Override public void onTitleChange(GeckoView view, String title) {