summaryrefslogtreecommitdiffstats
path: root/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoViewChrome.java
blob: 403c6dbca03c1b12fc5a23b1839dfba488cf8b81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/* -*- 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 that Gecko is ready to handle requests.
    * @param view The GeckoView that initiated the callback.
    */
    @Override
    public void onReady(GeckoView view) {}

    /**
    * Tell the host application to display an alert dialog.
    * @param view The GeckoView that initiated the callback.
    * @param browser The Browser that is loading the content.
    * @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, GeckoView.Browser browser, 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 browser The Browser that is loading the content.
    * @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, GeckoView.Browser browser, 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 browser The Browser that is loading the content.
    * @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, GeckoView.Browser browser, 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();
    }

    /**
    * Receive a message from an imported script.
    * @param view The GeckoView that initiated the callback.
    * @param data Bundle of data sent with the message. Never null.
    * @param result A MessageResult used to send back a response without blocking. Can be null.
    * Defaults to cancel requests with a failed response.
    */
    public void onScriptMessage(GeckoView view, Bundle data, GeckoView.MessageResult result) {
        if (result != null) {
            result.failure(null);
        }
    }
}