blob: 1c83a856a4d626ca881f625e205e3548962caa77 [file] [log] [blame]
// Copyright 2019 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.
// This provides an API to create and control webviews via gRPC.
// Each webview is a separate bidirectional message stream, the client creates
// a new one by sending a WebviewCreate message first. Subsequently, the client
// navigates and injects input as desired and the server will respond with
// event messages whenever page state changes, whether or not in direct response
// to client actions, eg if the renderer crashes.
syntax = "proto3";
option optimize_for = LITE_RUNTIME;
package chromecast.webview;
message AccessibilityTreeInfo {
string ax_tree_id = 1;
}
// Create a new, empty webview
message WebviewCreateRequest {
// This identifies the surface that this webview will display into.
// It should be unique and the same as whatever was set into
// |aura_surface_set_client_surface_id| on the wayland surface.
int32 webview_id = 1;
// This is the cast window ID that will be assigned to the web contents
// window.
int32 window_id = 2;
}
message WebviewCreateResponse {
AccessibilityTreeInfo accessibility_info = 1;
}
// These are a translation of ui::Event and children.
message KeyInput {
int32 key_code = 1;
int32 dom_code = 2;
int32 dom_key = 3;
bool is_char = 4;
}
message TouchInput {
float x = 1;
float y = 2;
float root_x = 3;
float root_y = 4;
int32 pointer_type = 5;
int32 pointer_id = 6;
float radius_x = 7;
float radius_y = 8;
float force = 9;
float twist = 10;
float tilt_x = 11;
float tilt_y = 12;
float tangential_pressure = 13;
}
message MouseEvent {
float x = 1;
float y = 2;
float root_x = 3;
float root_y = 4;
int32 changed_button_flags = 5;
}
message InputEvent {
int32 event_type = 1;
int32 flags = 2;
int64 timestamp = 3;
KeyInput key = 4;
TouchInput touch = 5;
MouseEvent mouse = 6;
}
// Navigate this webview to the provided url.
message NavigateRequest {
string url = 1;
}
message AsyncPageEvent {
enum State {
IDLE = 0;
LOADING = 1;
LOADED = 2;
CLOSED = 3;
DESTROYED = 4;
ERROR = 5;
}
// This is always set to the current state.
State current_page_state = 1;
// These will be set if the event just happened.
int32 stopped_error_code = 2;
bool resource_load_failed = 3;
bool did_first_visually_non_empty_paint = 4;
string url = 5;
}
message StopPageRequest {
int32 error_code = 1;
}
message EvaluateJavascriptRequest {
string javascript_blob = 1;
}
message EvaluateJavascriptResponse {
string json = 1;
}
message AddJavascriptChannelsRequest {
repeated string channels = 1;
}
message RemoveJavascriptChannelsRequest {
repeated string channels = 1;
}
message GetCurrentUrlRequest {}
message GetCurrentUrlResponse {
string url = 1;
}
message CanGoBackRequest {}
message CanGoBackResponse {
bool can_go_back = 1;
}
message CanGoForwardRequest {}
message CanGoForwardResponse {
bool can_go_forward = 1;
}
message GoBackRequest {}
message GoForwardRequest {}
message ReloadRequest {}
message ClearCacheRequest {}
message UserAgent {
oneof type {
bool is_null = 1;
string value = 2;
}
}
message UpdateSettingsRequest {
bool javascript_enabled = 1;
bool has_navigation_delegate = 2;
bool debugging_enabled = 3;
// A null value means the default user agent should be used.
// An absent value represents no change to this setting from the last time it
// was set.
UserAgent user_agent = 4;
}
message GetTitleRequest {}
message GetTitleResponse {
string title = 1;
}
message SetAutoMediaPlaybackPolicyRequest {
bool require_user_gesture = 1;
}
message NavigationRequestEvent {
string url = 1;
}
enum NavigationDecision {
NAVIGATE = 0;
PREVENT = 1;
}
message WebviewRequest {
// Unique identifier for the request. For requests that will have a response,
// the response id will match the request id.
// Valid ID values must be greater than 0.
int64 id = 18;
oneof type {
// This must be the first message.
WebviewCreateRequest create = 1;
// No response.
InputEvent input = 2;
// Expect page events to follow.
NavigateRequest navigate = 3;
// Expect page events to follow.
StopPageRequest stop_page = 4;
// Expect async response.
EvaluateJavascriptRequest evaluate_javascript = 5;
// No response.
AddJavascriptChannelsRequest add_javascript_channels = 6;
// No response.
RemoveJavascriptChannelsRequest remove_javascript_channels = 7;
// Expect async response.
GetCurrentUrlRequest get_current_url = 8;
// Expect async response.
CanGoBackRequest can_go_back = 9;
// Expect async response.
CanGoForwardRequest can_go_forward = 10;
// No response.
GoBackRequest go_back = 11;
// No response.
GoForwardRequest go_forward = 12;
// No response.
ReloadRequest reload = 13;
// No response.
ClearCacheRequest clear_cache = 14;
// No response.
UpdateSettingsRequest update_settings = 15;
// Expect async response.
GetTitleRequest get_title = 16;
// No response.
SetAutoMediaPlaybackPolicyRequest set_auto_media_playback_policy = 17;
// Response to a navigation request.
NavigationDecision navigation_decision = 19;
}
}
message WebviewResponse {
// Unique identifier. The value will match that of the request.
// Responses that do not have an associated request (such as page status
// event), the ID is meaningless.
int64 id = 8;
oneof type {
WebviewCreateResponse create_response = 1;
AsyncPageEvent page_event = 2;
EvaluateJavascriptResponse evaluate_javascript = 3;
GetCurrentUrlResponse get_current_url = 4;
CanGoBackResponse can_go_back = 5;
CanGoForwardResponse can_go_forward = 6;
GetTitleResponse get_title = 7;
// Triggered by web navigation events inside the webview.
NavigationRequestEvent navigation_event = 9;
}
}
service WebviewService {
// Creates a webview. See the comment at the top of the file.
rpc CreateWebview(stream WebviewRequest) returns (stream WebviewResponse);
}