зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1322581 - 1. Remove GeckoView.ChromeDelegate; r=snorp
Remove the old ChromeDelegate interface, to be replaced by PromptDelegate in a future patch.
This commit is contained in:
Родитель
8c1d0c7cd6
Коммит
f15b130cbb
|
@ -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',
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -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) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче